]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Bypass current selection when calling CdTableAction::disableDesc(). 35419/head
authorVolker Theile <vtheile@suse.com>
Tue, 23 Jun 2020 10:19:54 +0000 (12:19 +0200)
committerVolker Theile <vtheile@suse.com>
Wed, 24 Jun 2020 10:16:33 +0000 (12:16 +0200)
Signed-off-by: Volker Theile <vtheile@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-table-action.ts

index 9cc62f48b3da47b73eb9be412a4ecd2d9335fb23..591b0f189fd5cae01a1b02400410b4990084e27c 100644 (file)
@@ -103,7 +103,7 @@ describe('HostsComponent', () => {
     });
 
     it('should return undefined (no selection)', () => {
-      expect(component.getEditDisableDesc()).toBeUndefined();
+      expect(component.getEditDisableDesc(component.selection)).toBeUndefined();
     });
 
     it('should return undefined (managed by Orchestrator)', () => {
@@ -113,7 +113,7 @@ describe('HostsComponent', () => {
           orchestrator: true
         }
       });
-      expect(component.getEditDisableDesc()).toBeUndefined();
+      expect(component.getEditDisableDesc(component.selection)).toBeUndefined();
     });
   });
 });
index 50b04947c0d7aca4334bfad1524c4095842f9a2c..41594c1f55e7924504adb5cd137c36e031cafd19 100644 (file)
@@ -94,7 +94,7 @@ export class HostsComponent extends ListWithDetails implements OnInit {
         },
         disable: (selection: CdTableSelection) =>
           !selection.hasSingleSelection || !selection.first().sources.orchestrator,
-        disableDesc: () => this.getEditDisableDesc()
+        disableDesc: this.getEditDisableDesc.bind(this)
       },
       {
         name: this.actionLabels.DELETE,
@@ -189,12 +189,8 @@ export class HostsComponent extends ListWithDetails implements OnInit {
     });
   }
 
-  getEditDisableDesc(): string | undefined {
-    if (
-      this.selection &&
-      this.selection.hasSingleSelection &&
-      !this.selection.first().sources.orchestrator
-    ) {
+  getEditDisableDesc(selection: CdTableSelection): string | undefined {
+    if (selection && selection.hasSingleSelection && !selection.first().sources.orchestrator) {
       return this.i18n('Host editing is disabled because the host is not managed by Orchestrator.');
     }
     return undefined;
index 4f34fc574be75156c9bee44475e4624ad6061373..f494ae19f555ecc646c9ce6b3fd732d266aaf14c 100644 (file)
@@ -146,6 +146,6 @@ export class TableActionsComponent implements OnInit {
   }
 
   useDisableDesc(action: CdTableAction) {
-    return action.disableDesc && action.disableDesc();
+    return action.disableDesc && action.disableDesc(this.selection);
   }
 }
index ac8dcb61a98d05712921687d93dd8b85bf93e113..9af10625ae65bd3226dfeec3ff4cf6b5cee5660e 100644 (file)
@@ -29,7 +29,7 @@ export class CdTableAction {
    * disabled. The specified message will be shown to the user as a button
    * tooltip.
    */
-  disableDesc?: Function;
+  disableDesc?: (_: CdTableSelection) => string | undefined;
 
   /**
    * Defines if the button can become 'primary' (displayed as button and not