2015-06-05 15:17:35 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-06-03 10:27:11 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import UserActions from '../../actions/user_actions';
|
|
|
|
import UserStore from '../../stores/user_store';
|
|
|
|
|
|
|
|
import AclButton from '../ascribe_buttons/acl_button';
|
2015-06-11 15:03:55 +02:00
|
|
|
import DeleteButton from '../ascribe_buttons/delete_button';
|
2015-06-03 10:27:11 +02:00
|
|
|
|
|
|
|
let AclButtonList = React.createClass({
|
2015-06-05 15:17:35 +02:00
|
|
|
propTypes: {
|
2015-06-05 16:20:28 +02:00
|
|
|
className: React.PropTypes.string,
|
2015-07-13 17:09:44 +02:00
|
|
|
editions: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.object,
|
|
|
|
React.PropTypes.array
|
|
|
|
]),
|
2015-07-13 21:19:45 +02:00
|
|
|
availableAcls: React.PropTypes.object,
|
2015-07-13 17:09:44 +02:00
|
|
|
handleSuccess: React.PropTypes.func,
|
|
|
|
children: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
|
|
|
React.PropTypes.element
|
|
|
|
])
|
2015-06-03 10:27:11 +02:00
|
|
|
},
|
|
|
|
|
2015-06-05 15:17:35 +02:00
|
|
|
getInitialState() {
|
|
|
|
return UserStore.getState();
|
2015-06-03 10:27:11 +02:00
|
|
|
},
|
|
|
|
|
2015-06-03 11:49:39 +02:00
|
|
|
componentDidMount() {
|
2015-06-03 10:27:11 +02:00
|
|
|
UserStore.listen(this.onChange);
|
2015-06-03 11:49:39 +02:00
|
|
|
UserActions.fetchCurrentUser();
|
2015-06-03 10:27:11 +02:00
|
|
|
},
|
|
|
|
|
2015-06-05 15:17:35 +02:00
|
|
|
componentWillUnmount() {
|
2015-06-03 10:27:11 +02:00
|
|
|
UserStore.unlisten(this.onChange);
|
|
|
|
},
|
2015-06-03 11:49:39 +02:00
|
|
|
|
2015-06-05 15:17:35 +02:00
|
|
|
onChange(state) {
|
|
|
|
this.setState(state);
|
|
|
|
},
|
|
|
|
|
2015-06-03 10:27:11 +02:00
|
|
|
render() {
|
2015-06-03 11:49:39 +02:00
|
|
|
return (
|
2015-06-05 16:20:28 +02:00
|
|
|
<div className={this.props.className}>
|
2015-06-03 11:49:39 +02:00
|
|
|
<AclButton
|
|
|
|
availableAcls={this.props.availableAcls}
|
2015-07-13 21:19:45 +02:00
|
|
|
action="acl_transfer"
|
2015-07-10 20:00:35 +02:00
|
|
|
pieceOrEditions={this.props.editions}
|
2015-06-03 11:49:39 +02:00
|
|
|
currentUser={this.state.currentUser}
|
2015-07-01 10:53:40 +02:00
|
|
|
handleSuccess={this.props.handleSuccess}/>
|
2015-06-03 11:49:39 +02:00
|
|
|
<AclButton
|
|
|
|
availableAcls={this.props.availableAcls}
|
2015-07-13 21:19:45 +02:00
|
|
|
action="acl_consign"
|
2015-07-10 20:00:35 +02:00
|
|
|
pieceOrEditions={this.props.editions}
|
2015-06-03 11:49:39 +02:00
|
|
|
currentUser={this.state.currentUser}
|
|
|
|
handleSuccess={this.props.handleSuccess} />
|
2015-06-11 15:03:55 +02:00
|
|
|
<AclButton
|
|
|
|
availableAcls={this.props.availableAcls}
|
2015-07-13 21:19:45 +02:00
|
|
|
action="acl_unconsign"
|
2015-07-10 20:00:35 +02:00
|
|
|
pieceOrEditions={this.props.editions}
|
2015-06-11 15:03:55 +02:00
|
|
|
currentUser={this.state.currentUser}
|
|
|
|
handleSuccess={this.props.handleSuccess} />
|
2015-06-03 11:49:39 +02:00
|
|
|
<AclButton
|
|
|
|
availableAcls={this.props.availableAcls}
|
2015-07-13 21:19:45 +02:00
|
|
|
action="acl_loan"
|
2015-07-10 20:00:35 +02:00
|
|
|
pieceOrEditions={this.props.editions}
|
2015-06-03 11:49:39 +02:00
|
|
|
currentUser={this.state.currentUser}
|
|
|
|
handleSuccess={this.props.handleSuccess} />
|
|
|
|
<AclButton
|
|
|
|
availableAcls={this.props.availableAcls}
|
2015-07-13 21:19:45 +02:00
|
|
|
action="acl_share"
|
2015-07-10 20:00:35 +02:00
|
|
|
pieceOrEditions={this.props.editions}
|
2015-06-03 11:49:39 +02:00
|
|
|
currentUser={this.state.currentUser}
|
|
|
|
handleSuccess={this.props.handleSuccess} />
|
2015-07-13 14:10:46 +02:00
|
|
|
<DeleteButton
|
2015-07-14 00:56:23 +02:00
|
|
|
handleSuccess={this.props.handleSuccess}
|
2015-07-13 14:10:46 +02:00
|
|
|
editions={this.props.editions}/>
|
2015-07-13 17:09:44 +02:00
|
|
|
{this.props.children}
|
2015-06-03 11:49:39 +02:00
|
|
|
</div>
|
|
|
|
);
|
2015-06-03 10:27:11 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default AclButtonList;
|