Skip to content

Commit

Permalink
mgr/dashboard: disable delete on multisite
Browse files Browse the repository at this point in the history
Fixes: https://tracker.ceph.com/issues/59441
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
  • Loading branch information
Pegonzal committed Apr 28, 2023
1 parent 5609383 commit d7d5bff
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,26 @@
</span>
<div class="btn-group align-inline-btns"
*ngIf="node.isFocused"
[title]="title"
role="group">
<button type="button"
class="btn btn-light dropdown-toggle-split ms-1"
(click)="openModal(node, true)"
[disabled]="getDisable()"
ngbDropdownToggle>
<i [ngClass]="[icons.edit]"></i>
<div [title]="editTitle"
i18n-title>
<button type="button"
class="btn btn-light dropdown-toggle-split ms-1"
(click)="openModal(node, true)"
[disabled]="getDisable()"
ngbDropdownToggle>
<i [ngClass]="[icons.edit]"></i>
</button>
</div>
<div [title]="deleteTitle"
i18n-title>
<button type="button"
title="Delete"
class="btn btn-light ms-1"
i18n-title
[disabled]="isDeletedDisabled(node)"
(click)="delete(node)">
<i [ngClass]="[icons.destroy]"></i>
</button>
</div>
</div>
</ng-template>
</tree-root>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit {
defaultZoneId = '';
multisiteInfo: object[] = [];
defaultsInfo: string[] = [];
title: string = 'Edit';
editTitle: string = 'Edit';
deleteTitle: string = 'Delete';

constructor(
private modalService: ModalService,
Expand Down Expand Up @@ -302,16 +303,66 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit {
}
});
if (!isMasterZone) {
this.title =
this.editTitle =
'Please create a master zone for each existing zonegroup to enable this feature';
return this.messages.noMasterZone;
} else {
this.title = 'Edit';
this.editTitle = 'Edit';
return false;
}
}
}

isDeletedDisabled(node: TreeNode): boolean {
let disable: boolean = false;
let nMasterZonegroup: number = 0;
let nMasterZone: number = 0;

if (node.data.type === 'realm' && node.data.is_default && this.realms.length < 2) {
disable = true;
}

if (node.data.type === 'zonegroup') {
if (this.zonegroups.length < 2) {
disable = true;
} else if (node.data.is_master) {
for (let zonegroup of this.zonegroups) {
console.log(zonegroup);
if (zonegroup.is_master === true) {
nMasterZonegroup++;
if (nMasterZonegroup > 1) break;
}
}
if (nMasterZonegroup < 2) disable = true;
}
}

//console.log(nMasterZonegroup);
if (node.data.type === 'zone') {
if (this.zones.length < 2) {
disable = true;
} else if (node.data.is_master) {
for (let zonegroup of this.zonegroups) {
if (!_.isEmpty(zonegroup.master_zone)) {
nMasterZone++;
if (nMasterZone > 1) break;
}
}
if (nMasterZone < 2) disable = true;
}
}
// for (let zone of this.zones as Array<any>) {
// //console.log(zone);
// if (!_.isEmpty(zone.is_master)) {
// nMasterZone++;
// if (nMasterZone > 1) break;
// }
// }
// }
// }
return disable;
}

delete(node: TreeNode) {
if (node.data.type === 'realm') {
this.modalRef = this.modalService.show(CriticalConfirmationModalComponent, {
Expand Down

0 comments on commit d7d5bff

Please sign in to comment.