1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01:00

add acl proxy component

This commit is contained in:
Tim Daubenschütz 2015-07-14 11:11:28 +02:00
parent 27c4e588ef
commit f729e3c833
2 changed files with 40 additions and 3 deletions

View File

@ -0,0 +1,31 @@
'use strict';
import React from 'react';
let AclProxy = React.createClass({
propTypes: {
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.element
]).isRequired,
aclObject: React.PropTypes.object.isRequired,
aclName: React.PropTypes.string.isRequired
},
render() {
if(this.props.aclObject[this.props.aclName]) {
return (
<div>
{this.props.children}
</div>
);
} else {
if(typeof this.props.aclObject[this.props.aclName] === 'undefined') {
console.warn('The aclName you\'re filtering for was not present (undefined) in the aclObject.');
}
return null;
}
}
});
export default AclProxy;

View File

@ -9,6 +9,8 @@ import MediaPlayer from './../ascribe_media/media_player';
import CollapsibleButton from './../ascribe_collapsible/collapsible_button';
import AclProxy from '../acl_proxy';
let MediaContainer = React.createClass({
propTypes: {
@ -49,9 +51,13 @@ let MediaContainer = React.createClass({
url={this.props.content.digital_work.url}
extraData={extraData} />
<p className="text-center">
<Button bsSize="xsmall" className="ascribe-margin-1px" href={this.props.content.digital_work.url} target="_blank">
Download <Glyphicon glyph="cloud-download"/>
</Button>
<AclProxy
aclObject={this.props.content.acl}
aclName="acl_download">
<Button bsSize="xsmall" className="ascribe-margin-1px" href={this.props.content.digital_work.url} target="_blank">
Download <Glyphicon glyph="cloud-download"/>
</Button>
</AclProxy>
{embed}
</p>
</div>