ui: Only allow partition creation with a single datacenter setup (#11817)

pull/11955/head
John Cowen 2022-01-05 14:52:06 +00:00 committed by GitHub
parent 64767b53e7
commit 31dee2340f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -48,7 +48,15 @@ as |route|>
</h1> </h1>
</BlockSlot> </BlockSlot>
<BlockSlot @name="actions"> <BlockSlot @name="actions">
<a data-test-create href="{{href-to 'dc.partitions.create'}}" class="type-create">Create</a> {{#if (can 'create partitions')}}
<a
data-test-create
class="type-create"
href="{{href-to 'dc.partitions.create'}}"
>
Create
</a>
{{/if}}
</BlockSlot> </BlockSlot>
<BlockSlot @name="toolbar"> <BlockSlot @name="toolbar">
{{#if (gt items.length 0)}} {{#if (gt items.length 0)}}

View File

@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
export default class PartitionAbility extends BaseAbility { export default class PartitionAbility extends BaseAbility {
@service('env') env; @service('env') env;
@service('repository/dc') dcs;
resource = 'operator'; resource = 'operator';
segmented = false; segmented = false;
@ -12,7 +13,16 @@ export default class PartitionAbility extends BaseAbility {
} }
get canManage() { get canManage() {
return this.canCreate; // management currently means "can I write", not necessarily just create
return this.canWrite;
}
get canCreate() {
// we can only currently create a partition if you have only one datacenter
if (this.dcs.peekAll().length > 1) {
return false;
}
return super.canCreate;
} }
get canDelete() { get canDelete() {