open-nomad/ui/app/abilities/agent.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
639 B
JavaScript
Raw Normal View History

2020-06-16 01:37:03 +00:00
import AbstractAbility from './abstract';
import { computed, get } from '@ember/object';
import { or } from '@ember/object/computed';
export default class Client extends AbstractAbility {
2021-12-28 16:08:12 +00:00
@or(
'bypassAuthorization',
'selfTokenIsManagement',
'policiesIncludeAgentReadOrWrite'
)
2020-06-16 01:37:03 +00:00
canRead;
@computed('token.selfTokenPolicies.[]')
get policiesIncludeAgentReadOrWrite() {
2020-06-17 21:56:16 +00:00
const policies = (get(this, 'token.selfTokenPolicies') || [])
2020-06-16 01:37:03 +00:00
.toArray()
2021-12-28 14:45:20 +00:00
.map((policy) => get(policy, 'rulesJSON.Agent.Policy'))
2020-06-16 01:37:03 +00:00
.compact();
2021-12-28 14:45:20 +00:00
return policies.some((policy) => policy === 'read' || policy === 'write');
2020-06-16 01:37:03 +00:00
}
}