@malloy-publisher/sdk 0.9.2 → 0.9.4
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/dist/{RenderedResult-CBLHr32C.es.js → RenderedResult-DwB0-9Yx.es.js} +118 -119
- package/dist/{RenderedResult-B48wAjM8.cjs.js → RenderedResult-hKjFEqaN.cjs.js} +2 -2
- package/dist/{ServerProvider-DCV8BUWD.es.js → ServerProvider-CcSrGaRN.es.js} +1281 -1142
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +112 -115
- package/dist/builder/index.es.js +11766 -11502
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +170 -9
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +93 -89
- package/dist/client-entry.d.ts +2 -0
- package/dist/components/ApiErrorDisplay.d.ts +11 -0
- package/dist/components/AppDialog.d.ts +6 -6
- package/dist/components/Dashboard/DashboardGrid.d.ts +18 -3
- package/dist/components/Dashboard/DashboardTile.d.ts +12 -2
- package/dist/components/Dashboard/DashboardView.d.ts +38 -3
- package/dist/components/Dashboard/TileCard.d.ts +16 -2
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +3 -2
- package/dist/components/Dashboard/telemetry.d.ts +2 -1
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +7 -8
- package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
- package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
- package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +14 -17
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +3 -1
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +15 -7
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +28 -2
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +6 -4
- package/dist/components/DashboardBuilder/InlineText.d.ts +1 -1
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +4 -1
- package/dist/components/DashboardBuilder/TileFrame.d.ts +43 -6
- package/dist/components/DashboardBuilder/TileMenu.d.ts +6 -8
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +0 -18
- package/dist/components/DashboardBuilder/documentSession.d.ts +2 -2
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +3 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/sortable.d.ts +2 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -0
- package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
- package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
- package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +4 -7
- package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
- package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +2 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
- package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
- package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
- package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +32 -0
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/Package.d.ts +16 -1
- package/dist/components/Package/index.d.ts +1 -1
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +1 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +9760 -10363
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-CbbBcZl8.es.js → text-entry-CA0LZ1xL.es.js} +8 -8
- package/dist/text-entry.d.ts +1 -1
- package/dist/theme/accent.d.ts +29 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/keys.d.ts +1 -1
- package/dist/theme/motion.d.ts +31 -0
- package/dist/theme/readChartAnnotations.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +4 -4
- package/dist/theme/types.d.ts +33 -5
- package/dist/{DashboardTile-BFcxdv7R.es.js → useCompiledDocument-BU6d8FPp.es.js} +6978 -6289
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/package.json +11 -11
- package/src/builder-entry.ts +1 -0
- package/src/client-entry.ts +8 -0
- package/src/clientEntry.spec.ts +17 -0
- package/src/components/ApiErrorDisplay.tsx +37 -18
- package/src/components/AppDialog.tsx +8 -7
- package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
- package/src/components/Dashboard/Dashboard.tsx +2 -2
- package/src/components/Dashboard/DashboardGrid.tsx +23 -5
- package/src/components/Dashboard/DashboardTile.spec.tsx +97 -2
- package/src/components/Dashboard/DashboardTile.tsx +95 -31
- package/src/components/Dashboard/DashboardView.spec.tsx +156 -0
- package/src/components/Dashboard/DashboardView.tsx +165 -89
- package/src/components/Dashboard/RowsDialog.tsx +3 -2
- package/src/components/Dashboard/TileCard.tsx +17 -2
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +11 -2
- package/src/components/Dashboard/telemetry.ts +2 -1
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -56
- package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
- package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
- package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +86 -113
- package/src/components/DashboardBuilder/ChartPicker.tsx +4 -1
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +5 -5
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +74 -83
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +62 -18
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +55 -108
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +10 -62
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +50 -57
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +53 -40
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +10 -8
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +227 -704
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +32 -52
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +1 -50
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +12 -18
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +4 -24
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +4 -4
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +8 -13
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +142 -820
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +13 -8
- package/src/components/DashboardBuilder/FilterStrip.tsx +117 -79
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +7 -9
- package/src/components/DashboardBuilder/InlineText.tsx +23 -17
- package/src/components/DashboardBuilder/NotebookEditor.tsx +3 -3
- package/src/components/DashboardBuilder/TextTileBody.tsx +5 -2
- package/src/components/DashboardBuilder/TileFrame.tsx +255 -90
- package/src/components/DashboardBuilder/TileMenu.tsx +41 -91
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +1 -1
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +9 -4
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +0 -44
- package/src/components/DashboardBuilder/catalog.ts +0 -36
- package/src/components/DashboardBuilder/controls.spec.ts +1 -1
- package/src/components/DashboardBuilder/controls.ts +1 -1
- package/src/components/DashboardBuilder/documentSession.ts +3 -2
- package/src/components/DashboardBuilder/imports.spec.ts +61 -0
- package/src/components/DashboardBuilder/imports.ts +93 -0
- package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1 -1
- package/src/components/DashboardBuilder/malloyTree.ts +5 -1
- package/src/components/DashboardBuilder/newDashboard.ts +1 -1
- package/src/components/DashboardBuilder/preview.ts +1 -1
- package/src/components/DashboardBuilder/readDocument.spec.ts +36 -0
- package/src/components/DashboardBuilder/readDocument.ts +10 -4
- package/src/components/DashboardBuilder/readForEditor.ts +7 -2
- package/src/components/DashboardBuilder/sortable.spec.ts +25 -1
- package/src/components/DashboardBuilder/sortable.tsx +11 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +8 -3
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +62 -6
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/inline.ts +1 -1
- package/src/components/DashboardBuilder/testing/resize.ts +48 -0
- package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +43 -1
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +0 -85
- package/src/components/DashboardBuilder/useBuilderSession.ts +6 -43
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +32 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +11 -1
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +5 -2
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
- package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
- package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
- package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
- package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +146 -0
- package/src/components/DashboardBuilder/useTileResize.ts +133 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/guards.ts +1 -1
- package/src/components/Environment/Environment.tsx +0 -10
- package/src/components/Loading.tsx +14 -0
- package/src/components/Model/Model.tsx +16 -9
- package/src/components/Model/ModelExplorer.tsx +2 -2
- package/src/components/Notebook/Notebook.tsx +6 -2
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/Package.artifacts.spec.tsx +8 -12
- package/src/components/Package/Package.create.spec.tsx +22 -1
- package/src/components/Package/Package.tsx +51 -27
- package/src/components/Package/index.ts +1 -1
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +5 -7
- package/src/components/RenderedResult/ResultContainer.tsx +7 -2
- package/src/components/RenderedResult/ResultPanel.tsx +20 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.tsx +2 -8
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +1 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCompiledDocument.spec.tsx +86 -0
- package/src/hooks/useCompiledDocument.ts +59 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
- package/src/hooks/useDocumentControls.ts +13 -1
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +7 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/text-entry.ts +1 -1
- package/src/textEntry.spec.ts +2 -8
- package/src/theme/accent.spec.ts +116 -0
- package/src/theme/accent.ts +148 -0
- package/src/theme/buildTableCssVars.spec.ts +24 -0
- package/src/theme/buildTableCssVars.ts +1 -2
- package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
- package/src/theme/buildVegaThemeOverride.ts +5 -5
- package/src/theme/defaults.ts +34 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/keys.ts +6 -0
- package/src/theme/motion.ts +44 -0
- package/src/theme/readChartAnnotations.spec.ts +18 -0
- package/src/theme/readChartAnnotations.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +73 -0
- package/src/theme/resolveTheme.ts +61 -20
- package/src/theme/types.ts +30 -5
- package/src/utils/queryClient.ts +8 -0
- package/dist/DashboardTile-sg8LjUk8.cjs.js +0 -137
- package/dist/ServerProvider-HRqT3w1C.cjs.js +0 -1
- package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -7
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +0 -27
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -32
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +0 -194
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +0 -25
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -103
- package/src/components/DashboardBuilder/SaveNotice.tsx +0 -113
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +0 -87
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -326
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- /package/dist/{components/DashboardBuilder → utils}/malloyText.d.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.ts +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloy-publisher/sdk",
|
|
3
3
|
"description": "Malloy Publisher SDK",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
"generate-api-types": "bunx openapi-generator-cli generate -i ../../api-doc.yaml -g typescript-axios -o src/client/"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@malloydata/malloy": "^0.0.
|
|
84
|
+
"@malloydata/malloy": "^0.0.435",
|
|
85
85
|
"@malloydata/malloy-explorer": "0.0.338-dev260215172810",
|
|
86
|
-
"@malloydata/malloy-filter": "^0.0.
|
|
87
|
-
"@malloydata/malloy-interfaces": "^0.0.
|
|
88
|
-
"@malloydata/malloy-query-builder": "^0.0.
|
|
89
|
-
"@malloydata/malloy-tag": "^0.0.
|
|
90
|
-
"@malloydata/render": "^0.0.
|
|
86
|
+
"@malloydata/malloy-filter": "^0.0.435",
|
|
87
|
+
"@malloydata/malloy-interfaces": "^0.0.435",
|
|
88
|
+
"@malloydata/malloy-query-builder": "^0.0.435",
|
|
89
|
+
"@malloydata/malloy-tag": "^0.0.435",
|
|
90
|
+
"@malloydata/render": "^0.0.435",
|
|
91
91
|
"@mui/icons-material": ">=7.1.1",
|
|
92
92
|
"@mui/material": ">=7.1.1",
|
|
93
93
|
"@mui/system": ">=7.1.1",
|
|
@@ -114,11 +114,11 @@
|
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
116
|
"@happy-dom/global-registrator": "^20.11.1",
|
|
117
|
-
"@malloydata/malloy": "^0.0.
|
|
117
|
+
"@malloydata/malloy": "^0.0.435",
|
|
118
118
|
"@malloydata/malloy-explorer": "0.0.338-dev260215172810",
|
|
119
|
-
"@malloydata/malloy-filter": "^0.0.
|
|
120
|
-
"@malloydata/malloy-query-builder": "^0.0.
|
|
121
|
-
"@malloydata/malloy-tag": "^0.0.
|
|
119
|
+
"@malloydata/malloy-filter": "^0.0.435",
|
|
120
|
+
"@malloydata/malloy-query-builder": "^0.0.435",
|
|
121
|
+
"@malloydata/malloy-tag": "^0.0.435",
|
|
122
122
|
"@openapitools/openapi-generator-cli": "^2.40.1",
|
|
123
123
|
"@shikijs/langs": "^1.16.3",
|
|
124
124
|
"@shikijs/themes": "^1.16.3",
|
package/src/builder-entry.ts
CHANGED
package/src/client-entry.ts
CHANGED
|
@@ -18,3 +18,11 @@ export type {
|
|
|
18
18
|
|
|
19
19
|
// Export the query client for users who need direct access
|
|
20
20
|
export { globalQueryClient } from "./utils/queryClient";
|
|
21
|
+
|
|
22
|
+
// The theme hook a host reads at its root, to follow or set the SDK's light or
|
|
23
|
+
// dark mode. It lives beside `ServerProvider`, which mounts its provider, so
|
|
24
|
+
// taking it from here costs nothing the provider has not already loaded; from
|
|
25
|
+
// the main entry it would put the dashboard, explorer and renderer code on the
|
|
26
|
+
// host's critical path.
|
|
27
|
+
export { usePublisherTheme } from "./theme/ThemeContext";
|
|
28
|
+
export type { ResolvedTheme, Theme, ThemeMode } from "./theme/types";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
|
|
6
|
+
describe("@malloy-publisher/sdk/client", () => {
|
|
7
|
+
// A host mounts `ServerProvider` and follows the theme mode at its root;
|
|
8
|
+
// both have to come from the light entry, or the main entry's dashboard,
|
|
9
|
+
// explorer and renderer code lands on every page's critical path.
|
|
10
|
+
it("carries what a host needs at its root", async () => {
|
|
11
|
+
const client = await import("./client-entry");
|
|
12
|
+
expect(typeof client.ServerProvider).toBe("function");
|
|
13
|
+
expect(typeof client.useServer).toBe("function");
|
|
14
|
+
expect(typeof client.usePublisherTheme).toBe("function");
|
|
15
|
+
expect(client.globalQueryClient).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Alert, Box } from "@mui/material";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import { MONO_FONT_FAMILY } from "./styles";
|
|
5
7
|
|
|
6
8
|
export interface ApiError extends Error {
|
|
7
9
|
status?: number;
|
|
@@ -16,26 +18,43 @@ export interface ApiErrorDisplayProps {
|
|
|
16
18
|
context?: string;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
/**
|
|
22
|
+
* An error as an MUI `Alert`: a one-line summary, and the server's own words
|
|
23
|
+
* under it in a monospace block that keeps their line breaks. Themed, so it
|
|
24
|
+
* reads in dark mode as well as light. Shared with a notebook cell that could
|
|
25
|
+
* not run, so every request failure in a document looks the same.
|
|
26
|
+
*/
|
|
27
|
+
export function ErrorDetailAlert({
|
|
28
|
+
summary,
|
|
29
|
+
detail,
|
|
30
|
+
}: {
|
|
31
|
+
summary?: ReactNode;
|
|
32
|
+
detail: ReactNode;
|
|
33
|
+
}) {
|
|
21
34
|
return (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
<Alert
|
|
36
|
+
severity="error"
|
|
37
|
+
sx={{ "& .MuiAlert-message": { minWidth: 0, flex: 1 } }}
|
|
38
|
+
>
|
|
39
|
+
{summary !== undefined && <Box sx={{ mb: 0.5 }}>{summary}</Box>}
|
|
40
|
+
<Box
|
|
41
|
+
component="pre"
|
|
42
|
+
sx={{
|
|
43
|
+
m: 0,
|
|
31
44
|
whiteSpace: "pre-wrap",
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
wordBreak: "break-word",
|
|
46
|
+
fontFamily: MONO_FONT_FAMILY,
|
|
47
|
+
fontSize: "0.8125rem",
|
|
48
|
+
color: "text.secondary",
|
|
35
49
|
}}
|
|
36
50
|
>
|
|
37
|
-
{
|
|
38
|
-
</
|
|
39
|
-
|
|
51
|
+
{detail}
|
|
52
|
+
</Box>
|
|
53
|
+
</Alert>
|
|
40
54
|
);
|
|
41
55
|
}
|
|
56
|
+
|
|
57
|
+
export function ApiErrorDisplay({ error, context }: ApiErrorDisplayProps) {
|
|
58
|
+
const errorMessage = error.data?.message || "Unknown error";
|
|
59
|
+
return <ErrorDetailAlert summary={context} detail={errorMessage} />;
|
|
60
|
+
}
|
|
@@ -24,11 +24,10 @@ import { useId } from "react";
|
|
|
24
24
|
* with the same padding every time — a text Cancel and a filled confirm, the
|
|
25
25
|
* two roles `buttons.tsx` names.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* but a fourth exception is a reason to widen it, not to hand-roll a fourth.
|
|
27
|
+
* `ModelExplorerDialog` stays off it deliberately: it is `fullScreen`. The
|
|
28
|
+
* title takes a node as well as a string, so a dialog that titles itself with
|
|
29
|
+
* more than text (`RowsDialog`, `MaterializationDetailDialog`) can move onto
|
|
30
|
+
* this rather than hand-roll its own close button and type.
|
|
32
31
|
*/
|
|
33
32
|
export function AppDialog({
|
|
34
33
|
open,
|
|
@@ -42,7 +41,8 @@ export function AppDialog({
|
|
|
42
41
|
}: {
|
|
43
42
|
open: boolean;
|
|
44
43
|
onClose: () => void;
|
|
45
|
-
|
|
44
|
+
/** The heading. A string in the common case; a node when it needs more. */
|
|
45
|
+
title: React.ReactNode;
|
|
46
46
|
/** What the dialog is for, in a line. The page's description, in a box. */
|
|
47
47
|
description?: React.ReactNode;
|
|
48
48
|
maxWidth?: "xs" | "sm" | "md" | "lg" | false;
|
|
@@ -74,7 +74,8 @@ export function AppDialog({
|
|
|
74
74
|
// The page heading's type, so a dialog reads as part of the same
|
|
75
75
|
// application rather than as a system alert.
|
|
76
76
|
fontSize: "1.25rem",
|
|
77
|
-
|
|
77
|
+
// Medium, not bold: a host that bans 600/700 gets its own weight.
|
|
78
|
+
fontWeight: "fontWeightMedium",
|
|
78
79
|
letterSpacing: "-0.025em",
|
|
79
80
|
lineHeight: 1.2,
|
|
80
81
|
}}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { beforeEach, describe, expect, it, mock } from "bun:test";
|
|
13
13
|
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
14
|
-
import type { ReactNode } from "react";
|
|
15
14
|
import {
|
|
16
15
|
cacheKeys,
|
|
17
16
|
clearCache,
|
|
@@ -46,23 +45,6 @@ const getModel = mock(
|
|
|
46
45
|
) => pending<{ data: CompiledModel }>(),
|
|
47
46
|
);
|
|
48
47
|
|
|
49
|
-
// Stubbed rather than let "Explore from here" reach the real ModelExplorer:
|
|
50
|
-
// that pulls in the lazy-loaded, WASM-backed `@malloydata/malloy-explorer`,
|
|
51
|
-
// which is not this file's business. Only what the dashboard hands it matters
|
|
52
|
-
// here, so the stub just records its props.
|
|
53
|
-
const exploreDialogProps = mock(
|
|
54
|
-
(_props: { open: boolean; startingGivens?: Record<string, string> }) => {},
|
|
55
|
-
);
|
|
56
|
-
mock.module("../Model/ModelExplorerDialog", () => ({
|
|
57
|
-
ModelExplorerDialog: (props: {
|
|
58
|
-
open: boolean;
|
|
59
|
-
startingGivens?: Record<string, string>;
|
|
60
|
-
}) => {
|
|
61
|
-
exploreDialogProps(props);
|
|
62
|
-
return null as ReactNode;
|
|
63
|
-
},
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
48
|
mockServerProvider({
|
|
67
49
|
dashboards: { getDashboard },
|
|
68
50
|
models: { executeQueryModel, getModel },
|
|
@@ -98,7 +80,6 @@ beforeEach(() => {
|
|
|
98
80
|
executeQueryModel.mockImplementation(() => pending());
|
|
99
81
|
getModel.mockReset();
|
|
100
82
|
getModel.mockImplementation(() => pending());
|
|
101
|
-
exploreDialogProps.mockClear();
|
|
102
83
|
});
|
|
103
84
|
|
|
104
85
|
describe("the manifest fetch", () => {
|
|
@@ -240,7 +221,7 @@ describe("the version reaches what the manifest drives", () => {
|
|
|
240
221
|
expect(v2[0]).not.toContain("CA");
|
|
241
222
|
});
|
|
242
223
|
|
|
243
|
-
it("
|
|
224
|
+
it("offers no Explore button on a tile", async () => {
|
|
244
225
|
getDashboard.mockImplementation(() =>
|
|
245
226
|
Promise.resolve({
|
|
246
227
|
data: {
|
|
@@ -250,20 +231,10 @@ describe("the version reaches what the manifest drives", () => {
|
|
|
250
231
|
},
|
|
251
232
|
}),
|
|
252
233
|
);
|
|
253
|
-
getModel.mockImplementation(() =>
|
|
254
|
-
Promise.resolve({ data: { sourceInfos: [] } }),
|
|
255
|
-
);
|
|
256
234
|
|
|
257
235
|
render(dashboardAt(), { wrapper: serverWrapper });
|
|
258
236
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
});
|
|
262
|
-
fireEvent.click(await screen.findByRole("button", { name: /Explore/ }));
|
|
263
|
-
|
|
264
|
-
await waitFor(() => expect(exploreDialogProps).toHaveBeenCalled());
|
|
265
|
-
const lastCall = exploreDialogProps.mock.calls.at(-1)?.[0];
|
|
266
|
-
expect(lastCall?.open).toBe(true);
|
|
267
|
-
expect(lastCall?.startingGivens).toEqual({ REGION: "CA" });
|
|
237
|
+
await screen.findByLabelText("REGION");
|
|
238
|
+
expect(screen.queryByRole("button", { name: /^Explore / })).toBeNull();
|
|
268
239
|
});
|
|
269
240
|
});
|
|
@@ -6,7 +6,7 @@ import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
|
6
6
|
import { parseResourceUri } from "../../utils/formatting";
|
|
7
7
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
8
8
|
import type { DrillNavigation } from "../drill";
|
|
9
|
-
import { Loading } from "../Loading";
|
|
9
|
+
import { Loading, LOADING_COPY } from "../Loading";
|
|
10
10
|
import { useServer } from "../ServerProvider";
|
|
11
11
|
import { DashboardView } from "./DashboardView";
|
|
12
12
|
import type { DashboardEventHandler } from "./telemetry";
|
|
@@ -145,7 +145,7 @@ export function Dashboard({
|
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
147
|
if (!isSuccess || !manifest) {
|
|
148
|
-
return <Loading text="
|
|
148
|
+
return <Loading text={LOADING_COPY.opening("dashboard")} />;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
return (
|
|
@@ -14,10 +14,6 @@ export const MAX_COLUMNS = 24;
|
|
|
14
14
|
export const nudgedSpan = (current: number, delta: 1 | -1, columns: number) =>
|
|
15
15
|
Math.min(Math.max(current + delta, 1), Math.min(columns, MAX_COLUMNS));
|
|
16
16
|
|
|
17
|
-
/** A tile's width for a width preset: a share of the grid, held to what the builder offers. */
|
|
18
|
-
export const presetSpan = (columns: number, share: number) =>
|
|
19
|
-
Math.min(Math.max(1, Math.round(columns / share)), MAX_COLUMNS);
|
|
20
|
-
|
|
21
17
|
/**
|
|
22
18
|
* The gutter between tiles, in px.
|
|
23
19
|
*
|
|
@@ -27,6 +23,24 @@ export const presetSpan = (columns: number, share: number) =>
|
|
|
27
23
|
*/
|
|
28
24
|
export const GRID_GAP_PX = 16;
|
|
29
25
|
|
|
26
|
+
/**
|
|
27
|
+
* The space between a notebook's tiles, which stack in one column with no card
|
|
28
|
+
* around them: wider than a dashboard's gap so the reading flow breathes, and
|
|
29
|
+
* so the builder's selection ring, drawn {@link BARE_RING_OFFSET_PX} clear of
|
|
30
|
+
* a bare tile, never meets the next tile's.
|
|
31
|
+
*/
|
|
32
|
+
export const NOTEBOOK_GAP_PX = 40;
|
|
33
|
+
|
|
34
|
+
/** How far a bare (uncarded) tile's selection ring sits from its content. */
|
|
35
|
+
export const BARE_RING_OFFSET_PX = 12;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The space above and below a notebook's description, in both modes: a bare
|
|
39
|
+
* description's ring in the builder is {@link BARE_RING_OFFSET_PX} clear of
|
|
40
|
+
* its text, and needs the room to stay clear of the title and the filters.
|
|
41
|
+
*/
|
|
42
|
+
export const BARE_DESCRIPTION_MARGIN_PX = BARE_RING_OFFSET_PX + 8;
|
|
43
|
+
|
|
30
44
|
/**
|
|
31
45
|
* The `grid-column` one tile occupies: its `# colspan`, and a `# break` forcing
|
|
32
46
|
* it to start a fresh row.
|
|
@@ -99,6 +113,7 @@ export function DashboardGrid<T extends GridTile>({
|
|
|
99
113
|
keyOf,
|
|
100
114
|
renderTile,
|
|
101
115
|
minTilePx,
|
|
116
|
+
rowGapPx = GRID_GAP_PX,
|
|
102
117
|
}: {
|
|
103
118
|
tiles: readonly T[];
|
|
104
119
|
/** Track count — `# dashboard { columns=N }`, or {@link DEFAULT_COLUMNS}. */
|
|
@@ -116,6 +131,8 @@ export function DashboardGrid<T extends GridTile>({
|
|
|
116
131
|
* builder assumes an unset colspan is one column.
|
|
117
132
|
*/
|
|
118
133
|
minTilePx?: number;
|
|
134
|
+
/** The space between rows; a notebook's is {@link NOTEBOOK_GAP_PX}. */
|
|
135
|
+
rowGapPx?: number;
|
|
119
136
|
}) {
|
|
120
137
|
const ref = useRef<HTMLDivElement>(null);
|
|
121
138
|
const [width, setWidth] = useState(0);
|
|
@@ -144,7 +161,8 @@ export function DashboardGrid<T extends GridTile>({
|
|
|
144
161
|
xs: "1fr",
|
|
145
162
|
md: `repeat(${columns}, minmax(0, 1fr))`,
|
|
146
163
|
},
|
|
147
|
-
|
|
164
|
+
columnGap: `${GRID_GAP_PX}px`,
|
|
165
|
+
rowGap: `${rowGapPx}px`,
|
|
148
166
|
}}
|
|
149
167
|
>
|
|
150
168
|
{tiles.map((tile, index) => (
|
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
* itself, and `versionId` has to land in both the request and the key from the
|
|
9
9
|
* prop alone.
|
|
10
10
|
*/
|
|
11
|
-
import { beforeEach, expect, it, mock } from "bun:test";
|
|
12
|
-
import {
|
|
11
|
+
import { afterEach, beforeEach, expect, it, mock } from "bun:test";
|
|
12
|
+
import {
|
|
13
|
+
act,
|
|
14
|
+
fireEvent,
|
|
15
|
+
render,
|
|
16
|
+
screen,
|
|
17
|
+
waitFor,
|
|
18
|
+
} from "@testing-library/react";
|
|
13
19
|
import {
|
|
14
20
|
cacheKeys,
|
|
15
21
|
clearCache,
|
|
@@ -24,6 +30,8 @@ const executeQueryModel = mock(
|
|
|
24
30
|
_packageName: string,
|
|
25
31
|
_modelPath: string,
|
|
26
32
|
_request: { versionId?: string },
|
|
33
|
+
_includeHidden?: boolean,
|
|
34
|
+
_options?: { signal?: AbortSignal },
|
|
27
35
|
) => pending(),
|
|
28
36
|
);
|
|
29
37
|
|
|
@@ -127,3 +135,90 @@ it("puts the filter warning under the heading and above the result", () => {
|
|
|
127
135
|
expect(follows(heading, tag)).toBe(true);
|
|
128
136
|
expect(follows(tag, body)).toBe(true);
|
|
129
137
|
});
|
|
138
|
+
|
|
139
|
+
// The request's own signal, as react-query handed it to `executeQueryModel`.
|
|
140
|
+
const signalOf = (call: number) =>
|
|
141
|
+
executeQueryModel.mock.calls[call][5]?.signal as AbortSignal;
|
|
142
|
+
|
|
143
|
+
it("cancels a tile's request when the tile goes away", async () => {
|
|
144
|
+
const { unmount } = render(tileAt("v1"), { wrapper: serverWrapper });
|
|
145
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalledTimes(1));
|
|
146
|
+
expect(signalOf(0).aborted).toBe(false);
|
|
147
|
+
|
|
148
|
+
unmount();
|
|
149
|
+
|
|
150
|
+
await waitFor(() => expect(signalOf(0).aborted).toBe(true));
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("cancels the superseded request when what the tile asks for changes", async () => {
|
|
154
|
+
const { rerender } = render(tileAt("v1"), { wrapper: serverWrapper });
|
|
155
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalledTimes(1));
|
|
156
|
+
|
|
157
|
+
rerender(tileAt("v2"));
|
|
158
|
+
|
|
159
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalledTimes(2));
|
|
160
|
+
await waitFor(() => expect(signalOf(0).aborted).toBe(true));
|
|
161
|
+
expect(signalOf(1).aborted).toBe(false);
|
|
162
|
+
// A cancelled run is not a failed one: the tile is still waiting, not erroring.
|
|
163
|
+
expect(screen.getByText("Running…")).toBeDefined();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// An observer the spec drives by hand: `enter()` reports every observed element
|
|
167
|
+
// as intersecting, the way a scroll into the margin would.
|
|
168
|
+
let observers: Array<{
|
|
169
|
+
callback: IntersectionObserverCallback;
|
|
170
|
+
targets: Element[];
|
|
171
|
+
}> = [];
|
|
172
|
+
class DrivenIntersectionObserver {
|
|
173
|
+
private record: (typeof observers)[number];
|
|
174
|
+
constructor(callback: IntersectionObserverCallback) {
|
|
175
|
+
this.record = { callback, targets: [] };
|
|
176
|
+
observers.push(this.record);
|
|
177
|
+
}
|
|
178
|
+
observe(target: Element) {
|
|
179
|
+
this.record.targets.push(target);
|
|
180
|
+
}
|
|
181
|
+
disconnect() {
|
|
182
|
+
this.record.targets = [];
|
|
183
|
+
}
|
|
184
|
+
unobserve() {}
|
|
185
|
+
takeRecords() {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const enter = () =>
|
|
190
|
+
observers.forEach(({ callback, targets }) =>
|
|
191
|
+
callback(
|
|
192
|
+
targets.map(
|
|
193
|
+
(target) =>
|
|
194
|
+
({ isIntersecting: true, target }) as IntersectionObserverEntry,
|
|
195
|
+
),
|
|
196
|
+
{} as IntersectionObserver,
|
|
197
|
+
),
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const originalObserver = globalThis.IntersectionObserver;
|
|
201
|
+
const originalRect = HTMLElement.prototype.getBoundingClientRect;
|
|
202
|
+
afterEach(() => {
|
|
203
|
+
globalThis.IntersectionObserver = originalObserver;
|
|
204
|
+
HTMLElement.prototype.getBoundingClientRect = originalRect;
|
|
205
|
+
observers = [];
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("holds a tile's query until the tile comes near the viewport", async () => {
|
|
209
|
+
(globalThis as { IntersectionObserver?: unknown }).IntersectionObserver =
|
|
210
|
+
DrivenIntersectionObserver;
|
|
211
|
+
// Mounted far below the fold.
|
|
212
|
+
HTMLElement.prototype.getBoundingClientRect = () =>
|
|
213
|
+
({ top: 10_000, bottom: 10_400 }) as DOMRect;
|
|
214
|
+
render(tileAt(), { wrapper: serverWrapper });
|
|
215
|
+
|
|
216
|
+
// Offscreen: nothing asked of the warehouse, and the card is still drawn.
|
|
217
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
218
|
+
expect(executeQueryModel).not.toHaveBeenCalled();
|
|
219
|
+
expect(screen.getByText("Sales by month")).toBeDefined();
|
|
220
|
+
|
|
221
|
+
act(() => enter());
|
|
222
|
+
|
|
223
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalledTimes(1));
|
|
224
|
+
});
|
|
@@ -2,15 +2,23 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import ExploreOutlinedIcon from "@mui/icons-material/ExploreOutlined";
|
|
5
|
-
import { IconButton, Tooltip } from "@mui/material";
|
|
5
|
+
import { Box, IconButton, Tooltip, Typography } from "@mui/material";
|
|
6
|
+
import {
|
|
7
|
+
MOTION_FAST,
|
|
8
|
+
reducedMotionSx,
|
|
9
|
+
visibleWithoutHoverSx,
|
|
10
|
+
} from "../../theme/motion";
|
|
6
11
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
12
|
+
import { useNearViewport } from "../../hooks/useNearViewport";
|
|
7
13
|
import { useQueryResult } from "../../hooks/useQueryResult";
|
|
8
|
-
import type { GivenValue } from "../../hooks/givenValue";
|
|
14
|
+
import type { GivenValue, HostGivenValue } from "../../hooks/givenValue";
|
|
9
15
|
import { humanizeSlug, type DrillBinding } from "../drill";
|
|
10
|
-
import { givensToRequest } from "../given/paramCodec";
|
|
16
|
+
import { givensToRequest, withHostGivens } from "../given/paramCodec";
|
|
11
17
|
import { ResultPanel } from "../RenderedResult/ResultPanel";
|
|
18
|
+
import { dropValueUrlTags } from "./dropValueUrlTags";
|
|
12
19
|
import { promoteMeasureRowToKpis } from "./promoteMeasureRow";
|
|
13
20
|
import { TileFilterTag } from "./TileFilterTag";
|
|
21
|
+
import { isForbidden, RESTRICTED_NOTICE, withPreamble } from "./textSource";
|
|
14
22
|
import {
|
|
15
23
|
TileCard,
|
|
16
24
|
TileHeading,
|
|
@@ -18,6 +26,9 @@ import {
|
|
|
18
26
|
type TileHeadingSlots,
|
|
19
27
|
} from "./TileCard";
|
|
20
28
|
|
|
29
|
+
const textSourceTile = (result: string) =>
|
|
30
|
+
dropValueUrlTags(promoteMeasureRowToKpis(result));
|
|
31
|
+
|
|
21
32
|
export interface DashboardTileProps {
|
|
22
33
|
environmentName: string;
|
|
23
34
|
packageName: string;
|
|
@@ -45,6 +56,8 @@ export interface DashboardTileProps {
|
|
|
45
56
|
* does.
|
|
46
57
|
*/
|
|
47
58
|
givens: Map<string, GivenValue>;
|
|
59
|
+
/** Givens the host sets with no control, which may be lists; narrowed by `givenNames` like `givens`. */
|
|
60
|
+
hostGivens?: Readonly<Record<string, HostGivenValue>>;
|
|
48
61
|
/** Declared type per given name, which decides how a value is encoded. */
|
|
49
62
|
declaredTypes: ReadonlyMap<string, string | undefined>;
|
|
50
63
|
/**
|
|
@@ -66,6 +79,14 @@ export interface DashboardTileProps {
|
|
|
66
79
|
chrome?: TileChrome;
|
|
67
80
|
/** Labels of the page's filters this tile ignores, shown as a warning chip. */
|
|
68
81
|
ignoredFilters?: readonly string[];
|
|
82
|
+
/**
|
|
83
|
+
* Text-source mode: the document's definitions, sent ahead of the tile's
|
|
84
|
+
* `run:` so the tile runs as the viewer's own text. Absent, the tile runs
|
|
85
|
+
* the model's view by expression as it always has.
|
|
86
|
+
*/
|
|
87
|
+
preamble?: string;
|
|
88
|
+
/** The server marked this tile unreadable for the viewer: nothing is run. */
|
|
89
|
+
restricted?: boolean;
|
|
69
90
|
}
|
|
70
91
|
|
|
71
92
|
/**
|
|
@@ -105,6 +126,7 @@ export function DashboardTile({
|
|
|
105
126
|
heading,
|
|
106
127
|
borderless,
|
|
107
128
|
givens,
|
|
129
|
+
hostGivens,
|
|
108
130
|
declaredTypes,
|
|
109
131
|
givenNames,
|
|
110
132
|
height,
|
|
@@ -113,24 +135,47 @@ export function DashboardTile({
|
|
|
113
135
|
onExplore,
|
|
114
136
|
chrome = "card",
|
|
115
137
|
ignoredFilters,
|
|
138
|
+
preamble,
|
|
139
|
+
restricted,
|
|
116
140
|
}: DashboardTileProps) {
|
|
117
141
|
const { theme } = usePublisherTheme();
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
142
|
+
// A tile far below the fold waits to be scrolled near before it runs: its
|
|
143
|
+
// query is billed by the warehouse whether or not anyone ever sees it. The
|
|
144
|
+
// card holds its minimum height meanwhile, so the grid barely moves when it
|
|
145
|
+
// fills.
|
|
146
|
+
const [cardRef, nearViewport] = useNearViewport<HTMLDivElement>();
|
|
147
|
+
const state = useQueryResult(
|
|
148
|
+
{
|
|
149
|
+
environmentName,
|
|
150
|
+
packageName,
|
|
151
|
+
modelPath,
|
|
152
|
+
versionId,
|
|
153
|
+
queryName,
|
|
154
|
+
query:
|
|
155
|
+
tile !== undefined
|
|
156
|
+
? withPreamble(
|
|
157
|
+
preamble ?? "",
|
|
158
|
+
`${annotation ? `${annotation}\n` : ""}run: ${tile}`,
|
|
159
|
+
)
|
|
160
|
+
: undefined,
|
|
161
|
+
// Narrowed to the givens this tile references: see `givenNames`.
|
|
162
|
+
givens: withHostGivens(
|
|
163
|
+
givensToRequest(givens, declaredTypes, givenNames),
|
|
164
|
+
hostGivens,
|
|
165
|
+
givenNames,
|
|
166
|
+
),
|
|
167
|
+
},
|
|
168
|
+
// Restricted tiles never run; the rest wait to come near the viewport.
|
|
169
|
+
{ enabled: nearViewport && restricted !== true },
|
|
170
|
+
);
|
|
171
|
+
// A 403 is the viewer's access, which only text-source mode runs as them.
|
|
172
|
+
const noAccess =
|
|
173
|
+
restricted === true ||
|
|
174
|
+
(preamble !== undefined && state.isError && isForbidden(state.error));
|
|
131
175
|
|
|
132
176
|
return (
|
|
133
177
|
<TileCard
|
|
178
|
+
cardRef={cardRef}
|
|
134
179
|
borderless={borderless}
|
|
135
180
|
chrome={chrome}
|
|
136
181
|
sx={{
|
|
@@ -141,7 +186,9 @@ export function DashboardTile({
|
|
|
141
186
|
// the title on every card at once.
|
|
142
187
|
"& .publisher-tile-explore": {
|
|
143
188
|
opacity: 0,
|
|
144
|
-
transition:
|
|
189
|
+
transition: `opacity ${MOTION_FAST}`,
|
|
190
|
+
...reducedMotionSx,
|
|
191
|
+
...visibleWithoutHoverSx,
|
|
145
192
|
},
|
|
146
193
|
"&:hover .publisher-tile-explore, & .publisher-tile-explore:focus-visible":
|
|
147
194
|
{ opacity: 1 },
|
|
@@ -173,20 +220,37 @@ export function DashboardTile({
|
|
|
173
220
|
/>
|
|
174
221
|
)}
|
|
175
222
|
{ignoredFilters && <TileFilterTag ignored={ignoredFilters} />}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
223
|
+
{noAccess ? (
|
|
224
|
+
<Box sx={{ p: 2 }}>
|
|
225
|
+
<Typography variant="body2" role="status" color="text.secondary">
|
|
226
|
+
{RESTRICTED_NOTICE}
|
|
227
|
+
</Typography>
|
|
228
|
+
</Box>
|
|
229
|
+
) : (
|
|
230
|
+
<ResultPanel
|
|
231
|
+
fill
|
|
232
|
+
state={state}
|
|
233
|
+
context={tile ?? queryName ?? modelPath}
|
|
234
|
+
maxHeight={height}
|
|
235
|
+
maxResultSize={maxResultSize}
|
|
236
|
+
drill={drill}
|
|
237
|
+
// A composite tile that is one row of measures draws as KPI cards,
|
|
238
|
+
// the way Malloyyo splices the same tile into its grid, rather than
|
|
239
|
+
// as a one-row table. Composite only: the single-query form is one
|
|
240
|
+
// result the renderer lays out from the query's own tags, and its
|
|
241
|
+
// aggregates are already tiles.
|
|
242
|
+
transform={
|
|
243
|
+
// A document held as text draws no value-to-URL or markup tags.
|
|
244
|
+
preamble !== undefined
|
|
245
|
+
? tile !== undefined
|
|
246
|
+
? textSourceTile
|
|
247
|
+
: dropValueUrlTags
|
|
248
|
+
: tile !== undefined
|
|
249
|
+
? promoteMeasureRowToKpis
|
|
250
|
+
: undefined
|
|
251
|
+
}
|
|
252
|
+
/>
|
|
253
|
+
)}
|
|
190
254
|
</TileCard>
|
|
191
255
|
);
|
|
192
256
|
}
|