1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

separate contract settings from account settings

This commit is contained in:
Tim Daubenschütz 2015-09-23 15:16:46 +02:00
parent 4302da2f81
commit 2a4bc2af89
5 changed files with 111 additions and 90 deletions

View File

@ -8,6 +8,9 @@ import CreateContractForm from '../ascribe_forms/form_create_contract';
import ContractListStore from '../../stores/contract_list_store'; import ContractListStore from '../../stores/contract_list_store';
import ContractListActions from '../../actions/contract_list_actions'; import ContractListActions from '../../actions/contract_list_actions';
import UserStore from '../../stores/user_store';
import UserActions from '../../actions/user_actions';
import ActionPanel from '../ascribe_panel/action_panel'; import ActionPanel from '../ascribe_panel/action_panel';
import ContractSettingsUpdateButton from './contract_settings_update_button'; import ContractSettingsUpdateButton from './contract_settings_update_button';
@ -17,24 +20,27 @@ import GlobalNotificationActions from '../../actions/global_notification_actions
import AclProxy from '../acl_proxy'; import AclProxy from '../acl_proxy';
import { getLangText } from '../../utils/lang_utils'; import { getLangText } from '../../utils/lang_utils';
import { mergeOptions } from '../../utils/general_utils';
let ContractSettings = React.createClass({ let ContractSettings = React.createClass({
propTypes: {
currentUser: React.PropTypes.object,
defaultExpanded: React.PropTypes.bool
},
getInitialState(){ getInitialState(){
return ContractListStore.getState(); return mergeOptions(
ContractListStore.getState(),
UserStore.getState()
);
}, },
componentDidMount() { componentDidMount() {
ContractListStore.listen(this.onChange); ContractListStore.listen(this.onChange);
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
ContractListActions.fetchContractList(true); ContractListActions.fetchContractList(true);
}, },
componentWillUnmount() { componentWillUnmount() {
UserStore.unlisten(this.onChange);
ContractListStore.unlisten(this.onChange); ContractListStore.unlisten(this.onChange);
}, },
@ -82,86 +88,88 @@ let ContractSettings = React.createClass({
} }
return ( return (
<AclProxy <div className="settings-container">
aclName="acl_view_settings_contract" <AclProxy
aclObject={this.props.currentUser.acl}> aclName="acl_view_settings_contract"
<CollapsibleParagraph aclObject={this.state.currentUser.acl}>
title={getLangText('Contracts')} <CollapsibleParagraph
show={true} title={getLangText('Contracts')}
defaultExpanded={false}> show={true}
<AclProxy defaultExpanded={true}>
aclName="acl_edit_public_contract" <AclProxy
aclObject={this.props.currentUser.acl}> aclName="acl_edit_public_contract"
<div> aclObject={this.state.currentUser.acl}>
{createPublicContractForm} <div>
{publicContracts.map((contract, i) => { {createPublicContractForm}
return ( {publicContracts.map((contract, i) => {
<ActionPanel return (
key={i} <ActionPanel
title={contract.name} key={i}
content={contract.name} title={contract.name}
buttons={ content={contract.name}
<div className="pull-right"> buttons={
<ContractSettingsUpdateButton contract={contract}/> <div className="pull-right">
<a <ContractSettingsUpdateButton contract={contract}/>
className="btn btn-default btn-sm margin-left-2px" <a
href={contract.blob.url_safe} className="btn btn-default btn-sm margin-left-2px"
target="_blank"> href={contract.blob.url_safe}
{getLangText('PREVIEW')} target="_blank">
</a> {getLangText('PREVIEW')}
<button </a>
className="btn btn-danger btn-sm margin-left-2px" <button
onClick={this.removeContract(contract)}> className="btn btn-danger btn-sm margin-left-2px"
{getLangText('REMOVE')} onClick={this.removeContract(contract)}>
</button> {getLangText('REMOVE')}
</div> </button>
} </div>
leftColumnWidth="40%" }
rightColumnWidth="60%"/> leftColumnWidth="40%"
); rightColumnWidth="60%"/>
})} );
</div> })}
</AclProxy> </div>
<AclProxy </AclProxy>
aclName="acl_edit_private_contract" <AclProxy
aclObject={this.props.currentUser.acl}> aclName="acl_edit_private_contract"
<div> aclObject={this.state.currentUser.acl}>
<CreateContractForm <div>
isPublic={false} <CreateContractForm
fileClassToUpload={{ isPublic={false}
singular: getLangText('new contract'), fileClassToUpload={{
plural: getLangText('new contracts') singular: getLangText('new contract'),
}}/> plural: getLangText('new contracts')
{privateContracts.map((contract, i) => { }}/>
return ( {privateContracts.map((contract, i) => {
<ActionPanel return (
key={i} <ActionPanel
title={contract.name} key={i}
content={contract.name} title={contract.name}
buttons={ content={contract.name}
<div className="pull-right"> buttons={
<ContractSettingsUpdateButton contract={contract} /> <div className="pull-right">
<a <ContractSettingsUpdateButton contract={contract} />
className="btn btn-default btn-sm margin-left-2px" <a
href={contract.blob.url_safe} className="btn btn-default btn-sm margin-left-2px"
target="_blank"> href={contract.blob.url_safe}
{getLangText('PREVIEW')} target="_blank">
</a> {getLangText('PREVIEW')}
<button </a>
className="btn btn-danger btn-sm margin-left-2px" <button
onClick={this.removeContract(contract)}> className="btn btn-danger btn-sm margin-left-2px"
{getLangText('REMOVE')} onClick={this.removeContract(contract)}>
</button> {getLangText('REMOVE')}
</div> </button>
} </div>
leftColumnWidth="40%" }
rightColumnWidth="60%"/> leftColumnWidth="40%"
); rightColumnWidth="60%"/>
})} );
</div> })}
</AclProxy> </div>
</CollapsibleParagraph> </AclProxy>
</AclProxy> </CollapsibleParagraph>
</AclProxy>
</div>
); );
} }
}); });

