mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 01:25:17 +01:00
acl on contract settings
This commit is contained in:
parent
05fe507a3f
commit
7bccb26d82
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import UserStore from '../../stores/user_store';
|
|
||||||
import UserActions from '../../actions/user_actions';
|
|
||||||
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
@ -19,38 +16,26 @@ import AppConstants from '../../constants/application_constants';
|
|||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
let AccountSettings = React.createClass({
|
let AccountSettings = React.createClass({
|
||||||
getInitialState() {
|
propTypes: {
|
||||||
return UserStore.getState();
|
currentUser: React.PropTypes.object.required,
|
||||||
},
|
loadUser: React.PropTypes.func.required
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
UserStore.listen(this.onChange);
|
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
},
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
},
|
|
||||||
|
|
||||||
onChange(state) {
|
|
||||||
this.setState(state);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess(){
|
handleSuccess(){
|
||||||
UserActions.fetchCurrentUser();
|
this.props.loadUser();
|
||||||
let notification = new GlobalNotificationModel(getLangText('Settings succesfully updated'), 'success', 5000);
|
let notification = new GlobalNotificationModel(getLangText('Settings succesfully updated'), 'success', 5000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
},
|
},
|
||||||
|
|
||||||
getFormDataProfile(){
|
getFormDataProfile(){
|
||||||
return {'email': this.state.currentUser.email};
|
return {'email': this.props.currentUser.email};
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let content = <img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />;
|
let content = <img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />;
|
||||||
let profile = null;
|
let profile = null;
|
||||||
|
|
||||||
if (this.state.currentUser.username) {
|
if (this.props.currentUser.username) {
|
||||||
content = (
|
content = (
|
||||||
<Form
|
<Form
|
||||||
url={ApiUrls.users_username}
|
url={ApiUrls.users_username}
|
||||||
@ -60,7 +45,7 @@ let AccountSettings = React.createClass({
|
|||||||
label={getLangText('Username')}>
|
label={getLangText('Username')}>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
defaultValue={this.state.currentUser.username}
|
defaultValue={this.props.currentUser.username}
|
||||||
placeholder={getLangText('Enter your username')}
|
placeholder={getLangText('Enter your username')}
|
||||||
required/>
|
required/>
|
||||||
</Property>
|
</Property>
|
||||||
@ -70,7 +55,7 @@ let AccountSettings = React.createClass({
|
|||||||
editable={false}>
|
editable={false}>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
defaultValue={this.state.currentUser.email}
|
defaultValue={this.props.currentUser.email}
|
||||||
placeholder={getLangText('Enter your username')}
|
placeholder={getLangText('Enter your username')}
|
||||||
required/>
|
required/>
|
||||||
</Property>
|
</Property>
|
||||||
@ -87,7 +72,7 @@ let AccountSettings = React.createClass({
|
|||||||
className="ascribe-settings-property-collapsible-toggle"
|
className="ascribe-settings-property-collapsible-toggle"
|
||||||
style={{paddingBottom: 0}}>
|
style={{paddingBottom: 0}}>
|
||||||
<InputCheckbox
|
<InputCheckbox
|
||||||
defaultChecked={this.state.currentUser.profile.hash_locally}>
|
defaultChecked={this.props.currentUser.profile.hash_locally}>
|
||||||
<span>
|
<span>
|
||||||
{' ' + getLangText('Enable hash option, e.g. slow connections or to keep piece private')}
|
{' ' + getLangText('Enable hash option, e.g. slow connections or to keep piece private')}
|
||||||
</span>
|
</span>
|
||||||
|
@ -14,11 +14,14 @@ import ContractSettingsUpdateButton from './contract_settings_update_button';
|
|||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
import AclProxy from '../acl_proxy';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
|
|
||||||
let ContractSettings = React.createClass({
|
let ContractSettings = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
defaultExpanded: React.PropTypes.bool
|
defaultExpanded: React.PropTypes.bool
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -79,80 +82,92 @@ let ContractSettings = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CollapsibleParagraph
|
<AclProxy
|
||||||
title={getLangText('Contracts')}
|
aclName="acl_view_contract_settings"
|
||||||
show={true}
|
aclObject={this.props.currentUser.acl}>
|
||||||
defaultExpanded={true}>
|
|
||||||
<CollapsibleParagraph
|
<CollapsibleParagraph
|
||||||
title={getLangText('Public Contracts')}
|
title={getLangText('Contracts')}
|
||||||
show={true}
|
show={true}
|
||||||
defaultExpanded={true}>
|
defaultExpanded={true}>
|
||||||
{createPublicContractForm}
|
<AclProxy
|
||||||
{publicContracts.map((contract, i) => {
|
aclName="acl_edit_public_contract"
|
||||||
return (
|
aclObject={this.props.currentUser.acl}>
|
||||||
<ActionPanel
|
<CollapsibleParagraph
|
||||||
key={i}
|
title={getLangText('Public Contracts')}
|
||||||
title={contract.name}
|
show={true}
|
||||||
content={contract.name}
|
defaultExpanded={true}>
|
||||||
buttons={
|
{createPublicContractForm}
|
||||||
<div className="pull-right">
|
{publicContracts.map((contract, i) => {
|
||||||
<ContractSettingsUpdateButton contract={contract}/>
|
return (
|
||||||
<a
|
<ActionPanel
|
||||||
className="btn btn-default btn-sm margin-left-2px"
|
key={i}
|
||||||
href={contract.blob.url_safe}
|
title={contract.name}
|
||||||
target="_blank">
|
content={contract.name}
|
||||||
{getLangText('PREVIEW')}
|
buttons={
|
||||||
</a>
|
<div className="pull-right">
|
||||||
<button
|
<ContractSettingsUpdateButton contract={contract}/>
|
||||||
className="btn btn-default btn-sm margin-left-2px"
|
<a
|
||||||
onClick={this.removeContract(contract)}>
|
className="btn btn-default btn-sm margin-left-2px"
|
||||||
{getLangText('REMOVE')}
|
href={contract.blob.url_safe}
|
||||||
</button>
|
target="_blank">
|
||||||
</div>
|
{getLangText('PREVIEW')}
|
||||||
}
|
</a>
|
||||||
leftColumnWidth="40%"
|
<button
|
||||||
rightColumnWidth="60%"/>
|
className="btn btn-default btn-sm margin-left-2px"
|
||||||
);
|
onClick={this.removeContract(contract)}>
|
||||||
})}
|
{getLangText('REMOVE')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
leftColumnWidth="40%"
|
||||||
|
rightColumnWidth="60%"/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CollapsibleParagraph>
|
||||||
|
</AclProxy>
|
||||||
|
<AclProxy
|
||||||
|
aclName="acl_edit_private_contract"
|
||||||
|
aclObject={this.props.currentUser.acl}>
|
||||||
|
<CollapsibleParagraph
|
||||||
|
title={getLangText('Private Contracts')}
|
||||||
|
show={true}
|
||||||
|
defaultExpanded={true}>
|
||||||
|
<CreateContractForm
|
||||||
|
isPublic={false}
|
||||||
|
fileClassToUpload={{
|
||||||
|
singular: getLangText('new private contract'),
|
||||||
|
plural: getLangText('new private contracts')
|
||||||
|
}}/>
|
||||||
|
{privateContracts.map((contract, i) => {
|
||||||
|
return (
|
||||||
|
<ActionPanel
|
||||||
|
key={i}
|
||||||
|
title={contract.name}
|
||||||
|
content={contract.name}
|
||||||
|
buttons={
|
||||||
|
<div className="pull-right">
|
||||||
|
<ContractSettingsUpdateButton contract={contract} />
|
||||||
|
<a
|
||||||
|
className="btn btn-default btn-sm margin-left-2px"
|
||||||
|
href={contract.blob.url_safe}
|
||||||
|
target="_blank">
|
||||||
|
{getLangText('PREVIEW')}
|
||||||
|
</a>
|
||||||
|
<button
|
||||||
|
className="btn btn-default btn-sm margin-left-2px"
|
||||||
|
onClick={this.removeContract(contract)}>
|
||||||
|
{getLangText('REMOVE')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
leftColumnWidth="40%"
|
||||||
|
rightColumnWidth="60%"/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CollapsibleParagraph>
|
||||||
|
</AclProxy>
|
||||||
</CollapsibleParagraph>
|
</CollapsibleParagraph>
|
||||||
<CollapsibleParagraph
|
</AclProxy>
|
||||||
title={getLangText('Private Contracts')}
|
|
||||||
show={true}
|
|
||||||
defaultExpanded={true}>
|
|
||||||
<CreateContractForm
|
|
||||||
isPublic={false}
|
|
||||||
fileClassToUpload={{
|
|
||||||
singular: getLangText('new private contract'),
|
|
||||||
plural: getLangText('new private contracts')
|
|
||||||
}}/>
|
|
||||||
{privateContracts.map((contract, i) => {
|
|
||||||
return (
|
|
||||||
<ActionPanel
|
|
||||||
key={i}
|
|
||||||
title={contract.name}
|
|
||||||
content={contract.name}
|
|
||||||
buttons={
|
|
||||||
<div className="pull-right">
|
|
||||||
<ContractSettingsUpdateButton contract={contract} />
|
|
||||||
<a
|
|
||||||
className="btn btn-default btn-sm margin-left-2px"
|
|
||||||
href={contract.blob.url_safe}
|
|
||||||
target="_blank">
|
|
||||||
{getLangText('PREVIEW')}
|
|
||||||
</a>
|
|
||||||
<button
|
|
||||||
className="btn btn-default btn-sm margin-left-2px"
|
|
||||||
onClick={this.removeContract(contract)}>
|
|
||||||
{getLangText('REMOVE')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
leftColumnWidth="40%"
|
|
||||||
rightColumnWidth="60%"/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CollapsibleParagraph>
|
|
||||||
</CollapsibleParagraph>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Router from 'react-router';
|
import Router from 'react-router';
|
||||||
|
|
||||||
|
import UserStore from '../../stores/user_store';
|
||||||
|
import UserActions from '../../actions/user_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 ContractSettings from './contract_settings';
|
||||||
@ -18,14 +21,35 @@ let SettingsContainer = React.createClass({
|
|||||||
|
|
||||||
mixins: [Router.Navigation],
|
mixins: [Router.Navigation],
|
||||||
|
|
||||||
|
getInitialState() {
|
||||||
|
return UserStore.getState();
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
UserStore.listen(this.onChange);
|
||||||
|
UserActions.fetchCurrentUser();
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
UserStore.unlisten(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
loadUser(){
|
||||||
|
UserActions.fetchCurrentUser();
|
||||||
|
},
|
||||||
|
|
||||||
|
onChange(state) {
|
||||||
|
this.setState(state);
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="settings-container">
|
<div className="settings-container">
|
||||||
<AccountSettings />
|
<AccountSettings currentUser={this.state.currentUser} loadUser={this.loadUser}/>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
<APISettings />
|
<APISettings />
|
||||||
<BitcoinWalletSettings />
|
<BitcoinWalletSettings />
|
||||||
<ContractSettings />
|
<ContractSettings currentUser={this.state.currentUser} loadUser={this.loadUser}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@ function getWalletApiUrls(subdomain) {
|
|||||||
return {
|
return {
|
||||||
'pieces_list': walletConstants.walletApiEndpoint + subdomain + '/pieces/',
|
'pieces_list': walletConstants.walletApiEndpoint + subdomain + '/pieces/',
|
||||||
'piece': walletConstants.walletApiEndpoint + subdomain + '/pieces/${piece_id}/',
|
'piece': walletConstants.walletApiEndpoint + subdomain + '/pieces/${piece_id}/',
|
||||||
'piece_extradata': walletConstants.walletApiEndpoint + subdomain + '/pieces/${piece_id}/extradata/'
|
'piece_extradata': walletConstants.walletApiEndpoint + subdomain + '/pieces/${piece_id}/extradata/',
|
||||||
|
'user': walletConstants.walletApiEndpoint + subdomain + '/users/'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (subdomain === 'ikonotv'){
|
else if (subdomain === 'ikonotv'){
|
||||||
|
Loading…
Reference in New Issue
Block a user