1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 17:45:10 +01:00
onion/js/components/ascribe_buttons/acl_button_list.js

84 lines
2.8 KiB
JavaScript
Raw Normal View History

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';
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-06-05 16:20:28 +02:00
availableAcls: React.PropTypes.array,
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}
action="transfer"
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}
action="consign"
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}
action="unconsign"
pieceOrEditions={this.props.editions}
currentUser={this.state.currentUser}
handleSuccess={this.props.handleSuccess} />
2015-06-03 11:49:39 +02:00
<AclButton
availableAcls={this.props.availableAcls}
action="loan"
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}
action="share"
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
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;