2015-08-31 16:36:24 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
2015-09-18 09:46:37 +02:00
|
|
|
import UserActions from '../../actions/user_actions';
|
|
|
|
|
2015-08-31 16:36:24 +02:00
|
|
|
import AccountSettings from './account_settings';
|
2016-06-06 18:52:05 +02:00
|
|
|
import ApiSettings from './api_settings';
|
2015-08-31 16:36:24 +02:00
|
|
|
import BitcoinWalletSettings from './bitcoin_wallet_settings';
|
2015-11-27 03:24:37 +01:00
|
|
|
import WebhookSettings from './webhook_settings';
|
2015-08-31 16:36:24 +02:00
|
|
|
|
2015-09-23 15:41:12 +02:00
|
|
|
import AclProxy from '../acl_proxy';
|
2016-06-08 13:11:16 +02:00
|
|
|
import withContext from '../context/with_context';
|
2016-06-07 14:53:48 +02:00
|
|
|
import { whitelabelShape } from '../prop_types';
|
2015-09-23 15:41:12 +02:00
|
|
|
|
2016-06-13 14:35:02 +02:00
|
|
|
import { setDocumentTitle } from '../../utils/dom';
|
|
|
|
import { getLangText } from '../../utils/lang';
|
2015-09-23 15:41:12 +02:00
|
|
|
|
2015-08-31 16:36:24 +02:00
|
|
|
|
|
|
|
let SettingsContainer = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
children: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
2016-01-11 12:54:15 +01:00
|
|
|
React.PropTypes.element
|
|
|
|
]),
|
2015-08-31 16:36:24 +02:00
|
|
|
|
2016-06-07 12:05:07 +02:00
|
|
|
// Injected through HOCs
|
|
|
|
isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types
|
2016-06-08 14:54:05 +02:00
|
|
|
whitelabel: whitelabelShape.isRequired // eslint-disable-line react/sort-prop-types
|
2015-09-18 09:46:37 +02:00
|
|
|
},
|
|
|
|
|
2016-01-11 12:54:15 +01:00
|
|
|
loadUser(invalidateCache) {
|
2015-11-02 11:31:02 +01:00
|
|
|
UserActions.fetchCurrentUser(invalidateCache);
|
2015-09-18 09:46:37 +02:00
|
|
|
},
|
|
|
|
|
2015-08-31 16:36:24 +02:00
|
|
|
render() {
|
2016-06-07 12:05:07 +02:00
|
|
|
const { children, isLoggedIn, whitelabel } = this.props;
|
2016-01-11 12:54:15 +01:00
|
|
|
|
2015-10-13 16:42:40 +02:00
|
|
|
setDocumentTitle(getLangText('Account settings'));
|
|
|
|
|
2016-06-07 12:05:07 +02:00
|
|
|
if (isLoggedIn) {
|
2015-09-21 10:32:35 +02:00
|
|
|
return (
|
|
|
|
<div className="settings-container">
|
2016-06-07 14:53:48 +02:00
|
|
|
<AccountSettings loadUser={this.loadUser} />
|
2016-01-11 15:14:54 +01:00
|
|
|
{children}
|
2015-09-23 15:41:12 +02:00
|
|
|
<AclProxy
|
2016-01-11 12:54:15 +01:00
|
|
|
aclObject={whitelabel}
|
2015-09-23 15:41:12 +02:00
|
|
|
aclName="acl_view_settings_api">
|
2016-06-06 18:52:05 +02:00
|
|
|
<ApiSettings />
|
2015-09-23 15:41:12 +02:00
|
|
|
</AclProxy>
|
2015-11-27 03:24:37 +01:00
|
|
|
<WebhookSettings />
|
2015-09-23 15:41:12 +02:00
|
|
|
<AclProxy
|
2016-01-11 12:54:15 +01:00
|
|
|
aclObject={whitelabel}
|
2015-09-23 15:41:12 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-06-08 13:11:16 +02:00
|
|
|
export default withContext(SettingsContainer, 'isLoggedIn', 'whitelabel');
|