Files
mattermost/web/react/components/team_settings.jsx

85 lines
2.3 KiB
React
Raw Normal View History

// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import TeamStore from '../stores/team_store.jsx';
import ImportTab from './team_import_tab.jsx';
import ExportTab from './team_export_tab.jsx';
import GeneralTab from './team_general_tab.jsx';
import * as Utils from '../utils/utils.jsx';
export default class TeamSettings extends React.Component {
constructor(props) {
super(props);
this.onChange = this.onChange.bind(this);
this.state = {team: TeamStore.getCurrent()};
}
componentDidMount() {
2015-08-18 09:43:22 -04:00
TeamStore.addChangeListener(this.onChange);
}
componentWillUnmount() {
2015-08-18 09:43:22 -04:00
TeamStore.removeChangeListener(this.onChange);
}
onChange() {
2015-08-18 09:43:22 -04:00
var team = TeamStore.getCurrent();
if (!Utils.areObjectsEqual(this.state.team, team)) {
2015-09-24 10:52:32 -07:00
this.setState({team});
}
}
render() {
2016-02-08 07:26:10 -05:00
if (!this.state.team) {
return null;
}
2015-08-18 09:43:22 -04:00
var result;
switch (this.props.activeTab) {
case 'general':
result = (
<div>
<GeneralTab
team={this.state.team}
activeSection={this.props.activeSection}
updateSection={this.props.updateSection}
/>
</div>
);
break;
case 'import':
result = (
<div>
<ImportTab
team={this.state.team}
activeSection={this.props.activeSection}
updateSection={this.props.updateSection}
/>
</div>
);
break;
case 'export':
result = (
<div>
2016-02-22 08:31:10 -05:00
<ExportTab/>
</div>
);
break;
default:
result = (
<div/>
);
break;
2015-07-07 09:16:13 -04:00
}
2015-08-18 09:43:22 -04:00
return result;
}
}
TeamSettings.defaultProps = {
activeTab: '',
2015-10-27 22:18:52 -07:00
activeSection: ''
};
2015-10-27 22:18:52 -07:00
TeamSettings.propTypes = {
activeTab: React.PropTypes.string.isRequired,
activeSection: React.PropTypes.string.isRequired,
2015-10-27 22:18:52 -07:00
updateSection: React.PropTypes.func.isRequired
};