2020-05-11 19:43:17 +00:00
|
|
|
import AbstractAbility from './abstract';
|
2020-01-20 20:57:01 +00:00
|
|
|
import { computed, get } from '@ember/object';
|
2020-05-11 19:43:17 +00:00
|
|
|
import { or } from '@ember/object/computed';
|
2020-01-20 20:57:01 +00:00
|
|
|
|
2020-05-11 19:43:17 +00:00
|
|
|
export default AbstractAbility.extend({
|
2020-01-31 00:07:43 +00:00
|
|
|
canRun: or('bypassAuthorization', 'selfTokenIsManagement', 'policiesSupportRunning'),
|
2020-01-20 20:57:01 +00:00
|
|
|
|
|
|
|
policiesSupportRunning: computed('rulesForActiveNamespace.@each.capabilities', function() {
|
|
|
|
return this.rulesForActiveNamespace.some(rules => {
|
|
|
|
let capabilities = get(rules, 'Capabilities') || [];
|
|
|
|
return capabilities.includes('submit-job');
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
});
|