]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Fixes rbd image 'purge trash' button & modal text 33697/head
authoranurag <anurag@localhost.localdomain>
Thu, 6 Feb 2020 08:27:46 +0000 (13:57 +0530)
committeranurag <anurag@localhost.localdomain>
Tue, 3 Mar 2020 14:17:16 +0000 (19:47 +0530)
Fixes: https://tracker.ceph.com/issues/43801
Signed-off-by: anurag <abandhu@redhat.com>
(cherry picked from commit 803a0e2599f76a0a5894ba857bdeb57b6641a5ad)

Conflicts:
        src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.html
- nautilus uses button class="btn btn-sm btn-default btn-label" instead of class="btn btn-light"

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 9244b91cba7ac9dd22bf931be49eb04f6c133172..4b80c3b9b85717573139de7cda0b585afc2941f8 100644 (file)
@@ -146,7 +146,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 dd72e6623d24e3643a197033101026a3026ff99e..6ad31a2c3255a57218d756f653dce03da039bd81 100644 (file)
@@ -19,6 +19,7 @@
     <button class="btn btn-sm btn-default btn-label"
             type="button"
             (click)="purgeModal()"
+            [disabled]="disablePurgeBtn"
             *ngIf="permission.delete">
       <i class="fa fa-fw fa-times"
          aria-hidden="true"></i>
index dc84eaffdc5ac5b768bfc2f6c3703063ee66c670..98bf7662fdeb95ffd50d764470764cabcdac4d08 100644 (file)
@@ -85,7 +85,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();
     });
@@ -105,7 +105,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 62f8b2b3dce12bc76381b86e014812c21300cd95..85571492c8234fee1d69a170386a18ba1a03805a 100644 (file)
@@ -47,6 +47,7 @@ export class RbdTrashListComponent implements OnInit {
   selection = new CdTableSelection();
   tableActions: CdTableAction[];
   viewCacheStatusList: any[];
+  disablePurgeBtn = true;
 
   constructor(
     private authStorageService: AuthStorageService,
@@ -127,6 +128,7 @@ export class RbdTrashListComponent implements OnInit {
       }
       viewCacheStatusMap[pool.status].push(pool.pool_name);
       images = images.concat(pool.value);
+      this.disablePurgeBtn = !images.length;
     });
 
     const viewCacheStatusList = [];
index a7b489bb0810e2f0cbd70a0efc2902259296fb66..42a2a460c79bc4464a185e4d268ee43bfadf0c88 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>