mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 09:35:10 +01:00
add filter function for acl actions
This commit is contained in:
parent
9b663c64b2
commit
e13649383a
@ -82,7 +82,7 @@ let PieceListBulkModal = React.createClass({
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
let selectedEditions = this.fetchSelectedEditionList();
|
let selectedEditions = this.fetchSelectedEditionList();
|
||||||
let availableAcls = getAvailableAcls(selectedEditions);
|
let availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view');
|
||||||
|
|
||||||
if(Object.keys(availableAcls).length > 0) {
|
if(Object.keys(availableAcls).length > 0) {
|
||||||
return (
|
return (
|
||||||
|
@ -6,7 +6,7 @@ function intersectAcls(a, b) {
|
|||||||
return a.filter((val) => b.indexOf(val) > -1);
|
return a.filter((val) => b.indexOf(val) > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAvailableAcls(editions) {
|
export function getAvailableAcls(editions, filterFn) {
|
||||||
let availableAcls = [];
|
let availableAcls = [];
|
||||||
if (editions.constructor !== Array){
|
if (editions.constructor !== Array){
|
||||||
return [];
|
return [];
|
||||||
@ -26,6 +26,13 @@ export function getAvailableAcls(editions) {
|
|||||||
|
|
||||||
edition.acl = sanitize(edition.acl, (val) => !val);
|
edition.acl = sanitize(edition.acl, (val) => !val);
|
||||||
edition.acl = Object.keys(edition.acl);
|
edition.acl = Object.keys(edition.acl);
|
||||||
|
|
||||||
|
// additionally, the user can specify a filter function for
|
||||||
|
// an acl array
|
||||||
|
if(typeof filterFn === 'function') {
|
||||||
|
edition.acl = edition.acl.filter(filterFn);
|
||||||
|
}
|
||||||
|
|
||||||
return edition;
|
return edition;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user