]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Fixes rbd image 'purge trash' button & modal text
authoranurag <anurag@localhost.localdomain>
Thu, 6 Feb 2020 08:27:46 +0000 (13:57 +0530)
committeranurag <anurag@localhost.localdomain>
Wed, 26 Feb 2020 13:37:15 +0000 (19:07 +0530)
Fixes: https://tracker.ceph.com/issues/43801
Signed-off-by: anurag <abandhu@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.html

index 5710164d3185f339a1b091ddcad2bdd9ecfd84a4..b4b67710f33f3cc0e2a8d0708388fb03fac59c0e 100644 (file)
@@ -152,7 +152,7 @@ describe('RbdListComponent', () => {
       component.images = images;
       refresh({ executing_tasks: [], finished_tasks: [] });
       spyOn(rbdService, 'list').and.callFake(() =>
-        of([{ poool_name: 'rbd', status: 1, value: images }])
+        of([{ pool_name: 'rbd', status: 1, value: images }])
       );
       fixture.detectChanges();
     });
index ebf9a5266cd542010f539bb2521aa8a544b90501..8d55aea515cc81c46b22518f2d96695ca0a092d4 100644 (file)
                       [selection]="selection"
                       [tableActions]="tableActions">
     </cd-table-actions>
-
     <button class="btn btn-light"
             type="button"
             (click)="purgeModal()"
+            [disabled]="disablePurgeBtn"
             *ngIf="permission.delete">
       <i [ngClass]="[icons.destroy]"
          aria-hidden="true"></i>
index d98d338683877086ff59d12738127d845626db12..9a2a351a8c2816193c1955edda6d151c6838fe68 100644 (file)
@@ -82,7 +82,7 @@ describe('RbdTrashListComponent', () => {
       component.images = images;
       summaryService['summaryDataSource'].next({ executingTasks: [] });
       spyOn(rbdService, 'listTrash').and.callFake(() =>
-        of([{ poool_name: 'rbd', status: 1, value: images }])
+        of([{ pool_name: 'rbd', status: 1, value: images }])
       );
       fixture.detectChanges();
     });
@@ -104,7 +104,34 @@ describe('RbdTrashListComponent', () => {
   });
 
   describe('display purge button', () => {
-    beforeEach(() => {});
+    let images: any[];
+    const addImage = (id: string) => {
+      images.push({
+        id: id,
+        pool_name: 'pl',
+        deferment_end_time: 'abc'
+      });
+    };
+
+    beforeEach(() => {
+      summaryService['summaryDataSource'].next({ executingTasks: [] });
+      spyOn(rbdService, 'listTrash').and.callFake(() => {
+        of([{ pool_name: 'rbd', status: 1, value: images }]);
+      });
+      fixture.detectChanges();
+    });
+
+    it('should show button disabled when no image is in trash', () => {
+      expect(component.disablePurgeBtn).toBeTruthy();
+    });
+
+    it('should show button enabled when an existing image is in trash', () => {
+      images = [];
+      addImage('1');
+      const payload = [{ pool_name: 'rbd', status: 1, value: images }];
+      component.prepareResponse(payload);
+      expect(component.disablePurgeBtn).toBeFalsy();
+    });
 
     it('should show button with delete permission', () => {
       component.permission = {
index 90f37facd054d1f1bea5d4fac199a6ff7ac60734..ebbf28768c446b4679ec355ecc3e3728103bc8e4 100644 (file)
@@ -52,6 +52,7 @@ export class RbdTrashListComponent implements OnInit {
   selection = new CdTableSelection();
   tableActions: CdTableAction[];
   viewCacheStatusList: any[];
+  disablePurgeBtn = true;
 
   constructor(
     private authStorageService: AuthStorageService,
@@ -145,6 +146,7 @@ export class RbdTrashListComponent implements OnInit {
       }
       viewCacheStatusMap[pool.status].push(pool.pool_name);
       images = images.concat(pool.value);
+      this.disablePurgeBtn = !images.length;
     });
 
     const viewCacheStatusList: any[] = [];
index d4167175776942f013cab6e283a47390fc66886e..12be959c755b8270c00e20922df5bd9cb28bd665 100644 (file)
@@ -10,7 +10,9 @@
           novalidate>
       <div class="modal-body">
         <p>
-          <ng-container i18n>To purge, select one or All images and click</ng-container>&nbsp;
+          <ng-container i18n>To purge, select one or</ng-container>&nbsp;
+          <kbd i18n>All</kbd>&nbsp;
+          <ng-container i18n>pools and click</ng-container>&nbsp;
           <kbd i18n>Purge Trash</kbd>.&nbsp;
         </p>