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

This commit is contained in:
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>
</BlockSlot>
<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 @name="toolbar">
{{#if (gt items.length 0)}}

View File

@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
export default class PartitionAbility extends BaseAbility {
@service('env') env;
@service('repository/dc') dcs;
resource = 'operator';
segmented = false;
@ -12,7 +13,16 @@ export default class PartitionAbility extends BaseAbility {
}
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() {
@ -20,7 +30,7 @@ export default class PartitionAbility extends BaseAbility {
}
get canChoose() {
if(typeof this.dc === 'undefined') {
if (typeof this.dc === 'undefined') {
return false;
}
return this.canUse && this.dc.Primary;