diff --git a/js/actions/notification_actions.js b/js/actions/notification_actions.js
index c3a6db93..5d80e1e7 100644
--- a/js/actions/notification_actions.js
+++ b/js/actions/notification_actions.js
@@ -9,10 +9,13 @@ class NotificationActions {
constructor() {
this.generateActions(
'updatePieceListNotifications',
+ 'flushPieceListNotifications',
'updateEditionListNotifications',
+ 'flushEditionListNotifications',
'updateEditionNotifications',
'updatePieceNotifications',
- 'updateContractAgreementListNotifications'
+ 'updateContractAgreementListNotifications',
+ 'flushContractAgreementListNotifications'
);
}
diff --git a/js/components/piece_list.js b/js/components/piece_list.js
index 9424117c..de979e65 100644
--- a/js/components/piece_list.js
+++ b/js/components/piece_list.js
@@ -37,6 +37,7 @@ let PieceList = React.createClass({
bulkModalButtonListType: React.PropTypes.func,
canLoadPieceList: React.PropTypes.bool,
redirectTo: React.PropTypes.string,
+ shouldRedirect: React.PropTypes.func,
customSubmitButton: React.PropTypes.element,
customThumbnailPlaceholder: React.PropTypes.func,
filterParams: React.PropTypes.array,
@@ -114,7 +115,11 @@ let PieceList = React.createClass({
},
componentDidUpdate() {
- if (this.props.redirectTo && this.state.unfilteredPieceListCount === 0) {
+ const { redirectTo, shouldRedirect } = this.props;
+ const { unfilteredPieceListCount } = this.state;
+
+ if (redirectTo && unfilteredPieceListCount === 0 &&
+ (typeof shouldRedirect === 'function' && shouldRedirect(unfilteredPieceListCount))) {
// FIXME: hack to redirect out of the dispatch cycle
window.setTimeout(() => this.history.pushState(null, this.props.redirectTo, this.props.location.query), 0);
}
diff --git a/js/components/whitelabel/prize/simple_prize/prize_app.js b/js/components/whitelabel/prize/simple_prize/prize_app.js
index d95d7772..d5b55d5f 100644
--- a/js/components/whitelabel/prize/simple_prize/prize_app.js
+++ b/js/components/whitelabel/prize/simple_prize/prize_app.js
@@ -32,7 +32,7 @@ let PrizeApp = React.createClass({
if (!path || history.isActive('/login') || history.isActive('/signup')) {
header = ;
} else {
- header = ;
+ header = ;
}
return (
diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js
index d3479562..7975c1f3 100644
--- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js
+++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js
@@ -106,22 +106,27 @@ let IkonotvContractNotifications = React.createClass({
handleConfirm() {
let contractAgreement = this.state.contractAgreementListNotifications[0].contract_agreement;
- OwnershipFetcher.confirmContractAgreement(contractAgreement).then(
- () => this.handleConfirmSuccess()
- );
+ OwnershipFetcher
+ .confirmContractAgreement(contractAgreement)
+ .then(this.handleConfirmSuccess);
},
handleConfirmSuccess() {
let notification = new GlobalNotificationModel(getLangText('You have accepted the conditions'), 'success', 5000);
GlobalNotificationActions.appendGlobalNotification(notification);
+
+ // Flush contract notifications and refetch
+ NotificationActions.flushContractAgreementListNotifications();
+ NotificationActions.fetchContractAgreementListNotifications();
+
this.history.pushState(null, '/collection');
},
handleDeny() {
let contractAgreement = this.state.contractAgreementListNotifications[0].contract_agreement;
- OwnershipFetcher.denyContractAgreement(contractAgreement).then(
- () => this.handleDenySuccess()
- );
+ OwnershipFetcher
+ .denyContractAgreement(contractAgreement)
+ .then(this.handleDenySuccess);
},
handleDenySuccess() {
diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js
index 0b51bdbd..5b489d09 100644
--- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js
+++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_piece_list.js
@@ -1,15 +1,18 @@
'use strict';
import React from 'react';
+
import PieceList from '../../../../piece_list';
import UserActions from '../../../../../actions/user_actions';
import UserStore from '../../../../../stores/user_store';
+import NotificationStore from '../../../../../stores/notification_store';
import IkonotvAccordionListItem from './ikonotv_accordion_list/ikonotv_accordion_list_item';
-import { getLangText } from '../../../../../utils/lang_utils';
import { setDocumentTitle } from '../../../../../utils/dom_utils';
+import { mergeOptions } from '../../../../../utils/general_utils';
+import { getLangText } from '../../../../../utils/lang_utils';
let IkonotvPieceList = React.createClass({
@@ -18,20 +21,33 @@ let IkonotvPieceList = React.createClass({
},
getInitialState() {
- return UserStore.getState();
+ return mergeOptions(
+ NotificationStore.getState(),
+ UserStore.getState()
+ );
},
componentDidMount() {
+ NotificationStore.listen(this.onChange);
UserStore.listen(this.onChange);
+
UserActions.fetchCurrentUser();
},
componentWillUnmount() {
+ NotificationStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
+
+ },
+
+ redirectIfNoContractNotifications() {
+ const { contractAgreementListNotifications } = this.state;
+
+ return contractAgreementListNotifications && !contractAgreementListNotifications.length;
},
render() {
@@ -41,6 +57,7 @@ let IkonotvPieceList = React.createClass({
-1) {
header = ();
} else {
- header = ;
+ header = ;
}
// In react-router 1.0, Routes have no 'name' property anymore. To keep functionality however,
diff --git a/js/components/whitelabel/wallet/wallet_routes.js b/js/components/whitelabel/wallet/wallet_routes.js
index 92c6d77b..a5a0e075 100644
--- a/js/components/whitelabel/wallet/wallet_routes.js
+++ b/js/components/whitelabel/wallet/wallet_routes.js
@@ -54,7 +54,7 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)} />
@@ -63,18 +63,19 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)} />
+ headerTitle='+ NEW WORK'
+ aclName='acl_wallet_submit' />
+ headerTitle='COLLECTION' />
@@ -88,7 +89,7 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)} />
@@ -97,18 +98,18 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)} />
+ headerTitle='+ NEW WORK' />
+ headerTitle='COLLECTION' />
@@ -123,7 +124,7 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)} />
@@ -132,27 +133,27 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)} />
+ aclName='acl_create_contractagreement' />
+ aclName='acl_wallet_submit' />
+ headerTitle='COLLECTION' />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(IkonotvContractNotifications)} />
@@ -167,7 +168,7 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)} />
@@ -176,18 +177,19 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)} />
+ headerTitle='+ NEW WORK'
+ aclName='acl_wallet_submit' />
+ headerTitle='COLLECTION' />
@@ -202,7 +204,7 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)} />
@@ -211,19 +213,19 @@ let ROUTES = {
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)} />
+ component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)} />
+ aclName='acl_wallet_submit' />
+ headerTitle='COLLECTION' />
diff --git a/js/stores/notification_store.js b/js/stores/notification_store.js
index ffb3b0af..7a9add9c 100644
--- a/js/stores/notification_store.js
+++ b/js/stores/notification_store.js
@@ -10,6 +10,8 @@ class NotificationStore {
constructor() {
this.pieceListNotifications = {};
this.editionListNotifications = {};
+ // Need to determine if contract agreement notifications have been loaded or not,
+ // so we use null here instead of an empty array
this.contractAgreementListNotifications = null;
this.editionNotifications = null;
this.pieceNotifications = null;
@@ -20,6 +22,10 @@ class NotificationStore {
this.pieceListNotifications = res.notifications;
}
+ onFlushPieceListNotifications() {
+ this.pieceListNotifications = [];
+ }
+
onUpdatePieceNotifications(res) {
this.pieceNotifications = res.notification;
}
@@ -28,6 +34,10 @@ class NotificationStore {
this.editionListNotifications = res.notifications;
}
+ onFlushPieceListNotifications() {
+ this.editionListNotifications = [];
+ }
+
onUpdateEditionNotifications(res) {
this.editionNotifications = res.notification;
}
@@ -36,6 +46,9 @@ class NotificationStore {
this.contractAgreementListNotifications = res.notifications;
}
+ onFlushContractAgreementListNotifications() {
+ this.contractAgreementListNotifications = null;
+ }
}
export default alt.createStore(NotificationStore, 'NotificationStore');