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

75 lines
2.5 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-06-05 15:17:35 +02:00
editions: React.PropTypes.array,
2015-06-05 16:20:28 +02:00
availableAcls: React.PropTypes.array,
2015-06-05 15:17:35 +02:00
handleSuccess: React.PropTypes.func
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"
editions={this.props.editions}
currentUser={this.state.currentUser}
handleSuccess={this.props.handleSuccess} />
<AclButton
availableAcls={this.props.availableAcls}
action="consign"
editions={this.props.editions}
currentUser={this.state.currentUser}
handleSuccess={this.props.handleSuccess} />
<AclButton
availableAcls={this.props.availableAcls}
action="unconsign"
editions={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"
editions={this.props.editions}
currentUser={this.state.currentUser}
handleSuccess={this.props.handleSuccess} />
<AclButton
availableAcls={this.props.availableAcls}
action="share"
editions={this.props.editions}
currentUser={this.state.currentUser}
handleSuccess={this.props.handleSuccess} />
<DeleteButton editions={this.props.editions}/>
2015-06-03 11:49:39 +02:00
</div>
);
2015-06-03 10:27:11 +02:00
}
});
export default AclButtonList;