2020-05-11 19:43:17 +00:00
|
|
|
import AbstractAbility from './abstract';
|
2020-06-18 05:44:35 +00:00
|
|
|
import { computed } 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-06-10 13:49:16 +00:00
|
|
|
export default class Job extends AbstractAbility {
|
|
|
|
@or('bypassAuthorization', 'selfTokenIsManagement', 'policiesSupportRunning')
|
|
|
|
canRun;
|
2020-01-20 20:57:01 +00:00
|
|
|
|
2020-06-18 05:44:35 +00:00
|
|
|
@or(
|
|
|
|
'bypassAuthorization',
|
|
|
|
'selfTokenIsManagement',
|
|
|
|
'policiesSupportRunning',
|
|
|
|
'policiesSupportScaling'
|
|
|
|
)
|
|
|
|
canScale;
|
|
|
|
|
2020-11-04 23:24:34 +00:00
|
|
|
// TODO: A person can also see all jobs if their token grants read access to all namespaces,
|
|
|
|
// but given the complexity of namespaces and policy precedence, there isn't a good quick way
|
|
|
|
// to confirm this.
|
|
|
|
@or('bypassAuthorization', 'selfTokenIsManagement')
|
|
|
|
canListAll;
|
|
|
|
|
2021-12-28 16:08:12 +00:00
|
|
|
@or(
|
|
|
|
'bypassAuthorization',
|
|
|
|
'selfTokenIsManagement',
|
|
|
|
'policiesSupportDispatching'
|
|
|
|
)
|
2021-07-20 22:27:41 +00:00
|
|
|
canDispatch;
|
|
|
|
|
2021-04-29 20:00:59 +00:00
|
|
|
@computed('rulesForNamespace.@each.capabilities')
|
2020-06-10 13:49:16 +00:00
|
|
|
get policiesSupportRunning() {
|
2021-04-29 20:00:59 +00:00
|
|
|
return this.namespaceIncludesCapability('submit-job');
|
2020-06-18 05:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-04-29 20:00:59 +00:00
|
|
|
@computed('rulesForNamespace.@each.capabilities')
|
2020-06-18 05:44:35 +00:00
|
|
|
get policiesSupportScaling() {
|
2021-04-29 20:00:59 +00:00
|
|
|
return this.namespaceIncludesCapability('scale-job');
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2021-07-20 22:27:41 +00:00
|
|
|
|
|
|
|
@computed('rulesForNamespace.@each.capabilities')
|
|
|
|
get policiesSupportDispatching() {
|
|
|
|
return this.namespaceIncludesCapability('dispatch-job');
|
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|