// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. var Client = require('../../utils/client.jsx'); var Utils = require('../../utils/utils.jsx'); export default class UserItem extends React.Component { constructor(props) { super(props); this.handleMakeMember = this.handleMakeMember.bind(this); this.handleMakeActive = this.handleMakeActive.bind(this); this.handleMakeNotActive = this.handleMakeNotActive.bind(this); this.handleMakeAdmin = this.handleMakeAdmin.bind(this); this.handleMakeSystemAdmin = this.handleMakeSystemAdmin.bind(this); this.handleResetPassword = this.handleResetPassword.bind(this); this.state = {}; } handleMakeMember(e) { e.preventDefault(); const data = { user_id: this.props.user.id, new_roles: '' }; Client.updateRoles(data, () => { this.props.refreshProfiles(); }, (err) => { this.setState({serverError: err.message}); } ); } handleMakeActive(e) { e.preventDefault(); Client.updateActive(this.props.user.id, true, () => { this.props.refreshProfiles(); }, (err) => { this.setState({serverError: err.message}); } ); } handleMakeNotActive(e) { e.preventDefault(); Client.updateActive(this.props.user.id, false, () => { this.props.refreshProfiles(); }, (err) => { this.setState({serverError: err.message}); } ); } handleMakeAdmin(e) { e.preventDefault(); const data = { user_id: this.props.user.id, new_roles: 'admin' }; Client.updateRoles(data, () => { this.props.refreshProfiles(); }, (err) => { this.setState({serverError: err.message}); } ); } handleMakeSystemAdmin(e) { e.preventDefault(); const data = { user_id: this.props.user.id, new_roles: 'system_admin' }; Client.updateRoles(data, () => { this.props.refreshProfiles(); }, (err) => { this.setState({serverError: err.message}); } ); } handleResetPassword(e) { e.preventDefault(); this.props.doPasswordReset(this.props.user); } render() { let serverError = null; if (this.state.serverError) { serverError = (