mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
Update Cyland routes for loading user and whitelabel settings in top level app
This commit is contained in:
parent
443be236f5
commit
3e66b78d4c
@ -3,18 +3,18 @@
|
||||
import React from 'react';
|
||||
import Moment from 'moment';
|
||||
|
||||
import Piece from '../../../../../components/ascribe_detail/piece';
|
||||
|
||||
import WalletActionPanel from './wallet_action_panel';
|
||||
|
||||
import CollapsibleParagraph from '../../../../../components/ascribe_collapsible/collapsible_paragraph';
|
||||
|
||||
import DetailProperty from '../../../../ascribe_detail/detail_property';
|
||||
import HistoryIterator from '../../../../ascribe_detail/history_iterator';
|
||||
import Note from '../../../../ascribe_detail/note';
|
||||
import Piece from '../../../../../components/ascribe_detail/piece';
|
||||
|
||||
import DetailProperty from '../../../../ascribe_detail/detail_property';
|
||||
import AscribeSpinner from '../../../../ascribe_spinner';
|
||||
|
||||
import ApiUrls from '../../../../../constants/api_urls';
|
||||
import AscribeSpinner from '../../../../ascribe_spinner';
|
||||
|
||||
import { getLangText } from '../../../../../utils/lang_utils';
|
||||
|
||||
|
@ -3,28 +3,26 @@
|
||||
import React from 'react';
|
||||
import { History } from 'react-router';
|
||||
|
||||
import EditionListActions from '../../../../../../actions/edition_list_actions';
|
||||
|
||||
import GlobalNotificationModel from '../../../../../../models/global_notification_model';
|
||||
import GlobalNotificationActions from '../../../../../../actions/global_notification_actions';
|
||||
|
||||
import PieceActions from '../../../../../../actions/piece_actions';
|
||||
import PieceStore from '../../../../../../stores/piece_store';
|
||||
|
||||
import UserStore from '../../../../../../stores/user_store';
|
||||
|
||||
import PieceListStore from '../../../../../../stores/piece_list_store';
|
||||
import PieceListActions from '../../../../../../actions/piece_list_actions';
|
||||
|
||||
import EditionListActions from '../../../../../../actions/edition_list_actions';
|
||||
import CylandAdditionalDataForm from '../cyland_forms/cyland_additional_data_form';
|
||||
|
||||
import CylandSubmitButton from '../cyland_buttons/cyland_submit_button';
|
||||
|
||||
import CollapsibleParagraph from '../../../../../../components/ascribe_collapsible/collapsible_paragraph';
|
||||
|
||||
import CylandAdditionalDataForm from '../cyland_forms/cyland_additional_data_form';
|
||||
|
||||
import WalletPieceContainer from '../../ascribe_detail/wallet_piece_container';
|
||||
|
||||
import AscribeSpinner from '../../../../../ascribe_spinner';
|
||||
import CollapsibleParagraph from '../../../../../../components/ascribe_collapsible/collapsible_paragraph';
|
||||
|
||||
import GlobalNotificationModel from '../../../../../../models/global_notification_model';
|
||||
import GlobalNotificationActions from '../../../../../../actions/global_notification_actions';
|
||||
import AscribeSpinner from '../../../../../ascribe_spinner';
|
||||
|
||||
import { getLangText } from '../../../../../../utils/lang_utils';
|
||||
import { setDocumentTitle } from '../../../../../../utils/dom_utils';
|
||||
@ -33,6 +31,12 @@ import { mergeOptions } from '../../../../../../utils/general_utils';
|
||||
|
||||
let CylandPieceContainer = React.createClass({
|
||||
propTypes: {
|
||||
// Provided from PrizeApp
|
||||
currentUser: React.PropTypes.object,
|
||||
whitelabel: React.PropTypes.object,
|
||||
|
||||
// Provided from router
|
||||
location: React.PropTypes.object,
|
||||
params: React.PropTypes.object
|
||||
},
|
||||
|
||||
@ -41,14 +45,12 @@ let CylandPieceContainer = React.createClass({
|
||||
getInitialState() {
|
||||
return mergeOptions(
|
||||
PieceStore.getState(),
|
||||
UserStore.getState(),
|
||||
PieceListStore.getState()
|
||||
);
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
PieceStore.listen(this.onChange);
|
||||
UserStore.listen(this.onChange);
|
||||
PieceListStore.listen(this.onChange);
|
||||
|
||||
// Every time we enter the piece detail page, just reset the piece
|
||||
@ -61,7 +63,6 @@ let CylandPieceContainer = React.createClass({
|
||||
|
||||
componentWillUnmount() {
|
||||
PieceStore.unlisten(this.onChange);
|
||||
UserStore.unlisten(this.onChange);
|
||||
PieceListStore.listen(this.onChange);
|
||||
},
|
||||
|
||||
@ -82,20 +83,23 @@ let CylandPieceContainer = React.createClass({
|
||||
EditionListActions.closeAllEditionLists();
|
||||
EditionListActions.clearAllEditionSelections();
|
||||
|
||||
let notification = new GlobalNotificationModel(response.notification, 'success');
|
||||
const notification = new GlobalNotificationModel(response.notification, 'success');
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
||||
this.history.pushState(null, '/collection');
|
||||
},
|
||||
|
||||
render() {
|
||||
if(this.state.piece && this.state.piece.id) {
|
||||
if (this.state.piece && this.state.piece.id) {
|
||||
const { currentUser } = this.props;
|
||||
|
||||
setDocumentTitle([this.state.piece.artist_name, this.state.piece.title].join(', '));
|
||||
|
||||
return (
|
||||
<WalletPieceContainer
|
||||
{...this.props}
|
||||
piece={this.state.piece}
|
||||
currentUser={this.state.currentUser}
|
||||
currentUser={currentUser}
|
||||
loadPiece={this.loadPiece}
|
||||
handleDeleteSuccess={this.handleDeleteSuccess}
|
||||
submitButtonType={CylandSubmitButton}>
|
||||
|
@ -1,56 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
import { History } from 'react-router';
|
||||
|
||||
import WhitelabelActions from '../../../../../actions/whitelabel_actions';
|
||||
import WhitelabelStore from '../../../../../stores/whitelabel_store';
|
||||
|
||||
import Button from 'react-bootstrap/lib/Button';
|
||||
|
||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||
|
||||
import UserStore from '../../../../../stores/user_store';
|
||||
import UserActions from '../../../../../actions/user_actions';
|
||||
|
||||
import AscribeSpinner from '../../../../ascribe_spinner';
|
||||
|
||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
||||
import { getLangText } from '../../../../../utils/lang_utils';
|
||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||
|
||||
|
||||
let CylandLanding = React.createClass({
|
||||
propTypes: {
|
||||
// Provided from PrizeApp
|
||||
currentUser: React.PropTypes.object,
|
||||
whitelabel: React.PropTypes.object,
|
||||
|
||||
mixins: [History],
|
||||
|
||||
getInitialState() {
|
||||
return mergeOptions(
|
||||
UserStore.getState(),
|
||||
WhitelabelStore.getState()
|
||||
);
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
UserStore.listen(this.onChange);
|
||||
UserActions.fetchCurrentUser();
|
||||
WhitelabelStore.listen(this.onChange);
|
||||
WhitelabelActions.fetchWhitelabel();
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
UserStore.unlisten(this.onChange);
|
||||
WhitelabelStore.unlisten(this.onChange);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
this.setState(state);
|
||||
|
||||
// if user is already logged in, redirect him to piece list
|
||||
if(this.state.currentUser && this.state.currentUser.email) {
|
||||
// FIXME: hack to redirect out of the dispatch cycle
|
||||
window.setTimeout(() => this.history.replaceState(null, '/collection'), 0);
|
||||
}
|
||||
// Provided from router
|
||||
location: object
|
||||
},
|
||||
|
||||
render() {
|
||||
@ -61,7 +30,7 @@ let CylandLanding = React.createClass({
|
||||
<div className="row">
|
||||
<div className="col-xs-12">
|
||||
<div className="row" style={{border: '1px solid #CCC', padding: '2em'}}>
|
||||
<img src={this.state.whitelabel.logo} width="400px"/>
|
||||
<img src={this.props.whitelabel.logo} width="400px"/>
|
||||
<div style={{marginTop: '1em'}}>
|
||||
{getLangText('Submissions to Cyland Archive are powered by') + ' '}
|
||||
<span>
|
||||
|
@ -3,9 +3,6 @@
|
||||
import React from 'react';
|
||||
import PieceList from '../../../../piece_list';
|
||||
|
||||
import UserActions from '../../../../../actions/user_actions';
|
||||
import UserStore from '../../../../../stores/user_store';
|
||||
|
||||
import CylandAccordionListItem from './cyland_accordion_list/cyland_accordion_list_item';
|
||||
|
||||
import { getLangText } from '../../../../../utils/lang_utils';
|
||||
@ -14,32 +11,21 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||
|
||||
let CylandPieceList = React.createClass({
|
||||
propTypes: {
|
||||
// Provided from PrizeApp
|
||||
currentUser: React.PropTypes.object,
|
||||
whitelabel: React.PropTypes.object,
|
||||
|
||||
// Provided from router
|
||||
location: React.PropTypes.object
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return UserStore.getState();
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
UserStore.listen(this.onChange);
|
||||
UserActions.fetchCurrentUser();
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
UserStore.unlisten(this.onChange);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
this.setState(state);
|
||||
},
|
||||
|
||||
render() {
|
||||
setDocumentTitle(getLangText('Collection'));
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PieceList
|
||||
{...this.props}
|
||||
redirectTo="/register_piece?slide_num=0"
|
||||
accordionListItemType={CylandAccordionListItem}
|
||||
filterParams={[{
|
||||
@ -48,8 +34,7 @@ let CylandPieceList = React.createClass({
|
||||
key: 'acl_loaned',
|
||||
label: getLangText('loaned to Cyland')
|
||||
}]
|
||||
}]}
|
||||
location={this.props.location}/>
|
||||
}]} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -10,17 +10,9 @@ import Row from 'react-bootstrap/lib/Row';
|
||||
|
||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||
|
||||
import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece';
|
||||
|
||||
import WhitelabelActions from '../../../../../actions/whitelabel_actions';
|
||||
import WhitelabelStore from '../../../../../stores/whitelabel_store';
|
||||
|
||||
import PieceListStore from '../../../../../stores/piece_list_store';
|
||||
import PieceListActions from '../../../../../actions/piece_list_actions';
|
||||
|
||||
import UserStore from '../../../../../stores/user_store';
|
||||
import UserActions from '../../../../../actions/user_actions';
|
||||
|
||||
import PieceStore from '../../../../../stores/piece_store';
|
||||
import PieceActions from '../../../../../actions/piece_actions';
|
||||
|
||||
@ -30,6 +22,7 @@ import GlobalNotificationActions from '../../../../../actions/global_notificatio
|
||||
import CylandAdditionalDataForm from './cyland_forms/cyland_additional_data_form';
|
||||
|
||||
import LoanForm from '../../../../ascribe_forms/form_loan';
|
||||
import RegisterPieceForm from '../../../../ascribe_forms/form_register_piece';
|
||||
|
||||
import SlidesContainer from '../../../../ascribe_slides_container/slides_container';
|
||||
|
||||
@ -43,6 +36,11 @@ import { getAclFormMessage } from '../../../../../utils/form_utils';
|
||||
|
||||
let CylandRegisterPiece = React.createClass({
|
||||
propTypes: {
|
||||
// Provided from PrizeApp
|
||||
currentUser: React.PropTypes.object,
|
||||
whitelabel: React.PropTypes.object,
|
||||
|
||||
// Provided from router
|
||||
location: React.PropTypes.object
|
||||
},
|
||||
|
||||
@ -50,10 +48,8 @@ let CylandRegisterPiece = React.createClass({
|
||||
|
||||
getInitialState(){
|
||||
return mergeOptions(
|
||||
UserStore.getState(),
|
||||
PieceListStore.getState(),
|
||||
PieceStore.getState(),
|
||||
WhitelabelStore.getState(),
|
||||
{
|
||||
step: 0
|
||||
});
|
||||
@ -61,13 +57,9 @@ let CylandRegisterPiece = React.createClass({
|
||||
|
||||
componentDidMount() {
|
||||
PieceListStore.listen(this.onChange);
|
||||
UserStore.listen(this.onChange);
|
||||
PieceStore.listen(this.onChange);
|
||||
WhitelabelStore.listen(this.onChange);
|
||||
UserActions.fetchCurrentUser();
|
||||
WhitelabelActions.fetchWhitelabel();
|
||||
|
||||
let queryParams = this.props.location.query;
|
||||
const queryParams = this.props.location.query;
|
||||
|
||||
// Since every step of this register process is atomic,
|
||||
// we may need to enter the process at step 1 or 2.
|
||||
@ -76,16 +68,14 @@ let CylandRegisterPiece = React.createClass({
|
||||
//
|
||||
// We're using 'in' here as we want to know if 'piece_id' is present in the url,
|
||||
// we don't care about the value.
|
||||
if(queryParams && 'piece_id' in queryParams) {
|
||||
if (queryParams && 'piece_id' in queryParams) {
|
||||
PieceActions.fetchOne(queryParams.piece_id);
|
||||
}
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
PieceListStore.unlisten(this.onChange);
|
||||
UserStore.unlisten(this.onChange);
|
||||
PieceStore.unlisten(this.onChange);
|
||||
WhitelabelStore.unlisten(this.onChange);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
@ -93,11 +83,10 @@ let CylandRegisterPiece = React.createClass({
|
||||
},
|
||||
|
||||
handleRegisterSuccess(response){
|
||||
|
||||
this.refreshPieceList();
|
||||
|
||||
// also start loading the piece for the next step
|
||||
if(response && response.piece) {
|
||||
if (response && response.piece) {
|
||||
PieceActions.updatePiece({});
|
||||
PieceActions.updatePiece(response.piece);
|
||||
}
|
||||
@ -108,7 +97,6 @@ let CylandRegisterPiece = React.createClass({
|
||||
},
|
||||
|
||||
handleAdditionalDataSuccess() {
|
||||
|
||||
// We need to refetch the piece again after submitting the additional data
|
||||
// since we want it's otherData to be displayed when the user choses to click
|
||||
// on the browsers back button.
|
||||
@ -122,7 +110,7 @@ let CylandRegisterPiece = React.createClass({
|
||||
},
|
||||
|
||||
handleLoanSuccess(response) {
|
||||
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
||||
const notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
||||
this.refreshPieceList();
|
||||
@ -153,8 +141,8 @@ let CylandRegisterPiece = React.createClass({
|
||||
},
|
||||
|
||||
render() {
|
||||
const { location } = this.props;
|
||||
const { currentUser, piece, step, whitelabel } = this.state;
|
||||
const { currentUser, location, whitelabel } = this.props;
|
||||
const { piece, step } = this.state;
|
||||
|
||||
const today = new Moment();
|
||||
const datetimeWhenWeAllWillBeFlyingCoolHoverboardsAndDinosaursWillLiveAgain = new Moment();
|
||||
|
Loading…
Reference in New Issue
Block a user