View File

@ -50,7 +50,6 @@ let SettingsContainer = React.createClass({
{this.props.children} {this.props.children}
<APISettings /> <APISettings />
<BitcoinWalletSettings /> <BitcoinWalletSettings />
<ContractSettings currentUser={this.state.currentUser} loadUser={this.loadUser}/>
</div> </div>
); );
} }

View File

@ -3,7 +3,6 @@
import React from 'react'; import React from 'react';
import Router from 'react-router'; import Router from 'react-router';
import Nav from 'react-bootstrap/lib/Nav'; import Nav from 'react-bootstrap/lib/Nav';
import Navbar from 'react-bootstrap/lib/Navbar'; import Navbar from 'react-bootstrap/lib/Navbar';
import CollapsibleNav from 'react-bootstrap/lib/CollapsibleNav'; import CollapsibleNav from 'react-bootstrap/lib/CollapsibleNav';
@ -12,6 +11,8 @@ import MenuItem from 'react-bootstrap/lib/MenuItem';
import MenuItemLink from 'react-router-bootstrap/lib/MenuItemLink'; import MenuItemLink from 'react-router-bootstrap/lib/MenuItemLink';
import NavItemLink from 'react-router-bootstrap/lib/NavItemLink'; import NavItemLink from 'react-router-bootstrap/lib/NavItemLink';
import AclProxy from './acl_proxy';
import UserActions from '../actions/user_actions'; import UserActions from '../actions/user_actions';
import UserStore from '../stores/user_store'; import UserStore from '../stores/user_store';
@ -96,7 +97,7 @@ let Header = React.createClass({
} }
}, },
onMenuItemClick(event) { onMenuItemClick() {
/* /*
This is a hack to make the dropdown close after clicking on an item This is a hack to make the dropdown close after clicking on an item
The function just need to be defined The function just need to be defined
@ -137,6 +138,15 @@ let Header = React.createClass({
onClick={this.onMenuItemClick}> onClick={this.onMenuItemClick}>
{getLangText('Account Settings')} {getLangText('Account Settings')}
</MenuItemLink> </MenuItemLink>
<AclProxy
aclObject={this.state.whitelabel}
aclName="acl_view_settings_contract">
<MenuItemLink
to="contract_settings"
onClick={this.onMenuItemClick}>
{getLangText('Contract Settings')}
</MenuItemLink>
</AclProxy>
<MenuItem divider /> <MenuItem divider />
<MenuItemLink eventKey="3" to="logout">{getLangText('Log out')}</MenuItemLink> <MenuItemLink eventKey="3" to="logout">{getLangText('Log out')}</MenuItemLink>
</DropdownButton> </DropdownButton>

View File

@ -12,7 +12,7 @@ import PieceList from '../../../components/piece_list';
import PieceContainer from '../../../components/ascribe_detail/piece_container'; import PieceContainer from '../../../components/ascribe_detail/piece_container';
import EditionContainer from '../../../components/ascribe_detail/edition_container'; import EditionContainer from '../../../components/ascribe_detail/edition_container';
import SettingsContainer from '../../../components/ascribe_settings/settings_container'; import SettingsContainer from '../../../components/ascribe_settings/settings_container';
import RegisterPiece from '../../../components/register_piece'; import ContractSettings from '../../../components/ascribe_settings/contract_settings';
import CylandLanding from './components/cyland/cyland_landing'; import CylandLanding from './components/cyland/cyland_landing';
import CylandPieceContainer from './components/cyland/ascribe_detail/cyland_piece_container'; import CylandPieceContainer from './components/cyland/ascribe_detail/cyland_piece_container';
@ -49,6 +49,7 @@ let ROUTES = {
<Route name="piece" path="pieces/:pieceId" handler={CylandPieceContainer} /> <Route name="piece" path="pieces/:pieceId" handler={CylandPieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} /> <Route name="edition" path="editions/:editionId" handler={EditionContainer} />
<Route name="settings" path="settings" handler={SettingsContainer} /> <Route name="settings" path="settings" handler={SettingsContainer} />
<Route name="contract_settings" path="contract_settings" handler={ContractSettings} />
</Route> </Route>
), ),
'cc': ( 'cc': (
@ -79,6 +80,7 @@ let ROUTES = {
<Route name="piece" path="pieces/:pieceId" handler={IkonotvPieceContainer} /> <Route name="piece" path="pieces/:pieceId" handler={IkonotvPieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} /> <Route name="edition" path="editions/:editionId" handler={EditionContainer} />
<Route name="settings" path="settings" handler={SettingsContainer} /> <Route name="settings" path="settings" handler={SettingsContainer} />
<Route name="contract_settings" path="contract_settings" handler={ContractSettings} />
<Route name="contract_notifications" path="contract_notifications" handler={IkonotvContractNotifications} /> <Route name="contract_notifications" path="contract_notifications" handler={IkonotvContractNotifications} />
</Route> </Route>
) )

View File

@ -17,6 +17,7 @@ import LogoutContainer from './components/logout_container';
import SignupContainer from './components/signup_container'; import SignupContainer from './components/signup_container';
import PasswordResetContainer from './components/password_reset_container'; import PasswordResetContainer from './components/password_reset_container';
import ContractSettings from './components/ascribe_settings/contract_settings';
import SettingsContainer from './components/ascribe_settings/settings_container'; import SettingsContainer from './components/ascribe_settings/settings_container';
import CoaVerifyContainer from './components/coa_verify_container'; import CoaVerifyContainer from './components/coa_verify_container';
@ -43,6 +44,7 @@ const COMMON_ROUTES = (
<Route name="edition" path="editions/:editionId" handler={EditionContainer} /> <Route name="edition" path="editions/:editionId" handler={EditionContainer} />
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} /> <Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
<Route name="settings" path="settings" handler={SettingsContainer} /> <Route name="settings" path="settings" handler={SettingsContainer} />
<Route name="contract_settings" path="contract_settings" handler={ContractSettings} />
<Route name="coa_verify" path="verify" handler={CoaVerifyContainer} /> <Route name="coa_verify" path="verify" handler={CoaVerifyContainer} />
<Route name="contract_notifications" path="verify" handler={ContractNotification} /> <Route name="contract_notifications" path="verify" handler={ContractNotification} />
</Route> </Route>