Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/ag-grid/src/js/src/AgGridPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (key != null && key !== '') {
export const AgGridPlugin: WidgetPlugin<dh.Widget> = {
name: '@deephaven/js-plugin-ag-grid',
type: PluginType.WIDGET_PLUGIN,
supportedTypes: ['deephaven.ag_grid.AgGrid', 'PivotTable'],
supportedTypes: ['deephaven.ag_grid.AgGrid'],
component: AgGridWidget,
icon: vsTable,
title: 'AG Grid',
Expand Down
49 changes: 26 additions & 23 deletions plugins/ag-grid/src/js/src/hooks/useWidgetFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ import { AgGridTableType } from '../types';

const log = Log.module('@deephaven/js-plugin-ag-grid/hooks/useWidgetFetch');

function isWidget(obj: unknown): obj is DhType.Widget {
return (
obj != null &&
typeof obj === 'object' &&
'exportedObjects' in obj &&
'type' in obj &&
typeof (obj as DhType.Widget).type === 'string'
);
}

const PIVOT_TABLE_WIDGET_TYPE = 'PivotTable';

export function useWidgetFetch(
dh: typeof DhType | typeof CorePlusDhType,
fetch: () => Promise<DhType.Widget>
Expand All @@ -22,35 +34,26 @@ export function useWidgetFetch(
log.debug('Fetched widget of type', widget.type);
switch (widget.type) {
case 'deephaven.ag_grid.AgGrid': {
const newTable =
(await widget.exportedObjects[0].fetch()) as DhType.Table;
let newTable = await widget.exportedObjects[0].fetch();
if (isWidget(newTable)) {
if (newTable.type !== PIVOT_TABLE_WIDGET_TYPE) {
throw new Error(
`AgGrid widget contains unsupported widget type: ${newTable.type}`
);
}
if (!isCorePlusDhType(dh)) {
throw new Error(
'PivotTable widget is only supported in Core Plus builds'
);
}
newTable = new dh.coreplus.pivot.PivotTable(newTable);
}
if (!cancelled) {
log.info('Loaded table', newTable);
setTable(newTable);
}
Comment on lines +50 to 54
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there's no server side validation, you could also end up with a Figure here technically. I think it's the only non-generic widget that would hit this. We weren't checking it before, so I'm indifferent here (there's no type field on table, figure, etc. so you have to feature detect)

break;
}
case 'PivotTable': {
if (!isCorePlusDhType(dh)) {
throw new Error(
'PivotTable widget is only supported in Core Plus builds'
);
}
if (!cancelled) {
const pivotTable = new dh.coreplus.pivot.PivotTable(widget);
setTable(pivotTable);
}
break;
}
case dh.VariableType.TABLE:
case dh.VariableType.TREETABLE:
case dh.VariableType.HIERARCHICALTABLE: {
if (!cancelled) {
log.info('Loaded table', widget);
setTable(widget as unknown as AgGridTableType);
}
break;
}
default:
throw new Error(`Unsupported widget type: ${widget.type}`);
}
Expand Down
7 changes: 5 additions & 2 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export async function gotoPage(
): Promise<void> {
await test.step(`Go to page (${url})`, async () => {
await page.goto(url, options);
// Wait for any loading progress bars to disappear
await expect(
page.getByRole('progressbar', { name: 'Loading...', exact: true })
).toHaveCount(0);
Expand Down Expand Up @@ -55,14 +56,16 @@ export async function openPanel(
awaitLoad = true
): Promise<void> {
await test.step(`Open panel (${name})`, async () => {
const panelCount = await page.locator(panelLocator).count();

// open app panels menu
const appPanels = page.getByRole('button', {
name: 'Panels',
exact: true,
});
await expect(appPanels).toBeEnabled();

// Count how many panels are open before opening a new one
const panelCount = await page.locator(panelLocator).count();

await appPanels.click();

// search for the panel in list
Expand Down
Loading