github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/app/abilities/client.js (about) 1 import AbstractAbility from './abstract'; 2 import { computed, get } from '@ember/object'; 3 import { or } from '@ember/object/computed'; 4 5 export default AbstractAbility.extend({ 6 // Map abilities to policy options (which are coarse for nodes) 7 // instead of specific behaviors. 8 canWrite: or('bypassAuthorization', 'selfTokenIsManagement', 'policiesIncludeNodeWrite'), 9 10 policiesIncludeNodeWrite: computed('token.selfTokenPolicies.[]', function() { 11 // For each policy record, extract the Node policy 12 const policies = (this.get('token.selfTokenPolicies') || []) 13 .toArray() 14 .map(policy => get(policy, 'rulesJSON.Node.Policy')) 15 .compact(); 16 17 // Node write is allowed if any policy allows it 18 return policies.some(policy => policy === 'write'); 19 }), 20 });