Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete team tweaks #80

Merged
merged 2 commits into from
May 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 48 additions & 23 deletions src/parts/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,11 @@ export default class Team extends Component {
}
}

handleActiveTeamDelete = (e) => {
e.preventDefault()
const teamId = this.state.activeTeam
usure('Are you really sure you want to delete team ' + teamId).then(() => {
window.Einstore.deleteTeam(teamId).then(() => (window.location.href = '/'))
})
}

render() {
const { activeTeam, teams } = this.state
return (
<div className="page">
<EditTeam teamId={this.state.activeTeam} key={this.state.activeTeam} />
<EditTeam teamId={this.state.activeTeam} key={'editbox'+this.state.activeTeam} />

<div className="card">
<div className="card-footer">
Expand Down Expand Up @@ -172,20 +164,7 @@ export default class Team extends Component {
</div>
</div>

<div className="notice">
<h2 className="notice-title">
<IconInfo /> Want to delete team?
</h2>
<p className="notice-content">
By deleting this team you will remove all files associated with the team. All users
assigned to this team will lose access too.
</p>
<div>
<Button danger onClick={this.handleActiveTeamDelete}>
Delete team {this.state.activeTeam}
</Button>
</div>
</div>
<DeleteTeamBox key={'deletebox'+this.state.activeTeam} teamId={this.state.activeTeam} />
</div>
)
}
Expand All @@ -195,3 +174,49 @@ Team.contextTypes = {
connector: PropTypes.object,
team: PropTypes.string,
}

class DeleteTeamBox extends React.PureComponent {
state = {
team: null,
}

componentDidMount() {
window.Einstore.team(this.props.teamId).then((data) => this.setState({ team: data }))
}

handleDeleteTeam = (e) => {
e.preventDefault()
const teamId = this.props.teamId
usure(`Are you really sure you want to delete ${this.state.team.name}?`).then(() => {
window.Einstore.deleteTeam(teamId).then(() => (window.location.href = '/'))
})
}

render() {
return (
this.state.team && (
<div className="notice">
<h2 className="notice-title">
<IconInfo /> Want to delete team '{this.state.team.name}'?
</h2>
{this.state.team.admin ? (
<p className="notice-content">
This team cannot be deleted, because it is <strong>admin</strong> team.
</p>) : (
<>
<p className="notice-content">
By deleting this team you will remove all files associated with the team. All users
assigned to this team will lose access too.
</p>
<div>
<Button danger onClick={this.handleDeleteTeam}>
Delete team '{this.state.team.name}'
</Button>
</div>
</>
)}
</div>
)
)
}
}