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

Merge remote-tracking branch 'origin/AD-435-hash-locally-for-when-a-artist-do' into AD-435-hash-locally-for-when-a-artist-do

This commit is contained in:
diminator 2015-07-28 11:32:31 +02:00
commit c5072164eb
3 changed files with 43 additions and 16 deletions

View File

@ -63,7 +63,6 @@ let Form = React.createClass({
if ('getFormData' in this.props){
data = mergeOptionsWithDuplicates(data, this.props.getFormData());
}
console.log(data)
return data;
},

View File

@ -2,18 +2,21 @@
import React from 'react';
import AppConstants from '../../constants/application_constants';
import UserStore from '../../stores/user_store';
import UserActions from '../../actions/user_actions';
import Form from './form';
import Property from './property';
import FormPropertyHeader from './form_property_header';
import apiUrls from '../../constants/api_urls';
import ReactS3FineUploader from '../ascribe_uploader/react_s3_fine_uploader';
import AppConstants from '../../constants/application_constants';
import apiUrls from '../../constants/api_urls';
import { getCookie } from '../../utils/fetch_api_utils';
import { getLangText } from '../../utils/lang_utils';
import { mergeOptions } from '../../utils/general_utils';
let RegisterPieceForm = React.createClass({
@ -33,10 +36,26 @@ let RegisterPieceForm = React.createClass({
},
getInitialState(){
return {
return mergeOptions(
{
digitalWorkKey: null,
isUploadReady: false
};
},
UserStore.getState()
);
},
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
getFormData(){
@ -67,6 +86,9 @@ let RegisterPieceForm = React.createClass({
},
render() {
let currentUser = this.state.currentUser;
let enableLocalHashing = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false;
return (
<Form
className="ascribe-form-bordered"
@ -94,7 +116,8 @@ let RegisterPieceForm = React.createClass({
submitKey={this.submitKey}
setIsUploadReady={this.setIsUploadReady}
isReadyForFormSubmission={this.isReadyForFormSubmission}
editable={this.props.isFineUploaderEditable}/>
editable={this.props.isFineUploaderEditable}
enableLocalHashing={enableLocalHashing}/>
</Property>
<Property
name='artist_name'
@ -136,7 +159,8 @@ let FileUploader = React.createClass({
// editable is used to lock react fine uploader in case
// a user is actually not logged in already to prevent him from droping files
// before login in
editable: React.PropTypes.bool
editable: React.PropTypes.bool,
enableLocalHashing: React.PropTypes.bool
},
render() {
@ -174,7 +198,7 @@ let FileUploader = React.createClass({
}
}}
multiple={false}
enableLocalHashing={true} />
enableLocalHashing={this.props.enableLocalHashing} />
);
}
});

View File

@ -73,6 +73,7 @@ let AccountSettings = React.createClass({
getFormDataProfile(){
return {'email': this.state.currentUser.email};
},
render() {
let content = <img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />;
let profile = null;
@ -231,7 +232,6 @@ let LoanContractSettings = React.createClass({
},
render() {
return (
<CollapsibleParagraph
title="Loan Contract Settings"
@ -318,26 +318,30 @@ let APISettings = React.createClass({
onChange(state) {
this.setState(state);
},
handleCreateSuccess: function(){
handleCreateSuccess() {
ApplicationActions.fetchApplication();
let notification = new GlobalNotificationModel(getLangText('Application successfully created'), 'success', 5000);
GlobalNotificationActions.appendGlobalNotification(notification);
},
handleTokenRefresh: function(event){
handleTokenRefresh(event) {
let applicationName = event.target.getAttribute('data-id');
ApplicationActions.refreshApplicationToken(applicationName);
let notification = new GlobalNotificationModel(getLangText('Token refreshed'), 'success', 2000);
GlobalNotificationActions.appendGlobalNotification(notification);
},
render() {
let content = <img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />;
if (this.state.applications.length > -1) {
content = this.state.applications.map(function(app) {
content = this.state.applications.map(function(app, i) {
return (
<Property
name={app.name}
label={app.name}>
label={app.name}
key={i}>
<div className="row-same-height">
<div className="no-padding col-xs-6 col-sm-10 col-xs-height col-middle">
{'Bearer ' + app.bearer_token.token}