mirror of
https://github.com/ascribe/onion.git
synced 2024-12-31 09:07:48 +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 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 GlobalNotificationModel from '../../models/global_notification_model';
|
||||
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 { getLangText } from '../../utils/lang_utils';
|
||||
@ -30,6 +29,7 @@ import { mergeOptions } from '../../utils/general_utils';
|
||||
let AccordionListItemWallet = React.createClass({
|
||||
propTypes: {
|
||||
content: React.PropTypes.object.isRequired,
|
||||
whitelabel: React.PropTypes.object.isRequired,
|
||||
|
||||
className: React.PropTypes.string,
|
||||
thumbnailPlaceholder: React.PropTypes.func,
|
||||
@ -41,22 +41,19 @@ let AccordionListItemWallet = React.createClass({
|
||||
|
||||
getInitialState() {
|
||||
return mergeOptions(
|
||||
PieceListStore.getState(),
|
||||
{
|
||||
showCreateEditionsDialog: false
|
||||
},
|
||||
PieceListStore.getState(),
|
||||
WhitelabelStore.getState()
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
PieceListStore.listen(this.onChange);
|
||||
WhitelabelStore.listen(this.onChange);
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
PieceListStore.unlisten(this.onChange);
|
||||
WhitelabelStore.unlisten(this.onChange);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
@ -64,7 +61,7 @@ let AccordionListItemWallet = React.createClass({
|
||||
},
|
||||
|
||||
getGlyphicon() {
|
||||
if (this.props.content.notifications && this.props.content.notifications.length){
|
||||
if (this.props.content.notifications && this.props.content.notifications.length) {
|
||||
return (
|
||||
<OverlayTrigger
|
||||
delay={500}
|
||||
@ -93,7 +90,7 @@ let AccordionListItemWallet = React.createClass({
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
EditionListActions.toggleEditionList(pieceId);
|
||||
|
||||
let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000);
|
||||
const notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
},
|
||||
|
||||
@ -112,7 +109,7 @@ let AccordionListItemWallet = React.createClass({
|
||||
|
||||
getLicences() {
|
||||
// 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 (
|
||||
<span>
|
||||
<span>, </span>
|
||||
|
@ -84,8 +84,8 @@ let EditionContainer = React.createClass({
|
||||
},
|
||||
|
||||
render() {
|
||||
const { actionPanelButtonListType, currentUser, furtherDetailsType, whitelabel } = this.props;
|
||||
const { edition, coaMeta } = this.state;
|
||||
const { actionPanelButtonListType, currentUser, furtherDetailsType } = this.props;
|
||||
|
||||
if (Object.keys(edition).length && edition.id) {
|
||||
setDocumentTitle([edition.artist_name, edition.title].join(', '));
|
||||
@ -93,11 +93,12 @@ let EditionContainer = React.createClass({
|
||||
return (
|
||||
<Edition
|
||||
actionPanelButtonListType={actionPanelButtonListType}
|
||||
furtherDetailsType={furtherDetailsType}
|
||||
edition={edition}
|
||||
coaError={coaMeta.err}
|
||||
currentUser={currentUser}
|
||||
loadEdition={() => EditionActions.fetchEdition(this.props.params.editionId)} />
|
||||
edition={edition}
|
||||
furtherDetailsType={furtherDetailsType}
|
||||
loadEdition={() => EditionActions.fetchEdition(this.props.params.editionId)}
|
||||
whitelabel={whitelabel} />
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
|
@ -268,7 +268,8 @@ let PieceList = React.createClass({
|
||||
customSubmitButton,
|
||||
customThumbnailPlaceholder,
|
||||
filterParams,
|
||||
orderParams } = this.props;
|
||||
orderParams,
|
||||
whitelabel } = this.props;
|
||||
|
||||
const loadingElement = <AscribeSpinner color='dark-blue' size='lg'/>;
|
||||
|
||||
@ -276,6 +277,7 @@ let PieceList = React.createClass({
|
||||
const availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view');
|
||||
|
||||
setDocumentTitle(getLangText('Collection'));
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PieceListToolbar
|
||||
@ -302,8 +304,9 @@ let PieceList = React.createClass({
|
||||
<BulkModalButtonListType
|
||||
availableAcls={availableAcls}
|
||||
currentUser={currentUser}
|
||||
pieceOrEditions={selectedEditions}
|
||||
handleSuccess={this.handleAclSuccess}
|
||||
pieceOrEditions={selectedEditions}
|
||||
whitelabel={whitelabel}
|
||||
className="text-center ascribe-button-list collapse-group">
|
||||
<DeleteButton
|
||||
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"
|
||||
content={piece}
|
||||
currentUser={currentUser}
|
||||
thumbnailPlaceholder={customThumbnailPlaceholder}>
|
||||
thumbnailPlaceholder={customThumbnailPlaceholder}
|
||||
whitelabel={whitelabel}>
|
||||
<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"
|
||||
parentId={piece.id} />
|
||||
|
@ -6,9 +6,6 @@ import { History } from 'react-router';
|
||||
import Col from 'react-bootstrap/lib/Col';
|
||||
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 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 WhitelabelActions from '../../../../../../actions/whitelabel_actions';
|
||||
import WhitelabelStore from '../../../../../../stores/whitelabel_store';
|
||||
|
||||
import { getLangText } from '../../../../../../utils/lang_utils';
|
||||
|
||||
|
||||
let CylandSubmitButton = React.createClass({
|
||||
propTypes: {
|
||||
className: React.PropTypes.string,
|
||||
handleSuccess: React.PropTypes.func,
|
||||
piece: React.PropTypes.object.isRequired,
|
||||
username: React.PropTypes.string
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return WhitelabelStore.getState();
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
WhitelabelStore.listen(this.onChange);
|
||||
WhitelabelActions.fetchWhitelabel();
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
WhitelabelStore.unlisten(this.onChange);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
this.setState(state);
|
||||
className: React.PropTypes.string,
|
||||
handleSuccess: React.PropTypes.func
|
||||
},
|
||||
|
||||
render() {
|
||||
const { piece, className } = this.props;
|
||||
const { className, piece } = this.props;
|
||||
|
||||
return (
|
||||
<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,
|
||||
handleSuccess: React.PropTypes.func.isRequired,
|
||||
pieceOrEditions: React.PropTypes.array.isRequired,
|
||||
whitelabel: React.PropTypes.object.isRequired,
|
||||
|
||||
children: React.PropTypes.oneOfType([
|
||||
React.PropTypes.arrayOf(React.PropTypes.element),
|
||||
@ -32,7 +33,8 @@ let MarketAclButtonList = React.createClass({
|
||||
className,
|
||||
currentUser,
|
||||
handleSuccess,
|
||||
pieceOrEditions } = this.props;
|
||||
pieceOrEditions,
|
||||
whitelabel } = this.props;
|
||||
|
||||
const buttonProps = selectFromObject(this.props, [
|
||||
'availableAcls',
|
||||
@ -43,7 +45,9 @@ let MarketAclButtonList = React.createClass({
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<MarketSubmitButton {...buttonProps} />
|
||||
<MarketSubmitButton
|
||||
{...buttonProps}
|
||||
whitelabel={whitelabel} />
|
||||
<EmailButton {...buttonProps} />
|
||||
<TransferButton {...buttonProps} />
|
||||
<UnconsignButton {...buttonProps} />
|
||||
|
@ -3,6 +3,8 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import PieceActions from '../../../../../../actions/piece_actions';
|
||||
|
||||
import MarketAdditionalDataForm from '../market_forms/market_additional_data_form';
|
||||
|
||||
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 PieceActions from '../../../../../../actions/piece_actions';
|
||||
import WhitelabelActions from '../../../../../../actions/whitelabel_actions';
|
||||
import WhitelabelStore from '../../../../../../stores/whitelabel_store';
|
||||
|
||||
import ApiUrls from '../../../../../../constants/api_urls';
|
||||
|
||||
import { getAclFormMessage, getAclFormDataId } from '../../../../../../utils/form_utils';
|
||||
@ -24,30 +22,14 @@ import { getLangText } from '../../../../../../utils/lang_utils';
|
||||
let MarketSubmitButton = React.createClass({
|
||||
propTypes: {
|
||||
availableAcls: React.PropTypes.object.isRequired,
|
||||
currentUser: React.PropTypes.object,
|
||||
currentUser: React.PropTypes.object.isRequired,
|
||||
editions: React.PropTypes.array.isRequired,
|
||||
handleSuccess: React.PropTypes.func.isRequired,
|
||||
whitelabel: React.PropTypes.object.isRequired,
|
||||
|
||||
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) {
|
||||
if (edition && edition.extra_data && edition.other_data) {
|
||||
const { extra_data, other_data } = edition;
|
||||
@ -90,8 +72,14 @@ let MarketSubmitButton = React.createClass({
|
||||
},
|
||||
|
||||
render() {
|
||||
const { availableAcls, currentUser, className, editions, handleSuccess } = this.props;
|
||||
const { whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.state;
|
||||
const {
|
||||
availableAcls,
|
||||
currentUser,
|
||||
className,
|
||||
editions,
|
||||
handleSuccess,
|
||||
whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.props;
|
||||
|
||||
const { solePieceId, canSubmit } = this.getAggregateEditionDetails();
|
||||
const message = getAclFormMessage({
|
||||
aclName: 'acl_consign',
|
||||
@ -106,6 +94,7 @@ let MarketSubmitButton = React.createClass({
|
||||
{getLangText('CONSIGN TO %s', whitelabelName.toUpperCase())}
|
||||
</button>
|
||||
);
|
||||
|
||||
const consignForm = (
|
||||
<AclFormFactory
|
||||
action='acl_consign'
|
||||
|
Loading…
Reference in New Issue
Block a user