1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-08 04:34:26 +01:00
onion/js/components/ascribe_settings/settings_container.js

68 lines
2.1 KiB
JavaScript
Raw Normal View History

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