@malloy-publisher/sdk 0.9.1 → 0.9.3
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-BRgIgxWh.es.js → RenderedResult-DwB0-9Yx.es.js} +219 -210
- package/dist/RenderedResult-hKjFEqaN.cjs.js +141 -0
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-CcSrGaRN.es.js} +1473 -1326
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +143 -58
- package/dist/builder/index.es.js +12179 -9318
- package/dist/builder-entry.d.ts +5 -1
- package/dist/client/api.d.ts +247 -56
- 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 +94 -88
- 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/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +38 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +21 -2
- package/dist/components/Dashboard/DashboardView.d.ts +71 -0
- package/dist/components/Dashboard/TileCard.d.ts +30 -5
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +5 -1
- package/dist/components/Dashboard/telemetry.d.ts +16 -3
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +15 -9
- 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 +23 -15
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +31 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +56 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +44 -5
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +8 -4
- 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/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +10 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +51 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +12 -6
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -18
- 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/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- 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 +6 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +16 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +15 -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/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 +86 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- 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 +19 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- 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 +6 -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/Loading.d.ts +13 -0
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +17 -1
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +5 -1
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/Prose.d.ts +1 -1
- 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/loadRenderer.d.ts +7 -0
- 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/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9041 -7002
- 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-CA0LZ1xL.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- 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/{Dashboard-H1kJlDFo.es.js → useCompiledDocument-BU6d8FPp.es.js} +17904 -19057
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/dist/utils/clock.d.ts +2 -0
- package/dist/utils/malloyText.d.ts +104 -0
- package/package.json +20 -11
- package/src/builder-entry.ts +36 -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 +29 -280
- package/src/components/Dashboard/DashboardGrid.tsx +87 -8
- package/src/components/Dashboard/DashboardTile.spec.tsx +121 -2
- package/src/components/Dashboard/DashboardTile.tsx +121 -30
- package/src/components/Dashboard/DashboardView.spec.tsx +368 -0
- package/src/components/Dashboard/DashboardView.tsx +428 -0
- package/src/components/Dashboard/RowsDialog.tsx +4 -3
- package/src/components/Dashboard/TileCard.tsx +60 -11
- 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/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +13 -1
- package/src/components/Dashboard/telemetry.ts +17 -5
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +124 -138
- 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 +111 -80
- 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 +156 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +183 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +373 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +310 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +105 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +117 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +146 -108
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +179 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +330 -512
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +55 -25
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +142 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +310 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +39 -13
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +9 -26
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +102 -25
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +252 -780
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +23 -11
- package/src/components/DashboardBuilder/FilterStrip.tsx +130 -70
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +182 -0
- package/src/components/DashboardBuilder/InlineText.tsx +112 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +31 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +302 -163
- package/src/components/DashboardBuilder/TileMenu.tsx +125 -97
- 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 +46 -0
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -44
- package/src/components/DashboardBuilder/catalog.ts +61 -57
- 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 +258 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- 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/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/malloyTree.ts +159 -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 +174 -26
- package/src/components/DashboardBuilder/readDocument.ts +137 -45
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +52 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +89 -0
- package/src/components/DashboardBuilder/sortable.tsx +11 -10
- 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 +768 -131
- 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 +253 -0
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- 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 +760 -0
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +250 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +255 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +45 -9
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +57 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- 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/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/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +30 -5
- package/src/components/DashboardBuilder/useTileResize.ts +31 -8
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- 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/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.spec.tsx +2 -2
- package/src/components/Model/ModelExplorer.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 +72 -29
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- 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 +186 -0
- package/src/components/Package/Package.create.spec.tsx +401 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +396 -177
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +14 -1
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +23 -8
- package/src/components/RenderedResult/ResultContainer.tsx +51 -13
- package/src/components/RenderedResult/ResultPanel.tsx +24 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -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/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +5 -11
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +3 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +7 -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/useNarrowScreen.ts +21 -0
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +23 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +112 -0
- 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/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +48 -0
- package/src/utils/malloyText.ts +368 -0
- package/src/utils/queryClient.ts +8 -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/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -15
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -20
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/dist/components/DashboardBuilder/malloyText.d.ts +0 -64
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -122
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -168
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- package/src/components/DashboardBuilder/malloyText.ts +0 -214
- 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,45 +22,78 @@ 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
|
-
import { BackLink } from "../BackLink";
|
|
39
49
|
import { ItemRow } from "../ItemRow";
|
|
40
50
|
import { Materializations } from "../Materializations";
|
|
41
51
|
import { PackageSection } from "../PackageSection";
|
|
52
|
+
import {
|
|
53
|
+
documentRoute,
|
|
54
|
+
documentSlug,
|
|
55
|
+
type DocumentKind,
|
|
56
|
+
} from "./documentLocation";
|
|
42
57
|
|
|
43
58
|
// The pinned README: the root `.malloynb`, or a served notebook named README in `notebooks/`.
|
|
44
59
|
const README_NOTEBOOK = "README.malloynb";
|
|
45
60
|
const isServedReadme = (path: string | undefined) =>
|
|
46
61
|
path?.toLowerCase() === "notebooks/readme.malloy";
|
|
47
62
|
|
|
63
|
+
const draftPrefix = (
|
|
64
|
+
environmentName: string,
|
|
65
|
+
packageName: string,
|
|
66
|
+
kind: DocumentType,
|
|
67
|
+
) => `${environmentName}/${packageName}/${kind}s/`;
|
|
68
|
+
|
|
48
69
|
/** A served notebook opens by slug, like a dashboard; a `.malloynb` opens by path. */
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
|
|
71
|
+
/** A dashboard or notebook the package page asks its host to open, and how. */
|
|
72
|
+
export interface OpenDocumentRequest {
|
|
73
|
+
kind: DocumentKind;
|
|
74
|
+
slug: string;
|
|
75
|
+
/** `edit` for a document just created or a draft picked up; `view` otherwise. */
|
|
76
|
+
mode: "view" | "edit";
|
|
77
|
+
}
|
|
51
78
|
|
|
52
79
|
interface PackageProps {
|
|
53
80
|
onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Open a dashboard or notebook, to read or to edit. Where reading and
|
|
83
|
+
* editing live is the host's business, not the package page's, so a host
|
|
84
|
+
* with a builder of its own routes this. Absent, the page navigates to the
|
|
85
|
+
* Console's own routes: the document's, and `/edit` under it to edit.
|
|
86
|
+
*/
|
|
87
|
+
onOpenDocument?: (
|
|
88
|
+
request: OpenDocumentRequest,
|
|
89
|
+
event?: React.MouseEvent,
|
|
90
|
+
) => void;
|
|
54
91
|
resourceUri: string;
|
|
55
92
|
}
|
|
56
93
|
|
|
57
94
|
export default function Package({
|
|
58
95
|
onClickPackageFile,
|
|
96
|
+
onOpenDocument,
|
|
59
97
|
resourceUri,
|
|
60
98
|
}: PackageProps) {
|
|
61
99
|
const { apiClients, server, mutable } = useServer();
|
|
@@ -67,37 +105,66 @@ export default function Package({
|
|
|
67
105
|
});
|
|
68
106
|
const { environmentName, packageName, versionId } =
|
|
69
107
|
parseResourceUri(resourceUri);
|
|
108
|
+
const openDocument =
|
|
109
|
+
onOpenDocument ??
|
|
110
|
+
((request: OpenDocumentRequest, event?: React.MouseEvent) => {
|
|
111
|
+
const to = `${documentRoute(environmentName, packageName, request.kind, request.slug)}${request.mode === "edit" ? "/edit" : ""}`;
|
|
112
|
+
// Without an event, called exactly as before this hook existed.
|
|
113
|
+
if (event) onClick(to, event);
|
|
114
|
+
else onClick(to);
|
|
115
|
+
});
|
|
70
116
|
|
|
71
117
|
const [schemaDatabase, setSchemaDatabase] = useState<Database | null>(null);
|
|
72
|
-
const [creating, setCreating] = useState(
|
|
118
|
+
const [creating, setCreating] = useState<DocumentType | undefined>(
|
|
119
|
+
undefined,
|
|
120
|
+
);
|
|
121
|
+
const [newMenu, setNewMenu] = useState<HTMLElement | null>(null);
|
|
122
|
+
const narrow = useNarrowScreen();
|
|
73
123
|
|
|
74
|
-
// Dashboards the host keeps for this package and the package
|
|
75
|
-
// the builder's drafts, listed so they are found rather than
|
|
124
|
+
// Dashboards and notebooks the host keeps for this package and the package
|
|
125
|
+
// does not have: the builder's drafts, listed so they are found rather than
|
|
126
|
+
// stumbled on.
|
|
76
127
|
// Each carries the workspace's own description, because where a document is
|
|
77
128
|
// kept is the backend's to say and only one host's answer is "this browser".
|
|
78
129
|
const storage = useOptionalDocumentStorage()?.documentStorage;
|
|
79
130
|
const [drafts, setDrafts] = useState<
|
|
80
131
|
{ locator: DocumentLocator; where: string }[]
|
|
81
132
|
>([]);
|
|
82
|
-
|
|
133
|
+
// Where a create may land is the chosen workspace's to say, so New waits
|
|
134
|
+
// for the answer; a host whose workspaces cannot be listed gets no New
|
|
135
|
+
// rather than a guess that could write the package under its record.
|
|
136
|
+
const [workspace, setWorkspace] = useState<
|
|
137
|
+
{ state: "pending" | "failed" } | { state: "ready"; chosen?: Workspace }
|
|
138
|
+
>({ state: storage ? "pending" : "ready" });
|
|
83
139
|
const refreshDrafts = useCallback(async () => {
|
|
84
140
|
if (!storage) return;
|
|
85
|
-
|
|
141
|
+
let workspaces: Workspace[];
|
|
142
|
+
try {
|
|
143
|
+
workspaces = await storage.listWorkspaces(false);
|
|
144
|
+
} catch {
|
|
145
|
+
setWorkspace({ state: "failed" });
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setWorkspace({ state: "ready", chosen: chooseWorkspace(workspaces) });
|
|
86
149
|
const found: { locator: DocumentLocator; where: string }[] = [];
|
|
87
|
-
for (const
|
|
88
|
-
for (const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
150
|
+
for (const candidate of workspaces.filter((w) => w.writeable))
|
|
151
|
+
for (const kind of ["dashboard", "notebook"] as const)
|
|
152
|
+
for (const locator of await storage.listDocuments(candidate, kind))
|
|
153
|
+
if (
|
|
154
|
+
locator.path.startsWith(
|
|
155
|
+
draftPrefix(environmentName, packageName, kind),
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
found.push({ locator, where: candidate.description });
|
|
94
159
|
setDrafts(found);
|
|
95
|
-
}, [storage,
|
|
160
|
+
}, [storage, environmentName, packageName]);
|
|
96
161
|
useEffect(() => {
|
|
97
162
|
void refreshDrafts();
|
|
98
163
|
}, [refreshDrafts]);
|
|
99
164
|
const draftSlug = (locator: DocumentLocator) =>
|
|
100
|
-
locator.path
|
|
165
|
+
locator.path
|
|
166
|
+
.slice(draftPrefix(environmentName, packageName, locator.type).length)
|
|
167
|
+
.replace(/\.malloy$/, "");
|
|
101
168
|
|
|
102
169
|
const pkgQuery = useQueryWithApiError({
|
|
103
170
|
queryKey: ["package", environmentName, packageName, versionId],
|
|
@@ -112,12 +179,26 @@ export default function Package({
|
|
|
112
179
|
|
|
113
180
|
const notebooksQuery = useQueryWithApiError({
|
|
114
181
|
queryKey: ["notebooks", environmentName, packageName, versionId],
|
|
115
|
-
queryFn: () =>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
182
|
+
queryFn: async () => {
|
|
183
|
+
try {
|
|
184
|
+
return await apiClients.notebooks.listNotebooks(
|
|
185
|
+
environmentName,
|
|
186
|
+
packageName,
|
|
187
|
+
versionId,
|
|
188
|
+
);
|
|
189
|
+
} catch (e) {
|
|
190
|
+
// Non-fatal like the dashboards list: an older Publisher without
|
|
191
|
+
// the route has no notebooks to list.
|
|
192
|
+
const status = (e as { response?: { status?: number } })?.response
|
|
193
|
+
?.status;
|
|
194
|
+
if (status === 404 || status === undefined) {
|
|
195
|
+
return { data: [] } as Awaited<
|
|
196
|
+
ReturnType<typeof apiClients.notebooks.listNotebooks>
|
|
197
|
+
>;
|
|
198
|
+
}
|
|
199
|
+
throw e;
|
|
200
|
+
}
|
|
201
|
+
},
|
|
121
202
|
});
|
|
122
203
|
|
|
123
204
|
const modelsQuery = useQueryWithApiError({
|
|
@@ -195,28 +276,12 @@ export default function Package({
|
|
|
195
276
|
}
|
|
196
277
|
},
|
|
197
278
|
});
|
|
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
|
-
|
|
279
|
+
const dashboards = dashboardsQuery.data?.data ?? [];
|
|
216
280
|
const notebooks = (notebooksQuery.data?.data ?? [])
|
|
217
281
|
.slice()
|
|
218
|
-
.sort((a, b) =>
|
|
219
|
-
|
|
282
|
+
.sort((a, b) => (a.path ?? "").localeCompare(b.path ?? ""));
|
|
283
|
+
const artifacts = artifactRows(dashboards, notebooks);
|
|
284
|
+
// A dashboard is listed once, under Artifacts. Its file is a model like any
|
|
220
285
|
// other, so it would otherwise appear a second time under Semantic Models
|
|
221
286
|
// where clicking it opens the Explorer rather than the dashboard. Untagged
|
|
222
287
|
// shared includes in `dashboards/` are not dashboards and stay in the model
|
|
@@ -234,6 +299,74 @@ export default function Package({
|
|
|
234
299
|
.slice()
|
|
235
300
|
.sort((a, b) => a.path.localeCompare(b.path));
|
|
236
301
|
|
|
302
|
+
// A non-authoritative browser workspace is never a create target: a
|
|
303
|
+
// document made there would look saved and exist for one reader only.
|
|
304
|
+
const route =
|
|
305
|
+
workspace.state === "ready"
|
|
306
|
+
? createRoute({
|
|
307
|
+
authoritative: workspace.chosen?.authoritative === true,
|
|
308
|
+
mutable,
|
|
309
|
+
canStore: workspace.chosen?.writeable === true,
|
|
310
|
+
...(versionId === undefined ? {} : { versionId }),
|
|
311
|
+
})
|
|
312
|
+
: undefined;
|
|
313
|
+
// A name is chosen against the listings, so New waits for all three rather than offering names a still-loading listing would have taken.
|
|
314
|
+
const listingsSettled = [dashboardsQuery, notebooksQuery, modelsQuery].every(
|
|
315
|
+
(q) => q.isSuccess || q.isError,
|
|
316
|
+
);
|
|
317
|
+
const canCreate = route !== undefined && listingsSettled;
|
|
318
|
+
// The editors step aside on a narrow screen, so no entry point to one is offered there.
|
|
319
|
+
const canNew = canCreate && !narrow;
|
|
320
|
+
const createTarget = useMemo((): CreateTarget | undefined => {
|
|
321
|
+
if (!canCreate) return undefined;
|
|
322
|
+
const existing = [
|
|
323
|
+
...(dashboardsQuery.data?.data ?? []).flatMap((d) =>
|
|
324
|
+
d.path ? [d.path] : [],
|
|
325
|
+
),
|
|
326
|
+
...(notebooksQuery.data?.data ?? []).flatMap((n) =>
|
|
327
|
+
n.path ? [n.path] : [],
|
|
328
|
+
),
|
|
329
|
+
...(modelsQuery.data?.data ?? []).flatMap((m) =>
|
|
330
|
+
m.path ? [m.path] : [],
|
|
331
|
+
),
|
|
332
|
+
];
|
|
333
|
+
if (route === "storage" && storage && workspace.state === "ready") {
|
|
334
|
+
if (!workspace.chosen) return undefined;
|
|
335
|
+
return {
|
|
336
|
+
route,
|
|
337
|
+
storage,
|
|
338
|
+
workspace: workspace.chosen,
|
|
339
|
+
environmentName,
|
|
340
|
+
packageName,
|
|
341
|
+
existing,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
if (route !== "package") return undefined;
|
|
345
|
+
return {
|
|
346
|
+
route,
|
|
347
|
+
existing,
|
|
348
|
+
write: async (path, source) => {
|
|
349
|
+
await apiClients.models.updateModelSource(
|
|
350
|
+
environmentName,
|
|
351
|
+
packageName,
|
|
352
|
+
path,
|
|
353
|
+
{ source },
|
|
354
|
+
);
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
}, [
|
|
358
|
+
canCreate,
|
|
359
|
+
route,
|
|
360
|
+
storage,
|
|
361
|
+
workspace,
|
|
362
|
+
environmentName,
|
|
363
|
+
packageName,
|
|
364
|
+
apiClients,
|
|
365
|
+
dashboardsQuery.data,
|
|
366
|
+
notebooksQuery.data,
|
|
367
|
+
modelsQuery.data,
|
|
368
|
+
]);
|
|
369
|
+
|
|
237
370
|
const description = pkgQuery.data?.data?.description ?? "";
|
|
238
371
|
// The root `.malloynb` wins when both exist, so a listing order never flips the pin.
|
|
239
372
|
const readmePath = (
|
|
@@ -287,10 +420,6 @@ export default function Package({
|
|
|
287
420
|
sx={{ maxWidth: 1024, mx: "auto", px: 3, py: 6 }}
|
|
288
421
|
>
|
|
289
422
|
<Box sx={{ mb: 4 }}>
|
|
290
|
-
<BackLink
|
|
291
|
-
label={environmentName}
|
|
292
|
-
onClick={(event) => onClick(`/${environmentName}/`, event)}
|
|
293
|
-
/>
|
|
294
423
|
<Typography
|
|
295
424
|
variant="h4"
|
|
296
425
|
component="h1"
|
|
@@ -311,111 +440,163 @@ export default function Package({
|
|
|
311
440
|
|
|
312
441
|
{isLoading && <Loading text="Loading package..." />}
|
|
313
442
|
|
|
314
|
-
<
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
443
|
+
<Menu
|
|
444
|
+
anchorEl={newMenu}
|
|
445
|
+
open={newMenu !== null}
|
|
446
|
+
onClose={() => setNewMenu(null)}
|
|
447
|
+
>
|
|
448
|
+
{(["dashboard", "notebook"] as const).map((kind) => (
|
|
449
|
+
<MenuItem
|
|
450
|
+
key={kind}
|
|
451
|
+
onClick={() => {
|
|
452
|
+
setNewMenu(null);
|
|
453
|
+
setCreating(kind);
|
|
454
|
+
}}
|
|
455
|
+
>
|
|
456
|
+
{kind === "dashboard" ? "Dashboard" : "Notebook"}
|
|
457
|
+
</MenuItem>
|
|
458
|
+
))}
|
|
459
|
+
</Menu>
|
|
460
|
+
|
|
461
|
+
{createTarget && (
|
|
462
|
+
<NewDocumentDialog
|
|
463
|
+
open={creating !== undefined}
|
|
464
|
+
kind={creating ?? "dashboard"}
|
|
465
|
+
environmentName={environmentName}
|
|
466
|
+
packageName={packageName}
|
|
467
|
+
{...(versionId !== undefined ? { versionId } : {})}
|
|
468
|
+
models={models
|
|
469
|
+
.map((model) => model.path)
|
|
470
|
+
.filter(
|
|
471
|
+
(path): path is string =>
|
|
472
|
+
typeof path === "string" &&
|
|
473
|
+
path.endsWith(".malloy") &&
|
|
474
|
+
!path.startsWith("dashboards/") &&
|
|
475
|
+
!path.startsWith("notebooks/"),
|
|
476
|
+
)}
|
|
477
|
+
modelsLoading={modelsQuery.isPending}
|
|
478
|
+
{...(modelsQuery.isError
|
|
479
|
+
? { modelsError: modelsQuery.error }
|
|
480
|
+
: {})}
|
|
481
|
+
onRetryModels={() => void modelsQuery.refetch()}
|
|
482
|
+
target={createTarget}
|
|
483
|
+
onClose={() => setCreating(undefined)}
|
|
484
|
+
onCreated={(created) => {
|
|
485
|
+
setCreating(undefined);
|
|
486
|
+
for (const key of ["dashboards", "notebooks", "models"])
|
|
487
|
+
void queryClient.invalidateQueries({ queryKey: [key] });
|
|
488
|
+
openDocument({
|
|
489
|
+
kind: created.kind,
|
|
490
|
+
slug: created.slug,
|
|
491
|
+
mode: "edit",
|
|
492
|
+
});
|
|
493
|
+
}}
|
|
494
|
+
/>
|
|
495
|
+
)}
|
|
338
496
|
|
|
339
497
|
{!isLoading && (
|
|
340
498
|
<>
|
|
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
499
|
{/* 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 && (
|
|
500
|
+
none: the list falls back to `[]` and the section hides
|
|
501
|
+
itself. Only `pkgQuery` reaches the error page, so nothing
|
|
502
|
+
else here would say a word, and one failed list hides only
|
|
503
|
+
half the artifacts. The 404 swallowed in each query is an
|
|
504
|
+
older Publisher with no route, which genuinely has none. */}
|
|
505
|
+
{(dashboardsQuery.isError || notebooksQuery.isError) && (
|
|
354
506
|
<Box sx={{ mb: 4 }}>
|
|
355
507
|
<Alert severity="warning">
|
|
356
|
-
Could not list
|
|
357
|
-
|
|
508
|
+
Could not list some artifacts, so any this package has
|
|
509
|
+
are missing from this page.
|
|
358
510
|
</Alert>
|
|
359
511
|
</Box>
|
|
360
512
|
)}
|
|
361
|
-
{(
|
|
513
|
+
{(artifacts.length > 0 || canCreate) && (
|
|
362
514
|
<PackageSection
|
|
363
|
-
title="
|
|
364
|
-
count={
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
515
|
+
title="Artifacts"
|
|
516
|
+
count={artifacts.length}
|
|
517
|
+
{...(canNew
|
|
518
|
+
? {
|
|
519
|
+
action: (
|
|
520
|
+
<Button
|
|
521
|
+
variant="outlined"
|
|
522
|
+
size="small"
|
|
523
|
+
endIcon={<ArrowDropDownIcon />}
|
|
524
|
+
aria-haspopup="menu"
|
|
525
|
+
aria-label="New"
|
|
526
|
+
onClick={(event) =>
|
|
527
|
+
setNewMenu(event.currentTarget)
|
|
528
|
+
}
|
|
529
|
+
>
|
|
530
|
+
New
|
|
531
|
+
</Button>
|
|
532
|
+
),
|
|
533
|
+
}
|
|
534
|
+
: {})}
|
|
373
535
|
>
|
|
374
|
-
{
|
|
375
|
-
<EmptyRow
|
|
536
|
+
{artifacts.length === 0 && (
|
|
537
|
+
<EmptyRow
|
|
538
|
+
label="No artifacts yet"
|
|
539
|
+
{...(canNew
|
|
540
|
+
? {
|
|
541
|
+
action: {
|
|
542
|
+
label: "New artifact",
|
|
543
|
+
onClick: (event) =>
|
|
544
|
+
setNewMenu(event.currentTarget),
|
|
545
|
+
},
|
|
546
|
+
}
|
|
547
|
+
: {})}
|
|
548
|
+
/>
|
|
376
549
|
)}
|
|
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
|
-
|
|
550
|
+
{artifacts.map((artifact) => (
|
|
551
|
+
<PackageItemRow
|
|
552
|
+
key={`${artifact.kind}:${artifact.path}`}
|
|
553
|
+
type={
|
|
554
|
+
artifact.kind === "dashboard"
|
|
555
|
+
? "dashboard"
|
|
556
|
+
: "report"
|
|
557
|
+
}
|
|
558
|
+
label={artifact.label}
|
|
559
|
+
{...(artifact.secondary === undefined
|
|
560
|
+
? {}
|
|
561
|
+
: { description: artifact.secondary })}
|
|
562
|
+
onClick={(event) =>
|
|
563
|
+
artifact.slug === undefined
|
|
564
|
+
? onClick(
|
|
565
|
+
`/${environmentName}/${packageName}/${artifact.path}`,
|
|
566
|
+
event,
|
|
567
|
+
)
|
|
568
|
+
: openDocument(
|
|
569
|
+
{
|
|
570
|
+
kind: artifact.kind,
|
|
571
|
+
slug: artifact.slug,
|
|
572
|
+
mode: "view",
|
|
573
|
+
},
|
|
574
|
+
event,
|
|
575
|
+
)
|
|
576
|
+
}
|
|
577
|
+
/>
|
|
578
|
+
))}
|
|
406
579
|
</PackageSection>
|
|
407
580
|
)}
|
|
408
581
|
{drafts.length > 0 && (
|
|
409
582
|
<PackageSection title="Drafts" count={drafts.length}>
|
|
410
583
|
{drafts.map(({ locator, where }) => (
|
|
411
584
|
<PackageItemRow
|
|
412
|
-
key={locator.path}
|
|
413
|
-
type=
|
|
585
|
+
key={`${locator.type}:${locator.path}`}
|
|
586
|
+
type={
|
|
587
|
+
locator.type === "dashboard"
|
|
588
|
+
? "dashboard"
|
|
589
|
+
: "report"
|
|
590
|
+
}
|
|
414
591
|
label={draftSlug(locator)}
|
|
415
592
|
rightLabel={where}
|
|
416
593
|
onClick={(event) =>
|
|
417
|
-
|
|
418
|
-
|
|
594
|
+
openDocument(
|
|
595
|
+
{
|
|
596
|
+
kind: locator.type,
|
|
597
|
+
slug: draftSlug(locator),
|
|
598
|
+
mode: "edit",
|
|
599
|
+
},
|
|
419
600
|
event,
|
|
420
601
|
)
|
|
421
602
|
}
|
|
@@ -440,40 +621,6 @@ export default function Package({
|
|
|
440
621
|
</PackageSection>
|
|
441
622
|
)}
|
|
442
623
|
|
|
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
624
|
{dataApps.length > 0 && (
|
|
478
625
|
<PackageSection title="Data Apps" count={dataApps.length}>
|
|
479
626
|
{dataApps.map((dataApp) => {
|
|
@@ -628,12 +775,14 @@ export default function Package({
|
|
|
628
775
|
function PackageItemRow({
|
|
629
776
|
type,
|
|
630
777
|
label,
|
|
778
|
+
description,
|
|
631
779
|
rightLabel,
|
|
632
780
|
onClick,
|
|
633
781
|
trailingAction,
|
|
634
782
|
}: {
|
|
635
783
|
type: ContentType;
|
|
636
784
|
label: string;
|
|
785
|
+
description?: string;
|
|
637
786
|
rightLabel?: string;
|
|
638
787
|
onClick?: (event: React.MouseEvent) => void;
|
|
639
788
|
/** Optional element rendered at the end of the row (e.g. an
|
|
@@ -647,6 +796,7 @@ function PackageItemRow({
|
|
|
647
796
|
tint={CONTENT_TINT[type]}
|
|
648
797
|
label={label}
|
|
649
798
|
mono
|
|
799
|
+
{...(description === undefined ? {} : { description })}
|
|
650
800
|
{...(rightLabel === undefined ? {} : { rightLabel })}
|
|
651
801
|
{...(onClick === undefined ? {} : { onClick })}
|
|
652
802
|
{...(trailingAction === undefined ? {} : { trailingAction })}
|
|
@@ -654,15 +804,84 @@ function PackageItemRow({
|
|
|
654
804
|
);
|
|
655
805
|
}
|
|
656
806
|
|
|
657
|
-
|
|
807
|
+
interface ArtifactRow {
|
|
808
|
+
kind: DocumentKind;
|
|
809
|
+
path: string;
|
|
810
|
+
/** Absent for a `.malloynb`, which opens by path. */
|
|
811
|
+
slug: string | undefined;
|
|
812
|
+
label: string;
|
|
813
|
+
/** The path, when the label alone does not say which file this is. */
|
|
814
|
+
secondary: string | undefined;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/** Dashboards and notebooks as one list: the title when set, else the slug, ordered by what is shown. */
|
|
818
|
+
function artifactRows(
|
|
819
|
+
dashboards: readonly { name?: string; path?: string; title?: string }[],
|
|
820
|
+
notebooks: readonly { path?: string; title?: string }[],
|
|
821
|
+
): ArtifactRow[] {
|
|
822
|
+
const rows = [
|
|
823
|
+
...dashboards.map((d) => ({
|
|
824
|
+
kind: "dashboard" as const,
|
|
825
|
+
path: d.path ?? "",
|
|
826
|
+
slug: d.name ?? documentSlug(d.path),
|
|
827
|
+
title: d.title,
|
|
828
|
+
})),
|
|
829
|
+
...notebooks.map((n) => ({
|
|
830
|
+
kind: "notebook" as const,
|
|
831
|
+
path: n.path ?? "",
|
|
832
|
+
slug: documentSlug(n.path),
|
|
833
|
+
title: n.title,
|
|
834
|
+
})),
|
|
835
|
+
];
|
|
836
|
+
const slugCount = new Map<string, number>();
|
|
837
|
+
for (const row of rows)
|
|
838
|
+
if (row.slug !== undefined)
|
|
839
|
+
slugCount.set(row.slug, (slugCount.get(row.slug) ?? 0) + 1);
|
|
840
|
+
return rows
|
|
841
|
+
.map(({ title, ...row }): ArtifactRow => {
|
|
842
|
+
// A title equal to the slug or path is the server's fallback for a file that names itself neither way.
|
|
843
|
+
const hasTitle = !!title && title !== row.slug && title !== row.path;
|
|
844
|
+
const ambiguous =
|
|
845
|
+
row.slug !== undefined && (slugCount.get(row.slug) ?? 0) > 1;
|
|
846
|
+
return {
|
|
847
|
+
...row,
|
|
848
|
+
label: hasTitle ? title : (row.slug ?? row.path),
|
|
849
|
+
secondary: (row.slug === undefined ? hasTitle : ambiguous)
|
|
850
|
+
? row.path
|
|
851
|
+
: undefined,
|
|
852
|
+
};
|
|
853
|
+
})
|
|
854
|
+
.sort(
|
|
855
|
+
(a, b) =>
|
|
856
|
+
a.label.localeCompare(b.label) || a.path.localeCompare(b.path),
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
function EmptyRow({
|
|
861
|
+
label,
|
|
862
|
+
action,
|
|
863
|
+
}: {
|
|
864
|
+
label: string;
|
|
865
|
+
action?: {
|
|
866
|
+
label: string;
|
|
867
|
+
onClick: (event: React.MouseEvent<HTMLElement>) => void;
|
|
868
|
+
};
|
|
869
|
+
}) {
|
|
658
870
|
return (
|
|
659
|
-
<
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
871
|
+
<Stack direction="row" sx={{ alignItems: "center", gap: 1, py: 1 }}>
|
|
872
|
+
<Typography
|
|
873
|
+
variant="body2"
|
|
874
|
+
color="text.secondary"
|
|
875
|
+
sx={{ fontStyle: "italic" }}
|
|
876
|
+
>
|
|
877
|
+
{label}
|
|
878
|
+
</Typography>
|
|
879
|
+
{action && (
|
|
880
|
+
<Button size="small" onClick={action.onClick}>
|
|
881
|
+
{action.label}
|
|
882
|
+
</Button>
|
|
883
|
+
)}
|
|
884
|
+
</Stack>
|
|
666
885
|
);
|
|
667
886
|
}
|
|
668
887
|
|