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

Update prize routes for loading user and whitelabel settings in top level app

This commit is contained in:
Brett Sun 2016-01-11 15:14:54 +01:00
parent 5ae166edf3
commit 06ea23c627
17 changed files with 293 additions and 256 deletions

View File

@ -36,7 +36,7 @@ let SettingsContainer = React.createClass({
},
render() {
const { currentUser, whitelabel } = this.props;
const { children, currentUser, whitelabel } = this.props;
setDocumentTitle(getLangText('Account settings'));
@ -47,7 +47,7 @@ let SettingsContainer = React.createClass({
currentUser={currentUser}
loadUser={this.loadUser}
whitelabel={whitelabel} />
{this.props.children}
{children}
<AclProxy
aclObject={whitelabel}
aclName="acl_view_settings_api">

View File

@ -77,7 +77,7 @@ let RegisterPiece = React.createClass( {
},
getSpecifyEditions() {
if (this.props.whitelabel && this.props.whitelabel.acl_create_editions || Object.keys(this.props.whitelabel).length === 0) {
if (this.props.whitelabel && (this.props.whitelabel.acl_create_editions || Object.keys(this.props.whitelabel).length)) {
return (
<Property
name="num_editions"

View File

@ -26,7 +26,7 @@ let SignupContainer = React.createClass({
};
},
handleSuccess(message){
handleSuccess(message) {
this.setState({
submitted: true,
message: message
@ -34,14 +34,17 @@ let SignupContainer = React.createClass({
},
render() {
const { location } = this.props;
const { message, submitted } = this.state;
setDocumentTitle(getLangText('Sign up'));
if (this.state.submitted) {
if (submitted) {
return (
<div className="ascribe-login-wrapper">
<br/>
<div className="ascribe-login-text ascribe-login-header">
{this.state.message}
{message}
</div>
</div>
);
@ -50,7 +53,7 @@ let SignupContainer = React.createClass({
<div className="ascribe-login-wrapper">
<SignupForm
handleSuccess={this.handleSuccess}
location={this.props.location}/>
location={location}/>
<div className="ascribe-login-text">
{getLangText('Already an ascribe user')}&#63; <Link to="/login">{getLangText('Log in')}...</Link><br/>
</div>

View File

@ -30,9 +30,8 @@ const { object } = React.PropTypes;
const PRRegisterPieceForm = React.createClass({
propTypes: {
location: object,
history: object,
currentUser: object
currentUser: object,
location: object
},
mixins: [History],

View File

@ -3,43 +3,39 @@
import React from 'react';
import { History } from 'react-router';
import PrizeActions from '../../simple_prize/actions/prize_actions';
import PrizeStore from '../../simple_prize/stores/prize_store';
import Button from 'react-bootstrap/lib/Button';
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup';
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
import UserStore from '../../../../../stores/user_store';
import UserActions from '../../../../../actions/user_actions';
import PrizeActions from '../../simple_prize/actions/prize_actions';
import PrizeStore from '../../simple_prize/stores/prize_store';
import { mergeOptions } from '../../../../../utils/general_utils';
import { getLangText } from '../../../../../utils/lang_utils';
const PRLanding = React.createClass({
propTypes: {
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
//Provided from router
location: React.PropTypes.object
},
mixins: [History],
getInitialState() {
return mergeOptions(
PrizeStore.getState(),
UserStore.getState()
);
return PrizeStore.getState();
},
componentDidMount() {
const { location } = this.props;
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
PrizeStore.listen(this.onChange);
PrizeActions.fetchPrize();
if(location && location.query && location.query.redirect) {
if (location && location.query && location.query.redirect) {
let queryCopy = JSON.parse(JSON.stringify(location.query));
delete queryCopy.redirect;
window.setTimeout(() => this.history.replaceState(null, `/${location.query.redirect}`, queryCopy));
@ -47,7 +43,6 @@ const PRLanding = React.createClass({
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
PrizeStore.unlisten(this.onChange);
},
@ -56,7 +51,7 @@ const PRLanding = React.createClass({
},
getButtons() {
if (this.state.prize && this.state.prize.active){
if (this.state.prize && this.state.prize.active) {
return (
<ButtonGroup className="enter" bsSize="large" vertical>
<LinkContainer to="/signup">
@ -75,39 +70,37 @@ const PRLanding = React.createClass({
</LinkContainer>
</ButtonGroup>
);
}
return (
<ButtonGroup className="enter" bsSize="large" vertical>
<a className="btn btn-default" href="https://www.ascribe.io/app/signup">
{getLangText('Sign up to ascribe')}
</a>
} else {
return (
<ButtonGroup className="enter" bsSize="large" vertical>
<a className="btn btn-default" href="https://www.ascribe.io/app/signup">
{getLangText('Sign up to ascribe')}
</a>
<p>
{getLangText('or, already an ascribe user?')}
</p>
<LinkContainer to="/login">
<Button>
{getLangText('Log in')}
</Button>
</LinkContainer>
</ButtonGroup>
);
<p>
{getLangText('or, already an ascribe user?')}
</p>
<LinkContainer to="/login">
<Button>
{getLangText('Log in')}
</Button>
</LinkContainer>
</ButtonGroup>
);
}
},
getTitle() {
if (this.state.prize && this.state.prize.active){
return (
<p>
{getLangText('This is the submission page for Portfolio Review 2016.')}
</p>
);
}
const { prize } = this.state;
return (
<p>
{getLangText('Submissions for Portfolio Review 2016 are now closed.')}
{getLangText(prize && prize.active ? 'This is the submission page for Portfolio Review 2016.'
: 'Submissions for Portfolio Review 2016 are now closed.')}
</p>
);
},
render() {
return (
<div className="container">
@ -125,4 +118,4 @@ const PRLanding = React.createClass({
}
});
export default PRLanding;
export default PRLanding;

View File

@ -6,9 +6,6 @@ import { Link, History } from 'react-router';
import Col from 'react-bootstrap/lib/Col';
import Row from 'react-bootstrap/lib/Row';
import UserStore from '../../../../../stores/user_store';
import UserActions from '../../../../../actions/user_actions';
import PRRegisterPieceForm from './pr_forms/pr_register_piece_form';
import { getLangText } from '../../../../../utils/lang_utils';
@ -20,43 +17,31 @@ const { object } = React.PropTypes;
const PRRegisterPiece = React.createClass({
propTypes: {
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
//Provided from router
location: object
},
mixins: [History],
getInitialState() {
return UserStore.getState();
},
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
},
componentDidUpdate() {
const { currentUser } = this.state;
if(currentUser && currentUser.email) {
const { currentUser } = this.props;
if (currentUser && currentUser.email) {
const submittedPieceId = getCookie(currentUser.email);
if(submittedPieceId) {
if (submittedPieceId) {
this.history.pushState(null, `/pieces/${submittedPieceId}`);
}
}
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
render() {
const { currentUser } = this.state;
const { location } = this.props;
const { currentUser, location } = this.props;
setDocumentTitle(getLangText('Submit to Portfolio Review'));
return (
<Row>
<Col xs={6}>
@ -77,7 +62,7 @@ const PRRegisterPiece = React.createClass({
<Col xs={6}>
<PRRegisterPieceForm
location={location}
currentUser={currentUser}/>
currentUser={currentUser} />
</Col>
</Row>
);

View File

@ -1,17 +1,21 @@
'use strict';
import React from 'react';
import GlobalNotification from '../../../global_notification';
import Hero from './components/pr_hero';
import Header from '../../../header';
import EventActions from '../../../../actions/event_actions';
import UserStore from '../../../../stores/user_store';
import UserActions from '../../../../actions/user_actions';
import { getSubdomain } from '../../../../utils/general_utils';
import WhitelabelActions from '../../../../actions/whitelabel_actions';
import WhitelabelStore from '../../../../stores/whitelabel_store';
import AppRouteWrapper from '../../../app_route_wrapper';
import Hero from './components/pr_hero';
import Header from '../../../header';
import GlobalNotification from '../../../global_notification';
import { getSubdomain, mergeOptions } from '../../../../utils/general_utils';
import { getCookie } from '../../../../utils/fetch_api_utils';
@ -26,16 +30,23 @@ let PRApp = React.createClass({
},
getInitialState() {
return UserStore.getState();
return mergeOptions(
UserStore.getState(),
WhitelabelStore.getState()
);
},
componentDidMount() {
UserStore.listen(this.onChange);
WhitelabelStore.listen(this.onChange);
UserActions.fetchCurrentUser();
WhitelabelActions.fetchWhitelabel();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
WhitelabelActions.unlisten(this.onChange);
},
onChange(state) {
@ -43,13 +54,20 @@ let PRApp = React.createClass({
},
render() {
const { history, children, routes } = this.props;
const { currentUser } = this.state;
const { children, history, routes } = this.props;
const { currentUser, whitelabel } = this.state;
const subdomain = getSubdomain();
// Add the current user and whitelabel settings to all child routes
const childrenWithProps = React.Children.map(children, (child) => {
return React.cloneElement(child, {
currentUser,
whitelabel
});
});
let style = {};
let subdomain = getSubdomain();
let header;
if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) {
header = <Hero currentUser={currentUser} />;
style = { paddingTop: '0 !important' };
@ -65,7 +83,12 @@ let PRApp = React.createClass({
<div
style={style}
className={'container ascribe-prize-app client--' + subdomain}>
{children}
<AppRouteWrapper
currentUser={currentUser}
whitelabel={whitelabel}>
{/* Routes are injected here */}
{children}
</AppRouteWrapper>
<GlobalNotification />
<div id="modal" className="container"></div>
</div>

View File

@ -31,7 +31,7 @@ import { AuthPrizeRoleRedirect } from './portfolioreview/components/pr_routes/pr
const ROUTES = {
sluice: (
<Route path='/' component={SPApp}>
<IndexRoute component={SPLanding} />
<IndexRoute component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SPLanding)} />
<Route
path='login'
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SPLoginContainer)} />
@ -63,7 +63,7 @@ const ROUTES = {
),
portfolioreview: (
<Route path='/' component={PRApp}>
<IndexRoute component={ProxyHandler(AuthPrizeRoleRedirect({ to: '/collection', when: ['is_admin', 'is_judge', 'is_jury'] }))(PRLanding)} />
<IndexRoute component={ProxyHandler(AuthPrizeRoleRedirect({ to: '/collection', when: ['is_admin', 'is_judge', 'is_jury'] }))(PRLanding)} />
<Route
path='register_piece'
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(PRRegisterPiece)}/>

View File

@ -19,9 +19,6 @@ import PieceStore from '../../../../../../stores/piece_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 Piece from '../../../../../../components/ascribe_detail/piece';
import Note from '../../../../../../components/ascribe_detail/note';
@ -53,8 +50,15 @@ import { setDocumentTitle } from '../../../../../../utils/dom_utils';
*/
let PrizePieceContainer = React.createClass({
propTypes: {
params: React.PropTypes.object,
selectedPrizeActionButton: React.PropTypes.func
selectedPrizeActionButton: React.PropTypes.func,
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
//Provided from router
location: React.PropTypes.object,
params: React.PropTypes.object
},
mixins: [ReactError],
@ -62,7 +66,7 @@ let PrizePieceContainer = React.createClass({
getInitialState() {
//FIXME: this component uses the PieceStore, but we avoid using the getState() here since it may contain stale data
// It should instead use something like getInitialState() where that call also resets the state.
return UserStore.getState();
return {};
},
componentWillMount() {
@ -74,9 +78,7 @@ let PrizePieceContainer = React.createClass({
componentDidMount() {
PieceStore.listen(this.onChange);
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
this.loadPiece();
},
@ -99,7 +101,6 @@ let PrizePieceContainer = React.createClass({
componentWillUnmount() {
PieceStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange);
},
onChange(state) {
@ -107,7 +108,8 @@ let PrizePieceContainer = React.createClass({
},
getActions() {
const { currentUser, piece } = this.state;
const { currentUser } = this.props;
const { piece } = this.state;
if (piece && piece.notifications && piece.notifications.length > 0) {
return (
@ -124,8 +126,8 @@ let PrizePieceContainer = React.createClass({
},
render() {
const { selectedPrizeActionButton } = this.props;
const { currentUser, piece } = this.state;
const { currentUser, selectedPrizeActionButton } = this.props;
const { piece } = this.state;
if (piece && piece.id) {
/*

View File

@ -1,57 +1,47 @@
'use strict';
import React from 'react';
import { History } from 'react-router';
import PrizeActions from '../actions/prize_actions';
import PrizeStore from '../stores/prize_store';
import Button from 'react-bootstrap/lib/Button';
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup';
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
import UserStore from '../../../../../stores/user_store';
import UserActions from '../../../../../actions/user_actions';
import PrizeActions from '../actions/prize_actions';
import PrizeStore from '../stores/prize_store';
import { mergeOptions } from '../../../../../utils/general_utils';
import { getLangText } from '../../../../../utils/lang_utils';
let Landing = React.createClass({
mixins: [History],
let Landing = React.createClass({
propTypes: {
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
//Provided from router
location: React.PropTypes.object
},
getInitialState() {
return mergeOptions(
PrizeStore.getState(),
UserStore.getState()
);
return PrizeStore.getState();
},
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
PrizeStore.listen(this.onChange);
PrizeActions.fetchPrize();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
PrizeStore.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);
}
},
getButtons() {
if (this.state.prize && this.state.prize.active){
if (this.state.prize && this.state.prize.active) {
return (
<ButtonGroup className="enter" bsSize="large" vertical>
<LinkContainer to="/signup">
@ -70,39 +60,37 @@ let Landing = React.createClass({
</LinkContainer>
</ButtonGroup>
);
}
return (
<ButtonGroup className="enter" bsSize="large" vertical>
<a className="btn btn-default" href="https://www.ascribe.io/app/signup">
{getLangText('Sign up to ascribe')}
</a>
} else {
return (
<ButtonGroup className="enter" bsSize="large" vertical>
<a className="btn btn-default" href="https://www.ascribe.io/app/signup">
{getLangText('Sign up to ascribe')}
</a>
<p>
{getLangText('or, already an ascribe user?')}
</p>
<LinkContainer to="/login">
<Button>
{getLangText('Log in')}
</Button>
</LinkContainer>
</ButtonGroup>
);
<p>
{getLangText('or, already an ascribe user?')}
</p>
<LinkContainer to="/login">
<Button>
{getLangText('Log in')}
</Button>
</LinkContainer>
</ButtonGroup>
);
}
},
getTitle() {
if (this.state.prize && this.state.prize.active){
return (
<p>
{getLangText('This is the submission page for Sluice_screens ↄc Prize 2015.')}
</p>
);
}
const { prize } = this.state;
return (
<p>
{getLangText('Submissions for Sluice_screens ↄc Prize 2015 are now closed.')}
{getLangText(prize && prize.active ? 'This is the submission page for Sluice_screens ↄc Prize 2015.'
: 'Submissions for Sluice_screens ↄc Prize 2015 are now closed.')}
</p>
);
},
render() {
return (
<div className="container">

View File

@ -11,6 +11,11 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
let LoginContainer = React.createClass({
propTypes: {
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
//Provided from router
location: React.PropTypes.object
},

View File

@ -1,19 +1,15 @@
'use strict';
import React from 'react';
import PieceList from '../../../../piece_list';
import UserActions from '../../../../../actions/user_actions';
import UserStore from '../../../../../stores/user_store';
import Button from 'react-bootstrap/lib/Button';
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
import PrizeActions from '../actions/prize_actions';
import PrizeStore from '../stores/prize_store';
import Button from 'react-bootstrap/lib/Button';
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
import AccordionListItemPrize from './ascribe_accordion_list/accordion_list_item_prize';
import PieceList from '../../../../piece_list';
import { mergeOptions } from '../../../../../utils/general_utils';
import { getLangText } from '../../../../../utils/lang_utils';
@ -21,25 +17,24 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
let PrizePieceList = React.createClass({
propTypes: {
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
//Provided from router
location: React.PropTypes.object
},
getInitialState() {
return mergeOptions(
PrizeStore.getState(),
UserStore.getState()
);
return PrizeStore.getState();
},
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
PrizeStore.listen(this.onChange);
PrizeActions.fetchPrize();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
PrizeStore.unlisten(this.onChange);
},
@ -48,7 +43,8 @@ let PrizePieceList = React.createClass({
},
getButtonSubmit() {
const { currentUser, prize } = this.state;
const { currentUser } = this.props;
const { prize } = this.state;
if (prize && prize.active && !currentUser.is_jury && !currentUser.is_admin && !currentUser.is_judge) {
return (
<LinkContainer to="/register_piece">
@ -57,32 +53,34 @@ let PrizePieceList = React.createClass({
</Button>
</LinkContainer>
);
} else {
return null;
}
return null;
},
render() {
const { currentUser, location } = this.props;
setDocumentTitle(getLangText('Collection'));
let orderParams = ['artist_name', 'title'];
if (this.state.currentUser.is_jury) {
if (currentUser.is_jury) {
orderParams = ['rating', 'title'];
}
if (this.state.currentUser.is_judge) {
if (currentUser.is_judge) {
orderParams = ['rating', 'title', 'selected'];
}
return (
<div>
<PieceList
ref="list"
redirectTo="/register_piece"
accordionListItemType={AccordionListItemPrize}
orderParams={orderParams}
orderBy={this.state.currentUser.is_jury ? 'rating' : null}
filterParams={[]}
customSubmitButton={this.getButtonSubmit()}
location={this.props.location}/>
</div>
<PieceList
ref="list"
{...this.props}
redirectTo="/register_piece"
accordionListItemType={AccordionListItemPrize}
orderParams={orderParams}
orderBy={currentUser.is_jury ? 'rating' : null}
filterParams={[]}
customSubmitButton={this.getButtonSubmit()} />
);
}
});

View File

@ -16,6 +16,11 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
let PrizeRegisterPiece = React.createClass({
propTypes: {
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
//Provided from router
location: React.PropTypes.object
},
@ -38,62 +43,61 @@ let PrizeRegisterPiece = React.createClass({
render() {
const { location } = this.props;
const { prize } = this.state;
setDocumentTitle(getLangText('Submit to the prize'));
if(this.state.prize && this.state.prize.active){
if (prize && prize.active) {
return (
<div>
<RegisterPiece
enableLocalHashing={false}
headerMessage={''}
submitMessage={getLangText('Submit')}
location={location}>
<Property
name='artist_statement'
label={getLangText('Artist statement')}
editable={true}
overrideForm={true}>
<InputTextAreaToggable
rows={1}
placeholder={getLangText('Enter your statement')}
required />
</Property>
<Property
name='work_description'
label={getLangText('Work description')}
editable={true}
overrideForm={true}>
<InputTextAreaToggable
rows={1}
placeholder={getLangText('Enter the description for your work')}
required />
</Property>
<Property
name="terms"
className="ascribe-property-collapsible-toggle"
style={{paddingBottom: 0}}>
<InputCheckbox>
<span>
{' ' + getLangText('I agree to the Terms of Service the art price') + ' '}
(<a href="https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/sluice/terms.pdf" target="_blank" style={{fontSize: '0.9em', color: 'rgba(0,0,0,0.7)'}}>
{getLangText('read')}
</a>)
</span>
</InputCheckbox>
</Property>
</RegisterPiece>
</div>
<RegisterPiece
{...this.props}
enableLocalHashing={false}
headerMessage={''}
submitMessage={getLangText('Submit')}
location={location}>
<Property
name='artist_statement'
label={getLangText('Artist statement')}
editable={true}
overrideForm={true}>
<InputTextAreaToggable
rows={1}
placeholder={getLangText('Enter your statement')}
required />
</Property>
<Property
name='work_description'
label={getLangText('Work description')}
editable={true}
overrideForm={true}>
<InputTextAreaToggable
rows={1}
placeholder={getLangText('Enter the description for your work')}
required />
</Property>
<Property
name="terms"
className="ascribe-property-collapsible-toggle"
style={{paddingBottom: 0}}>
<InputCheckbox>
<span>
{' ' + getLangText('I agree to the Terms of Service the art price') + ' '}
(<a href="https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/sluice/terms.pdf" target="_blank" style={{fontSize: '0.9em', color: 'rgba(0,0,0,0.7)'}}>
{getLangText('read')}
</a>)
</span>
</InputCheckbox>
</Property>
</RegisterPiece>
);
}
else {
} else {
return (
<div className='row'>
<div style={{textAlign: 'center'}}>
{getLangText('The prize is no longer active')}
</div>
</div>
);
);
}
}
});

View File

@ -2,8 +2,6 @@
import React from 'react';
import UserStore from '../../../../../stores/user_store';
import UserActions from '../../../../../actions/user_actions';
import PrizeActions from '../actions/prize_actions';
import PrizeStore from '../stores/prize_store';
import PrizeJuryActions from '../actions/prize_jury_actions';
@ -28,40 +26,27 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
let Settings = React.createClass({
getInitialState() {
return UserStore.getState();
},
propTypes: {
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
//Provided from router
location: React.PropTypes.object
},
render() {
setDocumentTitle(getLangText('Account settings'));
let prizeSettings = null;
if (this.state.currentUser.is_admin){
prizeSettings = <PrizeSettings />;
}
return (
<SettingsContainer>
{prizeSettings}
<SettingsContainer {...this.props}>
{this.props.currentUser.is_admin ? <PrizeSettings /> : null}
</SettingsContainer>
);
}
});
let PrizeSettings = React.createClass({
getInitialState() {
return PrizeStore.getState();
},

View File

@ -8,6 +8,11 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
let SignupContainer = React.createClass({
propTypes: {
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
//Provided from router
location: React.PropTypes.object
},
@ -18,7 +23,7 @@ let SignupContainer = React.createClass({
};
},
handleSuccess(message){
handleSuccess(message) {
this.setState({
submitted: true,
message: message
@ -26,13 +31,15 @@ let SignupContainer = React.createClass({
},
render() {
const { location } = this.props;
const { message, submitted } = this.state;
setDocumentTitle(getLangText('Sign up'));
if (this.state.submitted){
if (submitted) {
return (
<div className="ascribe-login-wrapper">
<div className="ascribe-login-text ascribe-login-header">
{this.state.message}
{message}
</div>
</div>
);
@ -43,7 +50,7 @@ let SignupContainer = React.createClass({
headerMessage={getLangText('Create account for submission')}
submitMessage={getLangText('Sign up')}
handleSuccess={this.handleSuccess}
location={this.props.location}/>
location={location} />
</div>
);
}

View File

@ -1,12 +1,21 @@
'use strict';
import React from 'react';
import UserStore from '../../../../stores/user_store';
import UserActions from '../../../../actions/user_actions';
import WhitelabelActions from '../../../../actions/whitelabel_actions';
import WhitelabelStore from '../../../../stores/whitelabel_store';
import Hero from './components/prize_hero';
import AppRouteWrapper from '../../../app_route_wrapper';
import Header from '../../../header';
import Footer from '../../../footer';
import GlobalNotification from '../../../global_notification';
import { getSubdomain } from '../../../../utils/general_utils';
import { getSubdomain, mergeOptions } from '../../../../utils/general_utils';
let PrizeApp = React.createClass({
@ -19,15 +28,40 @@ let PrizeApp = React.createClass({
routes: React.PropTypes.arrayOf(React.PropTypes.object)
},
getInitialState() {
return mergeOptions(
UserStore.getState(),
WhitelabelStore.getState()
);
},
componentDidMount() {
UserStore.listen(this.onChange);
WhitelabelStore.listen(this.onChange);
UserActions.fetchCurrentUser();
WhitelabelActions.fetchWhitelabel();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
WhitelabelActions.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
render() {
const { history, routes } = this.props;
let header = null;
let subdomain = getSubdomain();
const { history, routes, children } = this.props;
const { currentUser, whitelabel } = this.state;
const subdomain = getSubdomain();
// The second element of routes is always the active component object, where we can
// extract the path.
let path = routes[1] ? routes[1].path : null;
let header = null;
// if the path of the current activeRoute is not defined, then this is the IndexRoute
if (!path || history.isActive('/login') || history.isActive('/signup')) {
header = <Hero />;
@ -38,10 +72,15 @@ let PrizeApp = React.createClass({
return (
<div className={'container ascribe-prize-app client--' + subdomain}>
{header}
{this.props.children}
<AppRouteWrapper
currentUser={currentUser}
whitelabel={whitelabel}>
{/* Routes are injected here */}
{children}
</AppRouteWrapper>
<Footer />
<GlobalNotification />
<div id="modal" className="container"></div>
<Footer />
</div>
);
}

View File

@ -8,6 +8,12 @@ import PrizePieceContainer from '../../../simple_prize/components/ascribe_detail
const SluicePieceContainer = 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
},