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