From: Nizamudeen A Date: Fri, 8 Jan 2021 07:37:27 +0000 (+0530) Subject: mgr/dashboard: Fix for datatable item not showing details after getting selected X-Git-Tag: v14.2.17~77^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F38813%2Fhead;p=ceph.git mgr/dashboard: Fix for datatable item not showing details after getting selected **Regression in nautilus** Datatable items are not showing the details even if an item in the list is selected. This is happening because of this backport (https://github.com/ceph/ceph/pull/37756/files) which backports the line this.selection.selected = $event['selected']; but this feature was not implemented in the nautilus branch originally. Fixes: https://tracker.ceph.com/issues/48796 Signed-off-by: Nizamudeen A --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts index 40f85b7d61ecd..682a9386fc693 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts @@ -295,6 +295,21 @@ describe('TableComponent', () => { }); }); + describe('select row', () => { + beforeEach(() => { + component.ngOnInit(); + component.data = []; + }); + + it('should select the row item', () => { + spyOn(component, 'onSelect').and.callThrough(); + component.data = createFakeData(3); + component.selection.selected = [_.clone(component.data[1])]; + component.onSelect(new Event('click')); + expect(component.selection.hasSelection).toBeTruthy(); + }); + }); + describe('reload data', () => { beforeEach(() => { component.ngOnInit(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts index 57fa7aad76801..b3e5eb41a56a7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts @@ -460,6 +460,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O if (_.has($event, 'selected')) { this.selection.selected = $event['selected']; } + this.selection.update(); this.updateSelection.emit(_.clone(this.selection)); }