mirror of https://github.com/status-im/consul.git
ui: Don't show the CRD menu for read-only intentions (#11149)
* ui: Don't show the CRD menu for read-only intentions The UI bug here manifests itself only when a user/token is configured to have read-only access to intentions. Instead of only letting folks click to see a read only page of the intention, we would show an additional message saying that the intention was read-only due to it being 'Managed by [a kubernetes] CRD'. Whilst the intention was still read only, this extra message was still confusing for users. This PR fixes up the conditional logic and further moves the logic to use ember-can - looking at the history of the files in question, this bug snuck itself in partly due to it being 'permission-y type stuff' previous to using ember-can and when something being editable or not was nothing to do with ACLs. Then we moved to start using ember-can without completely realising what IsEditable previously meant. So overall the code here is a tiny bit clearer/cleaner by adding a proper can view CRD intention instead of overloading the idea of 'editability'.
This commit is contained in:
parent
ce21c5109b
commit
bce724baf1
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
ui: Don't show a CRD warning for read-only intentions
|
||||||
|
```
|
|
@ -4,6 +4,9 @@ export default class IntentionAbility extends BaseAbility {
|
||||||
resource = 'intention';
|
resource = 'intention';
|
||||||
|
|
||||||
get canWrite() {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ as |item index|>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
|
{{#if (or (can "write intention" item=item) (can "view CRD intention" item=item))}}
|
||||||
<BlockSlot @name="actions" as |index change checked|>
|
<BlockSlot @name="actions" as |index change checked|>
|
||||||
<PopoverMenu
|
<PopoverMenu
|
||||||
@expanded={{if (eq checked index) true false}}
|
@expanded={{if (eq checked index) true false}}
|
||||||
|
@ -113,7 +114,7 @@ as |item index|>
|
||||||
</InformedAction>
|
</InformedAction>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{{else}}
|
{{else if (can "view CRD intention" item=item)}}
|
||||||
<li role="none">
|
<li role="none">
|
||||||
<div role="menu">
|
<div role="menu">
|
||||||
<InformedAction
|
<InformedAction
|
||||||
|
@ -152,4 +153,5 @@ as |item index|>
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
</PopoverMenu>
|
</PopoverMenu>
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
|
{{/if}}
|
||||||
</TabularCollection>
|
</TabularCollection>
|
||||||
|
|
|
@ -41,9 +41,4 @@ export default class Intention extends Model {
|
||||||
);
|
);
|
||||||
return typeof meta !== 'undefined';
|
return typeof meta !== 'undefined';
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed('IsManagedByCRD')
|
|
||||||
get IsEditable() {
|
|
||||||
return !this.IsManagedByCRD;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ as |item|}}
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
<BlockSlot @name="header">
|
<BlockSlot @name="header">
|
||||||
<h1>
|
<h1>
|
||||||
{{#if item.IsEditable}}
|
{{#if (can "write intention" item=item)}}
|
||||||
{{#if item.ID}}
|
{{#if item.ID}}
|
||||||
<route.Title @title="Edit Intention" />
|
<route.Title @title="Edit Intention" />
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
Loading…
Reference in New Issue