1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Change RegisterPieceForm and parents for loading UserStore from top level app

This commit is contained in:
Brett Sun 2016-01-11 18:16:46 +01:00
parent 58f57af932
commit 1c4ca0d152
5 changed files with 32 additions and 44 deletions

View File

@ -2,9 +2,6 @@
import React from 'react';
import UserStore from '../../stores/user_store';
import UserActions from '../../actions/user_actions';
import Form from './form';
import Property from './property';
import InputFineUploader from './input_fineuploader';
@ -16,22 +13,24 @@ import AppConstants from '../../constants/application_constants';
import AscribeSpinner from '../ascribe_spinner';
import { getLangText } from '../../utils/lang_utils';
import { mergeOptions } from '../../utils/general_utils';
import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
let RegisterPieceForm = React.createClass({
propTypes: {
currentUser: React.PropTypes.object.isRequired,
headerMessage: React.PropTypes.string,
submitMessage: React.PropTypes.string,
handleSuccess: React.PropTypes.func,
isFineUploaderActive: React.PropTypes.bool,
isFineUploaderEditable: React.PropTypes.bool,
enableLocalHashing: React.PropTypes.bool,
enableSeparateThumbnail: React.PropTypes.bool,
isFineUploaderActive: React.PropTypes.bool,
isFineUploaderEditable: React.PropTypes.bool,
handleSuccess: React.PropTypes.func,
// For this form to work with SlideContainer, we sometimes have to disable it
disabled: React.PropTypes.bool,
location: React.PropTypes.object,
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
@ -48,26 +47,10 @@ let RegisterPieceForm = React.createClass({
};
},
getInitialState(){
return mergeOptions(
{
getInitialState() {
return {
digitalWorkFile: null
},
UserStore.getState()
);
},
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
}
},
/**
@ -129,16 +112,17 @@ let RegisterPieceForm = React.createClass({
},
render() {
const { disabled,
const {
children,
currentUser,
disabled,
enableLocalHashing,
handleSuccess,
submitMessage,
headerMessage,
isFineUploaderActive,
isFineUploaderEditable,
location,
children,
enableLocalHashing } = this.props;
const { currentUser} = this.state;
submitMessage } = this.props;
const profileHashLocally = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false;
const hashLocally = profileHashLocally && enableLocalHashing;

View File

@ -102,8 +102,7 @@ let RegisterPiece = React.createClass( {
<RegisterPieceForm
{...this.props}
isFineUploaderActive={true}
handleSuccess={this.handleSuccess}
location={this.props.location}>
handleSuccess={this.handleSuccess}>
{this.props.children}
{this.getSpecifyEditions()}
</RegisterPieceForm>

View File

@ -183,13 +183,14 @@ let CylandRegisterPiece = React.createClass({
<Row className="no-margin">
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
<RegisterPieceForm
currentUser={currentUser}
disabled={step > 0}
enableLocalHashing={false}
headerMessage={getLangText('Submit to Cyland Archive')}
submitMessage={getLangText('Submit')}
isFineUploaderActive={true}
handleSuccess={this.handleRegisterSuccess}
location={location}/>
location={location} />
</Col>
</Row>
</div>

View File

@ -219,7 +219,8 @@ let IkonotvRegisterPiece = React.createClass({
},
render() {
const { pageExitWarning } = this.state;
const { currentUser, location } = this.props;
const { pageExitWarning, step } = this.state;
return (
<SlidesContainer
@ -229,19 +230,20 @@ let IkonotvRegisterPiece = React.createClass({
pending: 'glyphicon glyphicon-chevron-right',
completed: 'glyphicon glyphicon-lock'
}}
location={this.props.location}
location={location}
pageExitWarning={pageExitWarning}>
<div data-slide-title={getLangText('Register work')}>
<Row className="no-margin">
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
<RegisterPieceForm
disabled={this.state.step > 0}
currentUser={currentUser}
disabled={step > 0}
enableLocalHashing={false}
headerMessage={getLangText('Register work')}
submitMessage={getLangText('Register')}
isFineUploaderActive={true}
handleSuccess={this.handleRegisterSuccess}
location={this.props.location} />
location={location} />
</Col>
</Row>
</div>

View File

@ -107,6 +107,7 @@ let MarketRegisterPiece = React.createClass({
render() {
const {
currentUser,
location,
whitelabel: {
name: whitelabelName = 'Market'
@ -128,6 +129,7 @@ let MarketRegisterPiece = React.createClass({
<Row className="no-margin">
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
<RegisterPieceForm
currentUser={currentUser}
disabled={step > 0}
enableLocalHashing={false}
headerMessage={getLangText('Consign to %s', whitelabelName)}