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 +++++++++++++++++++--- 1 file changed, 71 insertions(+), 11 deletions(-) (limited to 'webapp/components/admin_console') 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} ); -- cgit v1.2.3-1-g7c22