@malloy-publisher/sdk 0.9.1 → 0.9.2
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/{Dashboard-H1kJlDFo.es.js → DashboardTile-BFcxdv7R.es.js} +15918 -17760
- package/dist/DashboardTile-sg8LjUk8.cjs.js +137 -0
- package/dist/RenderedResult-B48wAjM8.cjs.js +141 -0
- package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-CBLHr32C.es.js} +193 -183
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-DCV8BUWD.es.js} +529 -521
- package/dist/ServerProvider-HRqT3w1C.cjs.js +1 -0
- package/dist/builder/index.cjs.js +146 -58
- package/dist/builder/index.es.js +9076 -6479
- package/dist/builder-entry.d.ts +4 -0
- package/dist/client/api.d.ts +77 -47
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +84 -82
- package/dist/components/Dashboard/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +23 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +10 -1
- package/dist/components/Dashboard/DashboardView.d.ts +36 -0
- package/dist/components/Dashboard/TileCard.d.ts +15 -4
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/index.d.ts +3 -0
- package/dist/components/Dashboard/telemetry.d.ts +15 -3
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -1
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +16 -5
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +48 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -4
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +2 -10
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +3 -1
- package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
- package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +27 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +19 -7
- package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +7 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +14 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +11 -3
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -0
- package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
- package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
- package/dist/components/DashboardBuilder/controls.d.ts +2 -2
- package/dist/components/DashboardBuilder/document.d.ts +42 -26
- package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -5
- package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
- package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
- package/dist/components/DashboardBuilder/preview.d.ts +24 -4
- package/dist/components/DashboardBuilder/readDocument.d.ts +4 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +14 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +13 -13
- package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
- package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
- package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
- package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +89 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +17 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
- package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
- package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
- package/dist/components/DocumentCreate/events.d.ts +10 -0
- package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
- package/dist/components/DocumentCreate/guards.d.ts +12 -0
- package/dist/components/DocumentCreate/index.d.ts +6 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +1 -0
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +4 -0
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/given/GivensPanel.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9714 -7072
- package/dist/text/index.cjs.js +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.es.js +6 -0
- package/dist/text-entry-BJwltZiy.cjs.js +7 -0
- package/dist/text-entry-CbbBcZl8.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- package/dist/utils/clock.d.ts +2 -0
- package/package.json +10 -1
- package/src/builder-entry.ts +35 -0
- package/src/components/Dashboard/Dashboard.tsx +27 -278
- package/src/components/Dashboard/DashboardGrid.tsx +68 -7
- package/src/components/Dashboard/DashboardTile.spec.tsx +24 -0
- package/src/components/Dashboard/DashboardTile.tsx +31 -4
- package/src/components/Dashboard/DashboardView.spec.tsx +212 -0
- package/src/components/Dashboard/DashboardView.tsx +352 -0
- package/src/components/Dashboard/RowsDialog.tsx +1 -1
- package/src/components/Dashboard/TileCard.tsx +44 -10
- package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
- package/src/components/Dashboard/TileFilterTag.tsx +78 -0
- package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
- package/src/components/Dashboard/index.ts +3 -0
- package/src/components/Dashboard/telemetry.ts +16 -5
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +137 -111
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +85 -27
- package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
- package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
- package/src/components/DashboardBuilder/ChartPicker.tsx +153 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +192 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +329 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +363 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +194 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +157 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +124 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +103 -78
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +177 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +610 -315
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +58 -8
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +191 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +316 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +56 -10
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +5 -22
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +96 -14
- package/src/components/DashboardBuilder/DashboardEditor.tsx +482 -332
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +25 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +5 -24
- package/src/components/DashboardBuilder/DrillDialog.tsx +1 -1
- package/src/components/DashboardBuilder/FilterDialog.tsx +10 -3
- package/src/components/DashboardBuilder/FilterStrip.tsx +26 -4
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +184 -0
- package/src/components/DashboardBuilder/InlineText.tsx +106 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SaveNotice.tsx +113 -0
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +87 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +225 -67
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +28 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +89 -115
- package/src/components/DashboardBuilder/TileMenu.tsx +168 -90
- package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
- package/src/components/DashboardBuilder/annotationText.ts +17 -0
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +41 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -0
- package/src/components/DashboardBuilder/catalog.ts +61 -21
- package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
- package/src/components/DashboardBuilder/changedTile.ts +28 -0
- package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
- package/src/components/DashboardBuilder/chartLine.ts +121 -0
- package/src/components/DashboardBuilder/controls.spec.ts +21 -10
- package/src/components/DashboardBuilder/controls.ts +22 -8
- package/src/components/DashboardBuilder/document.ts +53 -5
- package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
- package/src/components/DashboardBuilder/documentSession.ts +257 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
- package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
- package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
- package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
- package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
- package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +48 -0
- package/src/components/DashboardBuilder/malloyText.ts +181 -27
- package/src/components/DashboardBuilder/malloyTree.ts +155 -7
- package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
- package/src/components/DashboardBuilder/newDashboard.ts +30 -3
- package/src/components/DashboardBuilder/openDraft.ts +52 -0
- package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
- package/src/components/DashboardBuilder/preview.spec.ts +159 -12
- package/src/components/DashboardBuilder/preview.ts +83 -9
- package/src/components/DashboardBuilder/readDocument.spec.ts +139 -27
- package/src/components/DashboardBuilder/readDocument.ts +130 -44
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +47 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +65 -0
- package/src/components/DashboardBuilder/sortable.tsx +2 -12
- package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
- package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
- package/src/components/DashboardBuilder/spliceDocument.ts +762 -130
- package/src/components/DashboardBuilder/spliceResult.ts +15 -0
- package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
- package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
- package/src/components/DashboardBuilder/tagParse.ts +103 -0
- package/src/components/DashboardBuilder/telemetry.ts +47 -0
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +197 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +718 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +335 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +292 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +65 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +36 -10
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +54 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
- package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
- package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
- package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
- package/src/components/DocumentCreate/canRetry.ts +19 -0
- package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
- package/src/components/DocumentCreate/createDocument.ts +159 -0
- package/src/components/DocumentCreate/documentPath.ts +40 -0
- package/src/components/DocumentCreate/events.ts +15 -0
- package/src/components/DocumentCreate/exportedSources.ts +25 -0
- package/src/components/DocumentCreate/guards.ts +45 -0
- package/src/components/DocumentCreate/index.ts +27 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
- package/src/components/DocumentCreate/newNotebook.ts +44 -0
- package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
- package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
- package/src/components/Model/ModelExplorer.spec.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -4
- package/src/components/NarrowEditGate.spec.tsx +73 -0
- package/src/components/NarrowEditGate.tsx +29 -0
- package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
- package/src/components/Notebook/Notebook.tsx +66 -27
- package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
- package/src/components/Package/NewDocumentDialog.tsx +401 -0
- package/src/components/Package/Package.artifacts.spec.tsx +190 -0
- package/src/components/Package/Package.create.spec.tsx +380 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +366 -171
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +13 -0
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/RenderedResult/RenderedResult.tsx +18 -1
- package/src/components/RenderedResult/ResultContainer.tsx +44 -11
- package/src/components/RenderedResult/ResultPanel.tsx +4 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
- package/src/components/RenderedResult/resultSizing.ts +14 -3
- package/src/components/ServerProvider.tsx +2 -1
- package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
- package/src/components/UnsavedChangesDialog.tsx +49 -0
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +3 -3
- package/src/components/index.ts +2 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useNarrowScreen.ts +21 -0
- package/src/hooks/useQueryResult.ts +16 -0
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +118 -0
- package/src/utils/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/vite.config.ts +4 -0
- package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
- package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
- package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
- package/dist/components/DashboardBuilder/useTileResize.d.ts +0 -29
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +0 -121
- package/src/components/DashboardBuilder/useTileResize.ts +0 -110
- package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
- package/src/components/Package/NewDashboardDialog.tsx +0 -265
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
|
|
4
5
|
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
|
5
6
|
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
|
|
6
7
|
import {
|
|
7
8
|
Alert,
|
|
8
9
|
Box,
|
|
10
|
+
Button,
|
|
9
11
|
Container,
|
|
10
12
|
IconButton,
|
|
13
|
+
Menu,
|
|
14
|
+
MenuItem,
|
|
15
|
+
Stack,
|
|
11
16
|
Table,
|
|
12
17
|
TableBody,
|
|
13
18
|
TableCell,
|
|
@@ -17,37 +22,52 @@ import {
|
|
|
17
22
|
Typography,
|
|
18
23
|
} from "@mui/material";
|
|
19
24
|
import { useQueryClient } from "@tanstack/react-query";
|
|
20
|
-
import React, { useCallback, useEffect, useState } from "react";
|
|
25
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
21
26
|
import { Database } from "../../client";
|
|
27
|
+
import { useNarrowScreen } from "../../hooks/useNarrowScreen";
|
|
22
28
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
23
29
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
24
30
|
import { Loading } from "../Loading";
|
|
25
|
-
import
|
|
31
|
+
import { chooseWorkspace } from "../DashboardBuilder/documentSession";
|
|
32
|
+
import { createRoute, type CreateTarget } from "../DocumentCreate";
|
|
33
|
+
import type {
|
|
34
|
+
DocumentLocator,
|
|
35
|
+
DocumentType,
|
|
36
|
+
Workspace,
|
|
37
|
+
} from "../DocumentStorage/DocumentStorage";
|
|
26
38
|
import { useOptionalDocumentStorage } from "../DocumentStorage/DocumentStorageProvider";
|
|
27
39
|
import { Notebook } from "../Notebook";
|
|
28
40
|
import { useServer } from "../ServerProvider";
|
|
29
|
-
import {
|
|
41
|
+
import { NewDocumentDialog } from "./NewDocumentDialog";
|
|
30
42
|
import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
|
|
31
43
|
import { serverBaseUrl } from "../../utils/dataAppEmbed";
|
|
32
44
|
import ContentTypeIcon, {
|
|
33
45
|
CONTENT_TINT,
|
|
34
46
|
type ContentType,
|
|
35
47
|
} from "./ContentTypeIcon";
|
|
36
|
-
import { AddButton } from "../buttons";
|
|
37
48
|
import { AppDialog } from "../AppDialog";
|
|
38
49
|
import { BackLink } from "../BackLink";
|
|
39
50
|
import { ItemRow } from "../ItemRow";
|
|
40
51
|
import { Materializations } from "../Materializations";
|
|
41
52
|
import { PackageSection } from "../PackageSection";
|
|
53
|
+
import {
|
|
54
|
+
documentRoute,
|
|
55
|
+
documentSlug,
|
|
56
|
+
type DocumentKind,
|
|
57
|
+
} from "./documentLocation";
|
|
42
58
|
|
|
43
59
|
// The pinned README: the root `.malloynb`, or a served notebook named README in `notebooks/`.
|
|
44
60
|
const README_NOTEBOOK = "README.malloynb";
|
|
45
61
|
const isServedReadme = (path: string | undefined) =>
|
|
46
62
|
path?.toLowerCase() === "notebooks/readme.malloy";
|
|
47
63
|
|
|
64
|
+
const draftPrefix = (
|
|
65
|
+
environmentName: string,
|
|
66
|
+
packageName: string,
|
|
67
|
+
kind: DocumentType,
|
|
68
|
+
) => `${environmentName}/${packageName}/${kind}s/`;
|
|
69
|
+
|
|
48
70
|
/** A served notebook opens by slug, like a dashboard; a `.malloynb` opens by path. */
|
|
49
|
-
const servedNotebookSlug = (path: string | undefined) =>
|
|
50
|
-
/^notebooks\/([^/]+)\.malloy$/.exec(path ?? "")?.[1];
|
|
51
71
|
|
|
52
72
|
interface PackageProps {
|
|
53
73
|
onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
|
|
@@ -69,35 +89,56 @@ export default function Package({
|
|
|
69
89
|
parseResourceUri(resourceUri);
|
|
70
90
|
|
|
71
91
|
const [schemaDatabase, setSchemaDatabase] = useState<Database | null>(null);
|
|
72
|
-
const [creating, setCreating] = useState(
|
|
92
|
+
const [creating, setCreating] = useState<DocumentType | undefined>(
|
|
93
|
+
undefined,
|
|
94
|
+
);
|
|
95
|
+
const [newMenu, setNewMenu] = useState<HTMLElement | null>(null);
|
|
96
|
+
const narrow = useNarrowScreen();
|
|
73
97
|
|
|
74
|
-
// Dashboards the host keeps for this package and the package
|
|
75
|
-
// the builder's drafts, listed so they are found rather than
|
|
98
|
+
// Dashboards and notebooks the host keeps for this package and the package
|
|
99
|
+
// does not have: the builder's drafts, listed so they are found rather than
|
|
100
|
+
// stumbled on.
|
|
76
101
|
// Each carries the workspace's own description, because where a document is
|
|
77
102
|
// kept is the backend's to say and only one host's answer is "this browser".
|
|
78
103
|
const storage = useOptionalDocumentStorage()?.documentStorage;
|
|
79
104
|
const [drafts, setDrafts] = useState<
|
|
80
105
|
{ locator: DocumentLocator; where: string }[]
|
|
81
106
|
>([]);
|
|
82
|
-
|
|
107
|
+
// Where a create may land is the chosen workspace's to say, so New waits
|
|
108
|
+
// for the answer; a host whose workspaces cannot be listed gets no New
|
|
109
|
+
// rather than a guess that could write the package under its record.
|
|
110
|
+
const [workspace, setWorkspace] = useState<
|
|
111
|
+
{ state: "pending" | "failed" } | { state: "ready"; chosen?: Workspace }
|
|
112
|
+
>({ state: storage ? "pending" : "ready" });
|
|
83
113
|
const refreshDrafts = useCallback(async () => {
|
|
84
114
|
if (!storage) return;
|
|
85
|
-
|
|
115
|
+
let workspaces: Workspace[];
|
|
116
|
+
try {
|
|
117
|
+
workspaces = await storage.listWorkspaces(false);
|
|
118
|
+
} catch {
|
|
119
|
+
setWorkspace({ state: "failed" });
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
setWorkspace({ state: "ready", chosen: chooseWorkspace(workspaces) });
|
|
86
123
|
const found: { locator: DocumentLocator; where: string }[] = [];
|
|
87
|
-
for (const
|
|
88
|
-
for (const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
124
|
+
for (const candidate of workspaces.filter((w) => w.writeable))
|
|
125
|
+
for (const kind of ["dashboard", "notebook"] as const)
|
|
126
|
+
for (const locator of await storage.listDocuments(candidate, kind))
|
|
127
|
+
if (
|
|
128
|
+
locator.path.startsWith(
|
|
129
|
+
draftPrefix(environmentName, packageName, kind),
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
found.push({ locator, where: candidate.description });
|
|
94
133
|
setDrafts(found);
|
|
95
|
-
}, [storage,
|
|
134
|
+
}, [storage, environmentName, packageName]);
|
|
96
135
|
useEffect(() => {
|
|
97
136
|
void refreshDrafts();
|
|
98
137
|
}, [refreshDrafts]);
|
|
99
138
|
const draftSlug = (locator: DocumentLocator) =>
|
|
100
|
-
locator.path
|
|
139
|
+
locator.path
|
|
140
|
+
.slice(draftPrefix(environmentName, packageName, locator.type).length)
|
|
141
|
+
.replace(/\.malloy$/, "");
|
|
101
142
|
|
|
102
143
|
const pkgQuery = useQueryWithApiError({
|
|
103
144
|
queryKey: ["package", environmentName, packageName, versionId],
|
|
@@ -112,12 +153,26 @@ export default function Package({
|
|
|
112
153
|
|
|
113
154
|
const notebooksQuery = useQueryWithApiError({
|
|
114
155
|
queryKey: ["notebooks", environmentName, packageName, versionId],
|
|
115
|
-
queryFn: () =>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
156
|
+
queryFn: async () => {
|
|
157
|
+
try {
|
|
158
|
+
return await apiClients.notebooks.listNotebooks(
|
|
159
|
+
environmentName,
|
|
160
|
+
packageName,
|
|
161
|
+
versionId,
|
|
162
|
+
);
|
|
163
|
+
} catch (e) {
|
|
164
|
+
// Non-fatal like the dashboards list: an older Publisher without
|
|
165
|
+
// the route has no notebooks to list.
|
|
166
|
+
const status = (e as { response?: { status?: number } })?.response
|
|
167
|
+
?.status;
|
|
168
|
+
if (status === 404 || status === undefined) {
|
|
169
|
+
return { data: [] } as Awaited<
|
|
170
|
+
ReturnType<typeof apiClients.notebooks.listNotebooks>
|
|
171
|
+
>;
|
|
172
|
+
}
|
|
173
|
+
throw e;
|
|
174
|
+
}
|
|
175
|
+
},
|
|
121
176
|
});
|
|
122
177
|
|
|
123
178
|
const modelsQuery = useQueryWithApiError({
|
|
@@ -195,28 +250,12 @@ export default function Package({
|
|
|
195
250
|
}
|
|
196
251
|
},
|
|
197
252
|
});
|
|
198
|
-
|
|
199
|
-
// underneath it. A list labelled by title and ordered by filename reads as
|
|
200
|
-
// unsorted: `overview` titled "Business Overview" sorts ahead of `regions`
|
|
201
|
-
// titled "Regional Sales". Notebooks acquired that mismatch here too, when
|
|
202
|
-
// they started being listed by title while still being ordered by path.
|
|
203
|
-
const dashboardLabel = (dashboard: { name?: string; title?: string }) =>
|
|
204
|
-
dashboard.title && dashboard.title !== dashboard.name
|
|
205
|
-
? dashboard.title
|
|
206
|
-
: (dashboard.name ?? "");
|
|
207
|
-
const notebookLabel = (notebook: { path?: string; title?: string }) =>
|
|
208
|
-
notebook.title && notebook.title !== notebook.path
|
|
209
|
-
? notebook.title
|
|
210
|
-
: (notebook.path ?? "");
|
|
211
|
-
|
|
212
|
-
const dashboards = (dashboardsQuery.data?.data ?? [])
|
|
213
|
-
.slice()
|
|
214
|
-
.sort((a, b) => dashboardLabel(a).localeCompare(dashboardLabel(b)));
|
|
215
|
-
|
|
253
|
+
const dashboards = dashboardsQuery.data?.data ?? [];
|
|
216
254
|
const notebooks = (notebooksQuery.data?.data ?? [])
|
|
217
255
|
.slice()
|
|
218
|
-
.sort((a, b) =>
|
|
219
|
-
|
|
256
|
+
.sort((a, b) => (a.path ?? "").localeCompare(b.path ?? ""));
|
|
257
|
+
const artifacts = artifactRows(dashboards, notebooks);
|
|
258
|
+
// A dashboard is listed once, under Artifacts. Its file is a model like any
|
|
220
259
|
// other, so it would otherwise appear a second time under Semantic Models
|
|
221
260
|
// where clicking it opens the Explorer rather than the dashboard. Untagged
|
|
222
261
|
// shared includes in `dashboards/` are not dashboards and stay in the model
|
|
@@ -234,6 +273,74 @@ export default function Package({
|
|
|
234
273
|
.slice()
|
|
235
274
|
.sort((a, b) => a.path.localeCompare(b.path));
|
|
236
275
|
|
|
276
|
+
// A non-authoritative browser workspace is never a create target: a
|
|
277
|
+
// document made there would look saved and exist for one reader only.
|
|
278
|
+
const route =
|
|
279
|
+
workspace.state === "ready"
|
|
280
|
+
? createRoute({
|
|
281
|
+
authoritative: workspace.chosen?.authoritative === true,
|
|
282
|
+
mutable,
|
|
283
|
+
canStore: workspace.chosen?.writeable === true,
|
|
284
|
+
...(versionId === undefined ? {} : { versionId }),
|
|
285
|
+
})
|
|
286
|
+
: undefined;
|
|
287
|
+
// A name is chosen against the listings, so New waits for all three rather than offering names a still-loading listing would have taken.
|
|
288
|
+
const listingsSettled = [dashboardsQuery, notebooksQuery, modelsQuery].every(
|
|
289
|
+
(q) => q.isSuccess || q.isError,
|
|
290
|
+
);
|
|
291
|
+
const canCreate = route !== undefined && listingsSettled;
|
|
292
|
+
// The editors step aside on a narrow screen, so no entry point to one is offered there.
|
|
293
|
+
const canNew = canCreate && !narrow;
|
|
294
|
+
const createTarget = useMemo((): CreateTarget | undefined => {
|
|
295
|
+
if (!canCreate) return undefined;
|
|
296
|
+
const existing = [
|
|
297
|
+
...(dashboardsQuery.data?.data ?? []).flatMap((d) =>
|
|
298
|
+
d.path ? [d.path] : [],
|
|
299
|
+
),
|
|
300
|
+
...(notebooksQuery.data?.data ?? []).flatMap((n) =>
|
|
301
|
+
n.path ? [n.path] : [],
|
|
302
|
+
),
|
|
303
|
+
...(modelsQuery.data?.data ?? []).flatMap((m) =>
|
|
304
|
+
m.path ? [m.path] : [],
|
|
305
|
+
),
|
|
306
|
+
];
|
|
307
|
+
if (route === "storage" && storage && workspace.state === "ready") {
|
|
308
|
+
if (!workspace.chosen) return undefined;
|
|
309
|
+
return {
|
|
310
|
+
route,
|
|
311
|
+
storage,
|
|
312
|
+
workspace: workspace.chosen,
|
|
313
|
+
environmentName,
|
|
314
|
+
packageName,
|
|
315
|
+
existing,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
if (route !== "package") return undefined;
|
|
319
|
+
return {
|
|
320
|
+
route,
|
|
321
|
+
existing,
|
|
322
|
+
write: async (path, source) => {
|
|
323
|
+
await apiClients.models.updateModelSource(
|
|
324
|
+
environmentName,
|
|
325
|
+
packageName,
|
|
326
|
+
path,
|
|
327
|
+
{ source },
|
|
328
|
+
);
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
}, [
|
|
332
|
+
canCreate,
|
|
333
|
+
route,
|
|
334
|
+
storage,
|
|
335
|
+
workspace,
|
|
336
|
+
environmentName,
|
|
337
|
+
packageName,
|
|
338
|
+
apiClients,
|
|
339
|
+
dashboardsQuery.data,
|
|
340
|
+
notebooksQuery.data,
|
|
341
|
+
modelsQuery.data,
|
|
342
|
+
]);
|
|
343
|
+
|
|
237
344
|
const description = pkgQuery.data?.data?.description ?? "";
|
|
238
345
|
// The root `.malloynb` wins when both exist, so a listing order never flips the pin.
|
|
239
346
|
const readmePath = (
|
|
@@ -311,111 +418,156 @@ export default function Package({
|
|
|
311
418
|
|
|
312
419
|
{isLoading && <Loading text="Loading package..." />}
|
|
313
420
|
|
|
314
|
-
<
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
421
|
+
<Menu
|
|
422
|
+
anchorEl={newMenu}
|
|
423
|
+
open={newMenu !== null}
|
|
424
|
+
onClose={() => setNewMenu(null)}
|
|
425
|
+
>
|
|
426
|
+
{(["dashboard", "notebook"] as const).map((kind) => (
|
|
427
|
+
<MenuItem
|
|
428
|
+
key={kind}
|
|
429
|
+
onClick={() => {
|
|
430
|
+
setNewMenu(null);
|
|
431
|
+
setCreating(kind);
|
|
432
|
+
}}
|
|
433
|
+
>
|
|
434
|
+
{kind === "dashboard" ? "Dashboard" : "Notebook"}
|
|
435
|
+
</MenuItem>
|
|
436
|
+
))}
|
|
437
|
+
</Menu>
|
|
438
|
+
|
|
439
|
+
{createTarget && (
|
|
440
|
+
<NewDocumentDialog
|
|
441
|
+
open={creating !== undefined}
|
|
442
|
+
kind={creating ?? "dashboard"}
|
|
443
|
+
environmentName={environmentName}
|
|
444
|
+
packageName={packageName}
|
|
445
|
+
{...(versionId !== undefined ? { versionId } : {})}
|
|
446
|
+
models={models
|
|
447
|
+
.map((model) => model.path)
|
|
448
|
+
.filter(
|
|
449
|
+
(path): path is string =>
|
|
450
|
+
typeof path === "string" &&
|
|
451
|
+
path.endsWith(".malloy") &&
|
|
452
|
+
!path.startsWith("dashboards/") &&
|
|
453
|
+
!path.startsWith("notebooks/"),
|
|
454
|
+
)}
|
|
455
|
+
modelsLoading={modelsQuery.isPending}
|
|
456
|
+
{...(modelsQuery.isError
|
|
457
|
+
? { modelsError: modelsQuery.error }
|
|
458
|
+
: {})}
|
|
459
|
+
onRetryModels={() => void modelsQuery.refetch()}
|
|
460
|
+
target={createTarget}
|
|
461
|
+
onClose={() => setCreating(undefined)}
|
|
462
|
+
onCreated={(created) => {
|
|
463
|
+
setCreating(undefined);
|
|
464
|
+
for (const key of ["dashboards", "notebooks", "models"])
|
|
465
|
+
void queryClient.invalidateQueries({ queryKey: [key] });
|
|
466
|
+
onClick(
|
|
467
|
+
`${documentRoute(environmentName, packageName, created.kind, created.slug)}/edit`,
|
|
468
|
+
);
|
|
469
|
+
}}
|
|
470
|
+
/>
|
|
471
|
+
)}
|
|
338
472
|
|
|
339
473
|
{!isLoading && (
|
|
340
474
|
<>
|
|
341
|
-
{/* First: the at-a-glance artifact a visitor most likely wants,
|
|
342
|
-
ahead of the notebooks and models it is built on. Hidden when
|
|
343
|
-
empty, like Data Apps. */}
|
|
344
475
|
{/* A listing that FAILED renders identically to a package with
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
transport error. The 404 above stays swallowed: that one is
|
|
352
|
-
an older Publisher with no route, which genuinely has none. */}
|
|
353
|
-
{dashboardsQuery.isError && (
|
|
476
|
+
none: the list falls back to `[]` and the section hides
|
|
477
|
+
itself. Only `pkgQuery` reaches the error page, so nothing
|
|
478
|
+
else here would say a word, and one failed list hides only
|
|
479
|
+
half the artifacts. The 404 swallowed in each query is an
|
|
480
|
+
older Publisher with no route, which genuinely has none. */}
|
|
481
|
+
{(dashboardsQuery.isError || notebooksQuery.isError) && (
|
|
354
482
|
<Box sx={{ mb: 4 }}>
|
|
355
483
|
<Alert severity="warning">
|
|
356
|
-
Could not list
|
|
357
|
-
|
|
484
|
+
Could not list some artifacts, so any this package has
|
|
485
|
+
are missing from this page.
|
|
358
486
|
</Alert>
|
|
359
487
|
</Box>
|
|
360
488
|
)}
|
|
361
|
-
{(
|
|
489
|
+
{(artifacts.length > 0 || canCreate) && (
|
|
362
490
|
<PackageSection
|
|
363
|
-
title="
|
|
364
|
-
count={
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
491
|
+
title="Artifacts"
|
|
492
|
+
count={artifacts.length}
|
|
493
|
+
{...(canNew
|
|
494
|
+
? {
|
|
495
|
+
action: (
|
|
496
|
+
<Button
|
|
497
|
+
variant="outlined"
|
|
498
|
+
size="small"
|
|
499
|
+
endIcon={<ArrowDropDownIcon />}
|
|
500
|
+
aria-haspopup="menu"
|
|
501
|
+
aria-label="New"
|
|
502
|
+
onClick={(event) =>
|
|
503
|
+
setNewMenu(event.currentTarget)
|
|
504
|
+
}
|
|
505
|
+
>
|
|
506
|
+
New
|
|
507
|
+
</Button>
|
|
508
|
+
),
|
|
509
|
+
}
|
|
510
|
+
: {})}
|
|
373
511
|
>
|
|
374
|
-
{
|
|
375
|
-
<EmptyRow
|
|
512
|
+
{artifacts.length === 0 && (
|
|
513
|
+
<EmptyRow
|
|
514
|
+
label="No artifacts yet"
|
|
515
|
+
{...(canNew
|
|
516
|
+
? {
|
|
517
|
+
action: {
|
|
518
|
+
label: "New artifact",
|
|
519
|
+
onClick: (event) =>
|
|
520
|
+
setNewMenu(event.currentTarget),
|
|
521
|
+
},
|
|
522
|
+
}
|
|
523
|
+
: {})}
|
|
524
|
+
/>
|
|
376
525
|
)}
|
|
377
|
-
{
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
})}
|
|
526
|
+
{artifacts.map((artifact) => (
|
|
527
|
+
<PackageItemRow
|
|
528
|
+
key={`${artifact.kind}:${artifact.path}`}
|
|
529
|
+
type={
|
|
530
|
+
artifact.kind === "dashboard"
|
|
531
|
+
? "dashboard"
|
|
532
|
+
: "report"
|
|
533
|
+
}
|
|
534
|
+
label={artifact.label}
|
|
535
|
+
{...(artifact.secondary === undefined
|
|
536
|
+
? {}
|
|
537
|
+
: { description: artifact.secondary })}
|
|
538
|
+
rightLabel={KIND_BADGE[artifact.kind]}
|
|
539
|
+
onClick={(event) =>
|
|
540
|
+
onClick(
|
|
541
|
+
artifact.slug === undefined
|
|
542
|
+
? `/${environmentName}/${packageName}/${artifact.path}`
|
|
543
|
+
: documentRoute(
|
|
544
|
+
environmentName,
|
|
545
|
+
packageName,
|
|
546
|
+
artifact.kind,
|
|
547
|
+
artifact.slug,
|
|
548
|
+
),
|
|
549
|
+
event,
|
|
550
|
+
)
|
|
551
|
+
}
|
|
552
|
+
/>
|
|
553
|
+
))}
|
|
406
554
|
</PackageSection>
|
|
407
555
|
)}
|
|
408
556
|
{drafts.length > 0 && (
|
|
409
557
|
<PackageSection title="Drafts" count={drafts.length}>
|
|
410
558
|
{drafts.map(({ locator, where }) => (
|
|
411
559
|
<PackageItemRow
|
|
412
|
-
key={locator.path}
|
|
413
|
-
type=
|
|
560
|
+
key={`${locator.type}:${locator.path}`}
|
|
561
|
+
type={
|
|
562
|
+
locator.type === "dashboard"
|
|
563
|
+
? "dashboard"
|
|
564
|
+
: "report"
|
|
565
|
+
}
|
|
414
566
|
label={draftSlug(locator)}
|
|
415
567
|
rightLabel={where}
|
|
416
568
|
onClick={(event) =>
|
|
417
569
|
onClick(
|
|
418
|
-
|
|
570
|
+
`${documentRoute(environmentName, packageName, locator.type, draftSlug(locator))}/edit`,
|
|
419
571
|
event,
|
|
420
572
|
)
|
|
421
573
|
}
|
|
@@ -440,40 +592,6 @@ export default function Package({
|
|
|
440
592
|
</PackageSection>
|
|
441
593
|
)}
|
|
442
594
|
|
|
443
|
-
{/* Hidden when empty, like Dashboards and Data Apps. A package
|
|
444
|
-
that holds no notebooks is not a package missing them, and a
|
|
445
|
-
heading over the words "No notebooks" is a row of furniture
|
|
446
|
-
saying nothing. */}
|
|
447
|
-
{notebooks.length > 0 && (
|
|
448
|
-
<PackageSection title="Notebooks" count={notebooks.length}>
|
|
449
|
-
{notebooks.map((notebook) => {
|
|
450
|
-
// Named the way dashboards and data apps are: a notebook
|
|
451
|
-
// that titles itself is listed by that title, with the
|
|
452
|
-
// filename kept as the secondary label so the path a
|
|
453
|
-
// reader needs to find the file is never lost.
|
|
454
|
-
const hasTitle =
|
|
455
|
-
!!notebook.title && notebook.title !== notebook.path;
|
|
456
|
-
const slug = servedNotebookSlug(notebook.path);
|
|
457
|
-
return (
|
|
458
|
-
<PackageItemRow
|
|
459
|
-
key={notebook.path}
|
|
460
|
-
type="report"
|
|
461
|
-
label={hasTitle ? notebook.title! : notebook.path}
|
|
462
|
-
rightLabel={hasTitle ? notebook.path : undefined}
|
|
463
|
-
onClick={(event) =>
|
|
464
|
-
onClick(
|
|
465
|
-
slug === undefined
|
|
466
|
-
? `/${environmentName}/${packageName}/${notebook.path}`
|
|
467
|
-
: `/${environmentName}/${packageName}/notebooks/${encodeURIComponent(slug)}`,
|
|
468
|
-
event,
|
|
469
|
-
)
|
|
470
|
-
}
|
|
471
|
-
/>
|
|
472
|
-
);
|
|
473
|
-
})}
|
|
474
|
-
</PackageSection>
|
|
475
|
-
)}
|
|
476
|
-
|
|
477
595
|
{dataApps.length > 0 && (
|
|
478
596
|
<PackageSection title="Data Apps" count={dataApps.length}>
|
|
479
597
|
{dataApps.map((dataApp) => {
|
|
@@ -628,12 +746,14 @@ export default function Package({
|
|
|
628
746
|
function PackageItemRow({
|
|
629
747
|
type,
|
|
630
748
|
label,
|
|
749
|
+
description,
|
|
631
750
|
rightLabel,
|
|
632
751
|
onClick,
|
|
633
752
|
trailingAction,
|
|
634
753
|
}: {
|
|
635
754
|
type: ContentType;
|
|
636
755
|
label: string;
|
|
756
|
+
description?: string;
|
|
637
757
|
rightLabel?: string;
|
|
638
758
|
onClick?: (event: React.MouseEvent) => void;
|
|
639
759
|
/** Optional element rendered at the end of the row (e.g. an
|
|
@@ -647,6 +767,7 @@ function PackageItemRow({
|
|
|
647
767
|
tint={CONTENT_TINT[type]}
|
|
648
768
|
label={label}
|
|
649
769
|
mono
|
|
770
|
+
{...(description === undefined ? {} : { description })}
|
|
650
771
|
{...(rightLabel === undefined ? {} : { rightLabel })}
|
|
651
772
|
{...(onClick === undefined ? {} : { onClick })}
|
|
652
773
|
{...(trailingAction === undefined ? {} : { trailingAction })}
|
|
@@ -654,15 +775,89 @@ function PackageItemRow({
|
|
|
654
775
|
);
|
|
655
776
|
}
|
|
656
777
|
|
|
657
|
-
|
|
778
|
+
const KIND_BADGE: Record<DocumentKind, string> = {
|
|
779
|
+
dashboard: "Dashboard",
|
|
780
|
+
notebook: "Notebook",
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
interface ArtifactRow {
|
|
784
|
+
kind: DocumentKind;
|
|
785
|
+
path: string;
|
|
786
|
+
/** Absent for a `.malloynb`, which opens by path. */
|
|
787
|
+
slug: string | undefined;
|
|
788
|
+
label: string;
|
|
789
|
+
/** The path, when the label alone does not say which file this is. */
|
|
790
|
+
secondary: string | undefined;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/** Dashboards and notebooks as one list: the title when set, else the slug, ordered by what is shown. */
|
|
794
|
+
function artifactRows(
|
|
795
|
+
dashboards: readonly { name?: string; path?: string; title?: string }[],
|
|
796
|
+
notebooks: readonly { path?: string; title?: string }[],
|
|
797
|
+
): ArtifactRow[] {
|
|
798
|
+
const rows = [
|
|
799
|
+
...dashboards.map((d) => ({
|
|
800
|
+
kind: "dashboard" as const,
|
|
801
|
+
path: d.path ?? "",
|
|
802
|
+
slug: d.name ?? documentSlug(d.path),
|
|
803
|
+
title: d.title,
|
|
804
|
+
})),
|
|
805
|
+
...notebooks.map((n) => ({
|
|
806
|
+
kind: "notebook" as const,
|
|
807
|
+
path: n.path ?? "",
|
|
808
|
+
slug: documentSlug(n.path),
|
|
809
|
+
title: n.title,
|
|
810
|
+
})),
|
|
811
|
+
];
|
|
812
|
+
const slugCount = new Map<string, number>();
|
|
813
|
+
for (const row of rows)
|
|
814
|
+
if (row.slug !== undefined)
|
|
815
|
+
slugCount.set(row.slug, (slugCount.get(row.slug) ?? 0) + 1);
|
|
816
|
+
return rows
|
|
817
|
+
.map(({ title, ...row }): ArtifactRow => {
|
|
818
|
+
// A title equal to the slug or path is the server's fallback for a file that names itself neither way.
|
|
819
|
+
const hasTitle = !!title && title !== row.slug && title !== row.path;
|
|
820
|
+
const ambiguous =
|
|
821
|
+
row.slug !== undefined && (slugCount.get(row.slug) ?? 0) > 1;
|
|
822
|
+
return {
|
|
823
|
+
...row,
|
|
824
|
+
label: hasTitle ? title : (row.slug ?? row.path),
|
|
825
|
+
secondary: (row.slug === undefined ? hasTitle : ambiguous)
|
|
826
|
+
? row.path
|
|
827
|
+
: undefined,
|
|
828
|
+
};
|
|
829
|
+
})
|
|
830
|
+
.sort(
|
|
831
|
+
(a, b) =>
|
|
832
|
+
a.label.localeCompare(b.label) || a.path.localeCompare(b.path),
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function EmptyRow({
|
|
837
|
+
label,
|
|
838
|
+
action,
|
|
839
|
+
}: {
|
|
840
|
+
label: string;
|
|
841
|
+
action?: {
|
|
842
|
+
label: string;
|
|
843
|
+
onClick: (event: React.MouseEvent<HTMLElement>) => void;
|
|
844
|
+
};
|
|
845
|
+
}) {
|
|
658
846
|
return (
|
|
659
|
-
<
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
847
|
+
<Stack direction="row" sx={{ alignItems: "center", gap: 1, py: 1 }}>
|
|
848
|
+
<Typography
|
|
849
|
+
variant="body2"
|
|
850
|
+
color="text.secondary"
|
|
851
|
+
sx={{ fontStyle: "italic" }}
|
|
852
|
+
>
|
|
853
|
+
{label}
|
|
854
|
+
</Typography>
|
|
855
|
+
{action && (
|
|
856
|
+
<Button size="small" onClick={action.onClick}>
|
|
857
|
+
{action.label}
|
|
858
|
+
</Button>
|
|
859
|
+
)}
|
|
860
|
+
</Stack>
|
|
666
861
|
);
|
|
667
862
|
}
|
|
668
863
|
|