INNER CODE UNIT · JavaScript
iCan
ongres/stackgres · stackgres-k8s/src/admin-ui/src/router/index.js:835
function iCan( action = 'any', kind, namespace = '' ) {
if(kind === 'sgstreams')
return true;
if(namespace.length) { // If filtered by namespace
if(namespace === 'all') {
return (store.state.permissions.allowed.namespaced.filter(n =>
(n.resources[kind].includes(action))
).length == store.state.permissions.allowed.namespaced.length
);
} else if(namespace === 'any') {
return (typeof store.state.permissions.allowed.namespaced.find(n =>
n.resources[kind].includes(action)
) !== 'undefined'
);
} else {
let permissions = store.state.permissions.allowed.namespaced.find(p => (p.namespace == namespace));