2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2020-05-11 19:43:17 +00:00
|
|
|
import AbstractAbility from './abstract';
|
|
|
|
import { computed, get } from '@ember/object';
|
|
|
|
import { or } from '@ember/object/computed';
|
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
export default class Allocation extends AbstractAbility {
|
|
|
|
@or('bypassAuthorization', 'selfTokenIsManagement', 'policiesSupportExec')
|
|
|
|
canExec;
|
2020-05-11 19:43:17 +00:00
|
|
|
|
2021-04-29 20:00:59 +00:00
|
|
|
@computed('rulesForNamespace.@each.capabilities')
|
2020-06-10 13:49:16 +00:00
|
|
|
get policiesSupportExec() {
|
2021-12-28 14:45:20 +00:00
|
|
|
return this.rulesForNamespace.some((rules) => {
|
2020-05-11 19:43:17 +00:00
|
|
|
let capabilities = get(rules, 'Capabilities') || [];
|
|
|
|
return capabilities.includes('alloc-exec');
|
|
|
|
});
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|