From cb972eb448e3d8eb2643a3a3b12f219644c7479f Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Fri, 4 Dec 2015 18:30:45 +0100 Subject: [PATCH] Add consign error to market white labels Can you beliebe? Magical 100th commit. --- .../market_buttons/market_submit_button.js | 62 +++++++++++++------ .../components/market/market_consign_error.js | 51 +++++++++++++++ sass/ascribe_form.scss | 9 ++- 3 files changed, 103 insertions(+), 19 deletions(-) create mode 100644 js/components/whitelabel/wallet/components/market/market_consign_error.js diff --git a/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js b/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js index d8ef4c41..bd333850 100644 --- a/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js +++ b/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js @@ -3,6 +3,8 @@ import React from 'react'; import classNames from 'classnames'; +import MarketConsignError from '../market_consign_error'; + import MarketAdditionalDataForm from '../market_forms/market_additional_data_form'; import AclFormFactory from '../../../../../ascribe_forms/acl_form_factory'; @@ -12,6 +14,7 @@ import ModalWrapper from '../../../../../ascribe_modal/modal_wrapper'; import AclProxy from '../../../../../acl_proxy'; +import EditionListActions from '../../../../../../actions/edition_list_actions'; import PieceActions from '../../../../../../actions/piece_actions'; import WhitelabelActions from '../../../../../../actions/whitelabel_actions'; import WhitelabelStore from '../../../../../../stores/whitelabel_store'; @@ -89,6 +92,11 @@ let MarketSubmitButton = React.createClass({ this.refs.consignModal.show(); }, + handleConsignError() { + // Unselect failed editions + EditionListActions.clearAllEditionSelections(); + }, + render() { const { availableAcls, currentUser, className, editions, handleSuccess } = this.props; const { whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.state; @@ -120,27 +128,45 @@ let MarketSubmitButton = React.createClass({ ); if (solePieceId && !canSubmit) { - return ( - + if (availableAcls.acl_edit) { + return ( + + + + + + + {consignForm} + + + ); + } else { + // Oops, well this is a difficult situation... + // The user's likely already transferred another edition from the piece so + // they can't update the missing fields that are necessary for consignment + // to marketplaces. + // Let's show an error in response to explain the problem and let them + // contact the whitelabel themselves. + return ( - + handleSuccess={this.handleConsignError} + title={getLangText("Oops, we can't consign this piece to %s", whitelabelName)}> + - - - {consignForm} - - - ); + ); + } } else { return ( +
+

+ {getLangText('Unfortunately, %s requires you to provide more information ' + + "about this edition, but it appears that you don't have the " + + 'permissions to edit the piece associated with this edition.', whitelabelName)} +

+

+ {getLangText('Please contact us if you would still like to consign this piece to %s.', whitelabelName)} +

+
+ + + ); + } +}); + +export default MarketConsignError; diff --git a/sass/ascribe_form.scss b/sass/ascribe_form.scss index 1b265e91..84be8be9 100644 --- a/sass/ascribe_form.scss +++ b/sass/ascribe_form.scss @@ -23,4 +23,11 @@ @media (max-width: 550px) { width: 100%; } -} \ No newline at end of file +} + +.ascribe-form-error-popup { + .error-popup-content { + margin-bottom: 30px; + margin-top: 20px; + } +}