1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 18:13:49 +01:00
onion/js/components/ascribe_buttons/acl_button_list.js

81 lines
2.7 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';
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
]),
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}
action="acl_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="acl_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="acl_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="acl_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="acl_share"
pieceOrEditions={this.props.editions}
2015-06-03 11:49:39 +02:00
currentUser={this.state.currentUser}
handleSuccess={this.props.handleSuccess} />
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;