@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
|
@@ -5,7 +5,7 @@ import { Alert } from "@mui/material";
|
|
|
5
5
|
import { useCallback, useEffect, useRef } from "react";
|
|
6
6
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
7
7
|
import { now } from "../../utils/clock";
|
|
8
|
-
import {
|
|
8
|
+
import { parseResourceUri } from "../../utils/formatting";
|
|
9
9
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
10
10
|
import type { NavigationClick } from "../click_helper";
|
|
11
11
|
import { DashboardView } from "../Dashboard/DashboardView";
|
|
@@ -13,8 +13,7 @@ import type { TileChrome } from "../Dashboard/TileCard";
|
|
|
13
13
|
import type { DrillNavigation } from "../drill";
|
|
14
14
|
import { Loading, LOADING_COPY } from "../Loading";
|
|
15
15
|
import { useServer } from "../ServerProvider";
|
|
16
|
-
import {
|
|
17
|
-
import { LinearReport } from "./LinearReport";
|
|
16
|
+
import { reportQueryOptions } from "./reportQuery";
|
|
18
17
|
import {
|
|
19
18
|
failureCategory,
|
|
20
19
|
ReportEventsContext,
|
|
@@ -74,14 +73,23 @@ export interface ReportProps {
|
|
|
74
73
|
* shown, a drill — for the host to log or count; see `ReportEvent`.
|
|
75
74
|
*/
|
|
76
75
|
onEvent?: ReportEventHandler;
|
|
77
|
-
/**
|
|
76
|
+
/** Ignored: kept so existing callers compile. Both layouts draw the same cards. */
|
|
78
77
|
chrome?: TileChrome;
|
|
78
|
+
/**
|
|
79
|
+
* How long a read of the report is reused without asking the server again,
|
|
80
|
+
* in ms. Default: the query client's staleness for the `report` key, which
|
|
81
|
+
* is 0 (every mount asks, so a change made elsewhere shows) unless the host
|
|
82
|
+
* sets one with `setQueryDefaults(["report"], …)`. A host that draws the
|
|
83
|
+
* same report twice in a row can set a few seconds, as the Console does
|
|
84
|
+
* while the builder loads over it.
|
|
85
|
+
*/
|
|
86
|
+
manifestStaleTime?: number;
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
/**
|
|
82
90
|
* A report of either layout, from `GET …/reports/{path}`: a grid drawn as a
|
|
83
|
-
* dashboard, a linear report top to bottom
|
|
84
|
-
*
|
|
91
|
+
* dashboard, or a linear report top to bottom (a legacy `.malloynb` among
|
|
92
|
+
* them, read-only), each tile run through the governed query endpoint.
|
|
85
93
|
*
|
|
86
94
|
* Host-agnostic, like `Dashboard`: it takes props rather than reading a
|
|
87
95
|
* router, and hands navigation and URL state back to whoever mounted it.
|
|
@@ -97,6 +105,7 @@ export function Report({
|
|
|
97
105
|
maxResultSize,
|
|
98
106
|
onEvent,
|
|
99
107
|
chrome,
|
|
108
|
+
manifestStaleTime,
|
|
100
109
|
}: ReportProps) {
|
|
101
110
|
const parsed = parseResourceUri(resourceUri);
|
|
102
111
|
const { apiClients } = useServer();
|
|
@@ -111,28 +120,21 @@ export function Report({
|
|
|
111
120
|
isError,
|
|
112
121
|
error,
|
|
113
122
|
} = useQueryWithApiError({
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{ signal },
|
|
125
|
-
)
|
|
126
|
-
).data,
|
|
123
|
+
...reportQueryOptions(
|
|
124
|
+
apiClients,
|
|
125
|
+
{
|
|
126
|
+
environmentName,
|
|
127
|
+
packageName,
|
|
128
|
+
path,
|
|
129
|
+
versionId,
|
|
130
|
+
},
|
|
131
|
+
manifestStaleTime,
|
|
132
|
+
),
|
|
127
133
|
enabled: uriNamesBoth && path !== "",
|
|
128
134
|
});
|
|
129
135
|
|
|
130
|
-
// The layout once the report has said
|
|
131
|
-
const layout = manifest
|
|
132
|
-
? manifest.notebook
|
|
133
|
-
? "linear"
|
|
134
|
-
: manifest.layout
|
|
135
|
-
: undefined;
|
|
136
|
+
// The layout once the report has said.
|
|
137
|
+
const layout = manifest?.layout;
|
|
136
138
|
const events = useReportEmitter({ path, layout }, onEvent);
|
|
137
139
|
// One open or one failure per report shown: a refetch is not another open,
|
|
138
140
|
// and the guard survives a development double-run of the effect.
|
|
@@ -172,9 +174,7 @@ export function Report({
|
|
|
172
174
|
type: "report.opened",
|
|
173
175
|
surface: "view",
|
|
174
176
|
from: "package",
|
|
175
|
-
tiles: manifest.
|
|
176
|
-
? (manifest.notebook.notebookCells?.length ?? 0)
|
|
177
|
-
: (manifest.tiles?.length ?? 0),
|
|
177
|
+
tiles: manifest.tiles?.length ?? 0,
|
|
178
178
|
durationMs: now() - started.current.at,
|
|
179
179
|
});
|
|
180
180
|
}
|
|
@@ -218,55 +218,23 @@ export function Report({
|
|
|
218
218
|
</Alert>
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
);
|
|
239
|
-
} else if (manifest.layout === "linear") {
|
|
240
|
-
body = (
|
|
241
|
-
<LinearReport
|
|
242
|
-
manifest={manifest}
|
|
243
|
-
environmentName={environmentName}
|
|
244
|
-
packageName={packageName}
|
|
245
|
-
versionId={versionId}
|
|
246
|
-
documentName={path}
|
|
247
|
-
givens={givens}
|
|
248
|
-
onGivensChange={onGivensChange}
|
|
249
|
-
onDrillNavigate={drillNavigate}
|
|
250
|
-
maxResultSize={maxResultSize}
|
|
251
|
-
/>
|
|
252
|
-
);
|
|
253
|
-
} else {
|
|
254
|
-
body = (
|
|
255
|
-
<DashboardView
|
|
256
|
-
manifest={manifest}
|
|
257
|
-
environmentName={environmentName}
|
|
258
|
-
packageName={packageName}
|
|
259
|
-
versionId={versionId}
|
|
260
|
-
documentName={path}
|
|
261
|
-
givens={givens}
|
|
262
|
-
onGivensChange={onGivensChange}
|
|
263
|
-
onNavigate={drillNavigate}
|
|
264
|
-
height={height}
|
|
265
|
-
maxResultSize={maxResultSize}
|
|
266
|
-
chrome={chrome}
|
|
267
|
-
/>
|
|
268
|
-
);
|
|
269
|
-
}
|
|
221
|
+
// Either layout: the same view, arranged as the manifest's layout says.
|
|
222
|
+
const body = (
|
|
223
|
+
<DashboardView
|
|
224
|
+
manifest={manifest}
|
|
225
|
+
environmentName={environmentName}
|
|
226
|
+
packageName={packageName}
|
|
227
|
+
versionId={versionId}
|
|
228
|
+
documentName={path}
|
|
229
|
+
givens={givens}
|
|
230
|
+
onGivensChange={onGivensChange}
|
|
231
|
+
onNavigate={drillNavigate}
|
|
232
|
+
{...(onLinkNavigate ? { onLinkNavigate } : {})}
|
|
233
|
+
height={height}
|
|
234
|
+
maxResultSize={maxResultSize}
|
|
235
|
+
chrome={chrome}
|
|
236
|
+
/>
|
|
237
|
+
);
|
|
270
238
|
return (
|
|
271
239
|
<ReportEventsContext.Provider value={events}>
|
|
272
240
|
{body}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { reportClasses } from "../../theme/classes";
|
|
5
|
+
import {
|
|
6
|
+
Box,
|
|
7
|
+
Stack,
|
|
8
|
+
Typography,
|
|
9
|
+
type SxProps,
|
|
10
|
+
type Theme,
|
|
11
|
+
} from "@mui/material";
|
|
12
|
+
import type { ReactNode } from "react";
|
|
13
|
+
import { MOTION_FAST, reducedMotionSx } from "../../theme/motion";
|
|
14
|
+
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
15
|
+
import { edgeColor } from "../controlTokens";
|
|
16
|
+
import { TileCard } from "../Dashboard/TileCard";
|
|
17
|
+
import { STUCK_TOP_PX, useStuck } from "../Dashboard/useStuck";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The parts of a report page that the reader and the builder both draw, in
|
|
21
|
+
* either layout: the page's arrangement, its header, its pinned control row,
|
|
22
|
+
* and a text tile's frame.
|
|
23
|
+
*
|
|
24
|
+
* Each surface fills the same slots with its own content (the reader with
|
|
25
|
+
* text, the builder with the same text made editable in place) rather than
|
|
26
|
+
* drawing a page of its own, so a change to how a report looks is made here
|
|
27
|
+
* once and editing a page can never draw it differently from reading it.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The control row's stacking level: above anything a tile raises inside
|
|
32
|
+
* itself as it scrolls under (a result's floating buttons sit at 1–2), and
|
|
33
|
+
* below MUI's app bar, popovers and dialogs.
|
|
34
|
+
*/
|
|
35
|
+
export const STICKY_CONTROLS_Z = 4;
|
|
36
|
+
|
|
37
|
+
/** The space between the page's parts and between its tiles' rows, in theme units. */
|
|
38
|
+
const PAGE_GAP = 2;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A report page, top to bottom: anything that must be said before it
|
|
42
|
+
* (`notice`), the header, the control row, then the body (the tiles, and
|
|
43
|
+
* whatever the surface adds under them).
|
|
44
|
+
*/
|
|
45
|
+
export function ReportPage({
|
|
46
|
+
layout,
|
|
47
|
+
notice,
|
|
48
|
+
header,
|
|
49
|
+
controls,
|
|
50
|
+
children,
|
|
51
|
+
sx,
|
|
52
|
+
}: {
|
|
53
|
+
/** Written as `data-layout` on the page, so a test or a host can tell the two apart. */
|
|
54
|
+
layout?: "grid" | "linear";
|
|
55
|
+
notice?: ReactNode;
|
|
56
|
+
header: ReactNode;
|
|
57
|
+
controls?: ReactNode;
|
|
58
|
+
children: ReactNode;
|
|
59
|
+
sx?: SxProps<Theme>;
|
|
60
|
+
}) {
|
|
61
|
+
return (
|
|
62
|
+
<Stack
|
|
63
|
+
className={reportClasses.report}
|
|
64
|
+
data-layout={layout}
|
|
65
|
+
sx={[{ gap: PAGE_GAP }, ...(Array.isArray(sx) ? sx : [sx])]}
|
|
66
|
+
>
|
|
67
|
+
{notice}
|
|
68
|
+
{header}
|
|
69
|
+
{controls}
|
|
70
|
+
{children}
|
|
71
|
+
</Stack>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A report's title, with the surface's actions on its line (the builder's
|
|
77
|
+
* toolbar), and its description beneath. The title and description are slots:
|
|
78
|
+
* text in the reader, the same text editable in place in the builder.
|
|
79
|
+
*/
|
|
80
|
+
export function ReportHeader({
|
|
81
|
+
title,
|
|
82
|
+
description,
|
|
83
|
+
actions,
|
|
84
|
+
}: {
|
|
85
|
+
title: ReactNode;
|
|
86
|
+
description?: ReactNode;
|
|
87
|
+
actions?: ReactNode;
|
|
88
|
+
}) {
|
|
89
|
+
const ui = usePublisherTheme().theme.ui;
|
|
90
|
+
return (
|
|
91
|
+
<Stack className={reportClasses.header} sx={{ gap: 1.5 }}>
|
|
92
|
+
<Stack direction="row" sx={{ alignItems: "center", gap: 2 }}>
|
|
93
|
+
<Typography
|
|
94
|
+
component="h1"
|
|
95
|
+
className={reportClasses.title}
|
|
96
|
+
sx={{ ...ui.type.pageTitle, m: 0, flex: 1, minWidth: 0 }}
|
|
97
|
+
>
|
|
98
|
+
{title}
|
|
99
|
+
</Typography>
|
|
100
|
+
{/* Overhangs the title's line rather than heightening it, so the
|
|
101
|
+
title sits at the same height with or without actions. */}
|
|
102
|
+
{actions && <Box sx={{ my: "-4px" }}>{actions}</Box>}
|
|
103
|
+
</Stack>
|
|
104
|
+
{description}
|
|
105
|
+
</Stack>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The frame a text tile (and the page description) is drawn in: none. Prose
|
|
111
|
+
* is part of the page, not a result, so it never takes a card, in either
|
|
112
|
+
* layout. One definition, so every text block on every surface agrees.
|
|
113
|
+
*/
|
|
114
|
+
export function TextTileFrame({
|
|
115
|
+
sx,
|
|
116
|
+
children,
|
|
117
|
+
}: {
|
|
118
|
+
sx?: SxProps<Theme>;
|
|
119
|
+
children: ReactNode;
|
|
120
|
+
}) {
|
|
121
|
+
return (
|
|
122
|
+
<TileCard chrome="none" kind="text" {...(sx ? { sx } : {})}>
|
|
123
|
+
{children}
|
|
124
|
+
</TileCard>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The control row, pinned to the top of the scroller so the controls stay in
|
|
130
|
+
* reach while the tiles scroll under, with a hairline under it only while
|
|
131
|
+
* pinned: tiles passing beneath read as going under a bar rather than being
|
|
132
|
+
* cut off by nothing.
|
|
133
|
+
*/
|
|
134
|
+
export function StickyControls({ children }: { children: ReactNode }) {
|
|
135
|
+
const { theme } = usePublisherTheme();
|
|
136
|
+
const { stickyRef, stuck } = useStuck();
|
|
137
|
+
return (
|
|
138
|
+
<Box
|
|
139
|
+
ref={stickyRef}
|
|
140
|
+
className={reportClasses.filterRow}
|
|
141
|
+
data-stuck={stuck || undefined}
|
|
142
|
+
sx={{
|
|
143
|
+
position: "sticky",
|
|
144
|
+
top: `${STUCK_TOP_PX}px`,
|
|
145
|
+
zIndex: STICKY_CONTROLS_Z,
|
|
146
|
+
bgcolor: "background.default",
|
|
147
|
+
// Room under the bar for the edge, so the line never sits on the
|
|
148
|
+
// controls themselves.
|
|
149
|
+
pb: 1,
|
|
150
|
+
// And room over them, for what stands above a control (a filter's
|
|
151
|
+
// × in the builder): pinned, the bar's top is the scroller's edge,
|
|
152
|
+
// and the badge was cut off there. Taken back by the margin, so the
|
|
153
|
+
// row sits where it did while unpinned.
|
|
154
|
+
pt: 1,
|
|
155
|
+
mt: -1,
|
|
156
|
+
// A shadow rather than a border: drawing the edge must not change
|
|
157
|
+
// the bar's height, or the page jumps as it pins.
|
|
158
|
+
boxShadow: stuck
|
|
159
|
+
? `0 1px 0 ${edgeColor(theme.cardBorder)}`
|
|
160
|
+
: "none",
|
|
161
|
+
transition: `box-shadow ${MOTION_FAST}`,
|
|
162
|
+
...reducedMotionSx,
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
{children}
|
|
166
|
+
</Box>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { DEFAULT_COLUMNS } from "../Dashboard/DashboardGrid";
|
|
6
|
+
import { layoutRules } from "./layoutRules";
|
|
7
|
+
|
|
8
|
+
describe("layoutRules", () => {
|
|
9
|
+
it("lays a linear report in one column of full-width tiles, added between others", () => {
|
|
10
|
+
expect(layoutRules("linear", 12)).toEqual({
|
|
11
|
+
layout: "linear",
|
|
12
|
+
columns: 1,
|
|
13
|
+
widths: false,
|
|
14
|
+
insertBetween: true,
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("lays a grid across its declared columns, with widths, added at the end", () => {
|
|
19
|
+
expect(layoutRules("grid", 12)).toEqual({
|
|
20
|
+
layout: "grid",
|
|
21
|
+
columns: 12,
|
|
22
|
+
widths: true,
|
|
23
|
+
insertBetween: false,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("reads no layout as a grid, at the default width", () => {
|
|
28
|
+
expect(layoutRules(undefined).columns).toBe(DEFAULT_COLUMNS);
|
|
29
|
+
expect(layoutRules(undefined).layout).toBe("grid");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("gives a one-column grid no widths to set", () => {
|
|
33
|
+
expect(layoutRules("grid", 1).widths).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import type { ReportLayout } from "../Package/documentLocation";
|
|
5
|
+
import { DEFAULT_COLUMNS } from "../Dashboard/DashboardGrid";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* What a report's layout decides, and nothing else.
|
|
9
|
+
*
|
|
10
|
+
* A linear report and a grid draw the same page (header, filter row, cards,
|
|
11
|
+
* prose) through the same components; the layout only constrains how tiles
|
|
12
|
+
* are arranged on it. Every surface that arranges tiles (the reader's grid,
|
|
13
|
+
* the builder's grid, adding a tile) asks this one function rather than
|
|
14
|
+
* branching on the layout itself, so a new constraint is added here once and
|
|
15
|
+
* the two layouts cannot drift apart in how they look.
|
|
16
|
+
*/
|
|
17
|
+
export interface LayoutRules {
|
|
18
|
+
layout: ReportLayout;
|
|
19
|
+
/** Columns the grid lays tiles across: one for linear, whatever it says, as the server reads it. */
|
|
20
|
+
columns: number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether a tile has a width of its own: dragged at its edge, stepped with
|
|
23
|
+
* the arrow keys, written as `# colspan`. Off in one column, where every
|
|
24
|
+
* tile is the column's width and a width in the file is not the builder's
|
|
25
|
+
* to rewrite.
|
|
26
|
+
*/
|
|
27
|
+
widths: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether tiles are added between others: a "+" under each tile and an
|
|
30
|
+
* "Add tile" after the last. A top-to-bottom report is written by
|
|
31
|
+
* inserting; a grid is arranged by dragging, so it adds at the end.
|
|
32
|
+
*/
|
|
33
|
+
insertBetween: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function layoutRules(
|
|
37
|
+
layout: ReportLayout | undefined,
|
|
38
|
+
/** `# dashboard { columns=N }` as the file has it. */
|
|
39
|
+
declaredColumns?: number,
|
|
40
|
+
): LayoutRules {
|
|
41
|
+
if (layout === "linear")
|
|
42
|
+
return {
|
|
43
|
+
layout: "linear",
|
|
44
|
+
columns: 1,
|
|
45
|
+
widths: false,
|
|
46
|
+
insertBetween: true,
|
|
47
|
+
};
|
|
48
|
+
const columns = declaredColumns ?? DEFAULT_COLUMNS;
|
|
49
|
+
return {
|
|
50
|
+
layout: "grid",
|
|
51
|
+
columns,
|
|
52
|
+
widths: columns > 1,
|
|
53
|
+
insertBetween: false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import type { useServer } from "../ServerProvider";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The one read of a report's manifest, `GET …/reports/{path}`, shared by the
|
|
8
|
+
* reader and the builder so switching between them draws from one cache entry
|
|
9
|
+
* rather than reading the report again.
|
|
10
|
+
*
|
|
11
|
+
* `staleTime` is how long a read is reused without asking the server: 0 (every
|
|
12
|
+
* mount asks) unless a caller draws the same report twice in a row, as the
|
|
13
|
+
* builder does over the reader it keeps on screen while it loads. A write this
|
|
14
|
+
* app makes invalidates every `report` entry, but a change it did not make (a
|
|
15
|
+
* watch-mode save, another client's write, a package reload) is only seen by
|
|
16
|
+
* asking, so a standalone reader keeps 0.
|
|
17
|
+
*/
|
|
18
|
+
export function reportQueryOptions(
|
|
19
|
+
apiClients: ReturnType<typeof useServer>["apiClients"],
|
|
20
|
+
{
|
|
21
|
+
environmentName,
|
|
22
|
+
packageName,
|
|
23
|
+
path,
|
|
24
|
+
versionId,
|
|
25
|
+
}: {
|
|
26
|
+
environmentName: string;
|
|
27
|
+
packageName: string;
|
|
28
|
+
path: string;
|
|
29
|
+
versionId: string | undefined;
|
|
30
|
+
},
|
|
31
|
+
/** Omitted, the query client's staleness for the `report` key decides. */
|
|
32
|
+
staleTime?: number,
|
|
33
|
+
) {
|
|
34
|
+
return {
|
|
35
|
+
// Every value the request is built from, so two versions of one report
|
|
36
|
+
// never share a cache entry.
|
|
37
|
+
queryKey: ["report", environmentName, packageName, versionId, path],
|
|
38
|
+
queryFn: async ({ signal }: { signal?: AbortSignal }) =>
|
|
39
|
+
(
|
|
40
|
+
await apiClients.reports.getReport(
|
|
41
|
+
environmentName,
|
|
42
|
+
packageName,
|
|
43
|
+
path,
|
|
44
|
+
versionId,
|
|
45
|
+
{ signal },
|
|
46
|
+
)
|
|
47
|
+
).data,
|
|
48
|
+
...(staleTime === undefined ? {} : { staleTime }),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** How long the builder, and the reader drawn while it loads, reuse one read of the report. */
|
|
53
|
+
export const BUILDER_HANDOFF_STALE_MS = 10_000;
|
|
@@ -107,8 +107,6 @@ export type ReportEvent =
|
|
|
107
107
|
tiles: number;
|
|
108
108
|
/** Whether a tile was added or removed, which moves declarations. */
|
|
109
109
|
structural: boolean;
|
|
110
|
-
/** The save rewrote a report in the cell format as tiles. */
|
|
111
|
-
converted?: boolean;
|
|
112
110
|
where: SavesTo;
|
|
113
111
|
/** The host workspace that took the write; never set for a package save. */
|
|
114
112
|
workspace?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { fireEvent, render, screen
|
|
4
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
5
5
|
import { describe, expect, it, mock } from "bun:test";
|
|
6
6
|
import { AddTileDialog } from "./AddTileDialog";
|
|
7
7
|
import { openDocument } from "./testing/fixtures";
|
|
@@ -32,57 +32,92 @@ const catalog = {
|
|
|
32
32
|
],
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
const mount = async (
|
|
36
|
+
onAdd: (tile: unknown) => void = () => {},
|
|
37
|
+
onAddText: () => void = () => {},
|
|
38
|
+
) =>
|
|
39
|
+
render(
|
|
40
|
+
<AddTileDialog
|
|
41
|
+
open
|
|
42
|
+
document={await openDocument(SOURCE)}
|
|
43
|
+
catalog={catalog}
|
|
44
|
+
columns={12}
|
|
45
|
+
onClose={() => {}}
|
|
46
|
+
onAdd={onAdd}
|
|
47
|
+
onAddText={onAddText}
|
|
48
|
+
/>,
|
|
49
|
+
);
|
|
50
|
+
|
|
35
51
|
describe("AddTileDialog", () => {
|
|
36
|
-
it("opens on
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)
|
|
61
|
-
|
|
52
|
+
it("opens on the first view, and names a source with no views rather than offering it", async () => {
|
|
53
|
+
await mount();
|
|
54
|
+
const option = screen.getByRole("option", { name: "Totals (totals)" });
|
|
55
|
+
expect(option.getAttribute("aria-selected")).toBe("true");
|
|
56
|
+
expect(screen.getByText(/with no views to show: empty/)).toBeDefined();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("adds the picked view, with the title typed for it", async () => {
|
|
60
|
+
const onAdd = mock((_tile: unknown) => {});
|
|
61
|
+
await mount(onAdd);
|
|
62
|
+
fireEvent.change(screen.getByLabelText("Tile title"), {
|
|
63
|
+
target: { value: "All totals" },
|
|
64
|
+
});
|
|
65
|
+
fireEvent.click(screen.getByRole("button", { name: "Add tile" }));
|
|
66
|
+
expect(onAdd).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(onAdd.mock.calls[0]?.[0]).toMatchObject({
|
|
68
|
+
base: "stocked",
|
|
69
|
+
view: "totals",
|
|
70
|
+
label: "All totals",
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("searches, and Enter adds what the search left picked", async () => {
|
|
75
|
+
const onAdd = mock((_tile: unknown) => {});
|
|
76
|
+
await mount(onAdd);
|
|
77
|
+
const search = screen.getByRole("combobox", { name: "Search views" });
|
|
78
|
+
fireEvent.change(search, { target: { value: "nothing like it" } });
|
|
79
|
+
expect(screen.getByText(/No view matches/)).toBeDefined();
|
|
80
|
+
fireEvent.change(search, { target: { value: "tot" } });
|
|
81
|
+
fireEvent.keyDown(search, { key: "Enter" });
|
|
82
|
+
expect(onAdd).toHaveBeenCalledTimes(1);
|
|
62
83
|
});
|
|
63
84
|
|
|
64
|
-
it("adds a text tile without
|
|
65
|
-
const
|
|
66
|
-
const onAdd = mock(() => {});
|
|
85
|
+
it("adds a text tile instead, without a view", async () => {
|
|
86
|
+
const onAdd = mock((_tile: unknown) => {});
|
|
67
87
|
const onAddText = mock(() => {});
|
|
88
|
+
await mount(onAdd, onAddText);
|
|
89
|
+
fireEvent.click(screen.getByRole("button", { name: "Add text instead" }));
|
|
90
|
+
expect(onAddText).toHaveBeenCalledTimes(1);
|
|
91
|
+
expect(onAdd).not.toHaveBeenCalled();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("Enter takes the top match when a search hides the pick", async () => {
|
|
95
|
+
const onAdd = mock((_tile: unknown) => {});
|
|
68
96
|
render(
|
|
69
97
|
<AddTileDialog
|
|
70
98
|
open
|
|
71
|
-
document={
|
|
72
|
-
catalog={
|
|
99
|
+
document={await openDocument(SOURCE)}
|
|
100
|
+
catalog={{
|
|
101
|
+
sources: [
|
|
102
|
+
{
|
|
103
|
+
name: "stocked",
|
|
104
|
+
modelPath: "m.malloy",
|
|
105
|
+
views: [{ name: "totals" }, { name: "by_brand" }],
|
|
106
|
+
givens: [],
|
|
107
|
+
fields: [],
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
}}
|
|
73
111
|
columns={12}
|
|
74
112
|
onClose={() => {}}
|
|
75
113
|
onAdd={onAdd}
|
|
76
|
-
onAddText={
|
|
114
|
+
onAddText={() => {}}
|
|
77
115
|
/>,
|
|
78
116
|
);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
fireEvent.click(screen.getByRole("button", { name: "Add text" }));
|
|
85
|
-
expect(onAddText).toHaveBeenCalledTimes(1);
|
|
86
|
-
expect(onAdd).not.toHaveBeenCalled();
|
|
117
|
+
// Opens on `totals`; the search hides it.
|
|
118
|
+
const search = screen.getByRole("combobox", { name: "Search views" });
|
|
119
|
+
fireEvent.change(search, { target: { value: "brand" } });
|
|
120
|
+
fireEvent.keyDown(search, { key: "Enter" });
|
|
121
|
+
expect(onAdd.mock.calls[0]?.[0]).toMatchObject({ view: "by_brand" });
|
|
87
122
|
});
|
|
88
123
|
});
|