mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
101 lines
3.3 KiB
JavaScript
101 lines
3.3 KiB
JavaScript
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
var UserStore = require('../stores/user_store.jsx');
|
|
var utils = require('../utils/utils.jsx');
|
|
var NotificationsTab = require('./user_settings_notifications.jsx');
|
|
var SecurityTab = require('./user_settings_security.jsx');
|
|
var GeneralTab = require('./user_settings_general.jsx');
|
|
var AppearanceTab = require('./user_settings_appearance.jsx');
|
|
var DeveloperTab = require('./user_settings_developer.jsx');
|
|
|
|
export default class UserSettings extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.onListenerChange = this.onListenerChange.bind(this);
|
|
|
|
this.state = {user: UserStore.getCurrentUser()};
|
|
}
|
|
|
|
componentDidMount() {
|
|
UserStore.addChangeListener(this.onListenerChange);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
UserStore.removeChangeListener(this.onListenerChange);
|
|
}
|
|
|
|
onListenerChange() {
|
|
var user = UserStore.getCurrentUser();
|
|
if (!utils.areStatesEqual(this.state.user, user)) {
|
|
this.setState({user: user});
|
|
}
|
|
}
|
|
|
|
render() {
|
|
if (this.props.activeTab === 'general') {
|
|
return (
|
|
<div>
|
|
<GeneralTab
|
|
user={this.state.user}
|
|
activeSection={this.props.activeSection}
|
|
updateSection={this.props.updateSection}
|
|
updateTab={this.props.updateTab}
|
|
/>
|
|
</div>
|
|
);
|
|
} else if (this.props.activeTab === 'security') {
|
|
return (
|
|
<div>
|
|
<SecurityTab
|
|
user={this.state.user}
|
|
activeSection={this.props.activeSection}
|
|
updateSection={this.props.updateSection}
|
|
updateTab={this.props.updateTab}
|
|
/>
|
|
</div>
|
|
);
|
|
} else if (this.props.activeTab === 'notifications') {
|
|
return (
|
|
<div>
|
|
<NotificationsTab
|
|
user={this.state.user}
|
|
activeSection={this.props.activeSection}
|
|
updateSection={this.props.updateSection}
|
|
updateTab={this.props.updateTab}
|
|
/>
|
|
</div>
|
|
);
|
|
} else if (this.props.activeTab === 'appearance') {
|
|
return (
|
|
<div>
|
|
<AppearanceTab
|
|
activeSection={this.props.activeSection}
|
|
updateSection={this.props.updateSection}
|
|
updateTab={this.props.updateTab}
|
|
/>
|
|
</div>
|
|
);
|
|
} else if (this.props.activeTab === 'developer') {
|
|
return (
|
|
<div>
|
|
<DeveloperTab
|
|
activeSection={this.props.activeSection}
|
|
updateSection={this.props.updateSection}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return <div/>;
|
|
}
|
|
}
|
|
|
|
UserSettings.propTypes = {
|
|
activeTab: React.PropTypes.string,
|
|
activeSection: React.PropTypes.string,
|
|
updateSection: React.PropTypes.func,
|
|
updateTab: React.PropTypes.func
|
|
};
|