From a481b3c00e06f5cc2b525cd07cfedc6d795fac24 Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 14 Oct 2016 11:51:20 +0200 Subject: [PATCH] bokk.ascribe.io --- js/app.js | 2 +- .../accordion_list_item_wallet.js | 2 +- .../components/bokk/bokk_register_piece.js | 105 ++++++++++++++++++ .../whitelabel/wallet/wallet_routes.js | 46 +++++++- js/constants/application_constants.js | 7 +- js/fetchers/license_fetcher.js | 2 +- 6 files changed, 159 insertions(+), 5 deletions(-) create mode 100644 js/components/whitelabel/wallet/components/bokk/bokk_register_piece.js diff --git a/js/app.js b/js/app.js index dc8e3d62..b93a1e87 100644 --- a/js/app.js +++ b/js/app.js @@ -55,7 +55,7 @@ const AppGateway = { if (subdomain) { // Some whitelabels have landing pages so we should not automatically redirect from / to /collection. // Only www and cc do not have a landing page. - if (subdomain !== 'cc') { + if (subdomain !== 'cc' || subdomain === 'bokk') { redirectRoute = null; } diff --git a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js index e752451e..804bf193 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_wallet.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_wallet.js @@ -114,7 +114,7 @@ let AccordionListItemWallet = React.createClass({ const { content, whitelabel } = this.props; // convert this to acl_view_licences later - if (whitelabel.name === 'Creative Commons France') { + if (whitelabel.subdomain === 'cc' || whitelabel.subdomain === 'bokk') { return ( , diff --git a/js/components/whitelabel/wallet/components/bokk/bokk_register_piece.js b/js/components/whitelabel/wallet/components/bokk/bokk_register_piece.js new file mode 100644 index 00000000..6353a555 --- /dev/null +++ b/js/components/whitelabel/wallet/components/bokk/bokk_register_piece.js @@ -0,0 +1,105 @@ +'use strict'; + +import React from 'react'; +import RegisterPiece from '../../../../register_piece'; +import Property from '../../../../ascribe_forms/property'; + +import LicenseActions from '../../../../../actions/license_actions'; +import LicenseStore from '../../../../../stores/license_store'; + +import { getLangText } from '../../../../../utils/lang_utils'; +import { setDocumentTitle } from '../../../../../utils/dom_utils'; +import { mergeOptions } from '../../../../../utils/general_utils'; + + +let BokkRegisterPiece = React.createClass({ + propTypes: { + // Provided from AscribeApp + currentUser: React.PropTypes.object, + whitelabel: React.PropTypes.object, + + // Provided from router + location: React.PropTypes.object + }, + + getInitialState() { + return mergeOptions( + LicenseStore.getState(), + { + selectedLicense: 0 + } + ); + }, + + componentDidMount() { + LicenseStore.listen(this.onChange); + LicenseActions.fetchLicense(); + }, + + componentWillUnmount() { + LicenseStore.unlisten(this.onChange); + }, + + onChange(state) { + this.setState(state); + }, + + onLicenseChange(event){ + this.setState({selectedLicense: event.target.selectedIndex}); + }, + + getLicenses() { + if (this.state.licenses && this.state.licenses.length > 1) { + return ( + + + {getLangText('Learn more about ') + this.state.licenses[this.state.selectedLicense].code} + +  ( + + {getLangText('ascribe faq')} + ) + + }> + + ); + } + return null; + }, + + render() { + setDocumentTitle(getLangText('Register a new piece')); + return ( + + {this.getLicenses()} + + ); + } +}); + +export default BokkRegisterPiece; diff --git a/js/components/whitelabel/wallet/wallet_routes.js b/js/components/whitelabel/wallet/wallet_routes.js index 2e0e9a10..1bea27db 100644 --- a/js/components/whitelabel/wallet/wallet_routes.js +++ b/js/components/whitelabel/wallet/wallet_routes.js @@ -20,6 +20,7 @@ import ErrorNotFoundPage from '../../../components/error_not_found_page'; import Footer from '../../../components/footer.js'; import CCRegisterPiece from './components/cc/cc_register_piece'; +import BokkRegisterPiece from './components/bokk/bokk_register_piece'; import CylandLanding from './components/cyland/cyland_landing'; import CylandPieceContainer from './components/cyland/cyland_detail/cyland_piece_container'; @@ -448,7 +449,50 @@ let ROUTES = { - ) + ), + 'bokk': ( + + + + + + + + + + + + + + + ), }; function getRoutes(commonRoutes, subdomain) { diff --git a/js/constants/application_constants.js b/js/constants/application_constants.js index 83b5a374..1c5b32f4 100644 --- a/js/constants/application_constants.js +++ b/js/constants/application_constants.js @@ -77,7 +77,12 @@ const constants = { 'subdomain': 'portfolioreview', 'name': 'Portfolio Review', 'type': 'prize' - } + }, + { + 'subdomain': 'bokk', + 'name': 'bokk Creative Commons France', + 'type': 'wallet' + }, ], 'defaultDomain': { 'type': 'default', diff --git a/js/fetchers/license_fetcher.js b/js/fetchers/license_fetcher.js index d5b296be..cb5e9224 100644 --- a/js/fetchers/license_fetcher.js +++ b/js/fetchers/license_fetcher.js @@ -10,7 +10,7 @@ let LicenseFetcher = { * Fetch the available licenses from the API (might be bound to the subdomain e.g. cc.ascribe.io). */ fetch() { - return requests.get('licenses', {'subdomain': getSubdomain()}); + return requests.get('licenses', {'subdomain': getSubdomain() }); } };