@malloy-publisher/sdk 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{RenderedResult-CBLHr32C.es.js → RenderedResult-DwB0-9Yx.es.js} +118 -119
- package/dist/{RenderedResult-B48wAjM8.cjs.js → RenderedResult-hKjFEqaN.cjs.js} +2 -2
- package/dist/{ServerProvider-DCV8BUWD.es.js → ServerProvider-CcSrGaRN.es.js} +1281 -1142
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +112 -115
- package/dist/builder/index.es.js +11766 -11502
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +170 -9
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +93 -89
- package/dist/client-entry.d.ts +2 -0
- package/dist/components/ApiErrorDisplay.d.ts +11 -0
- package/dist/components/AppDialog.d.ts +6 -6
- package/dist/components/Dashboard/DashboardGrid.d.ts +18 -3
- package/dist/components/Dashboard/DashboardTile.d.ts +12 -2
- package/dist/components/Dashboard/DashboardView.d.ts +38 -3
- package/dist/components/Dashboard/TileCard.d.ts +16 -2
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +3 -2
- package/dist/components/Dashboard/telemetry.d.ts +2 -1
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +7 -8
- package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
- package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
- package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +14 -17
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +3 -1
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +15 -7
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +28 -2
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +6 -4
- package/dist/components/DashboardBuilder/InlineText.d.ts +1 -1
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +4 -1
- package/dist/components/DashboardBuilder/TileFrame.d.ts +43 -6
- package/dist/components/DashboardBuilder/TileMenu.d.ts +6 -8
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +0 -18
- package/dist/components/DashboardBuilder/documentSession.d.ts +2 -2
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +3 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/sortable.d.ts +2 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -0
- package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
- package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
- package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +4 -7
- package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
- package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +2 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
- package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
- package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
- package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +32 -0
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/Package.d.ts +16 -1
- package/dist/components/Package/index.d.ts +1 -1
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +1 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +9760 -10363
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-CbbBcZl8.es.js → text-entry-CA0LZ1xL.es.js} +8 -8
- package/dist/text-entry.d.ts +1 -1
- package/dist/theme/accent.d.ts +29 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/keys.d.ts +1 -1
- package/dist/theme/motion.d.ts +31 -0
- package/dist/theme/readChartAnnotations.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +4 -4
- package/dist/theme/types.d.ts +33 -5
- package/dist/{DashboardTile-BFcxdv7R.es.js → useCompiledDocument-BU6d8FPp.es.js} +6978 -6289
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/package.json +11 -11
- package/src/builder-entry.ts +1 -0
- package/src/client-entry.ts +8 -0
- package/src/clientEntry.spec.ts +17 -0
- package/src/components/ApiErrorDisplay.tsx +37 -18
- package/src/components/AppDialog.tsx +8 -7
- package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
- package/src/components/Dashboard/Dashboard.tsx +2 -2
- package/src/components/Dashboard/DashboardGrid.tsx +23 -5
- package/src/components/Dashboard/DashboardTile.spec.tsx +97 -2
- package/src/components/Dashboard/DashboardTile.tsx +95 -31
- package/src/components/Dashboard/DashboardView.spec.tsx +156 -0
- package/src/components/Dashboard/DashboardView.tsx +165 -89
- package/src/components/Dashboard/RowsDialog.tsx +3 -2
- package/src/components/Dashboard/TileCard.tsx +17 -2
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +11 -2
- package/src/components/Dashboard/telemetry.ts +2 -1
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -56
- package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
- package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
- package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +86 -113
- package/src/components/DashboardBuilder/ChartPicker.tsx +4 -1
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +5 -5
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +74 -83
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +62 -18
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +55 -108
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +10 -62
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +50 -57
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +53 -40
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +10 -8
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +227 -704
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +32 -52
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +1 -50
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +12 -18
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +4 -24
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +4 -4
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +8 -13
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +142 -820
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +13 -8
- package/src/components/DashboardBuilder/FilterStrip.tsx +117 -79
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +7 -9
- package/src/components/DashboardBuilder/InlineText.tsx +23 -17
- package/src/components/DashboardBuilder/NotebookEditor.tsx +3 -3
- package/src/components/DashboardBuilder/TextTileBody.tsx +5 -2
- package/src/components/DashboardBuilder/TileFrame.tsx +255 -90
- package/src/components/DashboardBuilder/TileMenu.tsx +41 -91
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +1 -1
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +9 -4
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +0 -44
- package/src/components/DashboardBuilder/catalog.ts +0 -36
- package/src/components/DashboardBuilder/controls.spec.ts +1 -1
- package/src/components/DashboardBuilder/controls.ts +1 -1
- package/src/components/DashboardBuilder/documentSession.ts +3 -2
- package/src/components/DashboardBuilder/imports.spec.ts +61 -0
- package/src/components/DashboardBuilder/imports.ts +93 -0
- package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1 -1
- package/src/components/DashboardBuilder/malloyTree.ts +5 -1
- package/src/components/DashboardBuilder/newDashboard.ts +1 -1
- package/src/components/DashboardBuilder/preview.ts +1 -1
- package/src/components/DashboardBuilder/readDocument.spec.ts +36 -0
- package/src/components/DashboardBuilder/readDocument.ts +10 -4
- package/src/components/DashboardBuilder/readForEditor.ts +7 -2
- package/src/components/DashboardBuilder/sortable.spec.ts +25 -1
- package/src/components/DashboardBuilder/sortable.tsx +11 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +8 -3
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +62 -6
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/inline.ts +1 -1
- package/src/components/DashboardBuilder/testing/resize.ts +48 -0
- package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +43 -1
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +0 -85
- package/src/components/DashboardBuilder/useBuilderSession.ts +6 -43
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +32 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +11 -1
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +5 -2
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
- package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
- package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
- package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
- package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +146 -0
- package/src/components/DashboardBuilder/useTileResize.ts +133 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/guards.ts +1 -1
- package/src/components/Environment/Environment.tsx +0 -10
- package/src/components/Loading.tsx +14 -0
- package/src/components/Model/Model.tsx +16 -9
- package/src/components/Model/ModelExplorer.tsx +2 -2
- package/src/components/Notebook/Notebook.tsx +6 -2
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/Package.artifacts.spec.tsx +8 -12
- package/src/components/Package/Package.create.spec.tsx +22 -1
- package/src/components/Package/Package.tsx +51 -27
- package/src/components/Package/index.ts +1 -1
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +5 -7
- package/src/components/RenderedResult/ResultContainer.tsx +7 -2
- package/src/components/RenderedResult/ResultPanel.tsx +20 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.tsx +2 -8
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +1 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCompiledDocument.spec.tsx +86 -0
- package/src/hooks/useCompiledDocument.ts +59 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
- package/src/hooks/useDocumentControls.ts +13 -1
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +7 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/text-entry.ts +1 -1
- package/src/textEntry.spec.ts +2 -8
- package/src/theme/accent.spec.ts +116 -0
- package/src/theme/accent.ts +148 -0
- package/src/theme/buildTableCssVars.spec.ts +24 -0
- package/src/theme/buildTableCssVars.ts +1 -2
- package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
- package/src/theme/buildVegaThemeOverride.ts +5 -5
- package/src/theme/defaults.ts +34 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/keys.ts +6 -0
- package/src/theme/motion.ts +44 -0
- package/src/theme/readChartAnnotations.spec.ts +18 -0
- package/src/theme/readChartAnnotations.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +73 -0
- package/src/theme/resolveTheme.ts +61 -20
- package/src/theme/types.ts +30 -5
- package/src/utils/queryClient.ts +8 -0
- package/dist/DashboardTile-sg8LjUk8.cjs.js +0 -137
- package/dist/ServerProvider-HRqT3w1C.cjs.js +0 -1
- package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -7
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +0 -27
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -32
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +0 -194
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +0 -25
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -103
- package/src/components/DashboardBuilder/SaveNotice.tsx +0 -113
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +0 -87
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -326
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- /package/dist/{components/DashboardBuilder → utils}/malloyText.d.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.ts +0 -0
|
@@ -1,53 +1,28 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { Alert,
|
|
4
|
+
import { Alert, Button, Stack } from "@mui/material";
|
|
5
5
|
import { useQueryClient } from "@tanstack/react-query";
|
|
6
|
-
import { useCallback,
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
6
|
+
import { useCallback, useRef } from "react";
|
|
7
|
+
import type { Given } from "../../client";
|
|
8
|
+
import type { HostGivenValue } from "../../hooks/givenValue";
|
|
9
9
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
10
10
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
11
|
-
import { DashboardTile, tileTitle } from "../Dashboard/DashboardTile";
|
|
12
|
-
import { tileIgnoredFilterLabels } from "../Dashboard/TileFilterTag";
|
|
13
11
|
import type { BuilderEvent } from "./telemetry";
|
|
14
12
|
import { now } from "../../utils/clock";
|
|
15
|
-
import {
|
|
16
|
-
import { useDocumentControls } from "../../hooks/useDocumentControls";
|
|
17
|
-
import {
|
|
18
|
-
isDocumentNotFound,
|
|
19
|
-
useOptionalDocumentStorage,
|
|
20
|
-
type Workspace,
|
|
21
|
-
} from "../DocumentStorage";
|
|
22
|
-
import { GivensPanel } from "../given";
|
|
23
|
-
import { DashboardBar } from "../Dashboard/DashboardBar";
|
|
24
|
-
import type { TileHeadingSlots } from "../Dashboard/TileCard";
|
|
13
|
+
import { useOptionalDocumentStorage } from "../DocumentStorage";
|
|
25
14
|
import { Loading } from "../Loading";
|
|
26
|
-
import { TILE_MAX_HEIGHT } from "../RenderedResult/resultSizing";
|
|
27
15
|
import { useServer } from "../ServerProvider";
|
|
16
|
+
import type { DocumentKind } from "./document";
|
|
28
17
|
import {
|
|
29
|
-
buildCatalog,
|
|
30
|
-
isDashboardModel,
|
|
31
|
-
visibleToDashboard,
|
|
32
|
-
type PackageCatalog,
|
|
33
|
-
} from "./catalog";
|
|
34
|
-
import { locatorFor } from "../DocumentCreate/documentPath";
|
|
35
|
-
import { DashboardBuilder } from "./DashboardBuilder";
|
|
36
|
-
import type { DashboardDocument, DocumentKind, QueryTile } from "./document";
|
|
37
|
-
import { previewGivens, previewTileQuery, tileExpressionKey } from "./preview";
|
|
38
|
-
import {
|
|
39
|
-
chooseWorkspace,
|
|
40
|
-
expectedHashFor,
|
|
41
18
|
resolveEditorTarget,
|
|
42
19
|
saveCaption,
|
|
43
|
-
saveTarget,
|
|
44
|
-
storageErrorMessage,
|
|
45
20
|
withWorkspace,
|
|
46
|
-
writePackageFile,
|
|
47
|
-
type SavesTo,
|
|
48
21
|
} from "./documentSession";
|
|
49
|
-
import {
|
|
50
|
-
import
|
|
22
|
+
import { EditorSurface } from "./EditorSurface";
|
|
23
|
+
import { useHostCopy } from "./useHostCopy";
|
|
24
|
+
import { useOpenedDocument } from "./useOpenedDocument";
|
|
25
|
+
import { useSaveChannel } from "./useSaveChannel";
|
|
51
26
|
|
|
52
27
|
/**
|
|
53
28
|
* The builder, opened on a package dashboard, with everything a host has to
|
|
@@ -86,8 +61,6 @@ export type DashboardEditorProps = (
|
|
|
86
61
|
dashboardName: string;
|
|
87
62
|
}
|
|
88
63
|
) & {
|
|
89
|
-
/** Leave the editor: its "Close", which asks first when edits are unsaved. Absent, no such button. */
|
|
90
|
-
onExit?: () => void;
|
|
91
64
|
/**
|
|
92
65
|
* What the editor does — opened, saved, refused — for the host to log or
|
|
93
66
|
* count; see `DashboardEvent`. A notebook reports `NotebookEvent`s instead.
|
|
@@ -114,17 +87,47 @@ export type DashboardEditorProps = (
|
|
|
114
87
|
* without this a host cannot tell whether leaving costs anything.
|
|
115
88
|
*/
|
|
116
89
|
onDirtyChange?: (dirty: boolean) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Leave the editor: opted into, it draws Close after Save, which asks first
|
|
92
|
+
* when edits are unsaved. A host with a way out of its own (the Console's
|
|
93
|
+
* header View) leaves it unset and guards with `onDirtyChange`.
|
|
94
|
+
*/
|
|
95
|
+
onExit?: () => void;
|
|
96
|
+
/** Edit a document held as text; see {@link TextSourceOptions}. */
|
|
97
|
+
textSource?: TextSourceOptions;
|
|
117
98
|
};
|
|
118
99
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Open a document the host keeps as TEXT, rather than a file in a package.
|
|
102
|
+
*
|
|
103
|
+
* The text comes from the host's authoritative {@link DocumentStorage} and is
|
|
104
|
+
* compiled by the server, as the viewer, on top of `modelPath`: the model whose
|
|
105
|
+
* sources the document may name. The manifest is that compile's `document`, and
|
|
106
|
+
* every tile, cell and control option runs as the document's definitions
|
|
107
|
+
* followed by one `run:`, so each viewer sees what their own identity allows.
|
|
108
|
+
* The document carries no `import`, `##!` or `given:`, so "Add filter" is off
|
|
109
|
+
* and only the model's givens can be bound.
|
|
110
|
+
*/
|
|
111
|
+
export interface TextSourceOptions {
|
|
112
|
+
/** The model the text is compiled and run on top of. */
|
|
113
|
+
modelPath: string;
|
|
114
|
+
/** Givens the host sets itself: no control is shown for them. */
|
|
115
|
+
hiddenGivens?: readonly string[];
|
|
116
|
+
/** The values for the givens the host sets: sent with the compile and with each tile that reads one. */
|
|
117
|
+
givens?: Record<string, HostGivenValue>;
|
|
118
|
+
}
|
|
124
119
|
|
|
125
120
|
export function DashboardEditor(props: DashboardEditorProps) {
|
|
126
|
-
const {
|
|
121
|
+
const {
|
|
122
|
+
onEvent,
|
|
123
|
+
onDirtyChange,
|
|
124
|
+
onExit,
|
|
125
|
+
kind = "dashboard",
|
|
126
|
+
path,
|
|
127
|
+
textSource,
|
|
128
|
+
} = props;
|
|
127
129
|
const notebook = kind === "notebook";
|
|
130
|
+
const textHeld = textSource !== undefined;
|
|
128
131
|
// Degraded, not thrown, on a bad URI: a throw in a render body takes the host's whole tree down.
|
|
129
132
|
const {
|
|
130
133
|
environmentName,
|
|
@@ -172,422 +175,96 @@ export function DashboardEditor(props: DashboardEditorProps) {
|
|
|
172
175
|
versionId,
|
|
173
176
|
notebook ? true : undefined,
|
|
174
177
|
),
|
|
175
|
-
enabled: uriNamesBoth && !legacyFormat,
|
|
178
|
+
enabled: uriNamesBoth && !legacyFormat && !textHeld,
|
|
176
179
|
});
|
|
177
180
|
const packageText = (
|
|
178
181
|
modelQuery.data?.data as { sourceText?: string } | undefined
|
|
179
182
|
)?.sourceText;
|
|
180
183
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// Whether a copy was there when the editor opened: only that one is
|
|
186
|
-
// offered. A copy this session saves is not "edits from an earlier visit".
|
|
187
|
-
const [offered, setOffered] = useState(false);
|
|
188
|
-
// A read the backend could not answer, which is not the same as no
|
|
189
|
-
// document. Held rather than swallowed, because "there is nothing saved"
|
|
190
|
-
// is what makes overwriting the record look safe.
|
|
191
|
-
const [readFailure, setReadFailure] = useState<string | undefined>(
|
|
192
|
-
undefined,
|
|
193
|
-
);
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
if (!storage) return;
|
|
196
|
-
let stale = false;
|
|
197
|
-
setReadFailure(undefined);
|
|
198
|
-
(async () => {
|
|
199
|
-
try {
|
|
200
|
-
// Every workspace, not only the writeable ones: a reader who
|
|
201
|
-
// cannot write to the record still has to be shown the record.
|
|
202
|
-
// Asking for writeable only would hide it and fall back to the
|
|
203
|
-
// package, which on a server that takes writes means publishing a
|
|
204
|
-
// deploy of the record over the record.
|
|
205
|
-
const chosen = chooseWorkspace(await storage.listWorkspaces(false));
|
|
206
|
-
if (stale) return;
|
|
207
|
-
setWorkspace(chosen);
|
|
208
|
-
// Only a notebook's record is read: a copy beside the package is never offered back.
|
|
209
|
-
if (chosen !== undefined && (!notebook || chosen.authoritative)) {
|
|
210
|
-
const text = await storage
|
|
211
|
-
.getDocument(
|
|
212
|
-
locatorFor(
|
|
213
|
-
kind,
|
|
214
|
-
chosen.name,
|
|
215
|
-
environmentName,
|
|
216
|
-
packageName,
|
|
217
|
-
modelPath,
|
|
218
|
-
),
|
|
219
|
-
)
|
|
220
|
-
// Absence is the ordinary first visit, not a failure.
|
|
221
|
-
.catch((error: unknown) => {
|
|
222
|
-
if (isDocumentNotFound(error)) return undefined;
|
|
223
|
-
throw error;
|
|
224
|
-
});
|
|
225
|
-
if (stale) return;
|
|
226
|
-
setDraft(text);
|
|
227
|
-
setOffered(text !== undefined);
|
|
228
|
-
}
|
|
229
|
-
} catch (error) {
|
|
230
|
-
if (stale) return;
|
|
231
|
-
setReadFailure(storageErrorMessage(error));
|
|
232
|
-
}
|
|
233
|
-
if (!stale) setDraftChecked(true);
|
|
234
|
-
})();
|
|
235
|
-
return () => {
|
|
236
|
-
stale = true;
|
|
237
|
-
};
|
|
238
|
-
}, [storage, kind, notebook, environmentName, packageName, modelPath]);
|
|
239
|
-
|
|
240
|
-
// The host's copy is the record: the editor opens it, writes back to it,
|
|
241
|
-
// and never offers to "resume" it, because a record is not a pending edit.
|
|
242
|
-
const authoritative = workspace?.authoritative === true;
|
|
243
|
-
// The package file is a deploy of the record, so opening it when the record
|
|
244
|
-
// itself could not be read would put a reader on the wrong document.
|
|
245
|
-
const blockedOnRecord = authoritative && readFailure !== undefined;
|
|
246
|
-
|
|
247
|
-
// What the editor opens: the record when the host keeps one, the copy when
|
|
248
|
-
// the reader chose to resume it, the package file otherwise. `generation`
|
|
249
|
-
// remounts the builder for a fresh history when that choice changes.
|
|
250
|
-
const [resume, setResume] = useState<boolean | undefined>(undefined);
|
|
251
|
-
const fromDraft = authoritative
|
|
252
|
-
? draft !== undefined
|
|
253
|
-
: resume === true && draft !== undefined;
|
|
254
|
-
const [opened, setOpened] = useState<
|
|
255
|
-
| {
|
|
256
|
-
source: string;
|
|
257
|
-
document: DashboardDocument;
|
|
258
|
-
conversion?: { from: string; to: string };
|
|
259
|
-
/** The package file when this opened, which a draft's save overwrites. */
|
|
260
|
-
packageText?: string;
|
|
261
|
-
generation: number;
|
|
262
|
-
}
|
|
263
|
-
| undefined
|
|
264
|
-
>(undefined);
|
|
265
|
-
const [openError, setOpenError] = useState<string | undefined>(
|
|
266
|
-
legacyFormat ? LEGACY_REFUSAL : undefined,
|
|
267
|
-
);
|
|
268
|
-
// The package's hash after this editor's last write, as the server computed
|
|
269
|
-
// it: the base the next save is spliced against.
|
|
270
|
-
const savedHashRef = useRef<string | undefined>(undefined);
|
|
271
|
-
// The package file as it stood when the editor last opened a document. The
|
|
272
|
-
// base a save is spliced against is the package's, which is NOT the text
|
|
273
|
-
// the builder holds: a resumed copy was opened from the store, and a
|
|
274
|
-
// version held back while the reader keeps editing has moved the fetch
|
|
275
|
-
// past the file the reader is answering for.
|
|
276
|
-
const packageBaseRef = useRef<string | undefined>(undefined);
|
|
277
|
-
// What this editor last wrote into the package, and the fetch it was
|
|
278
|
-
// written on top of. The write is in the file before the fetch behind
|
|
279
|
-
// `packageText` catches up, so until a fetch actually lands `packageText`
|
|
280
|
-
// is the text the save replaced rather than a version to open. Tied to the
|
|
281
|
-
// fetch and not to the text, so the NEXT fetch speaks for the file whether
|
|
282
|
-
// it carries this editor's write or someone else's.
|
|
283
|
-
const [wrote, setWrote] = useState<
|
|
284
|
-
{ text: string; onFetch: number } | undefined
|
|
285
|
-
>(undefined);
|
|
286
|
-
const fetchedAt = modelQuery.dataUpdatedAt;
|
|
287
|
-
const fetchedAtRef = useRef(fetchedAt);
|
|
288
|
-
fetchedAtRef.current = fetchedAt;
|
|
289
|
-
const packageNow =
|
|
290
|
-
wrote !== undefined && wrote.onFetch === fetchedAt
|
|
291
|
-
? wrote.text
|
|
292
|
-
: packageText;
|
|
293
|
-
const packageNowRef = useRef(packageNow);
|
|
294
|
-
packageNowRef.current = packageNow;
|
|
295
|
-
const latest = fromDraft ? draft : packageNow;
|
|
296
|
-
|
|
297
|
-
// Whether the builder holds edits the record does not have, and the version
|
|
298
|
-
// being held back because of them.
|
|
299
|
-
const [dirty, setDirty] = useState(false);
|
|
300
|
-
// A save that can still be undone is held like an edit, until the next edit: remounting on a newer version would drop the offer silently.
|
|
301
|
-
const [undoOffered, setUndoOffered] = useState(false);
|
|
302
|
-
const [accepted, setAccepted] = useState<string | undefined>(undefined);
|
|
303
|
-
// The text on this channel the editor has already reckoned with: what it
|
|
304
|
-
// opened, and what it wrote. Compared against the CHANNEL rather than
|
|
305
|
-
// against the builder, because the two diverge legitimately — a copy saved
|
|
306
|
-
// beside the package leaves the builder ahead of a package that has not
|
|
307
|
-
// moved, and reading that as an incoming version would offer a reader
|
|
308
|
-
// their own work back forever.
|
|
309
|
-
const [seen, setSeen] = useState<string | undefined>(undefined);
|
|
310
|
-
const incoming = latest !== undefined && latest !== seen;
|
|
311
|
-
// What the builder is on. A save does not remount it, so this follows the
|
|
312
|
-
// save rather than the text the builder was opened with.
|
|
313
|
-
const current = opened?.source;
|
|
314
|
-
const holding =
|
|
315
|
-
incoming &&
|
|
316
|
-
(dirty || undoOffered) &&
|
|
317
|
-
current !== undefined &&
|
|
318
|
-
latest !== accepted;
|
|
319
|
-
const opening = holding ? current : incoming ? latest : (current ?? latest);
|
|
320
|
-
const held = holding ? latest : undefined;
|
|
321
|
-
|
|
322
|
-
// Read by the open effect so it keeps its single dependency: the guard must
|
|
323
|
-
// not re-run the effect when what it compares against changes.
|
|
324
|
-
const openedSourceRef = useRef(current);
|
|
325
|
-
openedSourceRef.current = current;
|
|
326
|
-
const latestRef = useRef(latest);
|
|
327
|
-
latestRef.current = latest;
|
|
328
|
-
const fromRef = useRef<"package" | "draft" | "record">("package");
|
|
329
|
-
fromRef.current = fromDraft
|
|
330
|
-
? authoritative
|
|
331
|
-
? "record"
|
|
332
|
-
: "draft"
|
|
333
|
-
: "package";
|
|
334
|
-
useEffect(() => {
|
|
335
|
-
// Not until the storage answer is in. Opening on the package file while
|
|
336
|
-
// the editor still has no idea whether the host keeps the record would
|
|
337
|
-
// open the wrong document, and report an open of it.
|
|
338
|
-
if (opening === undefined || !draftChecked || blockedOnRecord) return;
|
|
339
|
-
if (opening === openedSourceRef.current) return;
|
|
340
|
-
let stale = false;
|
|
341
|
-
const packageAtOpen = packageNowRef.current;
|
|
342
|
-
const latestAtOpen = latestRef.current;
|
|
343
|
-
void readForEditor(opening, modelPath)
|
|
344
|
-
.then((result) => {
|
|
345
|
-
if (stale) return;
|
|
346
|
-
if (result.ok === false) {
|
|
347
|
-
setOpenError(result.reason);
|
|
348
|
-
onEventRef.current?.({
|
|
349
|
-
type: refusedEvent,
|
|
350
|
-
reason: result.reason,
|
|
351
|
-
});
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
setOpenError(undefined);
|
|
355
|
-
// A different document is open, so what this editor wrote before is
|
|
356
|
-
// no longer the base anything is spliced against; the package file
|
|
357
|
-
// the reader is now answering for is the one current at this open.
|
|
358
|
-
savedHashRef.current = undefined;
|
|
359
|
-
packageBaseRef.current = packageAtOpen;
|
|
360
|
-
setWrote(undefined);
|
|
361
|
-
setAccepted(undefined);
|
|
362
|
-
setSeen(latestAtOpen);
|
|
363
|
-
setOpened((previous) => ({
|
|
364
|
-
source: opening,
|
|
365
|
-
document: result.document,
|
|
366
|
-
...(result.conversion ? { conversion: result.conversion } : {}),
|
|
367
|
-
...(packageAtOpen !== undefined
|
|
368
|
-
? { packageText: packageAtOpen }
|
|
369
|
-
: {}),
|
|
370
|
-
generation: (previous?.generation ?? 0) + 1,
|
|
371
|
-
}));
|
|
372
|
-
onEventRef.current?.(
|
|
373
|
-
notebook || result.document.kind === "notebook"
|
|
374
|
-
? {
|
|
375
|
-
type: "notebook.opened",
|
|
376
|
-
from:
|
|
377
|
-
fromRef.current === "package" ? "package" : "record",
|
|
378
|
-
cells: result.document.tiles.length,
|
|
379
|
-
durationMs: now() - startedAt.current,
|
|
380
|
-
}
|
|
381
|
-
: {
|
|
382
|
-
type: "dashboard.opened",
|
|
383
|
-
from: fromRef.current,
|
|
384
|
-
tiles: result.document.tiles.length,
|
|
385
|
-
durationMs: now() - startedAt.current,
|
|
386
|
-
},
|
|
387
|
-
);
|
|
388
|
-
})
|
|
389
|
-
.catch((error: unknown) => {
|
|
390
|
-
if (stale) return;
|
|
391
|
-
const reason = `Could not read the ${noun}: ${error instanceof Error ? error.message : String(error)}`;
|
|
392
|
-
setOpenError(reason);
|
|
393
|
-
onEventRef.current?.({ type: refusedEvent, reason });
|
|
394
|
-
});
|
|
395
|
-
return () => {
|
|
396
|
-
stale = true;
|
|
397
|
-
};
|
|
398
|
-
}, [
|
|
399
|
-
opening,
|
|
400
|
-
modelPath,
|
|
184
|
+
const {
|
|
185
|
+
workspace,
|
|
186
|
+
draft,
|
|
187
|
+
setDraft,
|
|
401
188
|
draftChecked,
|
|
189
|
+
offered,
|
|
190
|
+
setOffered,
|
|
191
|
+
readFailure,
|
|
192
|
+
} = useHostCopy({
|
|
193
|
+
storage,
|
|
194
|
+
kind,
|
|
195
|
+
notebook,
|
|
196
|
+
environmentName,
|
|
197
|
+
packageName,
|
|
198
|
+
modelPath,
|
|
199
|
+
});
|
|
200
|
+
const {
|
|
201
|
+
authoritative,
|
|
402
202
|
blockedOnRecord,
|
|
203
|
+
resume,
|
|
204
|
+
setResume,
|
|
205
|
+
fromDraft,
|
|
206
|
+
opened,
|
|
207
|
+
setOpened,
|
|
208
|
+
openError,
|
|
209
|
+
savedHashRef,
|
|
210
|
+
packageBaseRef,
|
|
211
|
+
setWrote,
|
|
212
|
+
fetchedAtRef,
|
|
213
|
+
setDirty,
|
|
214
|
+
setSeen,
|
|
215
|
+
held,
|
|
216
|
+
choose,
|
|
217
|
+
acceptHeld,
|
|
218
|
+
} = useOpenedDocument({
|
|
219
|
+
workspace,
|
|
220
|
+
draft,
|
|
221
|
+
draftChecked,
|
|
222
|
+
readFailure,
|
|
223
|
+
packageText,
|
|
224
|
+
fetchedAt: modelQuery.dataUpdatedAt,
|
|
225
|
+
packageSettled: modelQuery.isSuccess && !modelQuery.isFetching,
|
|
226
|
+
modelPath,
|
|
403
227
|
notebook,
|
|
404
228
|
noun,
|
|
405
229
|
refusedEvent,
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
const locator =
|
|
434
|
-
workspace === undefined
|
|
435
|
-
? undefined
|
|
436
|
-
: locatorFor(
|
|
437
|
-
kind,
|
|
438
|
-
workspace.name,
|
|
439
|
-
environmentName,
|
|
440
|
-
packageName,
|
|
441
|
-
modelPath,
|
|
442
|
-
);
|
|
443
|
-
// Into the host's store: the record when the host says so, and otherwise a
|
|
444
|
-
// copy kept beside the package.
|
|
445
|
-
const saveToStorage = useCallback(
|
|
446
|
-
async (source: string) => {
|
|
447
|
-
if (!storage || !locator)
|
|
448
|
-
throw new Error(
|
|
449
|
-
"This host keeps no documents, so there is nowhere to save.",
|
|
450
|
-
);
|
|
451
|
-
await storage.saveDocument(locator, source);
|
|
452
|
-
// The builder keeps its history and its text; what it holds is now
|
|
453
|
-
// this, not the text it was opened with.
|
|
454
|
-
setOpened((previous) => previous && { ...previous, source });
|
|
455
|
-
setDraft(source);
|
|
456
|
-
// Whenever the copy IS the channel — the record, or a copy the reader
|
|
457
|
-
// resumed — the write moved that channel, and its own text is not an
|
|
458
|
-
// incoming version. A copy written while the package is what is open
|
|
459
|
-
// leaves the package where it was, so nothing there has moved.
|
|
460
|
-
if (authoritative || resume === true) setSeen(source);
|
|
461
|
-
// Saving without choosing is choosing the package file.
|
|
462
|
-
if (!authoritative) setResume((chosen) => chosen ?? false);
|
|
463
|
-
},
|
|
464
|
-
[storage, locator, authoritative, resume],
|
|
465
|
-
);
|
|
466
|
-
// A supersede that did not happen, left where a reader can see it: the copy
|
|
467
|
-
// is still there and will be offered again on the next visit.
|
|
468
|
-
const [supersedeFailure, setSupersedeFailure] = useState<string | undefined>(
|
|
469
|
-
undefined,
|
|
470
|
-
);
|
|
471
|
-
// Into the package itself, when the server takes writes: compile-checked,
|
|
472
|
-
// written atomically and reloaded there, refused if the file changed since
|
|
473
|
-
// it was opened. A copy of the same file kept beside it is superseded by it.
|
|
474
|
-
const saveToPackage = useCallback(
|
|
475
|
-
async (source: string) => {
|
|
476
|
-
// The hash of the package file this editor opened against, never of
|
|
477
|
-
// the latest fetch. A version held back while the reader keeps
|
|
478
|
-
// editing moves the fetch past that file, and a hash taken from it
|
|
479
|
-
// would match, be accepted, and overwrite the change the reader was
|
|
480
|
-
// just told about.
|
|
481
|
-
const expectedHash = await expectedHashFor(
|
|
482
|
-
savedHashRef.current,
|
|
483
|
-
packageBaseRef.current,
|
|
484
|
-
);
|
|
485
|
-
if (expectedHash === undefined)
|
|
486
|
-
throw new Error("The package file is still loading; try again.");
|
|
487
|
-
const modelKey = [
|
|
488
|
-
"dashboard-editor-model",
|
|
489
|
-
environmentName,
|
|
490
|
-
packageName,
|
|
491
|
-
modelPath,
|
|
492
|
-
versionId,
|
|
493
|
-
notebook,
|
|
494
|
-
];
|
|
495
|
-
await writePackageFile({
|
|
496
|
-
apiClients,
|
|
497
|
-
queryClient,
|
|
498
|
-
environmentName,
|
|
499
|
-
packageName,
|
|
500
|
-
modelPath,
|
|
501
|
-
source,
|
|
502
|
-
expectedHash,
|
|
503
|
-
// A refused write usually means the file moved: fetching it offers the reader that version instead of re-saving against a base the server keeps rejecting.
|
|
504
|
-
invalidateOnError: [modelKey],
|
|
505
|
-
afterWrite: async (contentHash) => {
|
|
506
|
-
setOpened((previous) => previous && { ...previous, source });
|
|
507
|
-
setWrote({ text: source, onFetch: fetchedAtRef.current });
|
|
508
|
-
setSeen(source);
|
|
509
|
-
savedHashRef.current = contentHash;
|
|
510
|
-
setSupersedeFailure(undefined);
|
|
511
|
-
if (storage && locator) {
|
|
512
|
-
try {
|
|
513
|
-
await storage.deleteDocument(locator);
|
|
514
|
-
setDraft(undefined);
|
|
515
|
-
setOffered(false);
|
|
516
|
-
} catch (error) {
|
|
517
|
-
// Only absence means the copy is gone; any other rejection leaves it there, so the state must keep saying so.
|
|
518
|
-
if (isDocumentNotFound(error)) {
|
|
519
|
-
setDraft(undefined);
|
|
520
|
-
setOffered(false);
|
|
521
|
-
} else setSupersedeFailure(storageErrorMessage(error));
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
// The package is what is open now even if the copy survived the supersede; reading the channel off a stale copy would put the builder back on the text this save replaced.
|
|
525
|
-
setResume(false);
|
|
526
|
-
},
|
|
527
|
-
invalidate: [
|
|
528
|
-
{ queryKey: modelKey, wait: true },
|
|
529
|
-
// A cached result is keyed on the query text, not the file, so a changed chart would otherwise be drawn from the old rows.
|
|
530
|
-
{
|
|
531
|
-
queryKey: modelResultsKey({
|
|
532
|
-
environmentName,
|
|
533
|
-
packageName,
|
|
534
|
-
versionId,
|
|
535
|
-
modelPath,
|
|
536
|
-
}),
|
|
537
|
-
},
|
|
538
|
-
{ queryKey: ["dashboard-editor-manifest"] },
|
|
539
|
-
{ queryKey: ["dashboards"] },
|
|
540
|
-
{ queryKey: ["dashboard"] },
|
|
541
|
-
// The notebook viewer keys its read on the resource URI.
|
|
542
|
-
...(notebook
|
|
543
|
-
? [
|
|
544
|
-
{
|
|
545
|
-
queryKey: [
|
|
546
|
-
encodeResourceUri({
|
|
547
|
-
environmentName,
|
|
548
|
-
packageName,
|
|
549
|
-
modelPath,
|
|
550
|
-
}),
|
|
551
|
-
],
|
|
552
|
-
},
|
|
553
|
-
]
|
|
554
|
-
: []),
|
|
555
|
-
],
|
|
556
|
-
});
|
|
557
|
-
},
|
|
558
|
-
[
|
|
559
|
-
apiClients,
|
|
560
|
-
environmentName,
|
|
561
|
-
packageName,
|
|
562
|
-
modelPath,
|
|
563
|
-
versionId,
|
|
564
|
-
notebook,
|
|
565
|
-
storage,
|
|
566
|
-
locator,
|
|
567
|
-
queryClient,
|
|
568
|
-
],
|
|
569
|
-
);
|
|
570
|
-
const canWriteWorkspace = workspace?.writeable === true;
|
|
571
|
-
// Unknown while `/status` loads, and a package write needs a yes.
|
|
572
|
-
const takesWrites = mutable === true;
|
|
573
|
-
const { savesTo, pinnedPackageSave, writer } = saveTarget({
|
|
230
|
+
legacyFormat,
|
|
231
|
+
textHeld,
|
|
232
|
+
startedAt,
|
|
233
|
+
onEventRef,
|
|
234
|
+
});
|
|
235
|
+
const {
|
|
236
|
+
save,
|
|
237
|
+
savesTo,
|
|
238
|
+
writer,
|
|
239
|
+
pinnedPackageSave,
|
|
240
|
+
takesWrites,
|
|
241
|
+
supersedeFailure,
|
|
242
|
+
} = useSaveChannel({
|
|
243
|
+
storage,
|
|
244
|
+
workspace,
|
|
245
|
+
kind,
|
|
246
|
+
notebook,
|
|
247
|
+
environmentName,
|
|
248
|
+
packageName,
|
|
249
|
+
modelPath,
|
|
250
|
+
versionId,
|
|
251
|
+
apiClients,
|
|
252
|
+
queryClient,
|
|
253
|
+
mutable,
|
|
254
|
+
textHeld,
|
|
255
|
+
readFailure,
|
|
574
256
|
authoritative,
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
257
|
+
resume,
|
|
258
|
+
setResume,
|
|
259
|
+
setOpened,
|
|
260
|
+
setDraft,
|
|
261
|
+
setOffered,
|
|
262
|
+
setSeen,
|
|
263
|
+
setWrote,
|
|
264
|
+
savedHashRef,
|
|
265
|
+
packageBaseRef,
|
|
266
|
+
fetchedAtRef,
|
|
584
267
|
});
|
|
585
|
-
const save =
|
|
586
|
-
writer === "storage"
|
|
587
|
-
? saveToStorage
|
|
588
|
-
: writer === "package"
|
|
589
|
-
? saveToPackage
|
|
590
|
-
: undefined;
|
|
591
268
|
const workspaceName = workspace?.name;
|
|
592
269
|
const reportEvent = useCallback(
|
|
593
270
|
(event: BuilderEvent) => {
|
|
@@ -596,28 +273,20 @@ export function DashboardEditor(props: DashboardEditorProps) {
|
|
|
596
273
|
[workspaceName],
|
|
597
274
|
);
|
|
598
275
|
// Stable: the builder fires this from an effect that depends on it.
|
|
599
|
-
const reportDirty = useCallback(
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
startedAt.current = now();
|
|
607
|
-
setAccepted(resumeDraft ? draft : packageNow);
|
|
608
|
-
setResume(resumeDraft);
|
|
609
|
-
};
|
|
610
|
-
const acceptHeld = () => {
|
|
611
|
-
startedAt.current = now();
|
|
612
|
-
setAccepted(held);
|
|
613
|
-
};
|
|
276
|
+
const reportDirty = useCallback(
|
|
277
|
+
(value: boolean) => {
|
|
278
|
+
setDirty(value);
|
|
279
|
+
onDirtyChangeRef.current?.(value);
|
|
280
|
+
},
|
|
281
|
+
[setDirty],
|
|
282
|
+
);
|
|
614
283
|
|
|
615
284
|
const saveLabel =
|
|
616
285
|
savesTo === "host" && workspace?.description
|
|
617
286
|
? workspace.description
|
|
618
287
|
: undefined;
|
|
619
288
|
const caption =
|
|
620
|
-
!authoritative && mutable === undefined
|
|
289
|
+
!authoritative && !textHeld && mutable === undefined
|
|
621
290
|
? isLoadingStatus
|
|
622
291
|
? "Checking whether this server takes writes."
|
|
623
292
|
: "This server did not say whether it takes writes, so Save is off."
|
|
@@ -655,16 +324,8 @@ export function DashboardEditor(props: DashboardEditorProps) {
|
|
|
655
324
|
context={`Opening the ${noun}`}
|
|
656
325
|
/>
|
|
657
326
|
);
|
|
658
|
-
if (!opened && (!packageText || !draftChecked))
|
|
659
|
-
|
|
660
|
-
// shape: the reader's view had a bar in this spot, and a spinner where
|
|
661
|
-
// the bar was made the switch look like a page reload.
|
|
662
|
-
return (
|
|
663
|
-
<Stack sx={{ gap: 2 }}>
|
|
664
|
-
<DashboardBar />
|
|
665
|
-
<Loading text={`Opening the ${noun}…`} />
|
|
666
|
-
</Stack>
|
|
667
|
-
);
|
|
327
|
+
if (!opened && (!(textHeld || packageText) || !draftChecked))
|
|
328
|
+
return <Loading text={`Opening the ${noun}…`} />;
|
|
668
329
|
// Where the host's copy IS the document, a copy that could not be read
|
|
669
330
|
// leaves nothing safe to edit: the package file is a deploy of the record,
|
|
670
331
|
// so opening it and arming Save would publish it over the record.
|
|
@@ -714,13 +375,11 @@ export function DashboardEditor(props: DashboardEditorProps) {
|
|
|
714
375
|
</Button>
|
|
715
376
|
}
|
|
716
377
|
>
|
|
717
|
-
{
|
|
718
|
-
? "This dashboard changed since you opened it.
|
|
719
|
-
: savesTo === "
|
|
720
|
-
? "This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and
|
|
721
|
-
:
|
|
722
|
-
? "This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it."
|
|
723
|
-
: "The package's copy of this dashboard changed since you opened it. Your edits are still here; loading the new version replaces them."}
|
|
378
|
+
{savesTo === "package"
|
|
379
|
+
? "This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused."
|
|
380
|
+
: savesTo === "host"
|
|
381
|
+
? "This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it."
|
|
382
|
+
: "The package's copy of this dashboard changed since you opened it. Your edits are still here; loading the new version replaces them."}
|
|
724
383
|
</Alert>
|
|
725
384
|
)}
|
|
726
385
|
{supersedeFailure !== undefined && (
|
|
@@ -731,12 +390,13 @@ export function DashboardEditor(props: DashboardEditorProps) {
|
|
|
731
390
|
</Alert>
|
|
732
391
|
)}
|
|
733
392
|
{opened && (
|
|
734
|
-
<
|
|
393
|
+
<EditorSurface
|
|
735
394
|
key={opened.generation}
|
|
736
395
|
kind={kind}
|
|
737
396
|
environmentName={environmentName}
|
|
738
397
|
packageName={packageName}
|
|
739
398
|
modelPath={modelPath}
|
|
399
|
+
{...(textSource ? { textSource } : {})}
|
|
740
400
|
slug={dashboardName}
|
|
741
401
|
modelGivens={
|
|
742
402
|
(modelQuery.data?.data as { givens?: Given[] } | undefined)
|
|
@@ -751,351 +411,13 @@ export function DashboardEditor(props: DashboardEditorProps) {
|
|
|
751
411
|
: {})}
|
|
752
412
|
onSave={save}
|
|
753
413
|
onDirtyChange={reportDirty}
|
|
754
|
-
|
|
414
|
+
{...(onExit ? { onExit } : {})}
|
|
755
415
|
savesTo={savesTo}
|
|
756
416
|
{...(saveLabel ? { saveLabel } : {})}
|
|
757
417
|
{...(onEvent ? { onEvent: reportEvent } : {})}
|
|
758
|
-
{...(onExit ? { onExit } : {})}
|
|
759
418
|
note={note}
|
|
760
419
|
/>
|
|
761
420
|
)}
|
|
762
421
|
</Stack>
|
|
763
422
|
);
|
|
764
423
|
}
|
|
765
|
-
|
|
766
|
-
/**
|
|
767
|
-
* The builder under a real control row, with the controls driving the tiles,
|
|
768
|
-
* both following the LIVE document rather than the saved file.
|
|
769
|
-
*
|
|
770
|
-
* Owns the given values for the same reason the reader's `Dashboard` does: the
|
|
771
|
-
* bar and the tiles have to read one set of values, so whatever holds them has
|
|
772
|
-
* to sit above both. The manifest supplies what the file cannot say about the
|
|
773
|
-
* model's own givens, and the set of givens the server can be sent; a control
|
|
774
|
-
* declared here and not yet in the package is written into each tile's query as
|
|
775
|
-
* a literal, so it works the moment it is added.
|
|
776
|
-
*/
|
|
777
|
-
function Surface({
|
|
778
|
-
kind,
|
|
779
|
-
modelGivens,
|
|
780
|
-
environmentName,
|
|
781
|
-
packageName,
|
|
782
|
-
modelPath,
|
|
783
|
-
slug,
|
|
784
|
-
versionId,
|
|
785
|
-
opened,
|
|
786
|
-
replaces,
|
|
787
|
-
onSave,
|
|
788
|
-
onDirtyChange,
|
|
789
|
-
onSaveNoticeChange,
|
|
790
|
-
onEvent,
|
|
791
|
-
savesTo,
|
|
792
|
-
saveLabel,
|
|
793
|
-
onExit,
|
|
794
|
-
note,
|
|
795
|
-
}: {
|
|
796
|
-
kind: DocumentKind;
|
|
797
|
-
/** The model's own givens, for a cell-format notebook whose manifest the server cannot build until it is saved. */
|
|
798
|
-
modelGivens?: Given[];
|
|
799
|
-
environmentName: string;
|
|
800
|
-
packageName: string;
|
|
801
|
-
modelPath: string;
|
|
802
|
-
slug: string;
|
|
803
|
-
versionId?: string;
|
|
804
|
-
opened: {
|
|
805
|
-
source: string;
|
|
806
|
-
document: DashboardDocument;
|
|
807
|
-
conversion?: { from: string; to: string };
|
|
808
|
-
generation: number;
|
|
809
|
-
};
|
|
810
|
-
replaces?: string;
|
|
811
|
-
onSave?: (source: string) => Promise<void>;
|
|
812
|
-
onDirtyChange: (dirty: boolean) => void;
|
|
813
|
-
onSaveNoticeChange: (showing: boolean) => void;
|
|
814
|
-
onEvent?: (event: BuilderEvent) => void;
|
|
815
|
-
savesTo: SavesTo;
|
|
816
|
-
saveLabel?: string;
|
|
817
|
-
onExit?: () => void;
|
|
818
|
-
note: string;
|
|
819
|
-
}) {
|
|
820
|
-
const { apiClients } = useServer();
|
|
821
|
-
const notebook = kind === "notebook";
|
|
822
|
-
|
|
823
|
-
// The server serves a dashboard only once the package file has a tile, so
|
|
824
|
-
// an empty start becomes servable when a save puts the first one there.
|
|
825
|
-
const [served, setServed] = useState(opened.document.tiles.length > 0);
|
|
826
|
-
useEffect(
|
|
827
|
-
() => setServed(opened.document.tiles.length > 0),
|
|
828
|
-
[opened.generation, opened.document],
|
|
829
|
-
);
|
|
830
|
-
|
|
831
|
-
const { data, isSuccess, isError } = useQueryWithApiError({
|
|
832
|
-
queryKey: [
|
|
833
|
-
"dashboard-editor-manifest",
|
|
834
|
-
environmentName,
|
|
835
|
-
packageName,
|
|
836
|
-
slug,
|
|
837
|
-
versionId,
|
|
838
|
-
kind,
|
|
839
|
-
],
|
|
840
|
-
// A layout notebook's manifest rides on its notebook read; one in the cell format has only the tag's starting values until it is saved.
|
|
841
|
-
queryFn: async (): Promise<DashboardManifest> => {
|
|
842
|
-
if (!notebook)
|
|
843
|
-
return (
|
|
844
|
-
await apiClients.dashboards.getDashboard(
|
|
845
|
-
environmentName,
|
|
846
|
-
packageName,
|
|
847
|
-
slug,
|
|
848
|
-
versionId,
|
|
849
|
-
)
|
|
850
|
-
).data;
|
|
851
|
-
const read = (
|
|
852
|
-
await apiClients.notebooks.getNotebook(
|
|
853
|
-
environmentName,
|
|
854
|
-
packageName,
|
|
855
|
-
modelPath,
|
|
856
|
-
versionId,
|
|
857
|
-
)
|
|
858
|
-
).data;
|
|
859
|
-
return (
|
|
860
|
-
read.dashboard ?? {
|
|
861
|
-
...(read.startingGivens
|
|
862
|
-
? { startingGivens: read.startingGivens }
|
|
863
|
-
: {}),
|
|
864
|
-
...(read.autorun === undefined ? {} : { autorun: read.autorun }),
|
|
865
|
-
}
|
|
866
|
-
);
|
|
867
|
-
},
|
|
868
|
-
// The server does not serve a dashboard with no tiles, so asking would 404.
|
|
869
|
-
enabled: served,
|
|
870
|
-
});
|
|
871
|
-
const manifest = data;
|
|
872
|
-
|
|
873
|
-
// The package's other dashboards, by slug: where a clicked cell can go.
|
|
874
|
-
const { data: dashboardList } = useQueryWithApiError({
|
|
875
|
-
// Shares the listing the page's location lookup already fetches.
|
|
876
|
-
queryKey: ["dashboards", environmentName, packageName, versionId],
|
|
877
|
-
staleTime: 60_000,
|
|
878
|
-
queryFn: () =>
|
|
879
|
-
apiClients.dashboards.listDashboards(
|
|
880
|
-
environmentName,
|
|
881
|
-
packageName,
|
|
882
|
-
versionId,
|
|
883
|
-
),
|
|
884
|
-
enabled: !notebook,
|
|
885
|
-
});
|
|
886
|
-
const otherDashboards = useMemo(
|
|
887
|
-
() =>
|
|
888
|
-
(dashboardList?.data ?? [])
|
|
889
|
-
.map((d) => d.name)
|
|
890
|
-
.filter((name): name is string => !!name && name !== slug),
|
|
891
|
-
[dashboardList, slug],
|
|
892
|
-
);
|
|
893
|
-
|
|
894
|
-
// The catalog: what the package publishes, limited to what this file can
|
|
895
|
-
// see. A tile runs against this file and may read only the package surface,
|
|
896
|
-
// so offering a source from any other file would offer a tile that 404s.
|
|
897
|
-
// Files off the surface are not readable anyway (their model GET is 404).
|
|
898
|
-
const imports = useMemo(() => {
|
|
899
|
-
const dir = modelPath.slice(0, modelPath.lastIndexOf("/") + 1);
|
|
900
|
-
return opened.document.imports.map((imported) => ({
|
|
901
|
-
...imported,
|
|
902
|
-
path: new URL(
|
|
903
|
-
imported.from,
|
|
904
|
-
`https://malloy.invalid/${dir}`,
|
|
905
|
-
).pathname.slice(1),
|
|
906
|
-
}));
|
|
907
|
-
}, [opened.document.imports, modelPath]);
|
|
908
|
-
const { data: catalog } = useQueryWithApiError<PackageCatalog>({
|
|
909
|
-
queryKey: [
|
|
910
|
-
"dashboard-editor-catalog",
|
|
911
|
-
environmentName,
|
|
912
|
-
packageName,
|
|
913
|
-
...imports.map((i) => i.path),
|
|
914
|
-
versionId,
|
|
915
|
-
],
|
|
916
|
-
queryFn: async () => {
|
|
917
|
-
const listed = (
|
|
918
|
-
await apiClients.models.listModels(
|
|
919
|
-
environmentName,
|
|
920
|
-
packageName,
|
|
921
|
-
versionId,
|
|
922
|
-
)
|
|
923
|
-
).data.filter(
|
|
924
|
-
// The catalog leaves dashboards out, and this file's own text is already fetched above.
|
|
925
|
-
(m) =>
|
|
926
|
-
m.path &&
|
|
927
|
-
!m.error &&
|
|
928
|
-
!isDashboardModel(m.path) &&
|
|
929
|
-
!m.path.startsWith("notebooks/"),
|
|
930
|
-
);
|
|
931
|
-
// One model that fails to load (a reload racing this fetch, say)
|
|
932
|
-
// costs the catalog that model's sources, not every suggestion.
|
|
933
|
-
const settled = await Promise.allSettled(
|
|
934
|
-
listed.map((m) =>
|
|
935
|
-
apiClients.models
|
|
936
|
-
.getModel(environmentName, packageName, m.path!, versionId)
|
|
937
|
-
.then((response) => response.data),
|
|
938
|
-
),
|
|
939
|
-
);
|
|
940
|
-
const models = settled.flatMap((result) =>
|
|
941
|
-
result.status === "fulfilled" ? [result.value] : [],
|
|
942
|
-
);
|
|
943
|
-
return visibleToDashboard(buildCatalog(models), imports, models);
|
|
944
|
-
},
|
|
945
|
-
enabled: imports.length > 0,
|
|
946
|
-
});
|
|
947
|
-
|
|
948
|
-
const [doc, setDoc] = useState(opened.document);
|
|
949
|
-
useEffect(() => setDoc(opened.document), [opened.document]);
|
|
950
|
-
// Only a package write can make the package serve it; a copy in the host's store does not.
|
|
951
|
-
const saveThenServe = useMemo<SaveHandler<DashboardDocument> | undefined>(
|
|
952
|
-
() =>
|
|
953
|
-
onSave && savesTo === "package"
|
|
954
|
-
? async (
|
|
955
|
-
source: string,
|
|
956
|
-
context: SaveContext<DashboardDocument>,
|
|
957
|
-
) => {
|
|
958
|
-
await onSave(source);
|
|
959
|
-
// An undone first save writes back a file with no tile, which the server stops serving.
|
|
960
|
-
setServed(context.document.tiles.length > 0);
|
|
961
|
-
}
|
|
962
|
-
: onSave,
|
|
963
|
-
[onSave, savesTo],
|
|
964
|
-
);
|
|
965
|
-
const modelSpecs = useMemo(
|
|
966
|
-
() => manifest?.givens ?? (opened.conversion ? (modelGivens ?? []) : []),
|
|
967
|
-
[manifest, opened.conversion, modelGivens],
|
|
968
|
-
);
|
|
969
|
-
const runnable = useMemo(
|
|
970
|
-
() =>
|
|
971
|
-
new Set(
|
|
972
|
-
modelSpecs
|
|
973
|
-
.map((spec) => spec.name)
|
|
974
|
-
.filter((name): name is string => name !== undefined),
|
|
975
|
-
),
|
|
976
|
-
[modelSpecs],
|
|
977
|
-
);
|
|
978
|
-
const specs = useMemo(
|
|
979
|
-
() => previewGivens(doc, modelSpecs),
|
|
980
|
-
[doc, modelSpecs],
|
|
981
|
-
);
|
|
982
|
-
const { declaredTypes, applied, panel } = useDocumentControls({
|
|
983
|
-
specs,
|
|
984
|
-
loaded: isSuccess,
|
|
985
|
-
startingValues: manifest?.startingGivens,
|
|
986
|
-
documentKey: `${environmentName}/${packageName}/${versionId ?? ""}/${notebook ? "notebook/" : ""}${slug}/edit`,
|
|
987
|
-
autorun: manifest?.autorun !== false,
|
|
988
|
-
environmentName,
|
|
989
|
-
packageName,
|
|
990
|
-
modelPath: manifest?.path,
|
|
991
|
-
versionId,
|
|
992
|
-
documentName: slug,
|
|
993
|
-
});
|
|
994
|
-
|
|
995
|
-
const manifestSettled = !served || isSuccess || isError;
|
|
996
|
-
// What the saved file's compiled tiles read, keyed as the server keys a tile expression.
|
|
997
|
-
const servedReads = useMemo(
|
|
998
|
-
() =>
|
|
999
|
-
new Map(
|
|
1000
|
-
(manifest?.tiles ?? []).flatMap((tile) =>
|
|
1001
|
-
tile.kind !== "text" && tile.query && tile.givenNames
|
|
1002
|
-
? [[tileExpressionKey(tile.query), tile.givenNames] as const]
|
|
1003
|
-
: [],
|
|
1004
|
-
),
|
|
1005
|
-
),
|
|
1006
|
-
[manifest],
|
|
1007
|
-
);
|
|
1008
|
-
const renderTile = useMemo(
|
|
1009
|
-
() =>
|
|
1010
|
-
function LiveTile(tile: QueryTile, heading?: TileHeadingSlots) {
|
|
1011
|
-
// The bindings a tile runs with come from the manifest; running before it lands queries every tile once unbound and again bound.
|
|
1012
|
-
if (!manifestSettled) return <Loading text="Running…" />;
|
|
1013
|
-
const query = previewTileQuery(
|
|
1014
|
-
doc,
|
|
1015
|
-
tile,
|
|
1016
|
-
runnable,
|
|
1017
|
-
applied,
|
|
1018
|
-
servedReads.get(
|
|
1019
|
-
tileExpressionKey(`${tile.source} -> ${tile.name}`),
|
|
1020
|
-
),
|
|
1021
|
-
);
|
|
1022
|
-
return (
|
|
1023
|
-
<DashboardTile
|
|
1024
|
-
environmentName={environmentName}
|
|
1025
|
-
packageName={packageName}
|
|
1026
|
-
versionId={versionId}
|
|
1027
|
-
modelPath={modelPath}
|
|
1028
|
-
tile={query.expression}
|
|
1029
|
-
{...(query.annotation
|
|
1030
|
-
? { annotation: query.annotation }
|
|
1031
|
-
: {})}
|
|
1032
|
-
label={
|
|
1033
|
-
tile.label ?? tileTitle(`${tile.source} -> ${tile.name}`)
|
|
1034
|
-
}
|
|
1035
|
-
subtitle={tile.subtitle}
|
|
1036
|
-
{...(heading ? { heading } : {})}
|
|
1037
|
-
borderless={tile.borderless}
|
|
1038
|
-
givens={applied}
|
|
1039
|
-
declaredTypes={declaredTypes}
|
|
1040
|
-
givenNames={query.givenNames}
|
|
1041
|
-
ignoredFilters={tileIgnoredFilterLabels(query.reads, specs)}
|
|
1042
|
-
height={TILE_MAX_HEIGHT}
|
|
1043
|
-
/>
|
|
1044
|
-
);
|
|
1045
|
-
},
|
|
1046
|
-
[
|
|
1047
|
-
doc,
|
|
1048
|
-
manifestSettled,
|
|
1049
|
-
runnable,
|
|
1050
|
-
servedReads,
|
|
1051
|
-
environmentName,
|
|
1052
|
-
packageName,
|
|
1053
|
-
versionId,
|
|
1054
|
-
modelPath,
|
|
1055
|
-
applied,
|
|
1056
|
-
declaredTypes,
|
|
1057
|
-
specs,
|
|
1058
|
-
],
|
|
1059
|
-
);
|
|
1060
|
-
|
|
1061
|
-
return (
|
|
1062
|
-
<Stack sx={{ gap: 1 }}>
|
|
1063
|
-
<DashboardBuilder
|
|
1064
|
-
source={opened.source}
|
|
1065
|
-
document={opened.document}
|
|
1066
|
-
renderTile={renderTile}
|
|
1067
|
-
givens={specs
|
|
1068
|
-
.filter((spec) => spec.name !== undefined)
|
|
1069
|
-
.map((spec) => ({
|
|
1070
|
-
name: spec.name as string,
|
|
1071
|
-
...(spec.label ? { label: spec.label } : {}),
|
|
1072
|
-
...(spec.type ? { type: spec.type } : {}),
|
|
1073
|
-
...(spec.suggest?.dimension
|
|
1074
|
-
? { field: spec.suggest.dimension }
|
|
1075
|
-
: {}),
|
|
1076
|
-
}))}
|
|
1077
|
-
onChange={setDoc}
|
|
1078
|
-
onDirtyChange={onDirtyChange}
|
|
1079
|
-
onSaveNoticeChange={onSaveNoticeChange}
|
|
1080
|
-
{...(opened.conversion ? { conversion: opened.conversion } : {})}
|
|
1081
|
-
{...(catalog ? { catalog } : {})}
|
|
1082
|
-
dashboards={otherDashboards}
|
|
1083
|
-
{...(onEvent ? { onEvent } : {})}
|
|
1084
|
-
{...(onExit ? { onExit } : {})}
|
|
1085
|
-
controls={
|
|
1086
|
-
isSuccess ? <GivensPanel {...panel} layout="bar" /> : undefined
|
|
1087
|
-
}
|
|
1088
|
-
{...(saveThenServe ? { onSave: saveThenServe } : {})}
|
|
1089
|
-
savesTo={savesTo}
|
|
1090
|
-
{...(saveLabel ? { saveLabel } : {})}
|
|
1091
|
-
{...(replaces !== undefined ? { replaces } : {})}
|
|
1092
|
-
modelPath={modelPath}
|
|
1093
|
-
/>
|
|
1094
|
-
<Box sx={{ px: 0.5 }}>
|
|
1095
|
-
<Typography variant="caption" sx={{ opacity: 0.7 }}>
|
|
1096
|
-
{note}
|
|
1097
|
-
</Typography>
|
|
1098
|
-
</Box>
|
|
1099
|
-
</Stack>
|
|
1100
|
-
);
|
|
1101
|
-
}
|