* PLT-2713 Added ability for admins to list users not in any team * Updated style of unit test * Split SearchableUserList to give better control over its properties * Added users without any teams to the user store * Added ManageUsers page * Renamed ManageUsers to SystemUsers * Added ability to search by user id in SystemUsers page * Added SystemUsersDropdown * Removed unnecessary injectIntl * Created TeamUtils * Reduced scope of system console heading CSS * Added team filter to TeamAnalytics page * Updated admin console sidebar * Removed unnecessary TODO * Removed unused reference to deleted modal * Fixed system console sidebar not scrolling on first load * Fixed TeamAnalytics page not rendering on first load * Fixed chart.js throwing an error when switching between teams * Changed TeamAnalytics header to show the team's display name * Fixed appearance of TeamAnalytics and SystemUsers on small screen widths * Fixed placement of 'No users found' message * Fixed teams not appearing in SystemUsers on first load * Updated user count text for SystemUsers * Changed search by id fallback to trigger less often * Fixed SystemUsers list items not updating when searching * Fixed localization strings for SystemUsers page
141 строка
3.6 KiB
JavaScript
141 строка
3.6 KiB
JavaScript
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import React from 'react';
|
|
|
|
import * as AsyncClient from 'utils/async_client.jsx';
|
|
|
|
import FormError from 'components/form_error.jsx';
|
|
import SaveButton from 'components/admin_console/save_button.jsx';
|
|
|
|
import {saveConfig} from 'actions/admin_actions.jsx';
|
|
|
|
export default class AdminSettings extends React.Component {
|
|
static get propTypes() {
|
|
return {
|
|
config: React.PropTypes.object
|
|
};
|
|
}
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.handleChange = this.handleChange.bind(this);
|
|
this.handleSubmit = this.handleSubmit.bind(this);
|
|
this.doSubmit = this.doSubmit.bind(this);
|
|
|
|
this.state = Object.assign(this.getStateFromConfig(props.config), {
|
|
saveNeeded: false,
|
|
saving: false,
|
|
serverError: null
|
|
});
|
|
}
|
|
|
|
handleChange(id, value) {
|
|
this.setState({
|
|
saveNeeded: true,
|
|
[id]: value
|
|
});
|
|
}
|
|
|
|
handleSubmit(e) {
|
|
e.preventDefault();
|
|
|
|
this.doSubmit();
|
|
}
|
|
|
|
doSubmit(callback) {
|
|
this.setState({
|
|
saving: true,
|
|
serverError: null
|
|
});
|
|
|
|
// clone config so that we aren't modifying data in the stores
|
|
let config = JSON.parse(JSON.stringify(this.props.config));
|
|
config = this.getConfigFromState(config);
|
|
|
|
saveConfig(
|
|
config,
|
|
() => {
|
|
AsyncClient.getConfig((savedConfig) => {
|
|
this.setState(this.getStateFromConfig(savedConfig));
|
|
});
|
|
|
|
this.setState({
|
|
saveNeeded: false,
|
|
saving: false
|
|
});
|
|
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
},
|
|
(err) => {
|
|
this.setState({
|
|
saving: false,
|
|
serverError: err.message
|
|
});
|
|
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
parseInt(str, defaultValue) {
|
|
const n = parseInt(str, 10);
|
|
|
|
if (isNaN(n)) {
|
|
if (defaultValue) {
|
|
return defaultValue;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
return n;
|
|
}
|
|
|
|
parseIntNonZero(str, defaultValue) {
|
|
const n = parseInt(str, 10);
|
|
|
|
if (isNaN(n) || n < 1) {
|
|
if (defaultValue) {
|
|
return defaultValue;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
return n;
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className='wrapper--fixed'>
|
|
<h3 className='admin-console-header'>
|
|
{this.renderTitle()}
|
|
</h3>
|
|
<form
|
|
className='form-horizontal'
|
|
role='form'
|
|
onSubmit={this.handleSubmit}
|
|
>
|
|
{this.renderSettings()}
|
|
<div className='form-group'>
|
|
<FormError error={this.state.serverError}/>
|
|
</div>
|
|
<div className='form-group'>
|
|
<div className='col-sm-12'>
|
|
<SaveButton
|
|
saving={this.state.saving}
|
|
disabled={!this.state.saveNeeded || (this.canSave && !this.canSave())}
|
|
onClick={this.handleSubmit}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
);
|
|
}
|
|
}
|