Skip to content

Commit b6fef7f

Browse files
committed
feat: DH-18836 Add support for linker to UITable
1 parent 638f375 commit b6fef7f

2 files changed

Lines changed: 35 additions & 11 deletions

File tree

plugins/ui/src/js/src/elements/UITable/UITable.tsx

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ import {
2727
useTheme,
2828
viewStyleProps,
2929
} from '@deephaven/components';
30-
import { useDashboardColumnFilters } from '@deephaven/dashboard-core-plugins';
30+
import {
31+
useDashboardColumnFilters,
32+
useGridLinker,
33+
} from '@deephaven/dashboard-core-plugins';
3134
import { useApi } from '@deephaven/jsapi-bootstrap';
3235
import type { dh as DhType } from '@deephaven/jsapi-types';
3336
import Log from '@deephaven/log';
@@ -286,6 +289,14 @@ export function UITable({
286289
model.setColorMap(colorMap);
287290
}
288291

292+
const {
293+
alwaysFetchColumns: linkerAlwaysFetchColumns,
294+
columnSelectionValidator,
295+
isSelectingColumn,
296+
onColumnSelected,
297+
onDataSelected,
298+
} = useGridLinker(model, irisGrid);
299+
289300
const [dehydratedState, setDehydratedState] = usePersistentState<
290301
(DehydratedIrisGridState & DehydratedGridState) | undefined
291302
>(undefined, { type: 'UITable', version: 1 });
@@ -370,8 +381,12 @@ export function UITable({
370381
}, [format, columns]);
371382

372383
const alwaysFetchColumnsArray = useMemo(
373-
() => [...ensureArray(alwaysFetchColumnsProp), ...formatColumnSources],
374-
[alwaysFetchColumnsProp, formatColumnSources]
384+
() => [
385+
...ensureArray(alwaysFetchColumnsProp),
386+
...formatColumnSources,
387+
...linkerAlwaysFetchColumns,
388+
],
389+
[alwaysFetchColumnsProp, formatColumnSources, linkerAlwaysFetchColumns]
375390
);
376391

377392
const alwaysFetchColumns = useMemo(() => {
@@ -389,10 +404,15 @@ export function UITable({
389404
if (alwaysFetchColumnsArray[0] === false) {
390405
return [];
391406
}
392-
return alwaysFetchColumnsArray.filter(
393-
// This v is string can be removed when we're on a newer TS version. 5.7 infers this properly at least
394-
(v): v is string => typeof v === 'string'
395-
);
407+
return [
408+
// Deduplicate the alwaysFetchColumnsArray
409+
...new Set(
410+
alwaysFetchColumnsArray.filter(
411+
// This v is string can be removed when we're on a newer TS version. 5.7 infers this properly at least
412+
(v): v is string => typeof v === 'string'
413+
)
414+
),
415+
];
396416
}, [alwaysFetchColumnsArray, columns, throwError]);
397417

398418
const mouseHandlers = useMemo(
@@ -529,7 +549,7 @@ export function UITable({
529549
}, [irisGridServerProps, initialHydratedState]);
530550

531551
const inputFilters = useDashboardColumnFilters(
532-
model?.columns ?? EMPTY_ARRAY,
552+
model?.columns ?? null,
533553
model?.table
534554
);
535555

@@ -543,6 +563,10 @@ export function UITable({
543563
ref={ref => setIrisGrid(ref)}
544564
model={model}
545565
onStateChange={onStateChange}
566+
columnSelectionValidator={columnSelectionValidator}
567+
isSelectingColumn={isSelectingColumn}
568+
onColumnSelected={onColumnSelected}
569+
onDataSelected={onDataSelected}
546570
// eslint-disable-next-line react/jsx-props-no-spreading
547571
{...mergedIrisGridProps}
548572
inputFilters={inputFilters}

plugins/ui/src/js/src/layout/ReactPanel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { nanoid } from 'nanoid';
1010
import {
1111
LayoutUtils,
1212
PanelEvent,
13-
DhIdContext,
13+
PanelIdContext,
1414
useLayoutManager,
1515
useListener,
1616
} from '@deephaven/dashboard';
@@ -219,7 +219,7 @@ function ReactPanel({
219219
return portal
220220
? ReactDOM.createPortal(
221221
<ReactPanelContext.Provider value={panelId}>
222-
<DhIdContext.Provider value={panelId}>
222+
<PanelIdContext.Provider value={panelId}>
223223
<View
224224
height="100%"
225225
width="100%"
@@ -264,7 +264,7 @@ function ReactPanel({
264264
</ReactPanelErrorBoundary>
265265
</Flex>
266266
</View>
267-
</DhIdContext.Provider>
267+
</PanelIdContext.Provider>
268268
</ReactPanelContext.Provider>,
269269
portal,
270270
contentKey

0 commit comments

Comments
 (0)