1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-28 00:28:00 +02:00

Implement AclProxy for hash work in account settings

This commit is contained in:
Tim Daubenschütz 2015-09-28 12:00:13 +02:00
parent 62e85c66ac
commit 5b41e368ac
2 changed files with 28 additions and 51 deletions

View File

@ -10,6 +10,8 @@ import Property from '../ascribe_forms/property';
import InputCheckbox from '../ascribe_forms/input_checkbox'; import InputCheckbox from '../ascribe_forms/input_checkbox';
import CollapsibleParagraph from '../ascribe_collapsible/collapsible_paragraph'; import CollapsibleParagraph from '../ascribe_collapsible/collapsible_paragraph';
import AclProxy from '../acl_proxy';
import CopyrightAssociationForm from '../ascribe_forms/form_copyright_association'; import CopyrightAssociationForm from '../ascribe_forms/form_copyright_association';
import ApiUrls from '../../constants/api_urls'; import ApiUrls from '../../constants/api_urls';
@ -20,7 +22,8 @@ import { getLangText } from '../../utils/lang_utils';
let AccountSettings = React.createClass({ let AccountSettings = React.createClass({
propTypes: { propTypes: {
currentUser: React.PropTypes.object.isRequired, currentUser: React.PropTypes.object.isRequired,
loadUser: React.PropTypes.func.isRequired loadUser: React.PropTypes.func.isRequired,
whitelabel: React.PropTypes.object.isRequired
}, },
handleSuccess(){ handleSuccess(){
@ -66,37 +69,26 @@ let AccountSettings = React.createClass({
</Form> </Form>
); );
profile = ( profile = (
<Form <AclProxy
url={ApiUrls.users_profile} aclObject={this.props.whitelabel}
handleSuccess={this.handleSuccess} aclName="acl_view_settings_account_hash">
getFormData={this.getFormDataProfile}> <Form
<Property url={ApiUrls.users_profile}
name="hash_locally" handleSuccess={this.handleSuccess}
className="ascribe-settings-property-collapsible-toggle" getFormData={this.getFormDataProfile}>
style={{paddingBottom: 0}}> <Property
<InputCheckbox name="hash_locally"
defaultChecked={this.props.currentUser.profile.hash_locally}> className="ascribe-settings-property-collapsible-toggle"
<span> style={{paddingBottom: 0}}>
{' ' + getLangText('Enable hash option, e.g. slow connections or to keep piece private')} <InputCheckbox
</span> defaultChecked={this.props.currentUser.profile.hash_locally}>
</InputCheckbox> <span>
</Property> {' ' + getLangText('Enable hash option, e.g. slow connections or to keep piece private')}
<hr /> </span>
{/*<Property </InputCheckbox>
name='language' </Property>
label={getLangText('Choose your Language')} </Form>
editable={true}> </AclProxy>
<select id="select-lang" name="language">
<option value="fr">
Fran&ccedil;ais
</option>
<option value="en"
selected="selected">
English
</option>
</select>
</Property>*/}
</Form>
); );
} }
return ( return (
@ -106,24 +98,6 @@ let AccountSettings = React.createClass({
{content} {content}
<CopyrightAssociationForm currentUser={this.props.currentUser}/> <CopyrightAssociationForm currentUser={this.props.currentUser}/>
{profile} {profile}
{/*<Form
url={AppConstants.serverUrl + 'api/users/set_language/'}>
<Property
name='language'
label={getLangText('Choose your Language')}
editable={true}>
<select id="select-lang" name="language">
<option value="fr">
Fran&ccedil;ais
</option>
<option value="en"
selected="selected">
English
</option>
</select>
</Property>
<hr />
</Form>*/}
</CollapsibleParagraph> </CollapsibleParagraph>
); );
} }

View File

@ -59,7 +59,10 @@ let SettingsContainer = React.createClass({
if (this.state.currentUser && this.state.currentUser.username) { if (this.state.currentUser && this.state.currentUser.username) {
return ( return (
<div className="settings-container"> <div className="settings-container">
<AccountSettings currentUser={this.state.currentUser} loadUser={this.loadUser}/> <AccountSettings
currentUser={this.state.currentUser}
loadUser={this.loadUser}
whitelabel={this.state.whitelabel}/>
{this.props.children} {this.props.children}
<AclProxy <AclProxy
aclObject={this.state.whitelabel} aclObject={this.state.whitelabel}