From dc9c73a46b5cf322f558a0f06bd8da76209321a6 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Tue, 25 Apr 2017 12:41:40 -0400 Subject: Add confirmation modal for deactivating user (#6119) --- .../system_users/system_users_dropdown.jsx | 82 +++++++++++++++++++--- webapp/i18n/en.json | 4 ++ 2 files changed, 75 insertions(+), 11 deletions(-) (limited to 'webapp') 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 = ( + + ); + + const message = ( + + ); + + const confirmButtonClass = 'btn btn-danger'; + const deactivateMemberButton = ( + + ); + + return ( + + ); + } + render() { let serverError = null; if (this.state.serverError) { @@ -280,7 +337,7 @@ export default class SystemUsersDropdown extends React.Component { {makeDemoteModal} + {deactivateMemberModal} {serverError} ); diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index d52d1c331..1f122403a 100755 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -1230,6 +1230,10 @@ "custom_emoji.empty": "No custom emoji found", "custom_emoji.header": "Custom Emoji", "custom_emoji.search": "Search Custom Emoji", + "deactivate_member_modal.title": "Deactivate {username}", + "deactivate_member_modal.desc": "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}?", + "deactivate_member_modal.cancel": "Cancel", + "deactivate_member_modal.deactivate": "Deactivate", "default_channel.purpose": "Post messages here that you want everyone to see. Everyone automatically becomes a permanent member of this channel when they join the team.", "delete_channel.cancel": "Cancel", "delete_channel.confirm": "Confirm DELETE Channel", -- cgit v1.2.3-1-g7c22