summaryrefslogtreecommitdiffstats
path: root/webapp/components/admin_console
diff options
context:
space:
mode:
authorRyan Wang <R-Wang97@users.noreply.github.com>2017-04-25 12:41:40 -0400
committerCorey Hulen <corey@hulen.com>2017-04-25 09:41:40 -0700
commitdc9c73a46b5cf322f558a0f06bd8da76209321a6 (patch)
tree7767724cbe0f5bec3e28265f51c1705056830ecc /webapp/components/admin_console
parent7fc663ca75e966847243a845cff31c07737c4492 (diff)
downloadchat-dc9c73a46b5cf322f558a0f06bd8da76209321a6.tar.gz
chat-dc9c73a46b5cf322f558a0f06bd8da76209321a6.tar.bz2
chat-dc9c73a46b5cf322f558a0f06bd8da76209321a6.zip
Add confirmation modal for deactivating user (#6119)
Diffstat (limited to 'webapp/components/admin_console')
-rw-r--r--webapp/components/admin_console/system_users/system_users_dropdown.jsx82
1 files changed, 71 insertions, 11 deletions
diff --git a/webapp/components/admin_console/system_users/system_users_dropdown.jsx b/webapp/components/admin_console/system_users/system_users_dropdown.jsx
index 262b42929..b3667bb89 100644
--- a/webapp/components/admin_console/system_users/system_users_dropdown.jsx
+++ b/webapp/components/admin_console/system_users/system_users_dropdown.jsx
@@ -27,7 +27,9 @@ export default class SystemUsersDropdown extends React.Component {
this.handleMakeMember = this.handleMakeMember.bind(this);
this.handleMakeActive = this.handleMakeActive.bind(this);
- this.handleMakeNotActive = this.handleMakeNotActive.bind(this);
+ this.handleShowDeactivateMemberModal = this.handleShowDeactivateMemberModal.bind(this);
+ this.handleDeactivateMember = this.handleDeactivateMember.bind(this);
+ this.handleDeactivateCancel = this.handleDeactivateCancel.bind(this);
this.handleMakeSystemAdmin = this.handleMakeSystemAdmin.bind(this);
this.handleManageTeams = this.handleManageTeams.bind(this);
this.handleResetPassword = this.handleResetPassword.bind(this);
@@ -35,10 +37,12 @@ export default class SystemUsersDropdown extends React.Component {
this.handleDemoteSystemAdmin = this.handleDemoteSystemAdmin.bind(this);
this.handleDemoteSubmit = this.handleDemoteSubmit.bind(this);
this.handleDemoteCancel = this.handleDemoteCancel.bind(this);
+ this.renderDeactivateMemberModal = this.renderDeactivateMemberModal.bind(this);
this.state = {
serverError: null,
showDemoteModal: false,
+ showDeactivateMemberModal: false,
user: null,
role: null
};
@@ -74,15 +78,6 @@ export default class SystemUsersDropdown extends React.Component {
);
}
- handleMakeNotActive(e) {
- e.preventDefault();
- updateActive(this.props.user.id, false, null,
- (err) => {
- this.setState({serverError: err.message});
- }
- );
- }
-
handleMakeSystemAdmin(e) {
e.preventDefault();
@@ -150,6 +145,68 @@ export default class SystemUsersDropdown extends React.Component {
}
}
+ handleShowDeactivateMemberModal(e) {
+ e.preventDefault();
+
+ this.setState({showDeactivateMemberModal: true});
+ }
+
+ handleDeactivateMember() {
+ updateActive(this.props.user.id, false, null,
+ (err) => {
+ this.setState({serverError: err.message});
+ }
+ );
+
+ this.setState({showDeactivateMemberModal: false});
+ }
+
+ handleDeactivateCancel() {
+ this.setState({showDeactivateMemberModal: false});
+ }
+
+ renderDeactivateMemberModal() {
+ const title = (
+ <FormattedMessage
+ id='deactivate_member_modal.title'
+ defaultMessage='Deactivate {username}'
+ values={{
+ username: this.props.user.username
+ }}
+ />
+ );
+
+ const message = (
+ <FormattedMessage
+ id='deactivate_member_modal.desc'
+ defaultMessage='This action deactivates {username}. They will be logged out and not have access to any teams or channels on this system. Are you sure you want to deactivate {username}?'
+ values={{
+ username: this.props.user.username
+ }}
+ />
+ );
+
+ const confirmButtonClass = 'btn btn-danger';
+ const deactivateMemberButton = (
+ <FormattedMessage
+ id='deactivate_member_modal.deactivate'
+ defaultMessage='Deactivate'
+ />
+ );
+
+ return (
+ <ConfirmModal
+ show={this.state.showDeactivateMemberModal}
+ title={title}
+ message={message}
+ confirmButtonClass={confirmButtonClass}
+ confirmButton={deactivateMemberButton}
+ onConfirm={this.handleDeactivateMember}
+ onCancel={this.handleDeactivateCancel}
+ />
+ );
+ }
+
render() {
let serverError = null;
if (this.state.serverError) {
@@ -280,7 +337,7 @@ export default class SystemUsersDropdown extends React.Component {
<a
role='menuitem'
href='#'
- onClick={this.handleMakeNotActive}
+ onClick={this.handleShowDeactivateMemberModal}
>
<FormattedMessage
id='admin.user_item.makeInactive'
@@ -407,6 +464,8 @@ export default class SystemUsersDropdown extends React.Component {
);
}
+ const deactivateMemberModal = this.renderDeactivateMemberModal();
+
let displayedName = Utils.getDisplayName(user);
if (displayedName !== user.username) {
displayedName += ' (@' + user.username + ')';
@@ -437,6 +496,7 @@ export default class SystemUsersDropdown extends React.Component {
{passwordReset}
</ul>
{makeDemoteModal}
+ {deactivateMemberModal}
{serverError}
</div>
);