1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 18:35:09 +01:00

Integrate new ACLOptions into settings

This commit is contained in:
Tim Daubenschütz 2015-09-23 15:41:12 +02:00
parent 2a4bc2af89
commit 74e7c9a3d9
3 changed files with 102 additions and 85 deletions

View File

@ -89,86 +89,82 @@ let ContractSettings = React.createClass({
return ( return (
<div className="settings-container"> <div className="settings-container">
<AclProxy <CollapsibleParagraph
aclName="acl_view_settings_contract" title={getLangText('Contracts')}
aclObject={this.state.currentUser.acl}> show={true}
<CollapsibleParagraph defaultExpanded={true}>
title={getLangText('Contracts')} <AclProxy
show={true} aclName="acl_edit_public_contract"
defaultExpanded={true}> aclObject={this.state.currentUser.acl}>
<AclProxy <div>
aclName="acl_edit_public_contract" {createPublicContractForm}
aclObject={this.state.currentUser.acl}> {publicContracts.map((contract, i) => {
<div> return (
{createPublicContractForm} <ActionPanel
{publicContracts.map((contract, i) => { key={i}
return ( title={contract.name}
<ActionPanel content={contract.name}
key={i} buttons={
title={contract.name} <div className="pull-right">
content={contract.name} <ContractSettingsUpdateButton contract={contract}/>
buttons={ <a
<div className="pull-right"> className="btn btn-default btn-sm margin-left-2px"
<ContractSettingsUpdateButton contract={contract}/> href={contract.blob.url_safe}
<a target="_blank">
className="btn btn-default btn-sm margin-left-2px" {getLangText('PREVIEW')}
href={contract.blob.url_safe} </a>
target="_blank"> <button
{getLangText('PREVIEW')} className="btn btn-danger btn-sm margin-left-2px"
</a> onClick={this.removeContract(contract)}>
<button {getLangText('REMOVE')}
className="btn btn-danger btn-sm margin-left-2px" </button>
onClick={this.removeContract(contract)}> </div>
{getLangText('REMOVE')} }
</button> leftColumnWidth="40%"
</div> rightColumnWidth="60%"/>
} );
leftColumnWidth="40%" })}
rightColumnWidth="60%"/> </div>
); </AclProxy>
})} <AclProxy
</div> aclName="acl_edit_private_contract"
</AclProxy> aclObject={this.state.currentUser.acl}>
<AclProxy <div>
aclName="acl_edit_private_contract" <CreateContractForm
aclObject={this.state.currentUser.acl}> isPublic={false}
<div> fileClassToUpload={{
<CreateContractForm singular: getLangText('new contract'),
isPublic={false} plural: getLangText('new contracts')
fileClassToUpload={{ }}/>
singular: getLangText('new contract'), {privateContracts.map((contract, i) => {
plural: getLangText('new contracts') return (
}}/> <ActionPanel
{privateContracts.map((contract, i) => { key={i}
return ( title={contract.name}
<ActionPanel content={contract.name}
key={i} buttons={
title={contract.name} <div className="pull-right">
content={contract.name} <ContractSettingsUpdateButton contract={contract} />
buttons={ <a
<div className="pull-right"> className="btn btn-default btn-sm margin-left-2px"
<ContractSettingsUpdateButton contract={contract} /> href={contract.blob.url_safe}
<a target="_blank">
className="btn btn-default btn-sm margin-left-2px" {getLangText('PREVIEW')}
href={contract.blob.url_safe} </a>
target="_blank"> <button
{getLangText('PREVIEW')} className="btn btn-danger btn-sm margin-left-2px"
</a> onClick={this.removeContract(contract)}>
<button {getLangText('REMOVE')}
className="btn btn-danger btn-sm margin-left-2px" </button>
onClick={this.removeContract(contract)}> </div>
{getLangText('REMOVE')} }
</button> leftColumnWidth="40%"
</div> rightColumnWidth="60%"/>
} );
leftColumnWidth="40%" })}
rightColumnWidth="60%"/> </div>
); </AclProxy>
})} </CollapsibleParagraph>
</div>
</AclProxy>
</CollapsibleParagraph>
</AclProxy>
</div> </div>
); );
} }

View File

@ -6,11 +6,17 @@ import Router from 'react-router';
import UserStore from '../../stores/user_store'; import UserStore from '../../stores/user_store';
import UserActions from '../../actions/user_actions'; import UserActions from '../../actions/user_actions';
import WhitelabelStore from '../../stores/whitelabel_store';
import WhitelabelActions from '../../actions/whitelabel_actions';
import AccountSettings from './account_settings'; import AccountSettings from './account_settings';
import BitcoinWalletSettings from './bitcoin_wallet_settings'; import BitcoinWalletSettings from './bitcoin_wallet_settings';
import ContractSettings from './contract_settings';
import APISettings from './api_settings'; import APISettings from './api_settings';
import AclProxy from '../acl_proxy';
import { mergeOptions } from '../../utils/general_utils';
let SettingsContainer = React.createClass({ let SettingsContainer = React.createClass({
propTypes: { propTypes: {
@ -22,15 +28,22 @@ let SettingsContainer = React.createClass({
mixins: [Router.Navigation], mixins: [Router.Navigation],
getInitialState() { getInitialState() {
return UserStore.getState(); return mergeOptions(
UserStore.getState(),
WhitelabelStore.getState()
);
}, },
componentDidMount() { componentDidMount() {
UserStore.listen(this.onChange); UserStore.listen(this.onChange);
WhitelabelStore.listen(this.onChange);
WhitelabelActions.fetchWhitelabel();
UserActions.fetchCurrentUser(); UserActions.fetchCurrentUser();
}, },
componentWillUnmount() { componentWillUnmount() {
WhitelabelStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange); UserStore.unlisten(this.onChange);
}, },
@ -48,8 +61,16 @@ let SettingsContainer = React.createClass({
<div className="settings-container"> <div className="settings-container">
<AccountSettings currentUser={this.state.currentUser} loadUser={this.loadUser}/> <AccountSettings currentUser={this.state.currentUser} loadUser={this.loadUser}/>
{this.props.children} {this.props.children}
<APISettings /> <AclProxy
<BitcoinWalletSettings /> aclObject={this.state.whitelabel}
aclName="acl_view_settings_api">
<APISettings />
</AclProxy>
<AclProxy
aclObject={this.state.whitelabel}
aclName="acl_view_settings_bitcoin">
<BitcoinWalletSettings />
</AclProxy>
</div> </div>
); );
} }

View File

@ -139,7 +139,7 @@ let Header = React.createClass({
{getLangText('Account Settings')} {getLangText('Account Settings')}
</MenuItemLink> </MenuItemLink>
<AclProxy <AclProxy
aclObject={this.state.whitelabel} aclObject={this.state.currentUser.acl}
aclName="acl_view_settings_contract"> aclName="acl_view_settings_contract">
<MenuItemLink <MenuItemLink
to="contract_settings" to="contract_settings"