@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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import { clearReportDraft, reportDraftKey } from "./useReportDraft";
|
|
4
5
|
import { Alert, Button, Stack } from "@mui/material";
|
|
5
6
|
import { useQueryClient } from "@tanstack/react-query";
|
|
6
7
|
import { useCallback, useEffect, useRef } from "react";
|
|
7
|
-
import type { Given } from "../../client";
|
|
8
8
|
import type { HostGivenValue } from "../../hooks/givenValue";
|
|
9
9
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
10
10
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
} from "../Report/telemetry";
|
|
17
17
|
import { now } from "../../utils/clock";
|
|
18
18
|
import { useOptionalDocumentStorage } from "../DocumentStorage";
|
|
19
|
+
import type { ReactNode } from "react";
|
|
19
20
|
import { Loading } from "../Loading";
|
|
20
21
|
import { documentSlug } from "../Package/documentLocation";
|
|
21
22
|
import { useServer } from "../ServerProvider";
|
|
@@ -34,6 +35,7 @@ import { EditorSurface } from "./EditorSurface";
|
|
|
34
35
|
import { useHostCopy } from "./useHostCopy";
|
|
35
36
|
import { useOpenedDocument } from "./useOpenedDocument";
|
|
36
37
|
import { useSaveChannel } from "./useSaveChannel";
|
|
38
|
+
import type { BuilderControlsHandler } from "./builderControls";
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* The builder, opened on a package dashboard, with everything a host has to
|
|
@@ -92,6 +94,13 @@ export type ReportEditorProps = (
|
|
|
92
94
|
* layout — for the host to log or count; see `ReportEvent`.
|
|
93
95
|
*/
|
|
94
96
|
onEvent?: ReportEventHandler;
|
|
97
|
+
/**
|
|
98
|
+
* What to draw while the report opens (its text read, the builder's data
|
|
99
|
+
* loaded); default a spinner. A host that just showed the report can pass
|
|
100
|
+
* the report itself, so switching to edit replaces the page in place
|
|
101
|
+
* rather than blanking it to a spinner first.
|
|
102
|
+
*/
|
|
103
|
+
loading?: ReactNode;
|
|
95
104
|
/**
|
|
96
105
|
* The report's layout as the host knows it before the text is read: from
|
|
97
106
|
* the package's listing, or for a draft the layout its store recorded.
|
|
@@ -124,6 +133,26 @@ export type ReportEditorProps = (
|
|
|
124
133
|
* header View) leaves it unset and guards with `onDirtyChange`.
|
|
125
134
|
*/
|
|
126
135
|
onExit?: () => void;
|
|
136
|
+
/**
|
|
137
|
+
* Open a model by its package path (`storefront.malloy`). Offered as "Open
|
|
138
|
+
* the model" on a filter a model sets, which the builder can set but not
|
|
139
|
+
* change; omitted, the filter only says where it is set.
|
|
140
|
+
*/
|
|
141
|
+
onOpenModel?: (modelPath: string) => void;
|
|
142
|
+
/**
|
|
143
|
+
* Take over the builder's page-level controls (save status and Save, undo
|
|
144
|
+
* and redo, the layout switch, Add): handed over as `BuilderControls`
|
|
145
|
+
* whenever they change, with no toolbar drawn on the page. Draw them with
|
|
146
|
+
* `BuilderBar` in the host's header, or place each in its own chrome.
|
|
147
|
+
*/
|
|
148
|
+
onControlsChange?: BuilderControlsHandler;
|
|
149
|
+
/**
|
|
150
|
+
* Keep unsaved edits in this browser, per report, and put them back when
|
|
151
|
+
* the report is next opened for editing here: leaving never loses work, so
|
|
152
|
+
* the host's way out can be the controls' `done` (write, then leave) with
|
|
153
|
+
* no "leave with unsaved changes?" on the way.
|
|
154
|
+
*/
|
|
155
|
+
keepDraft?: boolean;
|
|
127
156
|
/** Edit a document held as text; see {@link TextSourceOptions}. */
|
|
128
157
|
textSource?: TextSourceOptions;
|
|
129
158
|
/**
|
|
@@ -143,8 +172,9 @@ export type ReportEditorProps = (
|
|
|
143
172
|
* sources the document may name. The manifest is that compile's `document`, and
|
|
144
173
|
* every tile, cell and control option runs as the document's definitions
|
|
145
174
|
* followed by one `run:`, so each viewer sees what their own identity allows.
|
|
146
|
-
* The
|
|
147
|
-
* and only the model's givens can be bound
|
|
175
|
+
* The server's compile refuses an `import`, `##!` or `given:` in the text, so
|
|
176
|
+
* "Add filter" is off and only the model's givens can be bound, unless the
|
|
177
|
+
* host resolves the document's own givens itself (`compileSource`).
|
|
148
178
|
*/
|
|
149
179
|
export interface TextSourceOptions {
|
|
150
180
|
/** The model the text is compiled and run on top of. */
|
|
@@ -153,13 +183,37 @@ export interface TextSourceOptions {
|
|
|
153
183
|
hiddenGivens?: readonly string[];
|
|
154
184
|
/** The values for the givens the host sets: sent with the compile and with each tile that reads one. */
|
|
155
185
|
givens?: Record<string, HostGivenValue>;
|
|
186
|
+
/**
|
|
187
|
+
* The text to compile in place of the document's own, for a host that
|
|
188
|
+
* resolves what the server's compile refuses in held text: the document's
|
|
189
|
+
* own `given:` declarations, say, written out as literal values. Called
|
|
190
|
+
* with the text as opened; the editor still edits and saves that text.
|
|
191
|
+
*
|
|
192
|
+
* A host that passes it owns how its text compiles, so "Add filter" is
|
|
193
|
+
* on: it writes a `given:` into the text like any report, and the builder
|
|
194
|
+
* runs each tile with that filter's value written in as a literal, since
|
|
195
|
+
* the server does not know the given. Without it, "Add filter" is off,
|
|
196
|
+
* because the server refuses a `given:` in held text.
|
|
197
|
+
*/
|
|
198
|
+
compileSource?: (text: string) => string | Promise<string>;
|
|
199
|
+
/**
|
|
200
|
+
* Names a filter added here must not take: with `compileSource`, every
|
|
201
|
+
* given the model declares, including one only a gate reads, which the
|
|
202
|
+
* page never shows. A document given of the same name would collide with
|
|
203
|
+
* the model's once the report is published.
|
|
204
|
+
*/
|
|
205
|
+
takenGivenNames?: readonly string[];
|
|
156
206
|
}
|
|
157
207
|
|
|
158
208
|
export function ReportEditor(props: ReportEditorProps) {
|
|
159
209
|
const {
|
|
160
210
|
onEvent,
|
|
211
|
+
loading,
|
|
161
212
|
onDirtyChange,
|
|
162
213
|
onExit,
|
|
214
|
+
onOpenModel,
|
|
215
|
+
onControlsChange,
|
|
216
|
+
keepDraft,
|
|
163
217
|
kind,
|
|
164
218
|
path,
|
|
165
219
|
textSource,
|
|
@@ -181,7 +235,7 @@ export function ReportEditor(props: ReportEditorProps) {
|
|
|
181
235
|
const dashboardName = named ?? documentSlug(path) ?? "";
|
|
182
236
|
const noun = "report";
|
|
183
237
|
|
|
184
|
-
const { apiClients, mutable, isLoadingStatus } = useServer();
|
|
238
|
+
const { apiClients, mutable, isLoadingStatus, server } = useServer();
|
|
185
239
|
const queryClient = useQueryClient();
|
|
186
240
|
// When the editor was asked for — or the reader chose what to open — so
|
|
187
241
|
// "opened" can say how long it took. Read through refs by the open effect,
|
|
@@ -328,14 +382,30 @@ export function ReportEditor(props: ReportEditorProps) {
|
|
|
328
382
|
});
|
|
329
383
|
}, [fetchFailed, modelQuery.error, modelPath, layout]);
|
|
330
384
|
// Stable: the builder fires this from an effect that depends on it.
|
|
385
|
+
// The editor's own record is every unsaved edit: it decides whether a
|
|
386
|
+
// newer version of the file may replace what is open, and with a draft
|
|
387
|
+
// kept, reporting only what leaving would lose let the other author's
|
|
388
|
+
// version replace the author's edits. The host's leave guard gets what
|
|
389
|
+
// leaving would lose.
|
|
331
390
|
const reportDirty = useCallback(
|
|
332
|
-
(value: boolean) => {
|
|
391
|
+
(value: boolean, wouldLose: boolean) => {
|
|
333
392
|
setDirty(value);
|
|
334
|
-
onDirtyChangeRef.current?.(
|
|
393
|
+
onDirtyChangeRef.current?.(wouldLose);
|
|
335
394
|
},
|
|
336
395
|
[setDirty],
|
|
337
396
|
);
|
|
338
397
|
|
|
398
|
+
// One per report, version and server: a draft is never restored onto a
|
|
399
|
+
// file it was not made on.
|
|
400
|
+
const draftKey = keepDraft
|
|
401
|
+
? reportDraftKey({
|
|
402
|
+
server,
|
|
403
|
+
environmentName,
|
|
404
|
+
packageName,
|
|
405
|
+
versionId,
|
|
406
|
+
path: path ?? dashboardName,
|
|
407
|
+
})
|
|
408
|
+
: undefined;
|
|
339
409
|
const saveLabel =
|
|
340
410
|
savesTo === "host" && workspace?.description
|
|
341
411
|
? workspace.description
|
|
@@ -353,8 +423,17 @@ export function ReportEditor(props: ReportEditorProps) {
|
|
|
353
423
|
...(readFailure !== undefined ? { readFailure } : {}),
|
|
354
424
|
...(versionId !== undefined ? { versionId } : {}),
|
|
355
425
|
});
|
|
356
|
-
//
|
|
357
|
-
|
|
426
|
+
// Only what is out of the ordinary: Save off, a pinned version, a copy
|
|
427
|
+
// that could not be read. Where an ordinary save goes is the bar's status
|
|
428
|
+
// to say (its tooltip), and a line under every report repeating it was
|
|
429
|
+
// noise. The description is already the Save caption, so it is not
|
|
430
|
+
// repeated either.
|
|
431
|
+
const ordinary =
|
|
432
|
+
savesTo === "package" &&
|
|
433
|
+
takesWrites === true &&
|
|
434
|
+
!pinnedPackageSave &&
|
|
435
|
+
readFailure === undefined;
|
|
436
|
+
const note = ordinary || caption === saveLabel ? "" : caption;
|
|
358
437
|
|
|
359
438
|
// After every hook, so the hook order does not depend on the URI. Same
|
|
360
439
|
// reasoning as `Dashboard`'s own check.
|
|
@@ -380,7 +459,7 @@ export function ReportEditor(props: ReportEditorProps) {
|
|
|
380
459
|
/>
|
|
381
460
|
);
|
|
382
461
|
if (!opened && (!(textHeld || packageText) || !draftChecked))
|
|
383
|
-
return <Loading text={`Opening the ${noun}…`} />;
|
|
462
|
+
return loading ?? <Loading text={`Opening the ${noun}…`} />;
|
|
384
463
|
// Where the host's copy IS the document, a copy that could not be read
|
|
385
464
|
// leaves nothing safe to edit: the package file is a deploy of the record,
|
|
386
465
|
// so opening it and arming Save would publish it over the record.
|
|
@@ -425,7 +504,16 @@ export function ReportEditor(props: ReportEditorProps) {
|
|
|
425
504
|
<Alert
|
|
426
505
|
severity="warning"
|
|
427
506
|
action={
|
|
428
|
-
<Button
|
|
507
|
+
<Button
|
|
508
|
+
size="small"
|
|
509
|
+
onClick={() => {
|
|
510
|
+
// Loading the other version is dropping these edits,
|
|
511
|
+
// so the draft holding them goes too: kept, it would
|
|
512
|
+
// be offered straight back over the version chosen.
|
|
513
|
+
if (draftKey !== undefined) clearReportDraft(draftKey);
|
|
514
|
+
acceptHeld();
|
|
515
|
+
}}
|
|
516
|
+
>
|
|
429
517
|
Load it
|
|
430
518
|
</Button>
|
|
431
519
|
}
|
|
@@ -444,6 +532,9 @@ export function ReportEditor(props: ReportEditorProps) {
|
|
|
444
532
|
{supersedeFailure}
|
|
445
533
|
</Alert>
|
|
446
534
|
)}
|
|
535
|
+
{/* The text is in hand but the document opens a pass later: the
|
|
536
|
+
loading view meanwhile, never an empty page. */}
|
|
537
|
+
{!opened && (loading ?? <Loading text={`Opening the ${noun}…`} />)}
|
|
447
538
|
{opened && (
|
|
448
539
|
<EditorSurface
|
|
449
540
|
key={opened.generation}
|
|
@@ -452,10 +543,6 @@ export function ReportEditor(props: ReportEditorProps) {
|
|
|
452
543
|
modelPath={modelPath}
|
|
453
544
|
{...(textSource ? { textSource } : {})}
|
|
454
545
|
slug={dashboardName}
|
|
455
|
-
modelGivens={
|
|
456
|
-
(modelQuery.data?.data as { givens?: Given[] } | undefined)
|
|
457
|
-
?.givens
|
|
458
|
-
}
|
|
459
546
|
{...(versionId !== undefined ? { versionId } : {})}
|
|
460
547
|
opened={opened}
|
|
461
548
|
{...(fromDraft &&
|
|
@@ -466,6 +553,9 @@ export function ReportEditor(props: ReportEditorProps) {
|
|
|
466
553
|
onSave={save}
|
|
467
554
|
onDirtyChange={reportDirty}
|
|
468
555
|
{...(onExit ? { onExit } : {})}
|
|
556
|
+
{...(onOpenModel ? { onOpenModel } : {})}
|
|
557
|
+
{...(onControlsChange ? { onControlsChange } : {})}
|
|
558
|
+
{...(draftKey !== undefined ? { draftKey } : {})}
|
|
469
559
|
{...(allowLayoutChange !== undefined
|
|
470
560
|
? { allowLayoutChange }
|
|
471
561
|
: {})}
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { TextTileFrame } from "../Report/ReportPage";
|
|
5
5
|
import { InlineMarkdown } from "./InlineMarkdown";
|
|
6
6
|
import type { TextTile } from "./document";
|
|
7
7
|
|
|
8
8
|
export const TEXT_TILE_PLACEHOLDER =
|
|
9
9
|
"Write markdown: # heading, **bold**, - list";
|
|
10
10
|
|
|
11
|
-
/** A text tile as the builder draws it: its markdown
|
|
11
|
+
/** A text tile as the builder draws it: the reader's prose frame, its markdown edited in place. */
|
|
12
12
|
export function TextTileBody({
|
|
13
13
|
tile,
|
|
14
14
|
onChange,
|
|
15
|
-
chrome = "card",
|
|
16
15
|
}: {
|
|
17
16
|
tile: TextTile;
|
|
18
17
|
onChange: (markdown: string) => void;
|
|
19
|
-
/** The document's tile chrome: a card on a dashboard, bare on a notebook, as the reader draws it. */
|
|
20
|
-
chrome?: TileChrome;
|
|
21
18
|
}) {
|
|
22
19
|
return (
|
|
23
|
-
|
|
20
|
+
// Overflow shown: the open editor's ring and hint stand a few pixels
|
|
21
|
+
// outside the prose, which a clipping frame cut off.
|
|
22
|
+
<TextTileFrame sx={{ overflow: "visible" }}>
|
|
24
23
|
<InlineMarkdown
|
|
25
24
|
markdown={tile.markdown}
|
|
26
25
|
placeholder={TEXT_TILE_PLACEHOLDER}
|
|
27
26
|
onCommit={onChange}
|
|
28
27
|
/>
|
|
29
|
-
</
|
|
28
|
+
</TextTileFrame>
|
|
30
29
|
);
|
|
31
30
|
}
|