From f729e3c83397f1e89c283e6595b964242368cfd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 14 Jul 2015 11:11:28 +0200 Subject: [PATCH] add acl proxy component --- js/components/acl_proxy.js | 31 +++++++++++++++++++ .../ascribe_detail/media_container.js | 12 +++++-- 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 js/components/acl_proxy.js diff --git a/js/components/acl_proxy.js b/js/components/acl_proxy.js new file mode 100644 index 00000000..d348a3f7 --- /dev/null +++ b/js/components/acl_proxy.js @@ -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 ( +
+ {this.props.children} +
+ ); + } 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; \ No newline at end of file diff --git a/js/components/ascribe_detail/media_container.js b/js/components/ascribe_detail/media_container.js index 65d7b96b..c5439925 100644 --- a/js/components/ascribe_detail/media_container.js +++ b/js/components/ascribe_detail/media_container.js @@ -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} />

- + + + {embed}