1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00
onion/js/components/acl_button.js

29 lines
839 B
JavaScript
Raw Normal View History

2015-05-27 14:35:33 +02:00
import React from 'react';
import AppConstants from '../constants/application_constants';
let AclButton = React.createClass({
propTypes: {
action: React.PropTypes.oneOf(AppConstants.aclList).isRequired,
2015-05-27 15:49:12 +02:00
availableAcls: React.PropTypes.array.isRequired,
actionFunction: React.PropTypes.func.isRequired
},
actionFunction() {
this.props.actionFunction(this.props.action);
2015-05-27 14:35:33 +02:00
},
render() {
let shouldDisplay = this.props.availableAcls.indexOf(this.props.action) > -1;
return (
<button
type="button"
2015-05-27 15:49:12 +02:00
className={shouldDisplay ? 'btn btn-default btn-sm' : 'hidden'}
onClick={this.actionFunction}>
2015-05-27 14:35:33 +02:00
{this.props.action.toUpperCase()}
</button>
);
}
});
export default AclButton;