2015-08-31 16:36:24 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
2015-09-18 09:46:37 +02:00
|
|
|
import UserStore from '../../stores/user_store';
|
|
|
|
import UserActions from '../../actions/user_actions';
|
|
|
|
|
2015-09-23 15:41:12 +02:00
|
|
|
import WhitelabelStore from '../../stores/whitelabel_store';
|
|
|
|
import WhitelabelActions from '../../actions/whitelabel_actions';
|
|
|
|
|
2015-08-31 16:36:24 +02:00
|
|
|
import AccountSettings from './account_settings';
|
|
|
|
import BitcoinWalletSettings from './bitcoin_wallet_settings';
|
|
|
|
import APISettings from './api_settings';
|
|
|
|
|
2015-09-23 15:41:12 +02:00
|
|
|
import AclProxy from '../acl_proxy';
|
|
|
|
|
|
|
|
import { mergeOptions } from '../../utils/general_utils';
|
|
|
|
|
2015-08-31 16:36:24 +02:00
|
|
|
|
|
|
|
let SettingsContainer = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
children: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
|
|
|
React.PropTypes.element])
|
|
|
|
},
|
|
|
|
|
2015-09-18 09:46:37 +02:00
|
|
|
getInitialState() {
|
2015-09-23 15:41:12 +02:00
|
|
|
return mergeOptions(
|
|
|
|
UserStore.getState(),
|
|
|
|
WhitelabelStore.getState()
|
|
|
|
);
|
2015-09-18 09:46:37 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
UserStore.listen(this.onChange);
|
2015-09-23 15:41:12 +02:00
|
|
|
WhitelabelStore.listen(this.onChange);
|
|
|
|
|
|
|
|
WhitelabelActions.fetchWhitelabel();
|
2015-09-18 09:46:37 +02:00
|
|
|
UserActions.fetchCurrentUser();
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
2015-09-23 15:41:12 +02:00
|
|
|
WhitelabelStore.unlisten(this.onChange);
|
2015-09-18 09:46:37 +02:00
|
|
|
UserStore.unlisten(this.onChange);
|
|
|
|
},
|
|
|
|
|
|
|
|
loadUser(){
|
|
|
|
UserActions.fetchCurrentUser();
|
|
|
|
},
|
|
|
|
|
|
|
|
onChange(state) {
|
|
|
|
this.setState(state);
|
|
|
|
},
|
|
|
|
|
2015-08-31 16:36:24 +02:00
|
|
|
render() {
|
2015-09-21 10:32:35 +02:00
|
|
|
if (this.state.currentUser && this.state.currentUser.username) {
|
|
|
|
return (
|
|
|
|
<div className="settings-container">
|
2015-09-28 12:00:13 +02:00
|
|
|
<AccountSettings
|
|
|
|
currentUser={this.state.currentUser}
|
|
|
|
loadUser={this.loadUser}
|
|
|
|
whitelabel={this.state.whitelabel}/>
|
2015-09-21 10:32:35 +02:00
|
|
|
{this.props.children}
|
2015-09-23 15:41:12 +02:00
|
|
|
<AclProxy
|
|
|
|
aclObject={this.state.whitelabel}
|
|
|
|
aclName="acl_view_settings_api">
|
|
|
|
<APISettings />
|
|
|
|
</AclProxy>
|
|
|
|
<AclProxy
|
|
|
|
aclObject={this.state.whitelabel}
|
|
|
|
aclName="acl_view_settings_bitcoin">
|
|
|
|
<BitcoinWalletSettings />
|
|
|
|
</AclProxy>
|
2015-09-21 10:32:35 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
2015-08-31 16:36:24 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default SettingsContainer;
|