]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Delete account integrated
authorNaman Munet <naman.munet@ibm.com>
Wed, 8 Jan 2025 07:41:58 +0000 (13:11 +0530)
committerNaman Munet <naman.munet@ibm.com>
Wed, 22 Jan 2025 11:35:34 +0000 (17:05 +0530)
Fixes: https://tracker.ceph.com/issues/69140
Signed-off-by: Naman Munet <naman.munet@ibm.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-accounts/rgw-user-accounts.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-accounts/rgw-user-accounts.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user-accounts.service.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts

index bddb749b466a13362dd101d8f09e8aa24c05fccb..ab53cd71baad6f81d4117fe66d830570d23e33c9 100644 (file)
@@ -10,8 +10,8 @@
           [autoReload]="false"
           [data]="accounts"
           [columns]="columns"
+          selectionType="single"
           columnMode="flex"
-          selectionType="multiClick"
           [hasDetails]="true"
           (setExpandedRow)="setExpandedRow($event)"
           (updateSelection)="updateSelection($event)"
index 0ad449761c1785142bc29177877c880ae1d83a74..a41955302863fca969fefe720524ce52019622b3 100644 (file)
@@ -14,6 +14,11 @@ import { URLBuilderService } from '~/app/shared/services/url-builder.service';
 import { Icons } from '~/app/shared/enum/icons.enum';
 import { Router } from '@angular/router';
 import { ListWithDetails } from '~/app/shared/classes/list-with-details.class';
+import { CriticalConfirmationModalComponent } from '~/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
+import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
+import { Observable, Subscriber, forkJoin as observableForkJoin } from 'rxjs';
+import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
+import { FinishedTask } from '~/app/shared/models/finished-task';
 
 const BASE_URL = 'rgw/accounts';
 
@@ -36,7 +41,9 @@ export class RgwUserAccountsComponent extends ListWithDetails implements OnInit
     private authStorageService: AuthStorageService,
     public actionLabels: ActionLabelsI18n,
     private router: Router,
-    private rgwUserAccountsService: RgwUserAccountsService
+    private rgwUserAccountsService: RgwUserAccountsService,
+    private cdsModalService: ModalCdsService,
+    private taskWrapper: TaskWrapperService
   ) {
     super();
   }
@@ -110,7 +117,13 @@ export class RgwUserAccountsComponent extends ListWithDetails implements OnInit
       click: () => this.router.navigate([`${BASE_URL}/${getEditURL()}`]),
       name: this.actionLabels.EDIT
     };
-    this.tableActions = [addAction, editAction];
+    const deleteAction: CdTableAction = {
+      permission: 'delete',
+      icon: Icons.destroy,
+      click: () => this.deleteAction(),
+      name: this.actionLabels.DELETE
+    };
+    this.tableActions = [addAction, editAction, deleteAction];
   }
 
   getAccountsList(context?: CdTableFetchDataContext) {
@@ -129,4 +142,42 @@ export class RgwUserAccountsComponent extends ListWithDetails implements OnInit
   updateSelection(selection: CdTableSelection) {
     this.selection = selection;
   }
+
+  deleteAction() {
+    const account_name = this.selection.first().name;
+    this.cdsModalService.show(CriticalConfirmationModalComponent, {
+      itemDescription: $localize`Account`,
+      itemNames: [account_name],
+      submitActionObservable: () => {
+        return new Observable((observer: Subscriber<any>) => {
+          this.taskWrapper
+            .wrapTaskAroundCall({
+              task: new FinishedTask(BASE_URL, {
+                account_names: [account_name]
+              }),
+              call: observableForkJoin(
+                this.selection.selected.map((account: Account) => {
+                  return this.rgwUserAccountsService.remove(account.id);
+                })
+              )
+            })
+            .subscribe({
+              error: (error: any) => {
+                // Forward the error to the observer.
+                observer.error(error);
+                // Reload the data table content because some deletions might
+                // have been executed successfully in the meanwhile.
+                this.table.refreshBtn();
+              },
+              complete: () => {
+                // Notify the observer that we are done.
+                observer.complete();
+                // Reload the data table content.
+                this.table.refreshBtn();
+              }
+            });
+        });
+      }
+    });
+  }
 }
index af53724d47d99cc42d2b3391bb148e235c31c24d..bd407357c61204e61f2cd61d347ce888896e7188 100644 (file)
@@ -34,6 +34,10 @@ export class RgwUserAccountsService {
     return this.http.put(`${this.url}/set`, payload);
   }
 
+  remove(accountId: string) {
+    return this.http.delete(`${this.url}/${accountId}`);
+  }
+
   setQuota(
     account_id: string,
     payload: { quota_type: string; max_size: string; max_objects: string; enabled: boolean }
index cf7662eac65e95ca6c93b970f095e2ca68fcaa32..4813af4fb4f3daf1152facef8006c5b70d588f97 100644 (file)
@@ -324,6 +324,9 @@ export class TaskMessageService {
         metadata.bucket_names.length > 1 ? 'selected buckets' : metadata.bucket_names[0]
       }`;
     }),
+    'rgw/accounts': this.newTaskMessage(this.commonOperations.delete, (metadata) => {
+      return $localize`${`account '${metadata.account_names[0]}'`}`;
+    }),
     'rgw/multisite/sync-policy/delete': this.newTaskMessage(
       this.commonOperations.delete,
       (metadata) => {