@malloy-publisher/sdk 0.9.10 → 0.9.12
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-Dp1Qdajz.es.js → RenderedResult-CDiXJAh9.es.js} +102 -102
- package/dist/RenderedResult-De51QvsZ.cjs.js +153 -0
- package/dist/ServerProvider-DKrBcXL7.cjs.js +1 -0
- package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-RvKSbvnL.es.js} +622 -587
- package/dist/builder/index.cjs.js +78 -130
- package/dist/builder/index.es.js +7493 -6769
- package/dist/builder-entry.d.ts +3 -0
- package/dist/client/api.d.ts +72 -23
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +9 -1
- package/dist/components/Connections/common.d.ts +11 -3
- package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
- package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
- package/dist/components/Dashboard/DashboardView.d.ts +22 -34
- package/dist/components/Dashboard/TileCard.d.ts +10 -3
- package/dist/components/Dashboard/useStuck.d.ts +15 -7
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
- package/dist/components/Package/PackageProblems.d.ts +14 -0
- package/dist/components/RemoveBadge.d.ts +40 -0
- package/dist/components/Report/Report.d.ts +13 -4
- package/dist/components/Report/ReportPage.d.ts +60 -0
- package/dist/components/Report/layoutRules.d.ts +32 -0
- package/dist/components/Report/reportQuery.d.ts +30 -0
- package/dist/components/Report/telemetry.d.ts +0 -2
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
- package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
- package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
- package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
- package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
- package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -8
- package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
- package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
- package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
- package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
- package/dist/components/ReportBuilder/TileMenu.d.ts +12 -9
- package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
- package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
- package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
- package/dist/components/ReportBuilder/catalog.d.ts +2 -4
- package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
- package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
- package/dist/components/ReportBuilder/preview.d.ts +17 -2
- package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
- package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
- package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
- package/dist/components/ReportBuilder/sortable.d.ts +4 -3
- package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
- package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
- package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
- package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
- package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
- package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
- package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
- package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
- package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
- package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
- package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
- package/dist/components/ServerProvider.d.ts +9 -0
- package/dist/components/controlTokens.d.ts +45 -0
- package/dist/components/drill/markDrillableCells.d.ts +1 -1
- package/dist/components/given/FilterButton.d.ts +35 -0
- package/dist/components/given/GivensPanel.d.ts +2 -1
- package/dist/components/given/filterEditing.d.ts +54 -0
- package/dist/components/given/filterSummary.d.ts +9 -0
- package/dist/components/given/paramCodec.d.ts +11 -0
- package/dist/components/given/required.d.ts +25 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/legacy/index.d.ts +1 -1
- package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
- package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
- package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
- package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
- package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
- package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
- package/dist/components/styles.d.ts +0 -2
- package/dist/hooks/useQueryResult.d.ts +7 -0
- package/dist/index.cjs.js +16 -19
- package/dist/index.es.js +8418 -7722
- package/dist/theme/ThemeContext.d.ts +8 -1
- package/dist/theme/classes.d.ts +49 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/ui.d.ts +75 -0
- package/dist/{useCompiledDocument-BMPDvdFx.es.js → useCompiledDocument-Bf4RSfB6.es.js} +8669 -7851
- package/dist/useCompiledDocument-XsQz85Ri.cjs.js +141 -0
- package/package.json +2 -2
- package/src/builder-entry.ts +9 -0
- package/src/components/AppDialog.tsx +23 -0
- package/src/components/Connections/AddConnectionDialog.tsx +34 -2
- package/src/components/Connections/EditConnectionDialog.tsx +45 -3
- package/src/components/Connections/common.spec.ts +69 -0
- package/src/components/Connections/common.ts +132 -0
- package/src/components/Dashboard/DashboardGrid.tsx +39 -17
- package/src/components/Dashboard/DashboardTile.tsx +19 -2
- package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
- package/src/components/Dashboard/DashboardView.tsx +137 -155
- package/src/components/Dashboard/RowsDialog.tsx +1 -2
- package/src/components/Dashboard/TileCard.tsx +28 -10
- package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
- package/src/components/Dashboard/useStuck.ts +28 -17
- package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
- package/src/components/Environment/Connections.tsx +1 -0
- package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
- package/src/components/Package/NewDocumentDialog.tsx +383 -119
- package/src/components/Package/Package.artifacts.spec.tsx +1 -1
- package/src/components/Package/Package.create.spec.tsx +7 -6
- package/src/components/Package/Package.tsx +10 -7
- package/src/components/Package/PackageProblems.spec.tsx +41 -0
- package/src/components/Package/PackageProblems.tsx +95 -0
- package/src/components/Prose.tsx +12 -7
- package/src/components/RemoveBadge.tsx +94 -0
- package/src/components/RenderedResult/RenderedResult.tsx +5 -9
- package/src/components/RenderedResult/ResultPanel.tsx +59 -3
- package/src/components/Report/Report.spec.tsx +50 -32
- package/src/components/Report/Report.telemetry.spec.tsx +0 -45
- package/src/components/Report/Report.tsx +45 -77
- package/src/components/Report/ReportPage.tsx +168 -0
- package/src/components/Report/layoutRules.spec.ts +35 -0
- package/src/components/Report/layoutRules.ts +55 -0
- package/src/components/Report/reportQuery.ts +53 -0
- package/src/components/Report/telemetry.ts +0 -2
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
- package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
- package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
- package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -39
- package/src/components/ReportBuilder/BuilderGrid.tsx +31 -29
- package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
- package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
- package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
- package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
- package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
- package/src/components/ReportBuilder/FilterStrip.tsx +130 -151
- package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
- package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -15
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
- package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
- package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +37 -31
- package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
- package/src/components/ReportBuilder/ReportBuilder.tsx +292 -117
- package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
- package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
- package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
- package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
- package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
- package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
- package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
- package/src/components/ReportBuilder/TileFrame.tsx +212 -75
- package/src/components/ReportBuilder/TileMenu.tsx +241 -140
- package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
- package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
- package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
- package/src/components/ReportBuilder/builderControls.ts +164 -0
- package/src/components/ReportBuilder/builderReport.ts +1 -2
- package/src/components/ReportBuilder/catalog.ts +10 -26
- package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
- package/src/components/ReportBuilder/localGiven.ts +56 -0
- package/src/components/ReportBuilder/preview.spec.ts +125 -5
- package/src/components/ReportBuilder/preview.ts +60 -44
- package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
- package/src/components/ReportBuilder/readDocument.ts +14 -11
- package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
- package/src/components/ReportBuilder/readForEditor.ts +4 -26
- package/src/components/ReportBuilder/reportTag.ts +28 -7
- package/src/components/ReportBuilder/sortable.tsx +15 -7
- package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
- package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
- package/src/components/ReportBuilder/testing/inline.ts +25 -5
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
- package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
- package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
- package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
- package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
- package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
- package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
- package/src/components/ReportBuilder/useExitGuard.ts +16 -0
- package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
- package/src/components/ReportBuilder/useFilterForm.ts +5 -1
- package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
- package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
- package/src/components/ReportBuilder/useReportDraft.ts +292 -0
- package/src/components/ReportBuilder/useReportEditor.ts +3 -12
- package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
- package/src/components/ReportBuilder/useTileEditing.ts +43 -12
- package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
- package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
- package/src/components/ReportBuilder/widthLabel.ts +26 -0
- package/src/components/ServerProvider.tsx +11 -0
- package/src/components/controlTokens.ts +47 -0
- package/src/components/drill/markDrillableCells.ts +2 -1
- package/src/components/given/FilterButton.spec.tsx +143 -0
- package/src/components/given/FilterButton.tsx +478 -0
- package/src/components/given/GivenInput.spec.tsx +47 -0
- package/src/components/given/GivenInput.tsx +20 -2
- package/src/components/given/GivensPanel.spec.tsx +11 -3
- package/src/components/given/GivensPanel.tsx +45 -44
- package/src/components/given/filterEditing.ts +60 -0
- package/src/components/given/filterSummary.spec.ts +108 -0
- package/src/components/given/filterSummary.ts +109 -0
- package/src/components/given/paramCodec.ts +1 -1
- package/src/components/given/required.spec.ts +60 -0
- package/src/components/given/required.ts +78 -0
- package/src/components/index.ts +9 -0
- package/src/components/legacy/Dashboard.spec.tsx +3 -1
- package/src/components/legacy/index.ts +1 -1
- package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
- package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
- package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
- package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
- package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
- package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
- package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
- package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
- package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
- package/src/components/legacy/malloynb/cellKind.ts +24 -0
- package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
- package/src/components/styles.ts +0 -18
- package/src/hooks/useGivensState.ts +7 -3
- package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
- package/src/hooks/useQueryResult.ts +26 -1
- package/src/theme/ThemeContext.tsx +21 -1
- package/src/theme/classes.ts +52 -0
- package/src/theme/index.ts +8 -0
- package/src/theme/resolveTheme.ts +3 -0
- package/src/theme/types.ts +7 -0
- package/src/theme/ui.spec.tsx +91 -0
- package/src/theme/ui.ts +115 -0
- package/dist/RenderedResult-BcgYjkZ0.cjs.js +0 -153
- package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
- package/dist/components/Notebook/cellKind.d.ts +0 -20
- package/dist/components/Report/LinearReport.d.ts +0 -18
- package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
- package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
- package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
- package/dist/useCompiledDocument-UY28ITET.cjs.js +0 -141
- package/src/components/Notebook/cellKind.spec.ts +0 -199
- package/src/components/Notebook/cellKind.ts +0 -74
- package/src/components/Report/LinearReport.tsx +0 -71
- package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
- package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
- package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
- package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
- package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
- package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
- package/src/components/legacy/Notebook.served.spec.tsx +0 -183
- /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.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.12",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"build": "bun generate-api-types && bunx vite build",
|
|
76
76
|
"postbuild": "cp ../../node_modules/@malloydata/malloy-explorer/dist/malloy-explorer.css ./dist/malloy-explorer.css && echo '/* SDK Styles */\n@import \"./malloy-explorer.css\";' > ./dist/styles.css",
|
|
77
77
|
"test": "bun test",
|
|
78
|
-
"test:tz": "bun test ./src/components/given/GivenInput.spec.tsx ./src/components/given/paramCodec.spec.ts ./src/utils/malloyLiteral.spec.ts ./src/components/drill/resolveDrill.spec.ts ./src/components/ReportBuilder/preview.spec.ts ./src/components/Materializations/cron.spec.ts ./src/components/Materializations/utils.spec.ts",
|
|
78
|
+
"test:tz": "bun test ./src/components/given/GivenInput.spec.tsx ./src/components/given/filterSummary.spec.ts ./src/components/given/paramCodec.spec.ts ./src/utils/malloyLiteral.spec.ts ./src/components/drill/resolveDrill.spec.ts ./src/components/ReportBuilder/preview.spec.ts ./src/components/Materializations/cron.spec.ts ./src/components/Materializations/utils.spec.ts",
|
|
79
79
|
"lint": "bunx eslint ./src ./test --fix",
|
|
80
80
|
"format": "bunx prettier --write --parser typescript '**/*.{ts,tsx}'",
|
|
81
81
|
"analyze": "bunx vite-bundle-visualizer",
|
package/src/builder-entry.ts
CHANGED
|
@@ -22,6 +22,15 @@ if (typeof globalThis.process === "undefined") {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export { ReportBuilder } from "./components/ReportBuilder/ReportBuilder";
|
|
25
|
+
export type { FixedFilter } from "./components/ReportBuilder/FilterStrip";
|
|
26
|
+
export {
|
|
27
|
+
BuilderBar,
|
|
28
|
+
type BuilderBarProps,
|
|
29
|
+
} from "./components/ReportBuilder/BuilderBar";
|
|
30
|
+
export type {
|
|
31
|
+
BuilderControls,
|
|
32
|
+
BuilderControlsHandler,
|
|
33
|
+
} from "./components/ReportBuilder/builderControls";
|
|
25
34
|
export type {
|
|
26
35
|
BuilderGiven,
|
|
27
36
|
ReportBuilderProps,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import { usePublisherTheme } from "../theme/ThemeContext";
|
|
4
5
|
import CloseIcon from "@mui/icons-material/Close";
|
|
5
6
|
import {
|
|
6
7
|
Dialog,
|
|
@@ -37,6 +38,8 @@ export function AppDialog({
|
|
|
37
38
|
maxWidth = "sm",
|
|
38
39
|
showClose = false,
|
|
39
40
|
actions,
|
|
41
|
+
initialFocus,
|
|
42
|
+
className,
|
|
40
43
|
children,
|
|
41
44
|
}: {
|
|
42
45
|
open: boolean;
|
|
@@ -50,9 +53,18 @@ export function AppDialog({
|
|
|
50
53
|
showClose?: boolean;
|
|
51
54
|
/** The buttons, in order. Cancel first, the thing it does last. */
|
|
52
55
|
actions?: React.ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* The control to start in. Focused once the window has opened: a child's
|
|
58
|
+
* own `autoFocus` loses to the focus trap, which takes focus to the
|
|
59
|
+
* window's container as it opens, after the child has mounted.
|
|
60
|
+
*/
|
|
61
|
+
initialFocus?: React.RefObject<HTMLElement | null>;
|
|
62
|
+
/** Classes on the window's root, for a host to style it by. */
|
|
63
|
+
className?: string;
|
|
53
64
|
children: React.ReactNode;
|
|
54
65
|
}) {
|
|
55
66
|
const titleId = useId();
|
|
67
|
+
const ui = usePublisherTheme().theme.ui;
|
|
56
68
|
return (
|
|
57
69
|
<Dialog
|
|
58
70
|
open={open}
|
|
@@ -60,6 +72,17 @@ export function AppDialog({
|
|
|
60
72
|
maxWidth={maxWidth}
|
|
61
73
|
fullWidth
|
|
62
74
|
aria-labelledby={titleId}
|
|
75
|
+
{...(className ? { className } : {})}
|
|
76
|
+
// The host's dialog radius (`ui.radius.dialog`), as every other
|
|
77
|
+
// corner on a report surface takes its token.
|
|
78
|
+
PaperProps={{ sx: { borderRadius: ui.radius.dialog } }}
|
|
79
|
+
{...(initialFocus
|
|
80
|
+
? {
|
|
81
|
+
TransitionProps: {
|
|
82
|
+
onEntered: () => initialFocus.current?.focus(),
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
: {})}
|
|
63
86
|
>
|
|
64
87
|
<DialogTitle
|
|
65
88
|
id={titleId}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
attachedDatabaseConnectionFieldName,
|
|
26
26
|
attributesFieldName,
|
|
27
27
|
connectionFieldsByType,
|
|
28
|
+
typedConnectionConfig,
|
|
28
29
|
gcsAttachedDatabaseFields,
|
|
29
30
|
getAttachedDatabaseFields,
|
|
30
31
|
s3AttachedDatabaseFields,
|
|
@@ -345,6 +346,22 @@ export default function AddConnectionDialog({
|
|
|
345
346
|
);
|
|
346
347
|
}
|
|
347
348
|
}
|
|
349
|
+
} else if (type === "sqlserver") {
|
|
350
|
+
const requiredFields = ["server", "database", "user", "password"];
|
|
351
|
+
// A named instance is located through SQL Browser and the port is
|
|
352
|
+
// then not used; otherwise the driver needs one.
|
|
353
|
+
if (!connectionConfig.instanceName && !connectionConfig.port) {
|
|
354
|
+
throw new Error(
|
|
355
|
+
"Port is required unless an instance name is given",
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
for (const fieldName of requiredFields) {
|
|
359
|
+
if (!connectionConfig[fieldName]) {
|
|
360
|
+
throw new Error(
|
|
361
|
+
`${fields.find((f) => f.name === fieldName)?.label || fieldName} is required`,
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
348
365
|
} else if (type === "motherduck") {
|
|
349
366
|
if (!connectionConfig.accessToken) {
|
|
350
367
|
throw new Error("Access Token is required");
|
|
@@ -369,7 +386,10 @@ export default function AddConnectionDialog({
|
|
|
369
386
|
connectionPayload = {
|
|
370
387
|
name,
|
|
371
388
|
type,
|
|
372
|
-
[attributesFieldName[type]]:
|
|
389
|
+
[attributesFieldName[type]]: typedConnectionConfig(
|
|
390
|
+
type,
|
|
391
|
+
connectionConfig,
|
|
392
|
+
),
|
|
373
393
|
} satisfies Connection;
|
|
374
394
|
}
|
|
375
395
|
|
|
@@ -814,7 +834,19 @@ export default function AddConnectionDialog({
|
|
|
814
834
|
fullWidth
|
|
815
835
|
size="small"
|
|
816
836
|
required={field.required}
|
|
817
|
-
|
|
837
|
+
select={!!field.selectOptions}
|
|
838
|
+
defaultValue={
|
|
839
|
+
field.selectOptions
|
|
840
|
+
? field.selectOptions[0]?.value
|
|
841
|
+
: undefined
|
|
842
|
+
}
|
|
843
|
+
>
|
|
844
|
+
{field.selectOptions?.map((option) => (
|
|
845
|
+
<MenuItem key={option.value} value={option.value}>
|
|
846
|
+
{option.label}
|
|
847
|
+
</MenuItem>
|
|
848
|
+
))}
|
|
849
|
+
</TextField>
|
|
818
850
|
))
|
|
819
851
|
)}
|
|
820
852
|
</Stack>
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
attachedDatabaseConnectionFieldName,
|
|
27
27
|
attributesFieldName,
|
|
28
28
|
connectionFieldsByType,
|
|
29
|
+
typedConnectionConfig,
|
|
29
30
|
gcsAttachedDatabaseFields,
|
|
30
31
|
getAttachedDatabaseFields,
|
|
31
32
|
s3AttachedDatabaseFields,
|
|
@@ -429,6 +430,22 @@ export default function EditConnectionDialog({
|
|
|
429
430
|
);
|
|
430
431
|
}
|
|
431
432
|
}
|
|
433
|
+
} else if (type === "sqlserver") {
|
|
434
|
+
const requiredFields = ["server", "database", "user"];
|
|
435
|
+
// A named instance is located through SQL Browser and the port is
|
|
436
|
+
// then not used; otherwise the driver needs one.
|
|
437
|
+
if (!connectionConfig.instanceName && !connectionConfig.port) {
|
|
438
|
+
throw new Error(
|
|
439
|
+
"Port is required unless an instance name is given",
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
for (const fieldName of requiredFields) {
|
|
443
|
+
if (!connectionConfig[fieldName]) {
|
|
444
|
+
throw new Error(
|
|
445
|
+
`${fields.find((f) => f.name === fieldName)?.label || fieldName} is required`,
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
432
449
|
} else if (type === "databricks") {
|
|
433
450
|
if (!connectionConfig.host) {
|
|
434
451
|
throw new Error("Host is required");
|
|
@@ -441,7 +458,10 @@ export default function EditConnectionDialog({
|
|
|
441
458
|
connectionPayload = {
|
|
442
459
|
name,
|
|
443
460
|
type,
|
|
444
|
-
[attributesFieldName[type]]:
|
|
461
|
+
[attributesFieldName[type]]: typedConnectionConfig(
|
|
462
|
+
type,
|
|
463
|
+
connectionConfig,
|
|
464
|
+
),
|
|
445
465
|
} satisfies Connection;
|
|
446
466
|
}
|
|
447
467
|
|
|
@@ -987,6 +1007,14 @@ export default function EditConnectionDialog({
|
|
|
987
1007
|
const isStored = withheldFields.has(
|
|
988
1008
|
`${attributesFieldName[type] ?? ""}.${field.name}`,
|
|
989
1009
|
);
|
|
1010
|
+
// A select shows the stored value as the option it
|
|
1011
|
+
// names (a boolean reads back as `true`/`false`), and
|
|
1012
|
+
// the first option when nothing is stored.
|
|
1013
|
+
const selectValue = field.selectOptions
|
|
1014
|
+
? existingValue === "" || existingValue === undefined
|
|
1015
|
+
? field.selectOptions[0]?.value
|
|
1016
|
+
: String(existingValue)
|
|
1017
|
+
: undefined;
|
|
990
1018
|
return (
|
|
991
1019
|
<TextField
|
|
992
1020
|
key={field.name}
|
|
@@ -1001,7 +1029,12 @@ export default function EditConnectionDialog({
|
|
|
1001
1029
|
!isPasswordField &&
|
|
1002
1030
|
!existingValue
|
|
1003
1031
|
}
|
|
1004
|
-
|
|
1032
|
+
select={!!field.selectOptions}
|
|
1033
|
+
defaultValue={
|
|
1034
|
+
field.selectOptions
|
|
1035
|
+
? selectValue
|
|
1036
|
+
: existingValue
|
|
1037
|
+
}
|
|
1005
1038
|
placeholder={
|
|
1006
1039
|
isStored
|
|
1007
1040
|
? "Leave empty to keep existing"
|
|
@@ -1014,7 +1047,16 @@ export default function EditConnectionDialog({
|
|
|
1014
1047
|
: "No value stored."
|
|
1015
1048
|
: undefined
|
|
1016
1049
|
}
|
|
1017
|
-
|
|
1050
|
+
>
|
|
1051
|
+
{field.selectOptions?.map((option) => (
|
|
1052
|
+
<MenuItem
|
|
1053
|
+
key={option.value}
|
|
1054
|
+
value={option.value}
|
|
1055
|
+
>
|
|
1056
|
+
{option.label}
|
|
1057
|
+
</MenuItem>
|
|
1058
|
+
))}
|
|
1059
|
+
</TextField>
|
|
1018
1060
|
);
|
|
1019
1061
|
})
|
|
1020
1062
|
)}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { typedConnectionConfig } from "./common";
|
|
6
|
+
|
|
7
|
+
describe("typedConnectionConfig", () => {
|
|
8
|
+
it("sends a SQL Server port as an integer and its TLS switches as booleans", () => {
|
|
9
|
+
// FormData yields strings; the connector reads port as a number and
|
|
10
|
+
// encrypt/trustServerCertificate as booleans, and drops a string.
|
|
11
|
+
expect(
|
|
12
|
+
typedConnectionConfig("sqlserver", {
|
|
13
|
+
server: "db.example",
|
|
14
|
+
port: "1433",
|
|
15
|
+
encrypt: "true",
|
|
16
|
+
trustServerCertificate: "false",
|
|
17
|
+
instanceName: "SQLEXPRESS",
|
|
18
|
+
}),
|
|
19
|
+
).toEqual({
|
|
20
|
+
server: "db.example",
|
|
21
|
+
port: 1433,
|
|
22
|
+
encrypt: true,
|
|
23
|
+
trustServerCertificate: false,
|
|
24
|
+
instanceName: "SQLEXPRESS",
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("leaves out a blank optional name rather than storing an empty one", () => {
|
|
29
|
+
// The edit form submits "" for an untouched optional field; stored, the
|
|
30
|
+
// connector would read a defined instanceName and drop the port.
|
|
31
|
+
expect(
|
|
32
|
+
typedConnectionConfig("sqlserver", {
|
|
33
|
+
server: "db.example",
|
|
34
|
+
port: "1434",
|
|
35
|
+
hostNameInCertificate: "",
|
|
36
|
+
instanceName: "",
|
|
37
|
+
}),
|
|
38
|
+
).toEqual({ server: "db.example", port: 1434 });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("leaves out a blank port rather than sending 0", () => {
|
|
42
|
+
// A named instance needs no port; Number("") would send 0.
|
|
43
|
+
expect(
|
|
44
|
+
typedConnectionConfig("sqlserver", {
|
|
45
|
+
server: "db.example",
|
|
46
|
+
port: "",
|
|
47
|
+
instanceName: "SQLEXPRESS",
|
|
48
|
+
}),
|
|
49
|
+
).toEqual({ server: "db.example", instanceName: "SQLEXPRESS" });
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("leaves a value that does not parse for the server to name", () => {
|
|
53
|
+
expect(typedConnectionConfig("sqlserver", { port: "14x3" })).toEqual({
|
|
54
|
+
port: "14x3",
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("leaves out a field the form did not collect", () => {
|
|
59
|
+
// An edit that leaves encrypt untouched must not send `encrypt: false`.
|
|
60
|
+
expect(typedConnectionConfig("sqlserver", { server: "x" })).toEqual({
|
|
61
|
+
server: "x",
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("passes a type with no typed fields through unchanged", () => {
|
|
66
|
+
const config = { host: "h", port: "3306" };
|
|
67
|
+
expect(typedConnectionConfig("mysql", config)).toBe(config);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
PostgresConnection,
|
|
15
15
|
S3Connection,
|
|
16
16
|
SnowflakeConnection,
|
|
17
|
+
SqlserverConnection,
|
|
17
18
|
TrinoConnection,
|
|
18
19
|
} from "../../client/api";
|
|
19
20
|
|
|
@@ -25,6 +26,7 @@ type ConnectionField = {
|
|
|
25
26
|
TrinoConnection &
|
|
26
27
|
DatabricksConnection &
|
|
27
28
|
MysqlConnection &
|
|
29
|
+
SqlserverConnection &
|
|
28
30
|
MotherDuckConnection &
|
|
29
31
|
S3Connection &
|
|
30
32
|
GCSConnection &
|
|
@@ -298,6 +300,70 @@ export const connectionFieldsByType: Record<
|
|
|
298
300
|
required: true, // Always required
|
|
299
301
|
},
|
|
300
302
|
],
|
|
303
|
+
sqlserver: [
|
|
304
|
+
{
|
|
305
|
+
label: "Server",
|
|
306
|
+
name: "server",
|
|
307
|
+
type: "text",
|
|
308
|
+
required: true, // Always required
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
label: "Port",
|
|
312
|
+
name: "port",
|
|
313
|
+
type: "number",
|
|
314
|
+
required: false, // Required unless an instance name locates the server
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
label: "Database",
|
|
318
|
+
name: "database",
|
|
319
|
+
type: "text",
|
|
320
|
+
required: true, // Always required
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
label: "User",
|
|
324
|
+
name: "user",
|
|
325
|
+
type: "text",
|
|
326
|
+
required: true, // Always required
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
label: "Password",
|
|
330
|
+
name: "password",
|
|
331
|
+
type: "password",
|
|
332
|
+
required: true, // Always required
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
label: "Encrypt",
|
|
336
|
+
name: "encrypt",
|
|
337
|
+
type: "text",
|
|
338
|
+
required: false,
|
|
339
|
+
selectOptions: [
|
|
340
|
+
{ label: "Yes", value: "true" },
|
|
341
|
+
{ label: "No", value: "false" },
|
|
342
|
+
],
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
label: "Trust server certificate",
|
|
346
|
+
name: "trustServerCertificate",
|
|
347
|
+
type: "text",
|
|
348
|
+
required: false,
|
|
349
|
+
selectOptions: [
|
|
350
|
+
{ label: "No", value: "false" },
|
|
351
|
+
{ label: "Yes", value: "true" },
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
label: "Host name in certificate",
|
|
356
|
+
name: "hostNameInCertificate",
|
|
357
|
+
type: "text",
|
|
358
|
+
required: false,
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
label: "Instance name",
|
|
362
|
+
name: "instanceName",
|
|
363
|
+
type: "text",
|
|
364
|
+
required: false,
|
|
365
|
+
},
|
|
366
|
+
],
|
|
301
367
|
// DuckDB connections use attached databases configured via duckdbConnection.attachedDatabases
|
|
302
368
|
duckdb: [],
|
|
303
369
|
motherduck: [
|
|
@@ -328,12 +394,78 @@ export const attributesFieldName: Record<ConnectionTypeEnum, string> = {
|
|
|
328
394
|
trino: "trinoConnection",
|
|
329
395
|
databricks: "databricksConnection",
|
|
330
396
|
mysql: "mysqlConnection",
|
|
397
|
+
sqlserver: "sqlserverConnection",
|
|
331
398
|
duckdb: "duckdbConnection",
|
|
332
399
|
motherduck: "motherduckConnection",
|
|
333
400
|
ducklake: "ducklakeConnection",
|
|
334
401
|
publisher: "publisherConnection",
|
|
335
402
|
};
|
|
336
403
|
|
|
404
|
+
/**
|
|
405
|
+
* Fields the form collects as text that the API declares as another type.
|
|
406
|
+
* `FormData` yields strings, and the server passes a connection's fields to
|
|
407
|
+
* its driver unchanged, so a port of "1433" or an encrypt of "true" would
|
|
408
|
+
* reach a driver that reads only a number or a boolean. Keyed by connection
|
|
409
|
+
* type; a type absent here sends what the form collected.
|
|
410
|
+
*/
|
|
411
|
+
const TYPED_FIELDS: Partial<
|
|
412
|
+
Record<ConnectionTypeEnum, Record<string, "integer" | "boolean">>
|
|
413
|
+
> = {
|
|
414
|
+
sqlserver: {
|
|
415
|
+
port: "integer",
|
|
416
|
+
encrypt: "boolean",
|
|
417
|
+
trustServerCertificate: "boolean",
|
|
418
|
+
},
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Optional text fields the edit form submits as "" when left empty, which
|
|
423
|
+
* the server must not store as a value: the SQL Server connector treats a
|
|
424
|
+
* defined `instanceName` as "locate through SQL Browser" and drops the port,
|
|
425
|
+
* and a defined `hostNameInCertificate` as the name to check the certificate
|
|
426
|
+
* against. An empty one is left out of the payload instead.
|
|
427
|
+
*/
|
|
428
|
+
const BLANK_MEANS_UNSET: Partial<Record<ConnectionTypeEnum, string[]>> = {
|
|
429
|
+
sqlserver: ["hostNameInCertificate", "instanceName"],
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* The connection config to send, with each field the API types as an integer
|
|
434
|
+
* or a boolean converted from the form's string, and each optional field in
|
|
435
|
+
* {@link BLANK_MEANS_UNSET} left out when blank. A value that does not parse
|
|
436
|
+
* is sent as collected, so the server's validation names it rather than a
|
|
437
|
+
* silent `NaN`.
|
|
438
|
+
*/
|
|
439
|
+
export function typedConnectionConfig(
|
|
440
|
+
type: ConnectionTypeEnum,
|
|
441
|
+
config: Record<string, string>,
|
|
442
|
+
): Record<string, unknown> {
|
|
443
|
+
const typed = TYPED_FIELDS[type];
|
|
444
|
+
const blankMeansUnset = BLANK_MEANS_UNSET[type];
|
|
445
|
+
if (!typed && !blankMeansUnset) return config;
|
|
446
|
+
const out: Record<string, unknown> = { ...config };
|
|
447
|
+
for (const name of blankMeansUnset ?? []) {
|
|
448
|
+
if (out[name] === "") delete out[name];
|
|
449
|
+
}
|
|
450
|
+
for (const [name, kind] of Object.entries(typed ?? {})) {
|
|
451
|
+
const value = config[name];
|
|
452
|
+
if (value === undefined) continue;
|
|
453
|
+
// The edit form submits "" for a field left empty, and Number("") is
|
|
454
|
+
// 0, which the server would read as a port.
|
|
455
|
+
if (value === "") {
|
|
456
|
+
delete out[name];
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (kind === "integer") {
|
|
460
|
+
const n = Number(value);
|
|
461
|
+
if (Number.isInteger(n)) out[name] = n;
|
|
462
|
+
} else if (value === "true" || value === "false") {
|
|
463
|
+
out[name] = value === "true";
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return out;
|
|
467
|
+
}
|
|
468
|
+
|
|
337
469
|
/**
|
|
338
470
|
* Connection types the Add/Edit dialogs offer as creatable. `publisher` proxy
|
|
339
471
|
* connections are configured in publisher.config.json rather than through the
|
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { Box } from "@mui/material";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
useEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
type RefObject,
|
|
11
|
+
} from "react";
|
|
6
12
|
|
|
7
13
|
/** Grid width when the dashboard declares no `# dashboard { columns=N }`. */
|
|
8
14
|
export const DEFAULT_COLUMNS = 2;
|
|
@@ -24,22 +30,10 @@ export const nudgedSpan = (current: number, delta: 1 | -1, columns: number) =>
|
|
|
24
30
|
export const GRID_GAP_PX = 16;
|
|
25
31
|
|
|
26
32
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
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.
|
|
33
|
+
* How far a bare (uncarded) tile's selection ring sits from its prose: half the
|
|
34
|
+
* {@link GRID_GAP_PX} between tiles, so a ring never reaches into the next tile.
|
|
31
35
|
*/
|
|
32
|
-
export const
|
|
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;
|
|
36
|
+
export const BARE_RING_OFFSET_PX = GRID_GAP_PX / 2;
|
|
43
37
|
|
|
44
38
|
/**
|
|
45
39
|
* The `grid-column` one tile occupies: its `# colspan`, and a `# break` forcing
|
|
@@ -58,6 +52,34 @@ export function tileGridColumn(
|
|
|
58
52
|
return tile.break ? `1 / span ${span}` : `span ${span}`;
|
|
59
53
|
}
|
|
60
54
|
|
|
55
|
+
/** Narrowest a tile that sets no `colspan` is drawn, by the reader and the builder alike. */
|
|
56
|
+
export const MIN_TILE_PX = 240;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The span a tile with no `# colspan` is drawn at in the grid inside `box`:
|
|
60
|
+
* {@link defaultTileSpan} on its measured width. For a surface that lays the
|
|
61
|
+
* grid out itself (the builder, whose width handle and row arithmetic need
|
|
62
|
+
* the span a tile is drawn at, not the one it writes).
|
|
63
|
+
*/
|
|
64
|
+
export function useDefaultTileSpan(
|
|
65
|
+
box: RefObject<HTMLElement | null>,
|
|
66
|
+
columns: number,
|
|
67
|
+
minTilePx: number = MIN_TILE_PX,
|
|
68
|
+
): number {
|
|
69
|
+
const [width, setWidth] = useState(0);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const node = box.current;
|
|
72
|
+
if (!node || typeof ResizeObserver === "undefined") return;
|
|
73
|
+
setWidth(node.getBoundingClientRect().width);
|
|
74
|
+
const observer = new ResizeObserver(([entry]) =>
|
|
75
|
+
setWidth(entry?.contentRect.width ?? 0),
|
|
76
|
+
);
|
|
77
|
+
observer.observe(node);
|
|
78
|
+
return () => observer.disconnect();
|
|
79
|
+
}, [box]);
|
|
80
|
+
return defaultTileSpan(columns, width, minTilePx);
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
/**
|
|
62
84
|
* Columns a tile with no `# colspan` spans so it is at least `minTilePx` wide.
|
|
63
85
|
*
|
|
@@ -131,7 +153,7 @@ export function DashboardGrid<T extends GridTile>({
|
|
|
131
153
|
* builder assumes an unset colspan is one column.
|
|
132
154
|
*/
|
|
133
155
|
minTilePx?: number;
|
|
134
|
-
/** The space between rows
|
|
156
|
+
/** The space between rows. */
|
|
135
157
|
rowGapPx?: number;
|
|
136
158
|
}) {
|
|
137
159
|
const ref = useRef<HTMLDivElement>(null);
|
|
@@ -89,6 +89,13 @@ export interface DashboardTileProps {
|
|
|
89
89
|
preamble?: string;
|
|
90
90
|
/** The server marked this tile unreadable for the viewer: nothing is run. */
|
|
91
91
|
restricted?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Set while a required filter this tile reads has no value: what to say in
|
|
94
|
+
* place of the result ("Waiting for Recall Year."). Nothing is run, since
|
|
95
|
+
* the query would only fail with the compiler's "has no value and no
|
|
96
|
+
* default".
|
|
97
|
+
*/
|
|
98
|
+
waitingFor?: string;
|
|
92
99
|
/** Its position in the report, for the `report.query_failed` it reports. */
|
|
93
100
|
index?: number;
|
|
94
101
|
}
|
|
@@ -141,6 +148,7 @@ export function DashboardTile({
|
|
|
141
148
|
ignoredFilters,
|
|
142
149
|
preamble,
|
|
143
150
|
restricted,
|
|
151
|
+
waitingFor,
|
|
144
152
|
index,
|
|
145
153
|
}: DashboardTileProps) {
|
|
146
154
|
const { theme } = usePublisherTheme();
|
|
@@ -171,7 +179,10 @@ export function DashboardTile({
|
|
|
171
179
|
),
|
|
172
180
|
},
|
|
173
181
|
// Restricted tiles never run; the rest wait to come near the viewport.
|
|
174
|
-
{
|
|
182
|
+
{
|
|
183
|
+
enabled:
|
|
184
|
+
nearViewport && restricted !== true && waitingFor === undefined,
|
|
185
|
+
},
|
|
175
186
|
);
|
|
176
187
|
// Each failed run once: the error is drawn in place, and the report's host
|
|
177
188
|
// hears of it when one is listening.
|
|
@@ -237,7 +248,13 @@ export function DashboardTile({
|
|
|
237
248
|
/>
|
|
238
249
|
)}
|
|
239
250
|
{ignoredFilters && <TileFilterTag ignored={ignoredFilters} />}
|
|
240
|
-
{
|
|
251
|
+
{waitingFor !== undefined ? (
|
|
252
|
+
<Box sx={{ p: 2 }}>
|
|
253
|
+
<Typography variant="body2" role="status" color="text.secondary">
|
|
254
|
+
{waitingFor}
|
|
255
|
+
</Typography>
|
|
256
|
+
</Box>
|
|
257
|
+
) : noAccess ? (
|
|
241
258
|
<Box sx={{ p: 2 }}>
|
|
242
259
|
<Typography variant="body2" role="status" color="text.secondary">
|
|
243
260
|
{RESTRICTED_NOTICE}
|