1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-23 01:36:28 +02:00
onion/js/components/whitelabel/wallet/components/ascribe_detail/wallet_action_panel.js

73 lines
2.6 KiB
JavaScript
Raw Normal View History

2015-09-21 18:04:15 +02:00
'use strict';
import React from 'react';
import ListRequestActions from '../../../../ascribe_forms/list_form_request_actions';
import AclButtonList from '../../../../ascribe_buttons/acl_button_list';
import DeleteButton from '../../../../ascribe_buttons/delete_button';
import AclProxy from '../../../../acl_proxy';
import { mergeOptions } from '../../../../../utils/general_utils';
let WalletActionPanel = React.createClass({
propTypes: {
piece: React.PropTypes.object.isRequired,
currentUser: React.PropTypes.object.isRequired,
loadPiece: React.PropTypes.func.isRequired,
submitButtonType: React.PropTypes.func.isRequired
},
render(){
if (this.props.piece &&
this.props.piece.notifications &&
this.props.piece.notifications.length > 0) {
return (
<ListRequestActions
pieceOrEditions={this.props.piece}
currentUser={this.props.currentUser}
handleSuccess={this.props.loadPiece}
notifications={this.props.piece.notifications}/>);
}
else {
//We need to disable the normal acl_loan because we're inserting a custom acl_loan button
let availableAcls;
if (this.props.piece && this.props.piece.acl && typeof this.props.piece.acl.acl_loan !== 'undefined') {
// make a copy to not have side effects
availableAcls = mergeOptions({}, this.props.piece.acl);
availableAcls.acl_loan = false;
}
let SubmitButtonType = this.props.submitButtonType;
return (
<AclButtonList
className="text-center ascribe-button-list"
availableAcls={availableAcls}
editions={this.props.piece}
2015-10-12 10:37:08 +02:00
handleSuccess={this.props.loadPiece}>
2015-09-21 18:04:15 +02:00
<AclProxy
aclObject={this.props.currentUser.acl}
aclName="acl_wallet_submit">
<AclProxy
aclObject={availableAcls}
aclName="acl_wallet_submit">
<SubmitButtonType
className="btn-sm"
piece={this.props.piece}/>
</AclProxy>
2015-09-21 18:04:15 +02:00
</AclProxy>
<DeleteButton
handleSuccess={this.handleDeleteSuccess}
piece={this.props.piece}/>
</AclButtonList>
);
}
}
});
export default WalletActionPanel;