mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
Use AclButton in LumenusSubmitButton
Instead of copying functionality from AclButton to add a default email, LumenusSubmitButton just returns one with preset settings.
This commit is contained in:
parent
ac1b43d24b
commit
633939b7fa
@ -30,6 +30,7 @@ let AclButton = React.createClass({
|
|||||||
currentUser: React.PropTypes.object,
|
currentUser: React.PropTypes.object,
|
||||||
buttonAcceptName: React.PropTypes.string,
|
buttonAcceptName: React.PropTypes.string,
|
||||||
buttonAcceptClassName: React.PropTypes.string,
|
buttonAcceptClassName: React.PropTypes.string,
|
||||||
|
email: React.PropTypes.string,
|
||||||
handleSuccess: React.PropTypes.func.isRequired,
|
handleSuccess: React.PropTypes.func.isRequired,
|
||||||
className: React.PropTypes.string
|
className: React.PropTypes.string
|
||||||
},
|
},
|
||||||
@ -52,6 +53,7 @@ let AclButton = React.createClass({
|
|||||||
tooltip: getLangText('Have someone else sell the artwork'),
|
tooltip: getLangText('Have someone else sell the artwork'),
|
||||||
form: (
|
form: (
|
||||||
<ConsignForm
|
<ConsignForm
|
||||||
|
email={this.props.email}
|
||||||
message={message}
|
message={message}
|
||||||
id={this.getFormDataId()}
|
id={this.getFormDataId()}
|
||||||
url={ApiUrls.ownership_consigns}/>
|
url={ApiUrls.ownership_consigns}/>
|
||||||
@ -88,6 +90,7 @@ let AclButton = React.createClass({
|
|||||||
tooltip: getLangText('Loan your artwork for a limited period of time'),
|
tooltip: getLangText('Loan your artwork for a limited period of time'),
|
||||||
form: (
|
form: (
|
||||||
<LoanForm
|
<LoanForm
|
||||||
|
email={this.props.email}
|
||||||
message={message}
|
message={message}
|
||||||
id={this.getFormDataId()}
|
id={this.getFormDataId()}
|
||||||
url={this.isPiece() ? ApiUrls.ownership_loans_pieces
|
url={this.isPiece() ? ApiUrls.ownership_loans_pieces
|
||||||
|
@ -4,10 +4,12 @@ import React from 'react';
|
|||||||
|
|
||||||
import LumenusSubmitButton from './lumenus_submit_button';
|
import LumenusSubmitButton from './lumenus_submit_button';
|
||||||
|
|
||||||
import AclProxy from '../../../../../acl_proxy';
|
import AclButton from '../../../../../ascribe_buttons/acl_button';
|
||||||
|
|
||||||
import DeleteButton from '../../../../../ascribe_buttons/delete_button';
|
import DeleteButton from '../../../../../ascribe_buttons/delete_button';
|
||||||
|
|
||||||
|
import UserActions from '../../../../../../actions/user_actions';
|
||||||
|
import UserStore from '../../../../../../stores/user_store';
|
||||||
|
|
||||||
let LumenusAclButtonList = React.createClass({
|
let LumenusAclButtonList = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
availableAcls: React.PropTypes.object.isRequired,
|
availableAcls: React.PropTypes.object.isRequired,
|
||||||
@ -20,16 +22,38 @@ let LumenusAclButtonList = React.createClass({
|
|||||||
])
|
])
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getInitialState() {
|
||||||
|
return UserStore.getState();
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
UserStore.listen(this.onChange);
|
||||||
|
UserActions.fetchCurrentUser();
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
UserStore.unlisten(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
onChange(state) {
|
||||||
|
this.setState(state);
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let { availableAcls, className, editions, handleSuccess } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className={this.props.className}>
|
<div className={className}>
|
||||||
<AclProxy
|
|
||||||
aclObject={this.props.availableAcls}
|
|
||||||
aclName={'acl_consign'}>
|
|
||||||
<LumenusSubmitButton
|
<LumenusSubmitButton
|
||||||
editions={this.props.editions}
|
availableAcls={availableAcls}
|
||||||
handleSuccess={this.props.handleSuccess} />
|
currentUser={this.state.currentUser}
|
||||||
</AclProxy>
|
editions={editions}
|
||||||
|
handleSuccess={handleSuccess} />
|
||||||
|
<AclButton
|
||||||
|
action="acl_share"
|
||||||
|
availableAcls={availableAcls}
|
||||||
|
currentUser={this.state.currentUser}
|
||||||
|
pieceOrEditions={editions}
|
||||||
|
handleSuccess={handleSuccess} />
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -3,47 +3,32 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import AclButton from '../../../../../ascribe_buttons/acl_button';
|
||||||
|
|
||||||
import GlobalNotificationModel from '../../../../../../models/global_notification_model';
|
|
||||||
import GlobalNotificationActions from '../../../../../../actions/global_notification_actions';
|
|
||||||
import UserActions from '../../../../../../actions/user_actions';
|
|
||||||
import UserStore from '../../../../../../stores/user_store';
|
|
||||||
import WhitelabelActions from '../../../../../../actions/whitelabel_actions';
|
import WhitelabelActions from '../../../../../../actions/whitelabel_actions';
|
||||||
import WhitelabelStore from '../../../../../../stores/whitelabel_store';
|
import WhitelabelStore from '../../../../../../stores/whitelabel_store';
|
||||||
|
|
||||||
import ConsignForm from '../../../../../ascribe_forms/form_consign';
|
|
||||||
|
|
||||||
import ModalWrapper from '../../../../../ascribe_modal/modal_wrapper';
|
|
||||||
|
|
||||||
import ApiUrls from '../../../../../../constants/api_urls';
|
|
||||||
|
|
||||||
import { getAclFormMessage, getAclFormDataId } from '../../../../../../utils/form_utils';
|
|
||||||
import { mergeOptions } from '../../../../../../utils/general_utils';
|
|
||||||
import { getLangText } from '../../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../../utils/lang_utils';
|
||||||
|
|
||||||
let LumenusSubmitButton = React.createClass({
|
let LumenusSubmitButton = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
className: React.PropTypes.string,
|
availableAcls: React.PropTypes.object.isRequired,
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
editions: React.PropTypes.array,
|
editions: React.PropTypes.array,
|
||||||
handleSuccess: React.PropTypes.func,
|
handleSuccess: React.PropTypes.func,
|
||||||
|
className: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return mergeOptions(
|
return WhitelabelStore.getState();
|
||||||
UserStore.getState(),
|
|
||||||
WhitelabelStore.getState()
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
UserStore.listen(this.onChange);
|
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
WhitelabelStore.listen(this.onChange);
|
WhitelabelStore.listen(this.onChange);
|
||||||
WhitelabelActions.fetchWhitelabel();
|
WhitelabelActions.fetchWhitelabel();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
WhitelabelStore.unlisten(this.onChange);
|
WhitelabelStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -51,39 +36,19 @@ let LumenusSubmitButton = React.createClass({
|
|||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
|
|
||||||
showNotification(response) {
|
|
||||||
this.props.handleSuccess();
|
|
||||||
if (response.notification) {
|
|
||||||
let notification = new GlobalNotificationModel(response.notification, 'success');
|
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { className, editions, handleSuccess } = this.props;
|
const { availableAcls, currentUser, className, editions, handleSuccess } = this.props;
|
||||||
const title = getLangText('Consign to Lumenus');
|
|
||||||
const message = getAclFormMessage({
|
|
||||||
aclName: 'acl_consign',
|
|
||||||
entities: editions,
|
|
||||||
isPiece: false,
|
|
||||||
senderName: this.state.currentUser.username
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalWrapper
|
<AclButton
|
||||||
trigger={
|
action='acl_consign'
|
||||||
<button className={classNames('btn', 'btn-default', 'btn-sm', className)}>
|
availableAcls={availableAcls}
|
||||||
{title}
|
buttonAcceptName={getLangText('CONSIGN TO LUMENUS')}
|
||||||
</button>
|
|
||||||
}
|
|
||||||
handleSuccess={this.showNotification}
|
|
||||||
title={title}>
|
|
||||||
<ConsignForm
|
|
||||||
email={this.state.whitelabel.user}
|
email={this.state.whitelabel.user}
|
||||||
message={message}
|
currentUser={currentUser}
|
||||||
id={getAclFormDataId(false, editions)}
|
handleSuccess={handleSuccess}
|
||||||
url={ApiUrls.ownership_consigns}/>
|
pieceOrEditions={editions}
|
||||||
</ModalWrapper>
|
className={className} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user