From 86e16eec31eed6a4e89a18c6412d4396a724bac0 Mon Sep 17 00:00:00 2001 From: Vlad Babich Date: Mon, 23 Sep 2024 11:26:32 -0600 Subject: [PATCH] fix: DH-17537: Fix Advanced Filter dialog not showing the values list on tree tables (#2232) Move `isValuesTableAvailable` getter from `IrisGridTableModel` to `IrisGridTableModelTemplate` to make it availalbe in tree table model. Fixes DH-17537 in enterprise. Note, this doesn't fix the issue with Advanced Filter on tree tables in Community. JSAPI throws an exception on a `treeTable.copy` call. ``` [AdvancedFilterCreator] Unable to open values table Error: java.lang.UnsupportedOperationException: reexport at UnsupportedOperationException_0.createError (dh-core.js:1383:10) at UnsupportedOperationException_0.initializeBackingError (dh-core.js:1409:46) at UnsupportedOperationException_0.Throwable_0 (dh-core.js:1348:8) at UnsupportedOperationException_0.Exception_1 (dh-core.js:1433:18) at UnsupportedOperationException_0.RuntimeException_1 (dh-core.js:1446:18) at new UnsupportedOperationException_0 (dh-core.js:35418:25) at Object.lambda$56 (dh-core.js:24457:14) at JsTreeTable$lambda$56$Type.fetch_25 [as fetch_1] (dh-core.js:25453:10) at Object.$lambda$32_0 (dh-core.js:31972:23) at ClientTableState$lambda$32$Type.accept_90 [as accept] (dh-core.js:32707:9) at Function.onInvoke_2 (dh-core.js:5068:12) at lambda (dh-core.js:174:22) at new Promise () at Object.$refetch_2 (dh-core.js:32098:13) at JsTreeTable.copy_1 [as copy] (dh-core.js:24514:16) at Proxy.valuesTable (IrisGridTableModelTemplate.ts:1519:32) at AdvancedFilterCreator.initValuesTable (AdvancedFilterCreator.tsx:212:13) ``` Filed an issue in Core: https://github.com/deephaven/deephaven-core/issues/6097 --- packages/iris-grid/src/IrisGridModel.test.ts | 10 +++++++ packages/iris-grid/src/IrisGridTableModel.ts | 4 --- .../src/IrisGridTableModelTemplate.ts | 4 +++ .../src/IrisGridTreeTableModel.test.ts | 27 +++++++++++++++++++ .../iris-grid/src/IrisGridTreeTableModel.ts | 2 +- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/packages/iris-grid/src/IrisGridModel.test.ts b/packages/iris-grid/src/IrisGridModel.test.ts index 34bd4bf7f1..a480324c06 100644 --- a/packages/iris-grid/src/IrisGridModel.test.ts +++ b/packages/iris-grid/src/IrisGridModel.test.ts @@ -150,6 +150,16 @@ it('updates the model correctly when adding and removing a rollup config', async expect(table.rollup).not.toHaveBeenCalled(); }); +it('isRollupAvailable checks if the rollup method is defined', async () => { + const table = irisGridTestUtils.makeTable(); + + const mock = jest.fn(); + table.rollup = mock; + const model = irisGridTestUtils.makeModel(table); + + expect(model.isRollupAvailable).toBe(true); +}); + it('closes the table correctly when the model is closed', () => { const table = irisGridTestUtils.makeTable(); table.close = jest.fn(); diff --git a/packages/iris-grid/src/IrisGridTableModel.ts b/packages/iris-grid/src/IrisGridTableModel.ts index 3719f34864..9768c2886b 100644 --- a/packages/iris-grid/src/IrisGridTableModel.ts +++ b/packages/iris-grid/src/IrisGridTableModel.ts @@ -63,10 +63,6 @@ class IrisGridTableModel return this.table.getColumnStatistics != null; } - get isValuesTableAvailable(): boolean { - return this.table.selectDistinct != null && this.table.copy != null; - } - get isRollupAvailable(): boolean { return this.table.rollup != null; } diff --git a/packages/iris-grid/src/IrisGridTableModelTemplate.ts b/packages/iris-grid/src/IrisGridTableModelTemplate.ts index 51407547f0..90c0c53ed6 100644 --- a/packages/iris-grid/src/IrisGridTableModelTemplate.ts +++ b/packages/iris-grid/src/IrisGridTableModelTemplate.ts @@ -446,6 +446,10 @@ class IrisGridTableModelTemplate< : 0; } + get isValuesTableAvailable(): boolean { + return this.table.selectDistinct != null && this.table.copy != null; + } + get isChartBuilderAvailable(): boolean { return true; } diff --git a/packages/iris-grid/src/IrisGridTreeTableModel.test.ts b/packages/iris-grid/src/IrisGridTreeTableModel.test.ts index 9228a23167..0fc72a3329 100644 --- a/packages/iris-grid/src/IrisGridTreeTableModel.test.ts +++ b/packages/iris-grid/src/IrisGridTreeTableModel.test.ts @@ -32,6 +32,23 @@ describe('IrisGridTreeTableModel virtual columns', () => { expect(model.columns).toEqual(expected); } ); + + test.each([ + ['filter', 'Filter'], + ['sort', 'Sort'], + ['formatColor', 'Color'], + ['get', 'get'], + ['getFormat', 'getFormat'], + ['formatNumber', 'formatNumber'], + ['formatDate', 'formatDate'], + ])('virtual column method %s is not implemented', (method, displayName) => { + const groupedColumns = columns.slice(0, 2); + const table = irisGridTestUtils.makeTreeTable(columns, groupedColumns); + const model = new IrisGridTreeTableModel(dh, table); + expect(() => model.columns[0][method]()).toThrow( + new Error(`${displayName} not implemented for virtual column`) + ); + }); }); describe('IrisGridTreeTableModel layoutHints', () => { @@ -78,3 +95,13 @@ describe('IrisGridTreeTableModel layoutHints', () => { expect(model.layoutHints).toEqual(undefined); }); }); + +describe('IrisGridTreeTableModel values table', () => { + it('is available for tree tables', () => { + const columns = irisGridTestUtils.makeColumns(); + const table = irisGridTestUtils.makeTreeTable(columns, columns, 100, []); + const model = new IrisGridTreeTableModel(dh, table); + + expect(model.isValuesTableAvailable).toBe(true); + }); +}); diff --git a/packages/iris-grid/src/IrisGridTreeTableModel.ts b/packages/iris-grid/src/IrisGridTreeTableModel.ts index eb2c00b5e8..4323591966 100644 --- a/packages/iris-grid/src/IrisGridTreeTableModel.ts +++ b/packages/iris-grid/src/IrisGridTreeTableModel.ts @@ -30,7 +30,7 @@ const VirtualGroupColumn = Object.freeze({ throw new Error('Filter not implemented for virtual column'); }, sort: () => { - throw new Error('Sort not implemented virtual column'); + throw new Error('Sort not implemented for virtual column'); }, formatColor: () => { throw new Error('Color not implemented for virtual column');