@malloy-publisher/sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -9
- package/dist/DocumentStorageProvider-CyOJ0hqf.es.js +24443 -0
- package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
- package/dist/RenderedResult-BnPzJ9Jf.es.js +549 -0
- package/dist/RenderedResult-Dp22kZsQ.cjs.js +115 -0
- package/dist/{ServerProvider-DSK9rfSY.es.js → ServerProvider-BWOEKg0O.es.js} +1256 -1318
- package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
- package/dist/builder/index.cjs.js +105 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/index.es.js +9482 -0
- package/dist/builder-entry.d.ts +8 -0
- package/dist/client/api.d.ts +100 -42
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +30 -0
- package/dist/components/BackLink.d.ts +32 -0
- package/dist/components/Dashboard/Dashboard.d.ts +19 -14
- package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
- package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
- package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
- package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
- package/dist/components/Dashboard/TileCard.d.ts +44 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +7 -3
- package/dist/components/Dashboard/telemetry.d.ts +48 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +31 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +118 -0
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +30 -0
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
- package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
- package/dist/components/DashboardBuilder/controls.d.ts +157 -0
- package/dist/components/DashboardBuilder/diff.d.ts +35 -0
- package/dist/components/DashboardBuilder/document.d.ts +218 -0
- package/dist/components/DashboardBuilder/layout.d.ts +71 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
- package/dist/components/DashboardBuilder/preview.d.ts +60 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +53 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
- package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +7 -0
- package/dist/components/DocumentStorage/index.d.ts +1 -1
- package/dist/components/FloatingIconButton.d.ts +16 -0
- package/dist/components/ItemRow.d.ts +38 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
- package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
- package/dist/components/Materializations/Materializations.d.ts +7 -3
- package/dist/components/Materializations/ScopeButton.d.ts +18 -0
- package/dist/components/Materializations/SectionLabel.d.ts +7 -4
- package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
- package/dist/components/Materializations/index.d.ts +0 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
- package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
- package/dist/components/Package/index.d.ts +0 -1
- package/dist/components/PackageSection.d.ts +23 -0
- package/dist/components/Prose.d.ts +46 -0
- package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
- package/dist/components/RenderedResult/index.d.ts +1 -0
- package/dist/components/buttons.d.ts +53 -0
- package/dist/components/drill/index.d.ts +1 -1
- package/dist/components/drill/resolveDrill.d.ts +22 -0
- package/dist/components/drill/useDrill.d.ts +11 -2
- package/dist/components/index.d.ts +6 -0
- package/dist/components/styles.d.ts +49 -44
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useCrudMutation.d.ts +42 -0
- package/dist/hooks/useDocumentControls.d.ts +70 -0
- package/dist/hooks/useQueryResult.d.ts +40 -0
- package/dist/index.cjs.js +22 -273
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +16888 -44451
- package/dist/telemetry/consoleEvents.d.ts +60 -0
- package/dist/utils/malloyLiteral.d.ts +11 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/package.json +24 -9
- package/src/builder-entry.ts +55 -0
- package/src/components/AppDialog.tsx +115 -0
- package/src/components/BackLink.tsx +83 -0
- package/src/components/Connections/AddConnectionDialog.tsx +50 -70
- package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
- package/src/components/Connections/EditConnectionDialog.tsx +54 -73
- package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
- package/src/components/Dashboard/Dashboard.tsx +165 -175
- package/src/components/Dashboard/DashboardBar.tsx +88 -0
- package/src/components/Dashboard/DashboardGrid.tsx +124 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
- package/src/components/Dashboard/DashboardTile.tsx +66 -123
- package/src/components/Dashboard/ExploreDialog.tsx +84 -0
- package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
- package/src/components/Dashboard/RowsDialog.tsx +234 -0
- package/src/components/Dashboard/TileCard.tsx +120 -0
- package/src/components/Dashboard/index.ts +2 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +70 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +33 -2
- package/src/components/Dashboard/telemetry.ts +51 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +247 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +852 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +666 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +188 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +567 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +122 -0
- package/src/components/DashboardBuilder/DrillDialog.tsx +269 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +562 -0
- package/src/components/DashboardBuilder/FilterStrip.tsx +126 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
- package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
- package/src/components/DashboardBuilder/catalog.ts +225 -0
- package/src/components/DashboardBuilder/controls.spec.ts +243 -0
- package/src/components/DashboardBuilder/controls.ts +398 -0
- package/src/components/DashboardBuilder/diff.spec.ts +44 -0
- package/src/components/DashboardBuilder/diff.ts +93 -0
- package/src/components/DashboardBuilder/document.ts +209 -0
- package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
- package/src/components/DashboardBuilder/layout.ts +143 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
- package/src/components/DashboardBuilder/malloyText.ts +151 -0
- package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
- package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
- package/src/components/DashboardBuilder/newDashboard.ts +48 -0
- package/src/components/DashboardBuilder/preview.spec.ts +149 -0
- package/src/components/DashboardBuilder/preview.ts +172 -0
- package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
- package/src/components/DashboardBuilder/readDocument.ts +467 -0
- package/src/components/DashboardBuilder/sortable.tsx +151 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +1161 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +1135 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +311 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +201 -0
- package/src/components/DashboardBuilder/useDraft.ts +43 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
- package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
- package/src/components/DashboardBuilder/useTileResize.ts +110 -0
- package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +12 -0
- package/src/components/DocumentStorage/index.ts +1 -0
- package/src/components/Environment/About.tsx +16 -62
- package/src/components/Environment/AddPackageDialog.tsx +85 -154
- package/src/components/Environment/Connections.tsx +125 -205
- package/src/components/Environment/DeletePackageDialog.tsx +32 -77
- package/src/components/Environment/EditPackageDialog.tsx +46 -58
- package/src/components/Environment/Environment.tsx +34 -36
- package/src/components/Environment/Packages.tsx +63 -128
- package/src/components/FloatingIconButton.tsx +41 -0
- package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
- package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
- package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
- package/src/components/Home/Home.tsx +101 -214
- package/src/components/ItemRow.tsx +165 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
- package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
- package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
- package/src/components/Materializations/Materializations.tsx +137 -140
- package/src/components/Materializations/ScopeButton.tsx +85 -0
- package/src/components/Materializations/SectionLabel.tsx +7 -4
- package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
- package/src/components/Materializations/TriggerLabel.tsx +36 -0
- package/src/components/Materializations/cron.spec.ts +113 -0
- package/src/components/Materializations/index.ts +0 -1
- package/src/components/Materializations/utils.spec.ts +182 -0
- package/src/components/Model/Model.tsx +6 -23
- package/src/components/Model/ModelCell.tsx +33 -72
- package/src/components/Notebook/Notebook.tsx +25 -88
- package/src/components/Notebook/NotebookCell.tsx +35 -183
- package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
- package/src/components/Package/ContentTypeIcon.tsx +10 -12
- package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
- package/src/components/Package/NewDashboardDialog.tsx +265 -0
- package/src/components/Package/Package.tsx +179 -238
- package/src/components/Package/index.ts +0 -1
- package/src/components/PackageSection.tsx +85 -0
- package/src/components/Prose.spec.tsx +85 -0
- package/src/components/Prose.tsx +179 -0
- package/src/components/QueryResult/QueryResult.tsx +15 -43
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
- package/src/components/RenderedResult/RenderedResult.tsx +22 -8
- package/src/components/RenderedResult/ResultContainer.tsx +4 -12
- package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
- package/src/components/RenderedResult/ResultPanel.tsx +73 -0
- package/src/components/RenderedResult/index.ts +1 -0
- package/src/components/ResultsDialog.tsx +8 -32
- package/src/components/buttons.tsx +114 -0
- package/src/components/designSystem.spec.tsx +316 -0
- package/src/components/drill/index.ts +1 -0
- package/src/components/drill/resolveDrill.ts +22 -1
- package/src/components/drill/useDrill.spec.tsx +94 -0
- package/src/components/drill/useDrill.tsx +52 -12
- package/src/components/given/GivensPanel.tsx +1 -1
- package/src/components/given/paramCodec.spec.ts +1 -1
- package/src/components/index.ts +16 -0
- package/src/components/styles.ts +49 -122
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useCrudMutation.spec.tsx +119 -0
- package/src/hooks/useCrudMutation.tsx +85 -0
- package/src/hooks/useDocumentControls.ts +170 -0
- package/src/hooks/useQueryResult.ts +82 -0
- package/src/index.ts +9 -0
- package/src/telemetry/consoleEvents.spec.ts +130 -0
- package/src/telemetry/consoleEvents.ts +124 -0
- package/src/theme/defaults.ts +34 -23
- package/src/theme/resolveTheme.spec.ts +9 -4
- package/src/theme/resolveTheme.ts +12 -8
- package/src/utils/malloyLiteral.spec.ts +43 -0
- package/src/utils/malloyLiteral.ts +76 -0
- package/src/utils/sha256.ts +13 -0
- package/test/README.md +1 -1
- package/test/serverProvider.tsx +5 -2
- package/vite.config.ts +5 -0
- package/dist/ServerProvider-CGnLjzag.cjs.js +0 -1
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
- package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
- package/dist/components/Materializations/TriggerChip.d.ts +0 -10
- package/dist/components/Package/Models.d.ts +0 -6
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
- package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
- package/src/components/Materializations/ScheduleCard.tsx +0 -231
- package/src/components/Materializations/TriggerChip.tsx +0 -44
- package/src/components/Package/Models.tsx +0 -71
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* prop alone.
|
|
10
10
|
*/
|
|
11
11
|
import { beforeEach, expect, it, mock } from "bun:test";
|
|
12
|
-
import { render, waitFor } from "@testing-library/react";
|
|
12
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
13
13
|
import {
|
|
14
14
|
cacheKeys,
|
|
15
15
|
clearCache,
|
|
@@ -54,7 +54,7 @@ it("puts the version in the request body and in the key", async () => {
|
|
|
54
54
|
|
|
55
55
|
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
56
56
|
expect(executeQueryModel.mock.calls[0][3].versionId).toBe("v2");
|
|
57
|
-
expect(cacheKeys("
|
|
57
|
+
expect(cacheKeys("queryResult")[0]).toContain('"v2"');
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
it("sends and keys nothing extra without one", async () => {
|
|
@@ -64,9 +64,9 @@ it("sends and keys nothing extra without one", async () => {
|
|
|
64
64
|
expect(executeQueryModel.mock.calls[0][3].versionId).toBeUndefined();
|
|
65
65
|
// The whole key: an empty slot rather than a literal "undefined", and
|
|
66
66
|
// nothing else disturbed. The narrow assertion above cannot see either.
|
|
67
|
-
expect(cacheKeys("
|
|
68
|
-
'["
|
|
69
|
-
'"sales_by_month","{}","http://localhost/api/v0"]',
|
|
67
|
+
expect(cacheKeys("queryResult")[0]).toBe(
|
|
68
|
+
'["queryResult","env","pkg",null,"dashboards/ops.malloy",null,' +
|
|
69
|
+
'"run: sales_by_month",null,"{}","http://localhost/api/v0"]',
|
|
70
70
|
);
|
|
71
71
|
});
|
|
72
72
|
|
|
@@ -77,5 +77,29 @@ it("keeps two versions of one tile apart", async () => {
|
|
|
77
77
|
rerender(tileAt("v2"));
|
|
78
78
|
|
|
79
79
|
await waitFor(() => expect(executeQueryModel).toHaveBeenCalledTimes(2));
|
|
80
|
-
expect(new Set(cacheKeys("
|
|
80
|
+
expect(new Set(cacheKeys("queryResult")).size).toBe(2);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("offers to explore from the tile when the host can take it somewhere", () => {
|
|
84
|
+
const onExplore = mock(() => {});
|
|
85
|
+
render(
|
|
86
|
+
<DashboardTile
|
|
87
|
+
environmentName="env"
|
|
88
|
+
packageName="pkg"
|
|
89
|
+
modelPath="dashboards/ops.malloy"
|
|
90
|
+
tile="overview -> sales_by_month"
|
|
91
|
+
givens={new Map()}
|
|
92
|
+
declaredTypes={new Map()}
|
|
93
|
+
height={400}
|
|
94
|
+
onExplore={onExplore}
|
|
95
|
+
/>,
|
|
96
|
+
{ wrapper: serverWrapper },
|
|
97
|
+
);
|
|
98
|
+
fireEvent.click(screen.getByLabelText("Explore Sales by month"));
|
|
99
|
+
expect(onExplore).toHaveBeenCalledTimes(1);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("has no explore button when the host offers nowhere to go", () => {
|
|
103
|
+
render(tileAt(), { wrapper: serverWrapper });
|
|
104
|
+
expect(screen.queryByLabelText(/^Explore /)).toBeNull();
|
|
81
105
|
});
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { DASHBOARD_CARD_PADDING_PX } from "../../theme/buildTableCssVars";
|
|
4
|
+
import ExploreOutlinedIcon from "@mui/icons-material/ExploreOutlined";
|
|
5
|
+
import { IconButton, Tooltip } from "@mui/material";
|
|
7
6
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
8
|
-
import {
|
|
7
|
+
import { useQueryResult } from "../../hooks/useQueryResult";
|
|
9
8
|
import type { GivenValue } from "../../hooks/givenValue";
|
|
10
|
-
import { CHART_RESULT_QUERY_OPTIONS } from "../../utils/queryClient";
|
|
11
|
-
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
12
9
|
import { humanizeSlug, type DrillBinding } from "../drill";
|
|
13
10
|
import { givensToRequest } from "../given/paramCodec";
|
|
14
|
-
import {
|
|
15
|
-
import ResultContainer from "../RenderedResult/ResultContainer";
|
|
16
|
-
import { useServer } from "../ServerProvider";
|
|
11
|
+
import { ResultPanel } from "../RenderedResult/ResultPanel";
|
|
17
12
|
import { promoteMeasureRowToKpis } from "./promoteMeasureRow";
|
|
13
|
+
import { TileCard, TileHeading } from "./TileCard";
|
|
18
14
|
|
|
19
15
|
export interface DashboardTileProps {
|
|
20
16
|
environmentName: string;
|
|
@@ -51,6 +47,11 @@ export interface DashboardTileProps {
|
|
|
51
47
|
maxResultSize?: number;
|
|
52
48
|
/** Cell clicks and their affordance, for the dashboard's `# drill`. */
|
|
53
49
|
drill?: DrillBinding;
|
|
50
|
+
/**
|
|
51
|
+
* Open this tile's query somewhere it can be changed. Shown as a button in
|
|
52
|
+
* the heading, on hover; absent, the heading has no button.
|
|
53
|
+
*/
|
|
54
|
+
onExplore?: () => void;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -93,130 +94,72 @@ export function DashboardTile({
|
|
|
93
94
|
height,
|
|
94
95
|
maxResultSize,
|
|
95
96
|
drill,
|
|
97
|
+
onExplore,
|
|
96
98
|
}: DashboardTileProps) {
|
|
97
|
-
const { apiClients } = useServer();
|
|
98
99
|
const { theme } = usePublisherTheme();
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
queryName,
|
|
109
|
-
tile,
|
|
110
|
-
// Re-runs when the applied values change, which is the whole point of
|
|
111
|
-
// the control row.
|
|
112
|
-
JSON.stringify(requestGivens),
|
|
113
|
-
],
|
|
114
|
-
queryFn: () =>
|
|
115
|
-
apiClients.models.executeQueryModel(
|
|
116
|
-
environmentName,
|
|
117
|
-
packageName,
|
|
118
|
-
modelPath,
|
|
119
|
-
{
|
|
120
|
-
queryName,
|
|
121
|
-
query: tile !== undefined ? `run: ${tile}` : undefined,
|
|
122
|
-
givens: requestGivens,
|
|
123
|
-
versionId,
|
|
124
|
-
},
|
|
125
|
-
),
|
|
126
|
-
...CHART_RESULT_QUERY_OPTIONS,
|
|
100
|
+
const state = useQueryResult({
|
|
101
|
+
environmentName,
|
|
102
|
+
packageName,
|
|
103
|
+
modelPath,
|
|
104
|
+
versionId,
|
|
105
|
+
queryName,
|
|
106
|
+
query: tile !== undefined ? `run: ${tile}` : undefined,
|
|
107
|
+
// Narrowed to the givens this tile references: see `givenNames`.
|
|
108
|
+
givens: givensToRequest(givens, declaredTypes, givenNames),
|
|
127
109
|
});
|
|
128
110
|
|
|
129
|
-
// A composite tile that is one row of measures draws as KPI cards, the way
|
|
130
|
-
// Malloyyo splices the same tile into its grid, rather than as a one-row
|
|
131
|
-
// table. Composite only: the single-query form is one result the renderer
|
|
132
|
-
// lays out from the query's own tags, and its aggregates are already tiles.
|
|
133
|
-
// Memoized on the result string so a large result is not re-parsed on every
|
|
134
|
-
// render of the tile around it.
|
|
135
|
-
const result = useMemo(() => {
|
|
136
|
-
const raw = data?.data.result;
|
|
137
|
-
if (raw === undefined || tile === undefined) return raw;
|
|
138
|
-
return promoteMeasureRowToKpis(raw);
|
|
139
|
-
}, [data, tile]);
|
|
140
|
-
|
|
141
111
|
return (
|
|
142
|
-
<
|
|
143
|
-
|
|
112
|
+
<TileCard
|
|
113
|
+
borderless={borderless}
|
|
144
114
|
sx={{
|
|
145
|
-
// The
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// both forms.
|
|
155
|
-
//
|
|
156
|
-
// The background is `theme.tile`, the same value the renderer card
|
|
157
|
-
// paints, and NOT MUI's Paper default. Leaving it unset was the last
|
|
158
|
-
// piece of the two cards' geometry that did not agree: measured on
|
|
159
|
-
// the `grid`/`tiled` fixture pair, the renderer card came out
|
|
160
|
-
// `#f5fafc` from the theme and this one plain white, so on a theme
|
|
161
|
-
// whose page is also white the composite tiles lost the tint that
|
|
162
|
-
// separates a card from the page while the single-query form kept
|
|
163
|
-
// it. Radius, padding, border, shadow and gap already matched.
|
|
164
|
-
border: borderless ? "none" : theme.border,
|
|
165
|
-
borderRadius: borderless ? 0 : 1,
|
|
166
|
-
background: borderless ? "none" : theme.tile,
|
|
167
|
-
overflow: "hidden",
|
|
168
|
-
minHeight: 120,
|
|
169
|
-
p: borderless ? "12px 0" : `${DASHBOARD_CARD_PADDING_PX}px`,
|
|
115
|
+
// The heading's button shows on hover and keyboard focus, the way
|
|
116
|
+
// a tile's chrome does everywhere else; always-on it competes with
|
|
117
|
+
// the title on every card at once.
|
|
118
|
+
"& .publisher-tile-explore": {
|
|
119
|
+
opacity: 0,
|
|
120
|
+
transition: "opacity 120ms",
|
|
121
|
+
},
|
|
122
|
+
"&:hover .publisher-tile-explore, & .publisher-tile-explore:focus-visible":
|
|
123
|
+
{ opacity: 1 },
|
|
170
124
|
}}
|
|
171
125
|
>
|
|
172
126
|
{tile !== undefined && (
|
|
173
|
-
<
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
opacity: 0.8,
|
|
195
|
-
}}
|
|
196
|
-
>
|
|
197
|
-
{subtitle}
|
|
198
|
-
</Typography>
|
|
199
|
-
)}
|
|
200
|
-
</Box>
|
|
201
|
-
)}
|
|
202
|
-
{!isSuccess && !isError && <Loading text="Running…" />}
|
|
203
|
-
{isSuccess && (
|
|
204
|
-
<ResultContainer
|
|
205
|
-
result={result}
|
|
206
|
-
maxHeight={height}
|
|
207
|
-
maxResultSize={maxResultSize}
|
|
208
|
-
renderLogs={data.data.renderLogs}
|
|
209
|
-
drill={drill}
|
|
127
|
+
<TileHeading
|
|
128
|
+
title={label ?? tileTitle(tile)}
|
|
129
|
+
subtitle={subtitle}
|
|
130
|
+
// The expression is what actually ran, so it stays reachable as
|
|
131
|
+
// a tooltip rather than as the heading.
|
|
132
|
+
tooltip={tile}
|
|
133
|
+
action={
|
|
134
|
+
onExplore && (
|
|
135
|
+
<Tooltip title="Explore from here">
|
|
136
|
+
<IconButton
|
|
137
|
+
className="publisher-tile-explore"
|
|
138
|
+
size="small"
|
|
139
|
+
aria-label={`Explore ${label ?? tileTitle(tile)}`}
|
|
140
|
+
onClick={onExplore}
|
|
141
|
+
sx={{ mt: -0.5, mr: -0.5, color: theme.tileTitle }}
|
|
142
|
+
>
|
|
143
|
+
<ExploreOutlinedIcon fontSize="small" />
|
|
144
|
+
</IconButton>
|
|
145
|
+
</Tooltip>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
210
148
|
/>
|
|
211
149
|
)}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
150
|
+
<ResultPanel
|
|
151
|
+
state={state}
|
|
152
|
+
context={tile ?? queryName ?? modelPath}
|
|
153
|
+
maxHeight={height}
|
|
154
|
+
maxResultSize={maxResultSize}
|
|
155
|
+
drill={drill}
|
|
156
|
+
// A composite tile that is one row of measures draws as KPI cards,
|
|
157
|
+
// the way Malloyyo splices the same tile into its grid, rather than
|
|
158
|
+
// as a one-row table. Composite only: the single-query form is one
|
|
159
|
+
// result the renderer lays out from the query's own tags, and its
|
|
160
|
+
// aggregates are already tiles.
|
|
161
|
+
transform={tile !== undefined ? promoteMeasureRowToKpis : undefined}
|
|
162
|
+
/>
|
|
163
|
+
</TileCard>
|
|
221
164
|
);
|
|
222
165
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import type * as Malloy from "@malloydata/malloy-interfaces";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { encodeResourceUri } from "../../utils/formatting";
|
|
7
|
+
import { ModelExplorerDialog } from "../Model/ModelExplorerDialog";
|
|
8
|
+
import { useModelData } from "../Model/useModelData";
|
|
9
|
+
import { sourceOf, stepsOf } from "./RowsDialog";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* "Explore from here": the tile's query, open in the model explorer on the
|
|
13
|
+
* tile's source, so the reader can change it rather than only look at it.
|
|
14
|
+
*
|
|
15
|
+
* The dashboard file is itself a model, so the explorer opens on that file:
|
|
16
|
+
* the tile's source is an extension declared there, and its query resolves
|
|
17
|
+
* as written. The model is fetched here rather than inside the explorer so
|
|
18
|
+
* the tile's source can be selected before it renders.
|
|
19
|
+
*/
|
|
20
|
+
export function ExploreDialog({
|
|
21
|
+
tile,
|
|
22
|
+
environmentName,
|
|
23
|
+
packageName,
|
|
24
|
+
versionId,
|
|
25
|
+
modelPath,
|
|
26
|
+
onClose,
|
|
27
|
+
}: {
|
|
28
|
+
/** The tile expression to open, or undefined when closed. */
|
|
29
|
+
tile: string | undefined;
|
|
30
|
+
environmentName: string;
|
|
31
|
+
packageName: string;
|
|
32
|
+
versionId?: string;
|
|
33
|
+
modelPath: string;
|
|
34
|
+
onClose: () => void;
|
|
35
|
+
}) {
|
|
36
|
+
const resourceUri = encodeResourceUri({
|
|
37
|
+
environmentName,
|
|
38
|
+
packageName,
|
|
39
|
+
modelPath,
|
|
40
|
+
...(versionId === undefined ? {} : { versionId }),
|
|
41
|
+
});
|
|
42
|
+
const { data } = useModelData(resourceUri, tile !== undefined);
|
|
43
|
+
const sourceIndex = useMemo(() => {
|
|
44
|
+
const source = sourceOf(tile);
|
|
45
|
+
if (!data || source === undefined) return 0;
|
|
46
|
+
const index = (data.sourceInfos ?? []).findIndex((info) => {
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(info)?.name === source;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return index < 0 ? 0 : index;
|
|
54
|
+
}, [data, tile]);
|
|
55
|
+
// As a query AST when the expression is `source -> view`, so the explorer's
|
|
56
|
+
// builder shows the view and its Run button works from the first render; a
|
|
57
|
+
// string otherwise, which the explorer runs as written but cannot show.
|
|
58
|
+
const existingQuery = useMemo(() => {
|
|
59
|
+
if (tile === undefined) return undefined;
|
|
60
|
+
const steps = stepsOf(tile);
|
|
61
|
+
const malloyQuery: Malloy.Query | string = steps
|
|
62
|
+
? {
|
|
63
|
+
definition: {
|
|
64
|
+
kind: "arrow",
|
|
65
|
+
source: { kind: "source_reference", name: steps.source },
|
|
66
|
+
view: { kind: "view_reference", name: steps.view },
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
: `run: ${tile}`;
|
|
70
|
+
return { query: `run: ${tile}`, malloyQuery, malloyResult: undefined };
|
|
71
|
+
}, [tile]);
|
|
72
|
+
if (tile === undefined || !data) return null;
|
|
73
|
+
return (
|
|
74
|
+
<ModelExplorerDialog
|
|
75
|
+
open
|
|
76
|
+
onClose={onClose}
|
|
77
|
+
resourceUri={resourceUri}
|
|
78
|
+
data={data}
|
|
79
|
+
title={`Explore: ${tile}`}
|
|
80
|
+
existingQuery={existingQuery}
|
|
81
|
+
initialSelectedSourceIndex={sourceIndex}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { rowsQuery, sourceOf, stepsOf } from "./RowsDialog";
|
|
6
|
+
|
|
7
|
+
describe("the rows query", () => {
|
|
8
|
+
it("drills through the tile's view to the value's rows", () => {
|
|
9
|
+
expect(
|
|
10
|
+
rowsQuery({
|
|
11
|
+
source: "overview",
|
|
12
|
+
view: "best_sellers",
|
|
13
|
+
field: "name",
|
|
14
|
+
rawValue: "Loft Insulated Jacket",
|
|
15
|
+
label: "Loft Insulated Jacket",
|
|
16
|
+
}),
|
|
17
|
+
).toBe(
|
|
18
|
+
"run: overview -> { drill: best_sellers.name = 'Loft Insulated Jacket'; select: *; limit: 200 }",
|
|
19
|
+
);
|
|
20
|
+
expect(
|
|
21
|
+
rowsQuery({
|
|
22
|
+
source: "a",
|
|
23
|
+
view: "v",
|
|
24
|
+
field: "f",
|
|
25
|
+
rawValue: {},
|
|
26
|
+
label: "",
|
|
27
|
+
}),
|
|
28
|
+
).toBeUndefined();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("reads the source and view off a tile expression, and nothing off any other shape", () => {
|
|
32
|
+
expect(stepsOf("overview -> revenue_trend")).toEqual({
|
|
33
|
+
source: "overview",
|
|
34
|
+
view: "revenue_trend",
|
|
35
|
+
});
|
|
36
|
+
expect(sourceOf("overview->kpis")).toBe("overview");
|
|
37
|
+
expect(stepsOf("{ group_by: x } -> y")).toBeUndefined();
|
|
38
|
+
expect(stepsOf("a -> b -> c")).toBeUndefined();
|
|
39
|
+
expect(stepsOf("a -> b + { limit: 2 }")).toBeUndefined();
|
|
40
|
+
expect(stepsOf(undefined)).toBeUndefined();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
5
|
+
import {
|
|
6
|
+
Box,
|
|
7
|
+
Button,
|
|
8
|
+
Dialog,
|
|
9
|
+
DialogActions,
|
|
10
|
+
DialogContent,
|
|
11
|
+
DialogTitle,
|
|
12
|
+
IconButton,
|
|
13
|
+
Typography,
|
|
14
|
+
} from "@mui/material";
|
|
15
|
+
import { useEffect, useRef } from "react";
|
|
16
|
+
import { useQueryResult } from "../../hooks/useQueryResult";
|
|
17
|
+
import { malloyLiteral } from "../../utils/malloyLiteral";
|
|
18
|
+
import { isIdentifier, tileSteps } from "../DashboardBuilder/malloyText";
|
|
19
|
+
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
20
|
+
import { ResultPanel } from "../RenderedResult/ResultPanel";
|
|
21
|
+
import { now } from "./telemetry";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The rows behind a value: "show the rows" on a cell, as one query.
|
|
25
|
+
*
|
|
26
|
+
* A grouped value is an aggregate over rows of the tile's source, and Malloy's
|
|
27
|
+
* `drill:` names exactly those rows: `drill: <view>.<field> = <value>` applies
|
|
28
|
+
* the view's own `where:` — the tile's control bindings included — and the
|
|
29
|
+
* clicked value's, so what comes back is the rows the number was made of.
|
|
30
|
+
* Measured: `where: name = …` alone failed on a view that spelled the column
|
|
31
|
+
* `name is products.name`, because the output name is not a source field;
|
|
32
|
+
* `drill:` resolves it through the view, which is where the name lives.
|
|
33
|
+
*/
|
|
34
|
+
export const ROW_LIMIT = 200;
|
|
35
|
+
|
|
36
|
+
export interface RowsRequest {
|
|
37
|
+
/** The source the rows are of: the tile expression's first step. */
|
|
38
|
+
source: string;
|
|
39
|
+
/** The view the value was grouped in: the expression's last step. */
|
|
40
|
+
view: string;
|
|
41
|
+
field: string;
|
|
42
|
+
rawValue: unknown;
|
|
43
|
+
label: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The query the dialog runs, or undefined when the value cannot be spelled. */
|
|
47
|
+
export function rowsQuery(request: RowsRequest): string | undefined {
|
|
48
|
+
const literal = malloyLiteral(request.rawValue);
|
|
49
|
+
if (literal === undefined) return undefined;
|
|
50
|
+
return `run: ${request.source} -> { drill: ${request.view}.${request.field} = ${literal}; select: *; limit: ${ROW_LIMIT} }`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* `overview -> revenue_trend` → its source and view; undefined for anything
|
|
55
|
+
* else — an inline stage has no view to drill through, a refined one carries
|
|
56
|
+
* filters `drill:` would not, and a longer pipeline has no one view its value
|
|
57
|
+
* came from.
|
|
58
|
+
*/
|
|
59
|
+
export function stepsOf(
|
|
60
|
+
tileExpression: string | undefined,
|
|
61
|
+
): { source: string; view: string } | undefined {
|
|
62
|
+
const steps = tileSteps(tileExpression);
|
|
63
|
+
if (
|
|
64
|
+
!steps ||
|
|
65
|
+
steps.refinement !== undefined ||
|
|
66
|
+
!isIdentifier(steps.source) ||
|
|
67
|
+
!isIdentifier(steps.view)
|
|
68
|
+
)
|
|
69
|
+
return undefined;
|
|
70
|
+
return { source: steps.source, view: steps.view };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The source alone, for opening the explorer on it. */
|
|
74
|
+
export const sourceOf = (tileExpression: string | undefined) =>
|
|
75
|
+
stepsOf(tileExpression)?.source;
|
|
76
|
+
|
|
77
|
+
export function RowsDialog({
|
|
78
|
+
request,
|
|
79
|
+
environmentName,
|
|
80
|
+
packageName,
|
|
81
|
+
versionId,
|
|
82
|
+
modelPath,
|
|
83
|
+
givens,
|
|
84
|
+
onClose,
|
|
85
|
+
onDone,
|
|
86
|
+
}: {
|
|
87
|
+
request: RowsRequest | undefined;
|
|
88
|
+
environmentName: string;
|
|
89
|
+
packageName: string;
|
|
90
|
+
versionId?: string;
|
|
91
|
+
modelPath: string;
|
|
92
|
+
/** The applied control row, which the source's own `where:` may read. */
|
|
93
|
+
givens: Record<string, unknown>;
|
|
94
|
+
onClose: () => void;
|
|
95
|
+
/** The query's outcome and how long it took, once per request. */
|
|
96
|
+
onDone?: (ok: boolean, durationMs: number) => void;
|
|
97
|
+
}) {
|
|
98
|
+
const { theme } = usePublisherTheme();
|
|
99
|
+
const query = request ? rowsQuery(request) : undefined;
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Dialog
|
|
103
|
+
open={request !== undefined}
|
|
104
|
+
onClose={onClose}
|
|
105
|
+
maxWidth="lg"
|
|
106
|
+
fullWidth
|
|
107
|
+
>
|
|
108
|
+
<DialogTitle
|
|
109
|
+
sx={{
|
|
110
|
+
display: "flex",
|
|
111
|
+
alignItems: "flex-start",
|
|
112
|
+
justifyContent: "space-between",
|
|
113
|
+
pb: 0.5,
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
<Box>
|
|
117
|
+
{request ? (
|
|
118
|
+
<>
|
|
119
|
+
Rows where{" "}
|
|
120
|
+
<Box component="code" sx={{ fontSize: "0.9em" }}>
|
|
121
|
+
{request.field}
|
|
122
|
+
</Box>{" "}
|
|
123
|
+
is {request.label}
|
|
124
|
+
</>
|
|
125
|
+
) : (
|
|
126
|
+
"Rows"
|
|
127
|
+
)}
|
|
128
|
+
<Typography
|
|
129
|
+
component="div"
|
|
130
|
+
variant="caption"
|
|
131
|
+
sx={{ color: theme.tileTitle, mt: 0.25 }}
|
|
132
|
+
>
|
|
133
|
+
{request
|
|
134
|
+
? `The first ${ROW_LIMIT} rows of ${request.source} behind this value, with the tile's own filters and the controls applied.`
|
|
135
|
+
: ""}
|
|
136
|
+
</Typography>
|
|
137
|
+
</Box>
|
|
138
|
+
<IconButton
|
|
139
|
+
onClick={onClose}
|
|
140
|
+
aria-label="Close"
|
|
141
|
+
size="small"
|
|
142
|
+
sx={{ color: "text.secondary", ml: 1 }}
|
|
143
|
+
>
|
|
144
|
+
<CloseIcon fontSize="small" />
|
|
145
|
+
</IconButton>
|
|
146
|
+
</DialogTitle>
|
|
147
|
+
<DialogContent dividers sx={{ p: 0, minHeight: 240 }}>
|
|
148
|
+
{query === undefined && request && (
|
|
149
|
+
<Typography variant="body2" sx={{ p: 2 }}>
|
|
150
|
+
This value cannot be written as a filter, so its rows cannot
|
|
151
|
+
be fetched.
|
|
152
|
+
</Typography>
|
|
153
|
+
)}
|
|
154
|
+
{query !== undefined && (
|
|
155
|
+
<RowsResult
|
|
156
|
+
query={query}
|
|
157
|
+
environmentName={environmentName}
|
|
158
|
+
packageName={packageName}
|
|
159
|
+
{...(versionId === undefined ? {} : { versionId })}
|
|
160
|
+
modelPath={modelPath}
|
|
161
|
+
givens={givens}
|
|
162
|
+
{...(onDone ? { onDone } : {})}
|
|
163
|
+
/>
|
|
164
|
+
)}
|
|
165
|
+
</DialogContent>
|
|
166
|
+
<DialogActions sx={{ px: 3, py: 1.5 }}>
|
|
167
|
+
{query !== undefined && (
|
|
168
|
+
<Typography
|
|
169
|
+
variant="caption"
|
|
170
|
+
sx={{
|
|
171
|
+
mr: "auto",
|
|
172
|
+
color: theme.tileTitle,
|
|
173
|
+
fontFamily: "ui-monospace, monospace",
|
|
174
|
+
overflow: "hidden",
|
|
175
|
+
textOverflow: "ellipsis",
|
|
176
|
+
whiteSpace: "nowrap",
|
|
177
|
+
}}
|
|
178
|
+
title={query}
|
|
179
|
+
>
|
|
180
|
+
{query}
|
|
181
|
+
</Typography>
|
|
182
|
+
)}
|
|
183
|
+
<Button onClick={onClose}>Close</Button>
|
|
184
|
+
</DialogActions>
|
|
185
|
+
</Dialog>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The rows themselves. Its own component so the query exists only while a
|
|
191
|
+
* request does: a closed dialog holds nothing in the cache.
|
|
192
|
+
*/
|
|
193
|
+
function RowsResult({
|
|
194
|
+
query,
|
|
195
|
+
environmentName,
|
|
196
|
+
packageName,
|
|
197
|
+
versionId,
|
|
198
|
+
modelPath,
|
|
199
|
+
givens,
|
|
200
|
+
onDone,
|
|
201
|
+
}: {
|
|
202
|
+
query: string;
|
|
203
|
+
environmentName: string;
|
|
204
|
+
packageName: string;
|
|
205
|
+
versionId?: string;
|
|
206
|
+
modelPath: string;
|
|
207
|
+
givens: Record<string, unknown>;
|
|
208
|
+
onDone?: (ok: boolean, durationMs: number) => void;
|
|
209
|
+
}) {
|
|
210
|
+
const state = useQueryResult({
|
|
211
|
+
environmentName,
|
|
212
|
+
packageName,
|
|
213
|
+
modelPath,
|
|
214
|
+
...(versionId === undefined ? {} : { versionId }),
|
|
215
|
+
query,
|
|
216
|
+
givens,
|
|
217
|
+
});
|
|
218
|
+
const { isSuccess, isError } = state;
|
|
219
|
+
// Reported once per request, when the query settles.
|
|
220
|
+
const started = useRef<number | undefined>(undefined);
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
started.current = now();
|
|
223
|
+
}, [query]);
|
|
224
|
+
useEffect(() => {
|
|
225
|
+
if (started.current === undefined || (!isSuccess && !isError)) return;
|
|
226
|
+
onDone?.(isSuccess, now() - started.current);
|
|
227
|
+
started.current = undefined;
|
|
228
|
+
}, [isSuccess, isError, onDone]);
|
|
229
|
+
return (
|
|
230
|
+
<Box sx={{ p: 1 }}>
|
|
231
|
+
<ResultPanel state={state} context={query} />
|
|
232
|
+
</Box>
|
|
233
|
+
);
|
|
234
|
+
}
|