1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +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 React from 'react';
import UserStore from '../../stores/user_store';
import UserActions from '../../actions/user_actions';
import Form from './form'; import Form from './form';
import Property from './property'; import Property from './property';
import InputFineUploader from './input_fineuploader'; import InputFineUploader from './input_fineuploader';
@ -16,22 +13,24 @@ import AppConstants from '../../constants/application_constants';
import AscribeSpinner from '../ascribe_spinner'; import AscribeSpinner from '../ascribe_spinner';
import { getLangText } from '../../utils/lang_utils'; import { getLangText } from '../../utils/lang_utils';
import { mergeOptions } from '../../utils/general_utils';
import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils'; import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
let RegisterPieceForm = React.createClass({ let RegisterPieceForm = React.createClass({
propTypes: { propTypes: {
currentUser: React.PropTypes.object.isRequired,
headerMessage: React.PropTypes.string, headerMessage: React.PropTypes.string,
submitMessage: React.PropTypes.string, submitMessage: React.PropTypes.string,
handleSuccess: React.PropTypes.func,
isFineUploaderActive: React.PropTypes.bool,
isFineUploaderEditable: React.PropTypes.bool,
enableLocalHashing: React.PropTypes.bool, enableLocalHashing: React.PropTypes.bool,
enableSeparateThumbnail: 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 // For this form to work with SlideContainer, we sometimes have to disable it
disabled: React.PropTypes.bool, disabled: React.PropTypes.bool,
location: React.PropTypes.object, location: React.PropTypes.object,
children: React.PropTypes.oneOfType([ children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.arrayOf(React.PropTypes.element),
@ -48,26 +47,10 @@ let RegisterPieceForm = React.createClass({
}; };
}, },
getInitialState(){ getInitialState() {
return mergeOptions( return {
{ digitalWorkFile: null
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() { render() {
const { disabled, const {
handleSuccess, children,
submitMessage, currentUser,
headerMessage, disabled,
isFineUploaderActive, enableLocalHashing,
isFineUploaderEditable, handleSuccess,
location, headerMessage,
children, isFineUploaderActive,
enableLocalHashing } = this.props; isFineUploaderEditable,
const { currentUser} = this.state; location,
submitMessage } = this.props;
const profileHashLocally = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false; const profileHashLocally = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false;
const hashLocally = profileHashLocally && enableLocalHashing; const hashLocally = profileHashLocally && enableLocalHashing;

View File

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

View File

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

View File

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

View File

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