mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
Update components for loading WhitelabelStore from top level app
This commit is contained in:
parent
4133922f31
commit
40041197d6
@ -7,20 +7,19 @@ import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
|||||||
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
|
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
|
||||||
import Tooltip from 'react-bootstrap/lib/Tooltip';
|
import Tooltip from 'react-bootstrap/lib/Tooltip';
|
||||||
|
|
||||||
import AccordionListItemPiece from './accordion_list_item_piece';
|
|
||||||
import AccordionListItemEditionWidget from './accordion_list_item_edition_widget';
|
|
||||||
import CreateEditionsForm from '../ascribe_forms/create_editions_form';
|
|
||||||
|
|
||||||
import PieceListActions from '../../actions/piece_list_actions';
|
|
||||||
import PieceListStore from '../../stores/piece_list_store';
|
|
||||||
|
|
||||||
import WhitelabelStore from '../../stores/whitelabel_store';
|
|
||||||
|
|
||||||
import EditionListActions from '../../actions/edition_list_actions';
|
import EditionListActions from '../../actions/edition_list_actions';
|
||||||
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
import PieceListActions from '../../actions/piece_list_actions';
|
||||||
|
import PieceListStore from '../../stores/piece_list_store';
|
||||||
|
|
||||||
|
import AccordionListItemPiece from './accordion_list_item_piece';
|
||||||
|
import AccordionListItemEditionWidget from './accordion_list_item_edition_widget';
|
||||||
|
import CreateEditionsForm from '../ascribe_forms/create_editions_form';
|
||||||
|
|
||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
@ -30,6 +29,7 @@ import { mergeOptions } from '../../utils/general_utils';
|
|||||||
let AccordionListItemWallet = React.createClass({
|
let AccordionListItemWallet = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
content: React.PropTypes.object.isRequired,
|
content: React.PropTypes.object.isRequired,
|
||||||
|
whitelabel: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
thumbnailPlaceholder: React.PropTypes.func,
|
thumbnailPlaceholder: React.PropTypes.func,
|
||||||
@ -41,22 +41,19 @@ let AccordionListItemWallet = React.createClass({
|
|||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return mergeOptions(
|
return mergeOptions(
|
||||||
|
PieceListStore.getState(),
|
||||||
{
|
{
|
||||||
showCreateEditionsDialog: false
|
showCreateEditionsDialog: false
|
||||||
},
|
}
|
||||||
PieceListStore.getState(),
|
|
||||||
WhitelabelStore.getState()
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
PieceListStore.listen(this.onChange);
|
PieceListStore.listen(this.onChange);
|
||||||
WhitelabelStore.listen(this.onChange);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
PieceListStore.unlisten(this.onChange);
|
PieceListStore.unlisten(this.onChange);
|
||||||
WhitelabelStore.unlisten(this.onChange);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
@ -64,7 +61,7 @@ let AccordionListItemWallet = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getGlyphicon() {
|
getGlyphicon() {
|
||||||
if (this.props.content.notifications && this.props.content.notifications.length){
|
if (this.props.content.notifications && this.props.content.notifications.length) {
|
||||||
return (
|
return (
|
||||||
<OverlayTrigger
|
<OverlayTrigger
|
||||||
delay={500}
|
delay={500}
|
||||||
@ -93,7 +90,7 @@ let AccordionListItemWallet = React.createClass({
|
|||||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||||
EditionListActions.toggleEditionList(pieceId);
|
EditionListActions.toggleEditionList(pieceId);
|
||||||
|
|
||||||
let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000);
|
const notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -112,7 +109,7 @@ let AccordionListItemWallet = React.createClass({
|
|||||||
|
|
||||||
getLicences() {
|
getLicences() {
|
||||||
// convert this to acl_view_licences later
|
// convert this to acl_view_licences later
|
||||||
if (this.state.whitelabel && this.state.whitelabel.name === 'Creative Commons France') {
|
if (this.props.whitelabel && this.props.whitelabel.name === 'Creative Commons France') {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<span>, </span>
|
<span>, </span>
|
||||||
|
@ -84,8 +84,8 @@ let EditionContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { actionPanelButtonListType, currentUser, furtherDetailsType, whitelabel } = this.props;
|
||||||
const { edition, coaMeta } = this.state;
|
const { edition, coaMeta } = this.state;
|
||||||
const { actionPanelButtonListType, currentUser, furtherDetailsType } = this.props;
|
|
||||||
|
|
||||||
if (Object.keys(edition).length && edition.id) {
|
if (Object.keys(edition).length && edition.id) {
|
||||||
setDocumentTitle([edition.artist_name, edition.title].join(', '));
|
setDocumentTitle([edition.artist_name, edition.title].join(', '));
|
||||||
@ -93,11 +93,12 @@ let EditionContainer = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<Edition
|
<Edition
|
||||||
actionPanelButtonListType={actionPanelButtonListType}
|
actionPanelButtonListType={actionPanelButtonListType}
|
||||||
furtherDetailsType={furtherDetailsType}
|
|
||||||
edition={edition}
|
|
||||||
coaError={coaMeta.err}
|
coaError={coaMeta.err}
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
loadEdition={() => EditionActions.fetchEdition(this.props.params.editionId)} />
|
edition={edition}
|
||||||
|
furtherDetailsType={furtherDetailsType}
|
||||||
|
loadEdition={() => EditionActions.fetchEdition(this.props.params.editionId)}
|
||||||
|
whitelabel={whitelabel} />
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
|
@ -268,7 +268,8 @@ let PieceList = React.createClass({
|
|||||||
customSubmitButton,
|
customSubmitButton,
|
||||||
customThumbnailPlaceholder,
|
customThumbnailPlaceholder,
|
||||||
filterParams,
|
filterParams,
|
||||||
orderParams } = this.props;
|
orderParams,
|
||||||
|
whitelabel } = this.props;
|
||||||
|
|
||||||
const loadingElement = <AscribeSpinner color='dark-blue' size='lg'/>;
|
const loadingElement = <AscribeSpinner color='dark-blue' size='lg'/>;
|
||||||
|
|
||||||
@ -276,6 +277,7 @@ let PieceList = React.createClass({
|
|||||||
const availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view');
|
const availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view');
|
||||||
|
|
||||||
setDocumentTitle(getLangText('Collection'));
|
setDocumentTitle(getLangText('Collection'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PieceListToolbar
|
<PieceListToolbar
|
||||||
@ -302,8 +304,9 @@ let PieceList = React.createClass({
|
|||||||
<BulkModalButtonListType
|
<BulkModalButtonListType
|
||||||
availableAcls={availableAcls}
|
availableAcls={availableAcls}
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
pieceOrEditions={selectedEditions}
|
|
||||||
handleSuccess={this.handleAclSuccess}
|
handleSuccess={this.handleAclSuccess}
|
||||||
|
pieceOrEditions={selectedEditions}
|
||||||
|
whitelabel={whitelabel}
|
||||||
className="text-center ascribe-button-list collapse-group">
|
className="text-center ascribe-button-list collapse-group">
|
||||||
<DeleteButton
|
<DeleteButton
|
||||||
handleSuccess={this.handleAclSuccess}
|
handleSuccess={this.handleAclSuccess}
|
||||||
@ -332,7 +335,8 @@ let PieceList = React.createClass({
|
|||||||
className="col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2 ascribe-accordion-list-item"
|
className="col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2 ascribe-accordion-list-item"
|
||||||
content={piece}
|
content={piece}
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
thumbnailPlaceholder={customThumbnailPlaceholder}>
|
thumbnailPlaceholder={customThumbnailPlaceholder}
|
||||||
|
whitelabel={whitelabel}>
|
||||||
<AccordionListItemTableEditions
|
<AccordionListItemTableEditions
|
||||||
className="ascribe-accordion-list-item-table col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2"
|
className="ascribe-accordion-list-item-table col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2"
|
||||||
parentId={piece.id} />
|
parentId={piece.id} />
|
||||||
|
@ -6,9 +6,6 @@ import { History } from 'react-router';
|
|||||||
import Col from 'react-bootstrap/lib/Col';
|
import Col from 'react-bootstrap/lib/Col';
|
||||||
import Row from 'react-bootstrap/lib/Row';
|
import Row from 'react-bootstrap/lib/Row';
|
||||||
|
|
||||||
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';
|
||||||
|
|
||||||
|
@ -7,39 +7,19 @@ import Button from 'react-bootstrap/lib/Button';
|
|||||||
|
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
import WhitelabelActions from '../../../../../../actions/whitelabel_actions';
|
|
||||||
import WhitelabelStore from '../../../../../../stores/whitelabel_store';
|
|
||||||
|
|
||||||
import { getLangText } from '../../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../../utils/lang_utils';
|
||||||
|
|
||||||
|
|
||||||
let CylandSubmitButton = React.createClass({
|
let CylandSubmitButton = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
className: React.PropTypes.string,
|
|
||||||
handleSuccess: React.PropTypes.func,
|
|
||||||
piece: React.PropTypes.object.isRequired,
|
piece: React.PropTypes.object.isRequired,
|
||||||
username: React.PropTypes.string
|
|
||||||
},
|
|
||||||
|
|
||||||
getInitialState() {
|
className: React.PropTypes.string,
|
||||||
return WhitelabelStore.getState();
|
handleSuccess: React.PropTypes.func
|
||||||
},
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
WhitelabelStore.listen(this.onChange);
|
|
||||||
WhitelabelActions.fetchWhitelabel();
|
|
||||||
},
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
WhitelabelStore.unlisten(this.onChange);
|
|
||||||
},
|
|
||||||
|
|
||||||
onChange(state) {
|
|
||||||
this.setState(state);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { piece, className } = this.props;
|
const { className, piece } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LinkContainer
|
<LinkContainer
|
||||||
@ -58,4 +38,4 @@ let CylandSubmitButton = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default CylandSubmitButton;
|
export default CylandSubmitButton;
|
||||||
|
@ -17,6 +17,7 @@ let MarketAclButtonList = React.createClass({
|
|||||||
currentUser: React.PropTypes.object.isRequired,
|
currentUser: React.PropTypes.object.isRequired,
|
||||||
handleSuccess: React.PropTypes.func.isRequired,
|
handleSuccess: React.PropTypes.func.isRequired,
|
||||||
pieceOrEditions: React.PropTypes.array.isRequired,
|
pieceOrEditions: React.PropTypes.array.isRequired,
|
||||||
|
whitelabel: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
children: React.PropTypes.oneOfType([
|
children: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.arrayOf(React.PropTypes.element),
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
||||||
@ -32,7 +33,8 @@ let MarketAclButtonList = React.createClass({
|
|||||||
className,
|
className,
|
||||||
currentUser,
|
currentUser,
|
||||||
handleSuccess,
|
handleSuccess,
|
||||||
pieceOrEditions } = this.props;
|
pieceOrEditions,
|
||||||
|
whitelabel } = this.props;
|
||||||
|
|
||||||
const buttonProps = selectFromObject(this.props, [
|
const buttonProps = selectFromObject(this.props, [
|
||||||
'availableAcls',
|
'availableAcls',
|
||||||
@ -43,7 +45,9 @@ let MarketAclButtonList = React.createClass({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
<MarketSubmitButton {...buttonProps} />
|
<MarketSubmitButton
|
||||||
|
{...buttonProps}
|
||||||
|
whitelabel={whitelabel} />
|
||||||
<EmailButton {...buttonProps} />
|
<EmailButton {...buttonProps} />
|
||||||
<TransferButton {...buttonProps} />
|
<TransferButton {...buttonProps} />
|
||||||
<UnconsignButton {...buttonProps} />
|
<UnconsignButton {...buttonProps} />
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import PieceActions from '../../../../../../actions/piece_actions';
|
||||||
|
|
||||||
import MarketAdditionalDataForm from '../market_forms/market_additional_data_form';
|
import MarketAdditionalDataForm from '../market_forms/market_additional_data_form';
|
||||||
|
|
||||||
import AclFormFactory from '../../../../../ascribe_forms/acl_form_factory';
|
import AclFormFactory from '../../../../../ascribe_forms/acl_form_factory';
|
||||||
@ -12,10 +14,6 @@ import ModalWrapper from '../../../../../ascribe_modal/modal_wrapper';
|
|||||||
|
|
||||||
import AclProxy from '../../../../../acl_proxy';
|
import AclProxy from '../../../../../acl_proxy';
|
||||||
|
|
||||||
import PieceActions from '../../../../../../actions/piece_actions';
|
|
||||||
import WhitelabelActions from '../../../../../../actions/whitelabel_actions';
|
|
||||||
import WhitelabelStore from '../../../../../../stores/whitelabel_store';
|
|
||||||
|
|
||||||
import ApiUrls from '../../../../../../constants/api_urls';
|
import ApiUrls from '../../../../../../constants/api_urls';
|
||||||
|
|
||||||
import { getAclFormMessage, getAclFormDataId } from '../../../../../../utils/form_utils';
|
import { getAclFormMessage, getAclFormDataId } from '../../../../../../utils/form_utils';
|
||||||
@ -24,30 +22,14 @@ import { getLangText } from '../../../../../../utils/lang_utils';
|
|||||||
let MarketSubmitButton = React.createClass({
|
let MarketSubmitButton = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
availableAcls: React.PropTypes.object.isRequired,
|
availableAcls: React.PropTypes.object.isRequired,
|
||||||
currentUser: React.PropTypes.object,
|
currentUser: React.PropTypes.object.isRequired,
|
||||||
editions: React.PropTypes.array.isRequired,
|
editions: React.PropTypes.array.isRequired,
|
||||||
handleSuccess: React.PropTypes.func.isRequired,
|
handleSuccess: React.PropTypes.func.isRequired,
|
||||||
|
whitelabel: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
|
||||||
return WhitelabelStore.getState();
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
WhitelabelStore.listen(this.onChange);
|
|
||||||
|
|
||||||
WhitelabelActions.fetchWhitelabel();
|
|
||||||
},
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
WhitelabelStore.unlisten(this.onChange);
|
|
||||||
},
|
|
||||||
|
|
||||||
onChange(state) {
|
|
||||||
this.setState(state);
|
|
||||||
},
|
|
||||||
|
|
||||||
canEditionBeSubmitted(edition) {
|
canEditionBeSubmitted(edition) {
|
||||||
if (edition && edition.extra_data && edition.other_data) {
|
if (edition && edition.extra_data && edition.other_data) {
|
||||||
const { extra_data, other_data } = edition;
|
const { extra_data, other_data } = edition;
|
||||||
@ -90,8 +72,14 @@ let MarketSubmitButton = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { availableAcls, currentUser, className, editions, handleSuccess } = this.props;
|
const {
|
||||||
const { whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.state;
|
availableAcls,
|
||||||
|
currentUser,
|
||||||
|
className,
|
||||||
|
editions,
|
||||||
|
handleSuccess,
|
||||||
|
whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.props;
|
||||||
|
|
||||||
const { solePieceId, canSubmit } = this.getAggregateEditionDetails();
|
const { solePieceId, canSubmit } = this.getAggregateEditionDetails();
|
||||||
const message = getAclFormMessage({
|
const message = getAclFormMessage({
|
||||||
aclName: 'acl_consign',
|
aclName: 'acl_consign',
|
||||||
@ -106,6 +94,7 @@ let MarketSubmitButton = React.createClass({
|
|||||||
{getLangText('CONSIGN TO %s', whitelabelName.toUpperCase())}
|
{getLangText('CONSIGN TO %s', whitelabelName.toUpperCase())}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
const consignForm = (
|
const consignForm = (
|
||||||
<AclFormFactory
|
<AclFormFactory
|
||||||
action='acl_consign'
|
action='acl_consign'
|
||||||
|
Loading…
Reference in New Issue
Block a user