2022-05-17 18:52:14 +00:00
|
|
|
import AbstractAbility from './abstract';
|
|
|
|
import { computed, get } from '@ember/object';
|
|
|
|
import { or } from '@ember/object/computed';
|
|
|
|
|
|
|
|
export default class extends AbstractAbility {
|
|
|
|
@or(
|
|
|
|
'bypassAuthorization',
|
|
|
|
'selfTokenIsManagement',
|
|
|
|
'policiesSupportVariableView'
|
|
|
|
)
|
|
|
|
canList;
|
|
|
|
|
2022-05-30 17:10:44 +00:00
|
|
|
@or(
|
|
|
|
'bypassAuthorization',
|
|
|
|
'selfTokenIsManagement',
|
|
|
|
'policiesSupportVariableCreation'
|
|
|
|
)
|
|
|
|
canCreate;
|
|
|
|
|
2022-05-17 18:52:14 +00:00
|
|
|
@computed('rulesForNamespace.@each.capabilities')
|
|
|
|
get policiesSupportVariableView() {
|
|
|
|
return this.rulesForNamespace.some((rules) => {
|
|
|
|
return get(rules, 'SecureVariables');
|
|
|
|
});
|
|
|
|
}
|
2022-05-30 17:10:44 +00:00
|
|
|
|
2022-06-20 20:43:01 +00:00
|
|
|
@computed('rulesForNamespace.@each.capabilities') // TODO: edit computed property to be SecureVariables.Path "DYNAMIC PATH"
|
2022-05-30 17:10:44 +00:00
|
|
|
get policiesSupportVariableCreation() {
|
2022-06-20 20:43:01 +00:00
|
|
|
return this.rulesForNamespace.some((rules) => {
|
|
|
|
const keyName = `SecureVariables.Path "*".Capabilities`; // TODO: add ability to edit path, however computed properties can't take parameters
|
|
|
|
const capabilities = get(rules, keyName) || [];
|
|
|
|
return capabilities.includes('create');
|
|
|
|
});
|
2022-05-30 17:10:44 +00:00
|
|
|
}
|
2022-05-17 18:52:14 +00:00
|
|
|
}
|