@malloy-publisher/sdk 0.9.9 → 0.9.11
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-BlNoIiSi.cjs.js +153 -0
- package/dist/{RenderedResult-BHuJpdSn.es.js → RenderedResult-Cmx8sX8d.es.js} +102 -102
- package/dist/ServerProvider-BOgiW8MX.cjs.js +1 -0
- package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-azXLkk1q.es.js} +619 -586
- package/dist/builder/index.cjs.js +78 -130
- package/dist/builder/index.es.js +7440 -6727
- package/dist/builder-entry.d.ts +3 -0
- package/dist/client/api.d.ts +26 -22
- 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/Dashboard/DashboardGrid.d.ts +14 -15
- package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
- package/dist/components/Dashboard/DashboardView.d.ts +22 -23
- package/dist/components/Dashboard/TileCard.d.ts +10 -3
- package/dist/components/Dashboard/useStuck.d.ts +22 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -5
- 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 -6
- 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 +19 -11
- 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 +8324 -7769
- 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-1dgF5CC9.es.js → useCompiledDocument-7j5cBjQd.es.js} +8768 -7912
- package/dist/useCompiledDocument-B21sVbb4.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/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 +136 -105
- 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 +49 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +8 -6
- package/src/components/DocumentCreate/newNotebook.ts +26 -12
- package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
- 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 +30 -39
- package/src/components/ReportBuilder/BuilderGrid.tsx +43 -31
- 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 +129 -150
- 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 -16
- 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 +41 -36
- package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
- package/src/components/ReportBuilder/ReportBuilder.tsx +292 -116
- 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 +248 -142
- 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/newDashboard.spec.ts +2 -3
- 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-Bw7EQc42.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-BKyRnXmA.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { Alert
|
|
4
|
+
import { Alert } from "@mui/material";
|
|
5
5
|
import { useCallback, useMemo, useState } from "react";
|
|
6
6
|
import type { DashboardManifest } from "../../client";
|
|
7
7
|
import type { HostGivenValue } from "../../hooks/givenValue";
|
|
@@ -15,31 +15,31 @@ import {
|
|
|
15
15
|
} from "../drill";
|
|
16
16
|
import { GivensPanel, type GivensLayout } from "../given";
|
|
17
17
|
import { givensToRequest, withHostGivens } from "../given/paramCodec";
|
|
18
|
-
import { Prose } from "../Prose";
|
|
19
|
-
import { TILE_MAX_HEIGHT } from "../RenderedResult/resultSizing";
|
|
20
18
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from "
|
|
19
|
+
missingRequiredGivens,
|
|
20
|
+
requiredPrompt,
|
|
21
|
+
waitingOn,
|
|
22
|
+
waitingText,
|
|
23
|
+
} from "../given/required";
|
|
24
|
+
import { Prose, type ProseLinkContext } from "../Prose";
|
|
25
|
+
import type { NavigationClick } from "../click_helper";
|
|
26
|
+
import { TILE_MAX_HEIGHT } from "../RenderedResult/resultSizing";
|
|
27
|
+
import { DashboardGrid, GRID_GAP_PX, MIN_TILE_PX } from "./DashboardGrid";
|
|
27
28
|
import { DashboardTile } from "./DashboardTile";
|
|
28
29
|
import { RowsDialog, stepsOf, type RowsRequest } from "./RowsDialog";
|
|
29
30
|
import { useReportEvents } from "../Report/telemetry";
|
|
30
|
-
import {
|
|
31
|
+
import type { TileChrome } from "./TileCard";
|
|
31
32
|
import { tileIgnoredFilterLabels } from "./TileFilterTag";
|
|
33
|
+
import { layoutRules } from "../Report/layoutRules";
|
|
34
|
+
import {
|
|
35
|
+
ReportHeader,
|
|
36
|
+
ReportPage,
|
|
37
|
+
StickyControls,
|
|
38
|
+
TextTileFrame,
|
|
39
|
+
} from "../Report/ReportPage";
|
|
32
40
|
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The sticky control row's stacking level: above anything a tile raises
|
|
38
|
-
* inside itself as it scrolls under (a result's floating buttons sit at 1–2),
|
|
39
|
-
* and below MUI's app bar, popovers and dialogs. Shared so the builder's
|
|
40
|
-
* control row sits at the same level as the reader's.
|
|
41
|
-
*/
|
|
42
|
-
export const STICKY_CONTROLS_Z = 4;
|
|
41
|
+
/** Re-exported for hosts that import it from here; defined with the page parts. */
|
|
42
|
+
export { STICKY_CONTROLS_Z } from "../Report/ReportPage";
|
|
43
43
|
|
|
44
44
|
export interface DashboardViewProps {
|
|
45
45
|
/** The dashboard, or the tile layout a layout notebook carries. */
|
|
@@ -62,7 +62,11 @@ export interface DashboardViewProps {
|
|
|
62
62
|
onNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
|
|
63
63
|
height?: number;
|
|
64
64
|
maxResultSize?: number;
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Ignored: kept so existing callers compile. A linear report and a grid
|
|
67
|
+
* draw the same header, cards and controls, and differ only in how tiles
|
|
68
|
+
* are arranged, which the manifest says.
|
|
69
|
+
*/
|
|
66
70
|
chrome?: TileChrome;
|
|
67
71
|
/**
|
|
68
72
|
* How the control row is drawn: `bar` for a dashboard, `panel` for a
|
|
@@ -79,6 +83,19 @@ export interface DashboardViewProps {
|
|
|
79
83
|
runModelPath?: string;
|
|
80
84
|
/** Givens the host sets itself: no control is shown for them. */
|
|
81
85
|
hiddenGivens?: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* Filters each tile reads through values the host writes into its query
|
|
88
|
+
* text rather than sending them as givens: a report held as text whose
|
|
89
|
+
* own `given:` the host resolves to literals before compiling. Keyed by
|
|
90
|
+
* the manifest's `tile.query`. Counted as read, so the tile is not marked
|
|
91
|
+
* as ignoring that filter, and never sent: the server does not know them.
|
|
92
|
+
*/
|
|
93
|
+
literalReads?: Readonly<Record<string, readonly string[]>>;
|
|
94
|
+
/**
|
|
95
|
+
* An ordinary link in the report's prose (its description and text tiles),
|
|
96
|
+
* for a host with its own router. Omitted, links are plain anchors.
|
|
97
|
+
*/
|
|
98
|
+
onLinkNavigate?: (to: string, event?: NavigationClick) => void;
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
/**
|
|
@@ -98,12 +115,35 @@ export function DashboardView({
|
|
|
98
115
|
onNavigate,
|
|
99
116
|
height,
|
|
100
117
|
maxResultSize,
|
|
101
|
-
chrome = "card",
|
|
102
118
|
controlsLayout = "bar",
|
|
103
119
|
preamble,
|
|
104
120
|
runModelPath,
|
|
105
121
|
hiddenGivens,
|
|
122
|
+
literalReads,
|
|
123
|
+
onLinkNavigate,
|
|
106
124
|
}: DashboardViewProps) {
|
|
125
|
+
// Where a relative link in the report's prose resolves from, and how the
|
|
126
|
+
// host navigates to it. Only a host with a router gets its links resolved:
|
|
127
|
+
// without one they stay plain anchors, since this view cannot know the
|
|
128
|
+
// host's routes (a version segment, a different prefix).
|
|
129
|
+
const links = useMemo<ProseLinkContext | undefined>(
|
|
130
|
+
() =>
|
|
131
|
+
onLinkNavigate
|
|
132
|
+
? {
|
|
133
|
+
environmentName,
|
|
134
|
+
packageName,
|
|
135
|
+
sourcePath: manifest.path ?? documentName,
|
|
136
|
+
onNavigate: onLinkNavigate,
|
|
137
|
+
}
|
|
138
|
+
: undefined,
|
|
139
|
+
[
|
|
140
|
+
environmentName,
|
|
141
|
+
packageName,
|
|
142
|
+
manifest.path,
|
|
143
|
+
documentName,
|
|
144
|
+
onLinkNavigate,
|
|
145
|
+
],
|
|
146
|
+
);
|
|
107
147
|
const specs = useMemo(
|
|
108
148
|
() =>
|
|
109
149
|
(manifest.givens ?? []).filter(
|
|
@@ -210,43 +250,53 @@ export function DashboardView({
|
|
|
210
250
|
[drill],
|
|
211
251
|
);
|
|
212
252
|
|
|
253
|
+
// The layout decides the arrangement only, as it does in the builder.
|
|
254
|
+
const { columns, layout } = layoutRules(
|
|
255
|
+
manifest.layout,
|
|
256
|
+
manifest.dashboardColumns,
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
// Required filters with no value yet: the tiles that read one wait, and the
|
|
260
|
+
// page asks for them, rather than every tile failing with the compiler's
|
|
261
|
+
// "has no value and no default".
|
|
262
|
+
const missing = useMemo(
|
|
263
|
+
() => missingRequiredGivens(specs, applied, givens),
|
|
264
|
+
[specs, applied, givens],
|
|
265
|
+
);
|
|
266
|
+
|
|
213
267
|
// Reachable on the in-process load path only: production aborts the package
|
|
214
268
|
// on the first compile error, so an uncompilable file answers 424 instead.
|
|
215
269
|
if (manifest.error) {
|
|
216
270
|
return (
|
|
217
|
-
<
|
|
218
|
-
|
|
271
|
+
<ReportPage
|
|
272
|
+
layout={layout}
|
|
273
|
+
header={<DashboardHeader manifest={manifest} links={links} />}
|
|
274
|
+
>
|
|
219
275
|
<Alert severity="error">{manifest.error}</Alert>
|
|
220
|
-
</
|
|
276
|
+
</ReportPage>
|
|
221
277
|
);
|
|
222
278
|
}
|
|
223
279
|
|
|
224
280
|
const modelPath = runModelPath ?? manifest.path;
|
|
225
281
|
const tiles = manifest.tiles ?? [];
|
|
226
|
-
const columns = manifest.dashboardColumns ?? DEFAULT_COLUMNS;
|
|
227
282
|
|
|
228
283
|
return (
|
|
229
|
-
<
|
|
230
|
-
{
|
|
231
|
-
|
|
284
|
+
<ReportPage
|
|
285
|
+
layout={layout}
|
|
286
|
+
header={<DashboardHeader manifest={manifest} links={links} />}
|
|
287
|
+
// Only when there are controls: GivensPanel draws nothing without
|
|
288
|
+
// them, and an empty bar would still cost the page a gap.
|
|
289
|
+
controls={
|
|
290
|
+
specs.length > 0 ? (
|
|
291
|
+
<StickyControls>
|
|
292
|
+
<GivensPanel {...controls.panel} layout={controlsLayout} />
|
|
293
|
+
</StickyControls>
|
|
294
|
+
) : undefined
|
|
295
|
+
}
|
|
296
|
+
>
|
|
297
|
+
{missing.length > 0 && (
|
|
298
|
+
<Alert severity="info">{requiredPrompt(missing)}</Alert>
|
|
232
299
|
)}
|
|
233
|
-
|
|
234
|
-
{/* Sticky so the controls stay in reach while the tiles scroll under.
|
|
235
|
-
Only when there are controls: GivensPanel draws nothing without
|
|
236
|
-
them, and an empty box would still cost the Stack a gap. */}
|
|
237
|
-
{specs.length > 0 && (
|
|
238
|
-
<Box
|
|
239
|
-
sx={{
|
|
240
|
-
position: "sticky",
|
|
241
|
-
top: 0,
|
|
242
|
-
zIndex: STICKY_CONTROLS_Z,
|
|
243
|
-
bgcolor: "background.default",
|
|
244
|
-
}}
|
|
245
|
-
>
|
|
246
|
-
<GivensPanel {...controls.panel} layout={controlsLayout} />
|
|
247
|
-
</Box>
|
|
248
|
-
)}
|
|
249
|
-
|
|
250
300
|
{modelPath === undefined ? (
|
|
251
301
|
<Alert severity="error">
|
|
252
302
|
This dashboard has no model path, so there is nothing to run.
|
|
@@ -259,7 +309,7 @@ export function DashboardView({
|
|
|
259
309
|
tiles={tiles}
|
|
260
310
|
columns={columns}
|
|
261
311
|
minTilePx={MIN_TILE_PX}
|
|
262
|
-
rowGapPx={
|
|
312
|
+
rowGapPx={GRID_GAP_PX}
|
|
263
313
|
// Position too, not the expression alone: `tiles=[…]` can repeat
|
|
264
314
|
// one, which is a typo rather than a request for two identical
|
|
265
315
|
// panels, and keying on the expression made the duplicate warn
|
|
@@ -270,7 +320,9 @@ export function DashboardView({
|
|
|
270
320
|
renderTile={(tile, index) =>
|
|
271
321
|
// An absent `kind` is a query tile, as it was before text tiles.
|
|
272
322
|
tile.kind === "text" || tile.query === undefined ? (
|
|
273
|
-
|
|
323
|
+
// Prose, never a card, in either layout: a text tile is
|
|
324
|
+
// part of the page, not a result.
|
|
325
|
+
<TextTile markdown={tile.markdown ?? ""} links={links} />
|
|
274
326
|
) : (
|
|
275
327
|
<DashboardTile
|
|
276
328
|
index={index}
|
|
@@ -289,14 +341,25 @@ export function DashboardView({
|
|
|
289
341
|
height={height ?? TILE_MAX_HEIGHT}
|
|
290
342
|
maxResultSize={maxResultSize}
|
|
291
343
|
drill={drillFor(tile.query)}
|
|
292
|
-
chrome={chrome}
|
|
293
344
|
ignoredFilters={tileIgnoredFilterLabels(
|
|
294
|
-
tile.givenNames
|
|
345
|
+
tile.givenNames &&
|
|
346
|
+
(tile.query && literalReads?.[tile.query]
|
|
347
|
+
? [
|
|
348
|
+
...tile.givenNames,
|
|
349
|
+
...literalReads[tile.query]!,
|
|
350
|
+
]
|
|
351
|
+
: tile.givenNames),
|
|
295
352
|
specs,
|
|
296
353
|
)}
|
|
297
354
|
{...(preamble !== undefined
|
|
298
355
|
? { preamble, restricted: tile.restricted }
|
|
299
356
|
: {})}
|
|
357
|
+
{...(() => {
|
|
358
|
+
const waiting = waitingOn(missing, tile.givenNames);
|
|
359
|
+
return waiting.length > 0
|
|
360
|
+
? { waitingFor: waitingText(waiting) }
|
|
361
|
+
: {};
|
|
362
|
+
})()}
|
|
300
363
|
/>
|
|
301
364
|
)
|
|
302
365
|
}
|
|
@@ -330,83 +393,51 @@ export function DashboardView({
|
|
|
330
393
|
}}
|
|
331
394
|
/>
|
|
332
395
|
)}
|
|
333
|
-
</
|
|
396
|
+
</ReportPage>
|
|
334
397
|
);
|
|
335
398
|
}
|
|
336
399
|
|
|
337
400
|
/** A text tile: its markdown and nothing else, no heading. */
|
|
338
401
|
function TextTile({
|
|
339
402
|
markdown,
|
|
340
|
-
|
|
403
|
+
links,
|
|
341
404
|
}: {
|
|
342
405
|
markdown: string;
|
|
343
|
-
|
|
406
|
+
links: ProseLinkContext | undefined;
|
|
344
407
|
}) {
|
|
345
408
|
return (
|
|
346
|
-
<
|
|
347
|
-
<Prose variant="document"
|
|
348
|
-
|
|
409
|
+
<TextTileFrame>
|
|
410
|
+
<Prose variant="document" links={links}>
|
|
411
|
+
{markdown}
|
|
412
|
+
</Prose>
|
|
413
|
+
</TextTileFrame>
|
|
349
414
|
);
|
|
350
415
|
}
|
|
351
416
|
|
|
352
417
|
/**
|
|
353
|
-
* The
|
|
354
|
-
*
|
|
418
|
+
* The report's header as the reader draws it: the shared {@link ReportHeader}
|
|
419
|
+
* with the title, and the description as markdown prose (Malloy carries a
|
|
420
|
+
* `##"` block through with its newlines intact) in a text tile's frame.
|
|
355
421
|
*/
|
|
356
422
|
function DashboardHeader({
|
|
357
423
|
manifest,
|
|
358
|
-
|
|
424
|
+
links,
|
|
359
425
|
}: {
|
|
360
426
|
manifest: DashboardManifest;
|
|
361
|
-
|
|
427
|
+
links: ProseLinkContext | undefined;
|
|
362
428
|
}) {
|
|
363
429
|
return (
|
|
364
|
-
<
|
|
365
|
-
// The description follows the text-tile rule: drawn in the same chrome
|
|
366
|
-
// the document's text tiles take, so a dashboard boxes it as it boxes
|
|
367
|
-
// a text tile, and a notebook (which passes `none`) leaves it bare.
|
|
368
|
-
chrome={chrome}
|
|
430
|
+
<ReportHeader
|
|
369
431
|
title={manifest.title ?? manifest.name}
|
|
370
|
-
{
|
|
371
|
-
|
|
372
|
-
|
|
432
|
+
description={
|
|
433
|
+
manifest.description ? (
|
|
434
|
+
<TextTileFrame>
|
|
435
|
+
<Prose variant="document" links={links}>
|
|
436
|
+
{manifest.description}
|
|
437
|
+
</Prose>
|
|
438
|
+
</TextTileFrame>
|
|
439
|
+
) : undefined
|
|
440
|
+
}
|
|
373
441
|
/>
|
|
374
442
|
);
|
|
375
443
|
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* The prose header over just the two fields it needs, so the BUILDER can draw
|
|
379
|
-
* the same header over a `DashboardDocument`, which is not a manifest.
|
|
380
|
-
*
|
|
381
|
-
* The description is drawn as a text tile is, in the document's own tile
|
|
382
|
-
* chrome: the same box and the same type as the markdown between the tiles,
|
|
383
|
-
* so the page's prose reads as one kind of thing wherever it sits.
|
|
384
|
-
*/
|
|
385
|
-
export function DashboardProse({
|
|
386
|
-
title,
|
|
387
|
-
description,
|
|
388
|
-
chrome = "card",
|
|
389
|
-
}: {
|
|
390
|
-
title: string;
|
|
391
|
-
description?: string;
|
|
392
|
-
/** The chrome the document's tiles take, which the description matches. */
|
|
393
|
-
chrome?: TileChrome;
|
|
394
|
-
}) {
|
|
395
|
-
return (
|
|
396
|
-
<Stack sx={{ gap: 2 }}>
|
|
397
|
-
{/* No explicit weight: the host theme's h5 weight applies. */}
|
|
398
|
-
<Typography variant="h5">{title}</Typography>
|
|
399
|
-
{description && (
|
|
400
|
-
<Box
|
|
401
|
-
sx={
|
|
402
|
-
chrome === "none"
|
|
403
|
-
? { my: `${BARE_DESCRIPTION_MARGIN_PX}px` }
|
|
404
|
-
: undefined
|
|
405
|
-
}
|
|
406
|
-
>
|
|
407
|
-
<TextTile markdown={description} chrome={chrome} />
|
|
408
|
-
</Box>
|
|
409
|
-
)}
|
|
410
|
-
</Stack>
|
|
411
|
-
);
|
|
412
|
-
}
|
|
@@ -18,7 +18,6 @@ import { malloyLiteral } from "../../utils/malloyLiteral";
|
|
|
18
18
|
import { isIdentifier, tileSteps } from "../../utils/malloyText";
|
|
19
19
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
20
20
|
import { ResultPanel } from "../RenderedResult/ResultPanel";
|
|
21
|
-
import { MONO_FONT_FAMILY } from "../styles";
|
|
22
21
|
import { now } from "../../utils/clock";
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -171,7 +170,7 @@ export function RowsDialog({
|
|
|
171
170
|
sx={{
|
|
172
171
|
mr: "auto",
|
|
173
172
|
color: theme.tileTitle,
|
|
174
|
-
fontFamily:
|
|
173
|
+
fontFamily: theme.ui.font.mono,
|
|
175
174
|
overflow: "hidden",
|
|
176
175
|
textOverflow: "ellipsis",
|
|
177
176
|
whiteSpace: "nowrap",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import { reportClasses } from "../../theme/classes";
|
|
4
5
|
import {
|
|
5
6
|
Box,
|
|
6
7
|
Paper,
|
|
@@ -34,8 +35,10 @@ export const TILE_MIN_HEIGHT = { query: 120, text: 72 } as const;
|
|
|
34
35
|
* a different card. Both surfaces moved together when the edge was darkened;
|
|
35
36
|
* either one left behind is a dashboard whose tiles are outlined two ways.
|
|
36
37
|
*
|
|
37
|
-
* Radius
|
|
38
|
-
*
|
|
38
|
+
* Radius is the report surfaces' tile radius ({@link ui.radius.tile}), which the
|
|
39
|
+
* renderer card is pointed at too, rather than the host's `shape.borderRadius`:
|
|
40
|
+
* a host's control radius is not a card radius, and taking it made tiles as
|
|
41
|
+
* round as buttons. The
|
|
39
42
|
* background is `theme.tile`, the value the renderer card paints — left unset,
|
|
40
43
|
* on a theme whose page is also white the composite tiles lost the tint that
|
|
41
44
|
* separates a card from the page while the single-query form kept it.
|
|
@@ -70,16 +73,20 @@ export function TileCard({
|
|
|
70
73
|
children: ReactNode;
|
|
71
74
|
}) {
|
|
72
75
|
const { theme } = usePublisherTheme();
|
|
76
|
+
const ui = theme.ui;
|
|
73
77
|
const bare = borderless || chrome === "none";
|
|
74
78
|
return (
|
|
75
79
|
<Paper
|
|
76
80
|
ref={cardRef}
|
|
81
|
+
className={reportClasses.tile}
|
|
77
82
|
elevation={0}
|
|
78
83
|
data-chrome={chrome}
|
|
84
|
+
// What it holds, for a host waiting on the query tiles to draw.
|
|
85
|
+
data-tile-kind={kind}
|
|
79
86
|
sx={[
|
|
80
87
|
{
|
|
81
88
|
border: bare ? "none" : theme.cardBorder,
|
|
82
|
-
borderRadius: bare ? 0 :
|
|
89
|
+
borderRadius: bare ? 0 : ui.radius.tile,
|
|
83
90
|
background: bare ? "none" : theme.tile,
|
|
84
91
|
overflow: "hidden",
|
|
85
92
|
// A column so a tile's result can take the room under its heading.
|
|
@@ -102,6 +109,12 @@ export function TileCard({
|
|
|
102
109
|
);
|
|
103
110
|
}
|
|
104
111
|
|
|
112
|
+
/**
|
|
113
|
+
* The class on a tile heading's root, so a surface that draws controls over
|
|
114
|
+
* the heading (the builder's tile menu) can leave room for them.
|
|
115
|
+
*/
|
|
116
|
+
export const TILE_HEADING_CLASS = reportClasses.tileHeading;
|
|
117
|
+
|
|
105
118
|
/** The heading's text as nodes, for a surface that makes it editable in place. */
|
|
106
119
|
export interface TileHeadingSlots {
|
|
107
120
|
title: ReactNode;
|
|
@@ -120,7 +133,7 @@ export function TileHeading({
|
|
|
120
133
|
action,
|
|
121
134
|
quiet = false,
|
|
122
135
|
}: {
|
|
123
|
-
/** A
|
|
136
|
+
/** A tighter gap under the heading, for a tile with no card around it. */
|
|
124
137
|
quiet?: boolean;
|
|
125
138
|
title: ReactNode;
|
|
126
139
|
subtitle?: ReactNode;
|
|
@@ -130,8 +143,10 @@ export function TileHeading({
|
|
|
130
143
|
action?: ReactNode;
|
|
131
144
|
}) {
|
|
132
145
|
const { theme } = usePublisherTheme();
|
|
146
|
+
const ui = theme.ui;
|
|
133
147
|
return (
|
|
134
148
|
<Box
|
|
149
|
+
className={TILE_HEADING_CLASS}
|
|
135
150
|
sx={{
|
|
136
151
|
pb: quiet ? 0.5 : 1.5,
|
|
137
152
|
display: "flex",
|
|
@@ -140,12 +155,13 @@ export function TileHeading({
|
|
|
140
155
|
}}
|
|
141
156
|
>
|
|
142
157
|
<Box sx={{ minWidth: 0, flex: 1 }}>
|
|
158
|
+
{/* One title style in both layouts: a linear report's tile titles
|
|
159
|
+
were 12px captions, smaller than the prose around them. */}
|
|
143
160
|
<Typography
|
|
144
|
-
|
|
161
|
+
component="div"
|
|
145
162
|
sx={{
|
|
146
|
-
|
|
147
|
-
display:
|
|
148
|
-
opacity: quiet ? 0.8 : undefined,
|
|
163
|
+
...ui.type.tileTitle,
|
|
164
|
+
display: "block",
|
|
149
165
|
color: theme.tileTitle,
|
|
150
166
|
fontFamily: theme.font.family,
|
|
151
167
|
}}
|
|
@@ -155,12 +171,14 @@ export function TileHeading({
|
|
|
155
171
|
</Typography>
|
|
156
172
|
{subtitle !== undefined && (
|
|
157
173
|
<Typography
|
|
158
|
-
|
|
174
|
+
component="div"
|
|
159
175
|
sx={{
|
|
176
|
+
...ui.type.caption,
|
|
160
177
|
display: "block",
|
|
178
|
+
mt: "2px",
|
|
161
179
|
color: theme.tileTitle,
|
|
162
180
|
fontFamily: theme.font.family,
|
|
163
|
-
opacity: 0.
|
|
181
|
+
opacity: 0.75,
|
|
164
182
|
}}
|
|
165
183
|
>
|
|
166
184
|
{subtitle}
|
|
@@ -30,3 +30,27 @@ describe("defaultTileSpan", () => {
|
|
|
30
30
|
expect(defaultTileSpan(1, 100, 240)).toBe(1);
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
|
+
|
|
34
|
+
describe("useDefaultTileSpan", () => {
|
|
35
|
+
it("is the reader's span for the measured box, so the builder draws an unset tile as the reader does", async () => {
|
|
36
|
+
const { renderHook } = await import("@testing-library/react");
|
|
37
|
+
const { useDefaultTileSpan } = await import("./DashboardGrid");
|
|
38
|
+
const box = document.createElement("div");
|
|
39
|
+
box.getBoundingClientRect = () => ({ width: 1200 }) as DOMRect;
|
|
40
|
+
const { result } = renderHook(() =>
|
|
41
|
+
useDefaultTileSpan({ current: box }, 12),
|
|
42
|
+
);
|
|
43
|
+
// Not 1: a one-column tile beside a colspan=6 one was a ~80px sliver.
|
|
44
|
+
expect(result.current).toBe(defaultTileSpan(12, 1200, 240));
|
|
45
|
+
expect(result.current).toBeGreaterThan(1);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("is one column while nothing is measured", async () => {
|
|
49
|
+
const { renderHook } = await import("@testing-library/react");
|
|
50
|
+
const { useDefaultTileSpan } = await import("./DashboardGrid");
|
|
51
|
+
const { result } = renderHook(() =>
|
|
52
|
+
useDefaultTileSpan({ current: null }, 12),
|
|
53
|
+
);
|
|
54
|
+
expect(result.current).toBe(1);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { useCallback, useRef, useState } from "react";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How far above the scroller's edge a pinned bar sits: one pixel, so the bar
|
|
8
|
+
* is clipped by exactly that pixel while pinned and whole while it is not,
|
|
9
|
+
* which is what {@link useStuck} observes.
|
|
10
|
+
*/
|
|
11
|
+
export const STUCK_TOP_PX = -1;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Whether a `position: sticky` bar (pinned at `top: {@link STUCK_TOP_PX}px`)
|
|
15
|
+
* is currently pinned, so it can draw an edge only while content scrolls under
|
|
16
|
+
* it. Unpinned, the bar sits in the flow and an edge would be a stray line
|
|
17
|
+
* between it and the first tile.
|
|
18
|
+
*
|
|
19
|
+
* Observes the bar itself: pinned, its top pixel is clipped by the scroller,
|
|
20
|
+
* so less than all of it is visible. No sentinel element, which as a sibling
|
|
21
|
+
* in a `gap` layout cost the page a gap of its own above the bar. No explicit
|
|
22
|
+
* root, so it works whichever ancestor scrolls: an observer with the implicit
|
|
23
|
+
* root counts clipping by every scrolling ancestor, not just the viewport.
|
|
24
|
+
*/
|
|
25
|
+
export function useStuck(): {
|
|
26
|
+
stickyRef: (node: HTMLElement | null) => void;
|
|
27
|
+
stuck: boolean;
|
|
28
|
+
} {
|
|
29
|
+
const [stuck, setStuck] = useState(false);
|
|
30
|
+
const observer = useRef<IntersectionObserver | null>(null);
|
|
31
|
+
const stickyRef = useCallback((node: HTMLElement | null) => {
|
|
32
|
+
observer.current?.disconnect();
|
|
33
|
+
observer.current = null;
|
|
34
|
+
if (!node || typeof IntersectionObserver === "undefined") return;
|
|
35
|
+
observer.current = new IntersectionObserver(
|
|
36
|
+
([entry]) => {
|
|
37
|
+
if (!entry) return;
|
|
38
|
+
// Partly hidden BELOW the fold is not pinned: only clipped at the top.
|
|
39
|
+
const atTop =
|
|
40
|
+
entry.boundingClientRect.top <
|
|
41
|
+
(entry.rootBounds?.height ?? window.innerHeight) / 2;
|
|
42
|
+
setStuck(entry.intersectionRatio < 1 && atTop);
|
|
43
|
+
},
|
|
44
|
+
{ threshold: [1] },
|
|
45
|
+
);
|
|
46
|
+
observer.current.observe(node);
|
|
47
|
+
}, []);
|
|
48
|
+
return { stickyRef, stuck };
|
|
49
|
+
}
|
|
@@ -35,7 +35,7 @@ describe("newNotebookSource", () => {
|
|
|
35
35
|
expect(lintNotebookText("notebooks/q3.malloy", text)).toEqual([]);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
it("reads back as a layout notebook:
|
|
38
|
+
it("reads back as a layout notebook: one labelled query tile, no text tile, and no run cell", async () => {
|
|
39
39
|
const text = newNotebookSource(INPUT);
|
|
40
40
|
const result = await readDashboardDocument(text);
|
|
41
41
|
if (readFailed(result)) throw new Error(result.reason);
|
|
@@ -43,9 +43,11 @@ describe("newNotebookSource", () => {
|
|
|
43
43
|
expect(document.layout).toBe("linear");
|
|
44
44
|
expect(
|
|
45
45
|
document.tiles.map((t) => (isTextTile(t) ? "text" : "query")),
|
|
46
|
-
).toEqual(["
|
|
46
|
+
).toEqual(["query"]);
|
|
47
47
|
const query = document.tiles.find(isQueryTile);
|
|
48
48
|
expect(query?.name).toBe("by_category_tile");
|
|
49
|
+
// Titled for the view it shows, not the extension's `_tile` name.
|
|
50
|
+
expect(query?.label).toBe("By category");
|
|
49
51
|
expect(text).toContain(
|
|
50
52
|
"source: order_items_tiles is order_items extend {",
|
|
51
53
|
);
|
|
@@ -54,7 +56,7 @@ describe("newNotebookSource", () => {
|
|
|
54
56
|
|
|
55
57
|
it("writes the artifact tag as a block with a tile on each line, named for its view", () => {
|
|
56
58
|
expect(newNotebookSource(INPUT)).toContain(
|
|
57
|
-
'##| artifact { layout=linear title="Sales \\"West\\""\n tiles=[\n
|
|
59
|
+
'##| artifact { layout=linear title="Sales \\"West\\""\n tiles=[\n "order_items_tiles -> by_category_tile"\n ]\n}\n|##\n',
|
|
58
60
|
);
|
|
59
61
|
});
|
|
60
62
|
|
|
@@ -118,7 +120,7 @@ describe("newReportSource", () => {
|
|
|
118
120
|
expect(grid.document.columns).toBe(12);
|
|
119
121
|
expect(
|
|
120
122
|
grid.document.tiles.map((t) => (isTextTile(t) ? "text" : "query")),
|
|
121
|
-
).toEqual(["
|
|
123
|
+
).toEqual(["query"]);
|
|
122
124
|
const linear = await readDashboardDocument(
|
|
123
125
|
newReportSource(INPUT, "linear"),
|
|
124
126
|
);
|
|
@@ -163,10 +165,10 @@ describe("newDocumentProblem", () => {
|
|
|
163
165
|
expect(newDocumentProblem({ ...INPUT, source: "date" })).toBeUndefined();
|
|
164
166
|
});
|
|
165
167
|
|
|
166
|
-
it("trims the title once
|
|
168
|
+
it("trims the title, and writes it once: in the tag, not again as a heading", () => {
|
|
167
169
|
const text = newNotebookSource({ ...INPUT, title: " Q3 " });
|
|
168
170
|
expect(text).toContain('title="Q3"');
|
|
169
|
-
expect(text).toContain("# Q3\n");
|
|
171
|
+
expect(text).not.toContain("# Q3\n");
|
|
170
172
|
});
|
|
171
173
|
|
|
172
174
|
it("refuses names that cannot be written", () => {
|