diff --git a/.changelog/11149.txt b/.changelog/11149.txt new file mode 100644 index 000000000..b028e0ac7 --- /dev/null +++ b/.changelog/11149.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Don't show a CRD warning for read-only intentions +``` diff --git a/ui/packages/consul-ui/app/abilities/intention.js b/ui/packages/consul-ui/app/abilities/intention.js index 35551e670..91f3a013b 100644 --- a/ui/packages/consul-ui/app/abilities/intention.js +++ b/ui/packages/consul-ui/app/abilities/intention.js @@ -4,6 +4,9 @@ export default class IntentionAbility extends BaseAbility { resource = 'intention'; get canWrite() { - return super.canWrite && (typeof this.item === 'undefined' || this.item.IsEditable); + return super.canWrite && (typeof this.item === 'undefined' || !this.canViewCRD); + } + get canViewCRD() { + return (typeof this.item !== 'undefined' && this.item.IsManagedByCRD); } } diff --git a/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs b/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs index 35e2bd39a..25044226e 100644 --- a/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs @@ -65,6 +65,7 @@ as |item index|> {{/if}} +{{#if (or (can "write intention" item=item) (can "view CRD intention" item=item))}} - {{else}} + {{else if (can "view CRD intention" item=item)}}
  • +{{/if}} diff --git a/ui/packages/consul-ui/app/models/intention.js b/ui/packages/consul-ui/app/models/intention.js index a0c8544f1..4f19696d2 100644 --- a/ui/packages/consul-ui/app/models/intention.js +++ b/ui/packages/consul-ui/app/models/intention.js @@ -41,9 +41,4 @@ export default class Intention extends Model { ); return typeof meta !== 'undefined'; } - - @computed('IsManagedByCRD') - get IsEditable() { - return !this.IsManagedByCRD; - } } diff --git a/ui/packages/consul-ui/app/templates/dc/intentions/edit.hbs b/ui/packages/consul-ui/app/templates/dc/intentions/edit.hbs index f933c7c25..56d54c379 100644 --- a/ui/packages/consul-ui/app/templates/dc/intentions/edit.hbs +++ b/ui/packages/consul-ui/app/templates/dc/intentions/edit.hbs @@ -31,7 +31,7 @@ as |item|}}

    - {{#if item.IsEditable}} + {{#if (can "write intention" item=item)}} {{#if item.ID}} {{else}}