From d8bd57901e33a7057e26e782e295099ffcc0da89 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 6 Sep 2017 23:04:13 -0700 Subject: Removing webapp --- .../admin_console/manage_roles_modal/index.js | 25 -- .../manage_roles_modal/manage_roles_modal.jsx | 349 --------------------- 2 files changed, 374 deletions(-) delete mode 100644 webapp/components/admin_console/manage_roles_modal/index.js delete mode 100644 webapp/components/admin_console/manage_roles_modal/manage_roles_modal.jsx (limited to 'webapp/components/admin_console/manage_roles_modal') diff --git a/webapp/components/admin_console/manage_roles_modal/index.js b/webapp/components/admin_console/manage_roles_modal/index.js deleted file mode 100644 index 1ca243621..000000000 --- a/webapp/components/admin_console/manage_roles_modal/index.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import {connect} from 'react-redux'; -import {bindActionCreators} from 'redux'; -import {updateUserRoles} from 'mattermost-redux/actions/users'; - -import ManageRolesModal from './manage_roles_modal.jsx'; - -function mapStateToProps(state, ownProps) { - return { - ...ownProps, - userAccessTokensEnabled: state.entities.admin.config.ServiceSettings.EnableUserAccessTokens - }; -} - -function mapDispatchToProps(dispatch) { - return { - actions: bindActionCreators({ - updateUserRoles - }, dispatch) - }; -} - -export default connect(mapStateToProps, mapDispatchToProps)(ManageRolesModal); diff --git a/webapp/components/admin_console/manage_roles_modal/manage_roles_modal.jsx b/webapp/components/admin_console/manage_roles_modal/manage_roles_modal.jsx deleted file mode 100644 index 2358f0241..000000000 --- a/webapp/components/admin_console/manage_roles_modal/manage_roles_modal.jsx +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import * as UserUtils from 'mattermost-redux/utils/user_utils'; -import {Client4} from 'mattermost-redux/client'; -import {General} from 'mattermost-redux/constants'; - -import {trackEvent} from 'actions/diagnostics_actions.jsx'; - -import React from 'react'; -import {Modal} from 'react-bootstrap'; -import PropTypes from 'prop-types'; -import {FormattedMessage, FormattedHTMLMessage} from 'react-intl'; - -function getStateFromProps(props) { - const roles = props.user && props.user.roles ? props.user.roles : ''; - - return { - error: null, - hasPostAllRole: UserUtils.hasPostAllRole(roles), - hasPostAllPublicRole: UserUtils.hasPostAllPublicRole(roles), - hasUserAccessTokenRole: UserUtils.hasUserAccessTokenRole(roles), - isSystemAdmin: UserUtils.isSystemAdmin(roles) - }; -} - -export default class ManageRolesModal extends React.PureComponent { - static propTypes = { - - /** - * Set to render the modal - */ - show: PropTypes.bool.isRequired, - - /** - * The user the roles are being managed for - */ - user: PropTypes.object, - - /** - * Set if user access tokens are enabled - */ - userAccessTokensEnabled: PropTypes.bool.isRequired, - - /** - * Function called when modal is dismissed - */ - onModalDismissed: PropTypes.func.isRequired, - - actions: PropTypes.shape({ - - /** - * Function to update a user's roles - */ - updateUserRoles: PropTypes.func.isRequired - }).isRequired - }; - - constructor(props) { - super(props); - this.state = getStateFromProps(props); - } - - componentWillReceiveProps(nextProps) { - const user = this.props.user || {}; - const nextUser = nextProps.user || {}; - if (user.id !== nextUser.id) { - this.setState(getStateFromProps(nextProps)); - } - } - - handleError = (error) => { - this.setState({ - error - }); - } - - handleSystemAdminChange = (e) => { - if (e.target.name === 'systemadmin') { - this.setState({isSystemAdmin: true}); - } else if (e.target.name === 'systemmember') { - this.setState({isSystemAdmin: false}); - } - }; - - handleUserAccessTokenChange = (e) => { - this.setState({ - hasUserAccessTokenRole: e.target.checked - }); - }; - - handlePostAllChange = (e) => { - this.setState({ - hasPostAllRole: e.target.checked - }); - }; - - handlePostAllPublicChange = (e) => { - this.setState({ - hasPostAllPublicRole: e.target.checked - }); - }; - - trackRoleChanges = (roles, oldRoles) => { - if (UserUtils.hasUserAccessTokenRole(roles) && !UserUtils.hasUserAccessTokenRole(oldRoles)) { - trackEvent('actions', 'add_roles', {role: General.SYSTEM_USER_ACCESS_TOKEN_ROLE}); - } else if (!UserUtils.hasUserAccessTokenRole(roles) && UserUtils.hasUserAccessTokenRole(oldRoles)) { - trackEvent('actions', 'remove_roles', {role: General.SYSTEM_USER_ACCESS_TOKEN_ROLE}); - } - - if (UserUtils.hasPostAllRole(roles) && !UserUtils.hasPostAllRole(oldRoles)) { - trackEvent('actions', 'add_roles', {role: General.SYSTEM_POST_ALL_ROLE}); - } else if (!UserUtils.hasPostAllRole(roles) && UserUtils.hasPostAllRole(oldRoles)) { - trackEvent('actions', 'remove_roles', {role: General.SYSTEM_POST_ALL_ROLE}); - } - - if (UserUtils.hasPostAllPublicRole(roles) && !UserUtils.hasPostAllPublicRole(oldRoles)) { - trackEvent('actions', 'add_roles', {role: General.SYSTEM_POST_ALL_PUBLIC_ROLE}); - } else if (!UserUtils.hasPostAllPublicRole(roles) && UserUtils.hasPostAllPublicRole(oldRoles)) { - trackEvent('actions', 'remove_roles', {role: General.SYSTEM_POST_ALL_PUBLIC_ROLE}); - } - } - - handleSave = async () => { - this.setState({error: null}); - - let roles = General.SYSTEM_USER_ROLE; - - if (this.state.isSystemAdmin) { - roles += ' ' + General.SYSTEM_ADMIN_ROLE; - } else if (this.state.hasUserAccessTokenRole) { - roles += ' ' + General.SYSTEM_USER_ACCESS_TOKEN_ROLE; - if (this.state.hasPostAllRole) { - roles += ' ' + General.SYSTEM_POST_ALL_ROLE; - } else if (this.state.hasPostAllPublicRole) { - roles += ' ' + General.SYSTEM_POST_ALL_PUBLIC_ROLE; - } - } - - const data = await this.props.actions.updateUserRoles(this.props.user.id, roles); - - this.trackRoleChanges(roles, this.props.user.roles); - - if (data) { - this.props.onModalDismissed(); - } else { - this.handleError( - - ); - } - } - - renderContents = () => { - const {user} = this.props; - - if (user == null) { - return
; - } - - let name = UserUtils.getFullName(user); - if (name) { - name += ` (@${user.username})`; - } else { - name = `@${user.username}`; - } - - let additionalRoles; - if (this.state.hasUserAccessTokenRole || this.state.isSystemAdmin) { - additionalRoles = ( -
-

- -

-
- -
-
- -
-
- ); - } - - let userAccessTokenContent; - if (this.props.userAccessTokensEnabled) { - userAccessTokenContent = ( -
-
- -
-
- {additionalRoles} -
-
- ); - } - - return ( -
-
- -
-
- {name} -
-
- {user.email} -
-
-
-
-
-
- -
-
- -
-
- {userAccessTokenContent} -
-
- ); - } - - render() { - return ( - - - - - - - - {this.renderContents()} - {this.state.error} - - - - - - - ); - } -} -- cgit v1.2.3-1-g7c22