1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Custom bokk ACL button

This commit is contained in:
tim 2016-11-07 17:47:13 +01:00
parent c9a62a0523
commit 3230b0d8c0
5 changed files with 125 additions and 1 deletions

View File

@ -42,6 +42,7 @@ export default function AclButton({ action, displayName, title, tooltip }) {
render() { render() {
const { availableAcls, const { availableAcls,
buttonAcceptName,
buttonAcceptClassName, buttonAcceptClassName,
currentUser, currentUser,
email, email,
@ -63,6 +64,7 @@ export default function AclButton({ action, displayName, title, tooltip }) {
title={title}> title={title}>
<AclFormFactory <AclFormFactory
action={action} action={action}
acceptName={buttonAcceptName}
currentUser={currentUser} currentUser={currentUser}
email={email} email={email}
pieceOrEditions={pieceOrEditions} pieceOrEditions={pieceOrEditions}

View File

@ -2,6 +2,8 @@
import React from 'react'; import React from 'react';
import Button from 'react-bootstrap/lib/Button';
import ConsignForm from '../ascribe_forms/form_consign'; import ConsignForm from '../ascribe_forms/form_consign';
import UnConsignForm from '../ascribe_forms/form_unconsign'; import UnConsignForm from '../ascribe_forms/form_unconsign';
import TransferForm from '../ascribe_forms/form_transfer'; import TransferForm from '../ascribe_forms/form_transfer';
@ -16,10 +18,13 @@ import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions'; import GlobalNotificationActions from '../../actions/global_notification_actions';
import { getAclFormMessage, getAclFormDataId } from '../../utils/form_utils'; import { getAclFormMessage, getAclFormDataId } from '../../utils/form_utils';
import { getLangText } from '../../utils/lang_utils';
let AclFormFactory = React.createClass({ let AclFormFactory = React.createClass({
propTypes: { propTypes: {
action: React.PropTypes.oneOf(AppConstants.aclList).isRequired, action: React.PropTypes.oneOf(AppConstants.aclList).isRequired,
acceptName: React.PropTypes.string,
pieceOrEditions: React.PropTypes.oneOfType([ pieceOrEditions: React.PropTypes.oneOfType([
React.PropTypes.object, React.PropTypes.object,
React.PropTypes.array React.PropTypes.array
@ -63,6 +68,7 @@ let AclFormFactory = React.createClass({
labels, labels,
handleSuccess, handleSuccess,
showNotification } = this.props; showNotification } = this.props;
let acceptButton;
const formMessage = message || getAclFormMessage({ const formMessage = message || getAclFormMessage({
aclName: action, aclName: action,
@ -71,9 +77,24 @@ let AclFormFactory = React.createClass({
senderName: currentUser && currentUser.username senderName: currentUser && currentUser.username
}); });
if (this.props.acceptName) {
acceptButton = (
<div className="modal-footer">
<p className="pull-right">
<Button
className="btn btn-default btn-sm ascribe-margin-1px"
type="submit">
{getLangText(this.props.acceptName)}
</Button>
</p>
</div>
);
}
if (action === 'acl_consign') { if (action === 'acl_consign') {
return ( return (
<ConsignForm <ConsignForm
buttons={acceptName}
autoFocusProperty={autoFocusProperty} autoFocusProperty={autoFocusProperty}
email={email} email={email}
message={formMessage} message={formMessage}
@ -85,6 +106,7 @@ let AclFormFactory = React.createClass({
} else if (action === 'acl_unconsign') { } else if (action === 'acl_unconsign') {
return ( return (
<UnConsignForm <UnConsignForm
buttons={acceptButton}
message={formMessage} message={formMessage}
id={this.getFormDataId()} id={this.getFormDataId()}
url={ApiUrls.ownership_unconsigns} url={ApiUrls.ownership_unconsigns}
@ -93,6 +115,7 @@ let AclFormFactory = React.createClass({
} else if (action === 'acl_transfer') { } else if (action === 'acl_transfer') {
return ( return (
<TransferForm <TransferForm
buttons={acceptButton}
message={formMessage} message={formMessage}
id={this.getFormDataId()} id={this.getFormDataId()}
url={ApiUrls.ownership_transfers} url={ApiUrls.ownership_transfers}
@ -101,6 +124,7 @@ let AclFormFactory = React.createClass({
} else if (action === 'acl_loan') { } else if (action === 'acl_loan') {
return ( return (
<LoanForm <LoanForm
buttons={acceptButton}
email={email} email={email}
message={formMessage} message={formMessage}
id={this.getFormDataId()} id={this.getFormDataId()}
@ -119,6 +143,7 @@ let AclFormFactory = React.createClass({
} else if (action === 'acl_share') { } else if (action === 'acl_share') {
return ( return (
<ShareForm <ShareForm
buttons={acceptButton}
message={formMessage} message={formMessage}
id={this.getFormDataId()} id={this.getFormDataId()}
url={this.isPiece() ? ApiUrls.ownership_shares_pieces url={this.isPiece() ? ApiUrls.ownership_shares_pieces

View File

@ -0,0 +1,61 @@
'use strict';
import React from 'react';
import AclButton from '../../../../ascribe_buttons/acls/acl_button';
import DeleteButton from '../../../../ascribe_buttons/delete_button';
import EmailButton from '../../../../ascribe_buttons/acls/email_button';
import { selectFromObject } from '../../../../../utils/general_utils';
import { getLangText } from '../../../../../utils/lang_utils';
let BokkAclButtonList = React.createClass({
propTypes: {
availableAcls: React.PropTypes.object.isRequired,
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),
React.PropTypes.element
]),
className: React.PropTypes.string
},
render() {
const { availableAcls,
children,
className,
currentUser,
handleSuccess,
pieceOrEditions,
whitelabel } = this.props;
const buttonProps = selectFromObject(this.props, [
'availableAcls',
'currentUser',
'handleSuccess',
'pieceOrEditions'
]);
let BokkButton = AclButton({
action: 'acl_loan',
displayName: 'LoanButton',
title: getLangText('Partager avec Bokk')
})
return (
<div className={className}>
<EmailButton {...buttonProps} />
<DeleteButton {...buttonProps} />
<BokkButton buttonAcceptName='PARTAGER AVEC BOKK' {...buttonProps} />
{children}
</div>
);
}
});
export default BokkAclButtonList;

View File

@ -0,0 +1,34 @@
'use strict';
import React from 'react';
import PieceList from '../../../../piece_list';
import BokkAclButtonList from './bokk_acl_button_list.js';
let BokkPieceList = React.createClass({
propTypes: {
// Provided from PrizeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
// Provided from router
location: React.PropTypes.object
},
render() {
return (
<PieceList
{...this.props}
redirectTo={{
pathname: '/register_piece',
query: {
'slide_num': 0
}
}}
bulkModalButtonListType={BokkAclButtonList} />
);
}
});
export default BokkPieceList;

View File

@ -20,7 +20,9 @@ import ErrorNotFoundPage from '../../../components/error_not_found_page';
import Footer from '../../../components/footer.js'; import Footer from '../../../components/footer.js';
import CCRegisterPiece from './components/cc/cc_register_piece'; import CCRegisterPiece from './components/cc/cc_register_piece';
import BokkRegisterPiece from './components/bokk/bokk_register_piece'; import BokkRegisterPiece from './components/bokk/bokk_register_piece';
import BokkPieceList from './components/bokk/bokk_piece_list';
import CylandLanding from './components/cyland/cyland_landing'; import CylandLanding from './components/cyland/cyland_landing';
import CylandPieceContainer from './components/cyland/cyland_detail/cyland_piece_container'; import CylandPieceContainer from './components/cyland/cyland_detail/cyland_piece_container';
@ -476,7 +478,7 @@ let ROUTES = {
headerTitle={getLangText('+ NEW WORK')} /> headerTitle={getLangText('+ NEW WORK')} />
<Route <Route
path='collection' path='collection'
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(PieceList)} component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(BokkPieceList)}
headerTitle={getLangText('COLLECTION')} headerTitle={getLangText('COLLECTION')}
disableOn='noPieces' /> disableOn='noPieces' />
<Route <Route