consul/ui/packages/consul-ui/app/abilities/service.js

38 lines
991 B
JavaScript

import BaseAbility from './base';
export default class ServiceAbility extends BaseAbility {
resource = 'service';
get isLinkable() {
return this.item.InstanceCount > 0;
}
get canReadIntention() {
if (typeof this.item === 'undefined' || typeof this.item.Resources === 'undefined') {
return false;
}
const found = this.item.Resources.find(
item => item.Resource === 'intention' && item.Access === 'read' && item.Allow === true
);
return typeof found !== 'undefined';
}
get canWriteIntention() {
if (typeof this.item === 'undefined' || typeof this.item.Resources === 'undefined') {
return false;
}
const found = this.item.Resources.find(
item => item.Resource === 'intention' && item.Access === 'write' && item.Allow === true
);
return typeof found !== 'undefined';
}
get canCreateIntention() {
return this.canWriteIntention;
}
get canUpdateIntention() {
return this.canWriteIntention;
}
}