github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/app/abilities/job.js (about)

     1  import AbstractAbility from './abstract';
     2  import { computed } from '@ember/object';
     3  import { or } from '@ember/object/computed';
     4  
     5  export default class Job extends AbstractAbility {
     6    @or('bypassAuthorization', 'selfTokenIsManagement', 'policiesSupportRunning')
     7    canRun;
     8  
     9    @or(
    10      'bypassAuthorization',
    11      'selfTokenIsManagement',
    12      'policiesSupportRunning',
    13      'policiesSupportScaling'
    14    )
    15    canScale;
    16  
    17    // TODO: A person can also see all jobs if their token grants read access to all namespaces,
    18    // but given the complexity of namespaces and policy precedence, there isn't a good quick way
    19    // to confirm this.
    20    @or('bypassAuthorization', 'selfTokenIsManagement')
    21    canListAll;
    22  
    23    @computed('rulesForActiveNamespace.@each.capabilities')
    24    get policiesSupportRunning() {
    25      return this.activeNamespaceIncludesCapability('submit-job');
    26    }
    27  
    28    @computed('rulesForActiveNamespace.@each.capabilities')
    29    get policiesSupportScaling() {
    30      return this.activeNamespaceIncludesCapability('scale-job');
    31    }
    32  }