@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
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Alert,
|
|
6
|
+
Button,
|
|
7
|
+
MenuItem,
|
|
8
|
+
Stack,
|
|
9
|
+
TextField,
|
|
10
|
+
Tooltip,
|
|
11
|
+
} from "@mui/material";
|
|
12
|
+
import { useEffect, useMemo, useState } from "react";
|
|
13
|
+
import {
|
|
14
|
+
createDocument,
|
|
15
|
+
documentPathForTitle,
|
|
16
|
+
MAX_SLUG_ATTEMPTS,
|
|
17
|
+
newDocumentProblem,
|
|
18
|
+
useDocumentChoices,
|
|
19
|
+
type CreatedDocument,
|
|
20
|
+
type CreateTarget,
|
|
21
|
+
type DocumentCreatedEvent,
|
|
22
|
+
} from "../DocumentCreate";
|
|
23
|
+
import { canRetryRequest } from "../DocumentCreate/canRetry";
|
|
24
|
+
import type { DocumentType } from "../DocumentStorage/DocumentStorage";
|
|
25
|
+
import { AppDialog } from "../AppDialog";
|
|
26
|
+
|
|
27
|
+
const KIND_LABEL: Record<DocumentType, string> = {
|
|
28
|
+
dashboard: "Dashboard",
|
|
29
|
+
notebook: "Notebook",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export interface NewDocumentDialogProps {
|
|
33
|
+
open: boolean;
|
|
34
|
+
/** Which kind the dialog opens on. */
|
|
35
|
+
kind: DocumentType;
|
|
36
|
+
/** Whether the reader may switch to the other kind. Default true. */
|
|
37
|
+
allowKindChange?: boolean;
|
|
38
|
+
environmentName: string;
|
|
39
|
+
packageName: string;
|
|
40
|
+
versionId?: string;
|
|
41
|
+
/** The package's model files, relative to its root, to pick a source from. */
|
|
42
|
+
models: readonly string[];
|
|
43
|
+
/** The host is still listing `models`, so an empty list is not yet "no models". */
|
|
44
|
+
modelsLoading?: boolean;
|
|
45
|
+
/** The host's listing of `models` failed, so an empty list is not "no models". */
|
|
46
|
+
modelsError?: unknown;
|
|
47
|
+
/** Lists the models again; offered when `modelsError` is one a retry can clear. */
|
|
48
|
+
onRetryModels?: () => void;
|
|
49
|
+
/** Where the file is written, and (on the package route) which names are taken. */
|
|
50
|
+
target: CreateTarget;
|
|
51
|
+
/** The line under the title on the storage route, saying where the host keeps the new file. */
|
|
52
|
+
savedAs?: string;
|
|
53
|
+
onClose: () => void;
|
|
54
|
+
onCreated: (created: CreatedDocument) => void;
|
|
55
|
+
onEvent?: (event: DocumentCreatedEvent) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A new dashboard or notebook: pick the model, the view its first tile or
|
|
60
|
+
* query shows, and a title. The file is the one the builder would write, so
|
|
61
|
+
* everything after this is the builder's; the host opens it from `onCreated`.
|
|
62
|
+
*/
|
|
63
|
+
export function NewDocumentDialog({
|
|
64
|
+
open,
|
|
65
|
+
kind: initialKind,
|
|
66
|
+
allowKindChange = true,
|
|
67
|
+
environmentName,
|
|
68
|
+
packageName,
|
|
69
|
+
versionId,
|
|
70
|
+
models,
|
|
71
|
+
modelsLoading = false,
|
|
72
|
+
modelsError,
|
|
73
|
+
onRetryModels,
|
|
74
|
+
target,
|
|
75
|
+
savedAs,
|
|
76
|
+
onClose,
|
|
77
|
+
onCreated,
|
|
78
|
+
onEvent,
|
|
79
|
+
}: NewDocumentDialogProps) {
|
|
80
|
+
const [kind, setKind] = useState<DocumentType>(initialKind);
|
|
81
|
+
const [modelPath, setModelPath] = useState("");
|
|
82
|
+
/** The chosen view, as `source::view` — one value, so the pair is always valid. */
|
|
83
|
+
const [tile, setTile] = useState("");
|
|
84
|
+
const [title, setTitle] = useState("");
|
|
85
|
+
const [touchedTitle, setTouchedTitle] = useState(false);
|
|
86
|
+
const [attempted, setAttempted] = useState(false);
|
|
87
|
+
const [busy, setBusy] = useState(false);
|
|
88
|
+
const [failure, setFailure] = useState<string | undefined>(undefined);
|
|
89
|
+
const modelsFailed = modelsError !== undefined && modelsError !== null;
|
|
90
|
+
|
|
91
|
+
// Every model at once rather than the chosen one: a model that declares no
|
|
92
|
+
// source with a view cannot start a document, and the only way to offer a
|
|
93
|
+
// list without those is to know before the reader picks.
|
|
94
|
+
const { choices, isLoading, isSuccess, failed, retry, canRetry } =
|
|
95
|
+
useDocumentChoices({
|
|
96
|
+
environmentName,
|
|
97
|
+
packageName,
|
|
98
|
+
...(versionId !== undefined ? { versionId } : {}),
|
|
99
|
+
models,
|
|
100
|
+
enabled: open && models.length > 0,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const tiles = useMemo(
|
|
104
|
+
() => choices.get(modelPath) ?? [],
|
|
105
|
+
[choices, modelPath],
|
|
106
|
+
);
|
|
107
|
+
const chosen = tiles.find((t) => `${t.source}::${t.view}` === tile);
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (open) setKind(initialKind);
|
|
111
|
+
}, [open, initialKind]);
|
|
112
|
+
|
|
113
|
+
// Everything with one answer answers itself: a package with one usable
|
|
114
|
+
// model, a model with one view, and a title taken from that view.
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (!open) return;
|
|
117
|
+
const usable = [...choices.keys()];
|
|
118
|
+
if (modelPath === "" && usable.length > 0) setModelPath(usable[0]);
|
|
119
|
+
}, [open, choices, modelPath]);
|
|
120
|
+
|
|
121
|
+
// Only a pick not yet made is filled in: a picked view that leaves the list stays unpicked, never swapped.
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (!open || tiles.length === 0 || tile !== "") return;
|
|
124
|
+
setTile(`${tiles[0].source}::${tiles[0].view}`);
|
|
125
|
+
}, [open, tiles, tile]);
|
|
126
|
+
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (!open || touchedTitle || chosen === undefined) return;
|
|
129
|
+
setTitle(chosen.view.replace(/_/g, " "));
|
|
130
|
+
}, [open, touchedTitle, chosen]);
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (open) return;
|
|
134
|
+
// Reset on close, so the next open starts from the package again.
|
|
135
|
+
setModelPath("");
|
|
136
|
+
setTile("");
|
|
137
|
+
setTitle("");
|
|
138
|
+
setTouchedTitle(false);
|
|
139
|
+
setAttempted(false);
|
|
140
|
+
setFailure(undefined);
|
|
141
|
+
}, [open]);
|
|
142
|
+
|
|
143
|
+
// The first name the package listing leaves free; the storage route checks
|
|
144
|
+
// each name against the store itself when it writes.
|
|
145
|
+
const path = useMemo(() => {
|
|
146
|
+
if (title.trim() === "") return undefined;
|
|
147
|
+
for (let n = 1; n <= MAX_SLUG_ATTEMPTS; n++) {
|
|
148
|
+
const candidate = documentPathForTitle(kind, title, n);
|
|
149
|
+
if (!target.existing?.includes(candidate)) return candidate;
|
|
150
|
+
}
|
|
151
|
+
return undefined;
|
|
152
|
+
}, [kind, title, target]);
|
|
153
|
+
const problem =
|
|
154
|
+
chosen === undefined
|
|
155
|
+
? undefined
|
|
156
|
+
: newDocumentProblem(kind, {
|
|
157
|
+
title,
|
|
158
|
+
modelPath,
|
|
159
|
+
source: chosen.source,
|
|
160
|
+
view: chosen.view,
|
|
161
|
+
});
|
|
162
|
+
const titleProblem =
|
|
163
|
+
problem ??
|
|
164
|
+
(title.trim() !== "" && path === undefined
|
|
165
|
+
? "No free file name for this title; choose another."
|
|
166
|
+
: undefined);
|
|
167
|
+
// A blank title is said only once Create is pressed; anything else as it is typed.
|
|
168
|
+
const showTitleProblem =
|
|
169
|
+
titleProblem !== undefined && (attempted || title.trim() !== "");
|
|
170
|
+
|
|
171
|
+
const loading = modelsLoading || isLoading;
|
|
172
|
+
const unread = choices.size === 0 && (modelsFailed || failed.length > 0);
|
|
173
|
+
// Create is off only when nothing typed could make it succeed; the title is checked on press.
|
|
174
|
+
const blocked = loading
|
|
175
|
+
? "Loading model views"
|
|
176
|
+
: unread
|
|
177
|
+
? "Couldn't read the model views to start from"
|
|
178
|
+
: choices.size === 0
|
|
179
|
+
? "No model view to start from yet"
|
|
180
|
+
: chosen === undefined
|
|
181
|
+
? "Pick a view to start from"
|
|
182
|
+
: undefined;
|
|
183
|
+
const label = KIND_LABEL[kind].toLowerCase();
|
|
184
|
+
const createLabel = busy ? `Creating ${label}…` : `Create ${label}`;
|
|
185
|
+
const first = kind === "dashboard" ? "First tile" : "First query";
|
|
186
|
+
const picked = tile !== "" && chosen === undefined && tiles.length > 0;
|
|
187
|
+
|
|
188
|
+
const create = async () => {
|
|
189
|
+
if (blocked !== undefined || chosen === undefined || busy) return;
|
|
190
|
+
if (titleProblem !== undefined) {
|
|
191
|
+
setAttempted(true);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
setBusy(true);
|
|
195
|
+
setFailure(undefined);
|
|
196
|
+
try {
|
|
197
|
+
const created = await createDocument({
|
|
198
|
+
kind,
|
|
199
|
+
document: {
|
|
200
|
+
title,
|
|
201
|
+
modelPath,
|
|
202
|
+
source: chosen.source,
|
|
203
|
+
view: chosen.view,
|
|
204
|
+
},
|
|
205
|
+
target,
|
|
206
|
+
...(onEvent ? { onEvent } : {}),
|
|
207
|
+
});
|
|
208
|
+
onCreated(created);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
const message = (
|
|
211
|
+
error as { response?: { data?: { message?: string } } }
|
|
212
|
+
).response?.data?.message;
|
|
213
|
+
setFailure(
|
|
214
|
+
message ?? (error instanceof Error ? error.message : String(error)),
|
|
215
|
+
);
|
|
216
|
+
} finally {
|
|
217
|
+
setBusy(false);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const retryButton = (onRetry: () => void) => (
|
|
222
|
+
<Button color="inherit" size="small" onClick={onRetry}>
|
|
223
|
+
Retry
|
|
224
|
+
</Button>
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<AppDialog
|
|
229
|
+
open={open}
|
|
230
|
+
// A write in flight is not abandoned by Escape or a backdrop click.
|
|
231
|
+
onClose={busy ? () => {} : onClose}
|
|
232
|
+
title={`New ${label}`}
|
|
233
|
+
description={
|
|
234
|
+
kind === "dashboard"
|
|
235
|
+
? "A dashboard is a Malloy file in the package. Pick what its first tile shows; the rest is the builder."
|
|
236
|
+
: "A notebook is a Malloy file in the package that mixes text and queries. Pick what its first query runs; the rest is the builder."
|
|
237
|
+
}
|
|
238
|
+
actions={
|
|
239
|
+
<>
|
|
240
|
+
<Button onClick={onClose} disabled={busy}>
|
|
241
|
+
Cancel
|
|
242
|
+
</Button>
|
|
243
|
+
{/* A disabled button fires no events, so the tooltip hangs on a wrapper. */}
|
|
244
|
+
<Tooltip title={busy ? "" : (blocked ?? "")}>
|
|
245
|
+
<span>
|
|
246
|
+
<Button
|
|
247
|
+
variant="contained"
|
|
248
|
+
disabled={busy || blocked !== undefined}
|
|
249
|
+
aria-label={
|
|
250
|
+
!busy && blocked !== undefined
|
|
251
|
+
? `${createLabel}: ${blocked}`
|
|
252
|
+
: createLabel
|
|
253
|
+
}
|
|
254
|
+
onClick={() => void create()}
|
|
255
|
+
>
|
|
256
|
+
{createLabel}
|
|
257
|
+
</Button>
|
|
258
|
+
</span>
|
|
259
|
+
</Tooltip>
|
|
260
|
+
</>
|
|
261
|
+
}
|
|
262
|
+
>
|
|
263
|
+
<Stack sx={{ gap: 2, pt: 1 }}>
|
|
264
|
+
{modelsFailed ? (
|
|
265
|
+
<Alert
|
|
266
|
+
severity="error"
|
|
267
|
+
action={
|
|
268
|
+
onRetryModels && canRetryRequest(modelsError)
|
|
269
|
+
? retryButton(onRetryModels)
|
|
270
|
+
: undefined
|
|
271
|
+
}
|
|
272
|
+
>
|
|
273
|
+
Couldn't read this package's models, so no view is
|
|
274
|
+
listed to start from.
|
|
275
|
+
</Alert>
|
|
276
|
+
) : models.length === 0 ? (
|
|
277
|
+
!modelsLoading && (
|
|
278
|
+
<Alert severity="info">
|
|
279
|
+
This package has no models yet. Add a .malloy file that
|
|
280
|
+
declares a source with a view, then create a {label} from
|
|
281
|
+
it.
|
|
282
|
+
</Alert>
|
|
283
|
+
)
|
|
284
|
+
) : failed.length > 0 ? (
|
|
285
|
+
<Alert
|
|
286
|
+
severity="warning"
|
|
287
|
+
action={canRetry ? retryButton(retry) : undefined}
|
|
288
|
+
>
|
|
289
|
+
Couldn't read {failed.join(", ")}, so{" "}
|
|
290
|
+
{failed.length === 1 ? "its" : "their"} views aren't
|
|
291
|
+
listed.
|
|
292
|
+
</Alert>
|
|
293
|
+
) : (
|
|
294
|
+
isSuccess &&
|
|
295
|
+
choices.size === 0 && (
|
|
296
|
+
<Alert severity="info">
|
|
297
|
+
A {label} starts from a view of a source, and no model in
|
|
298
|
+
this package declares one yet. Add a view to a source in a
|
|
299
|
+
model file and this list fills in.
|
|
300
|
+
</Alert>
|
|
301
|
+
)
|
|
302
|
+
)}
|
|
303
|
+
{allowKindChange && (
|
|
304
|
+
<TextField
|
|
305
|
+
select
|
|
306
|
+
size="small"
|
|
307
|
+
label="Type"
|
|
308
|
+
value={kind}
|
|
309
|
+
disabled={busy}
|
|
310
|
+
onChange={(event) =>
|
|
311
|
+
setKind(event.target.value as DocumentType)
|
|
312
|
+
}
|
|
313
|
+
inputProps={{ "aria-label": "Type" }}
|
|
314
|
+
>
|
|
315
|
+
{(Object.keys(KIND_LABEL) as DocumentType[]).map((k) => (
|
|
316
|
+
<MenuItem key={k} value={k}>
|
|
317
|
+
{KIND_LABEL[k]}
|
|
318
|
+
</MenuItem>
|
|
319
|
+
))}
|
|
320
|
+
</TextField>
|
|
321
|
+
)}
|
|
322
|
+
<TextField
|
|
323
|
+
select
|
|
324
|
+
size="small"
|
|
325
|
+
label="Model"
|
|
326
|
+
value={choices.has(modelPath) ? modelPath : ""}
|
|
327
|
+
disabled={choices.size === 0 || busy}
|
|
328
|
+
onChange={(event) => {
|
|
329
|
+
setModelPath(event.target.value);
|
|
330
|
+
setTile("");
|
|
331
|
+
}}
|
|
332
|
+
inputProps={{ "aria-label": "Model" }}
|
|
333
|
+
helperText={
|
|
334
|
+
loading
|
|
335
|
+
? "Reading the package's models…"
|
|
336
|
+
: choices.size === 1
|
|
337
|
+
? "The only model with a view to start from."
|
|
338
|
+
: "Models with a view to start from."
|
|
339
|
+
}
|
|
340
|
+
>
|
|
341
|
+
{[...choices.keys()].map((modelFile) => (
|
|
342
|
+
<MenuItem key={modelFile} value={modelFile}>
|
|
343
|
+
{modelFile}
|
|
344
|
+
</MenuItem>
|
|
345
|
+
))}
|
|
346
|
+
</TextField>
|
|
347
|
+
{/* One field, not two: the file needs a view OF a source, so the
|
|
348
|
+
pair is the thing being chosen. */}
|
|
349
|
+
<TextField
|
|
350
|
+
select
|
|
351
|
+
size="small"
|
|
352
|
+
label={first}
|
|
353
|
+
value={chosen ? tile : ""}
|
|
354
|
+
disabled={tiles.length === 0 || busy}
|
|
355
|
+
onChange={(event) => setTile(event.target.value)}
|
|
356
|
+
inputProps={{ "aria-label": first }}
|
|
357
|
+
error={picked}
|
|
358
|
+
helperText={
|
|
359
|
+
picked
|
|
360
|
+
? "The view you picked is no longer in this model; pick another."
|
|
361
|
+
: tiles.length === 1
|
|
362
|
+
? "The only view this model offers; more are added in the builder."
|
|
363
|
+
: "A view of a source; more are added in the builder."
|
|
364
|
+
}
|
|
365
|
+
>
|
|
366
|
+
{tiles.map((option) => (
|
|
367
|
+
<MenuItem
|
|
368
|
+
key={`${option.source}::${option.view}`}
|
|
369
|
+
value={`${option.source}::${option.view}`}
|
|
370
|
+
>
|
|
371
|
+
{option.source} → {option.view}
|
|
372
|
+
</MenuItem>
|
|
373
|
+
))}
|
|
374
|
+
</TextField>
|
|
375
|
+
<TextField
|
|
376
|
+
size="small"
|
|
377
|
+
label="Title"
|
|
378
|
+
value={title}
|
|
379
|
+
disabled={busy}
|
|
380
|
+
onChange={(event) => {
|
|
381
|
+
setTouchedTitle(true);
|
|
382
|
+
setTitle(event.target.value);
|
|
383
|
+
}}
|
|
384
|
+
inputProps={{ "aria-label": `${KIND_LABEL[kind]} title` }}
|
|
385
|
+
error={showTitleProblem}
|
|
386
|
+
helperText={
|
|
387
|
+
showTitleProblem
|
|
388
|
+
? titleProblem
|
|
389
|
+
: path
|
|
390
|
+
? target.route === "package"
|
|
391
|
+
? `Written as ${path}, and opened in the builder.`
|
|
392
|
+
: (savedAs ??
|
|
393
|
+
`Saved as a new ${label} in the host's store, and opened in the builder.`)
|
|
394
|
+
: "Names the file too."
|
|
395
|
+
}
|
|
396
|
+
/>
|
|
397
|
+
{failure && <Alert severity="error">{failure}</Alert>}
|
|
398
|
+
</Stack>
|
|
399
|
+
</AppDialog>
|
|
400
|
+
);
|
|
401
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/** The package page's one Artifacts list: dashboards and notebooks, named by one rule. */
|
|
5
|
+
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
6
|
+
import { afterEach, beforeEach, expect, it, mock } from "bun:test";
|
|
7
|
+
import type { ReactNode } from "react";
|
|
8
|
+
import {
|
|
9
|
+
clearCache,
|
|
10
|
+
mockServerProvider,
|
|
11
|
+
pending,
|
|
12
|
+
serverWrapper,
|
|
13
|
+
} from "../../../test/serverProvider";
|
|
14
|
+
import type {
|
|
15
|
+
DocumentLocator,
|
|
16
|
+
DocumentStorage,
|
|
17
|
+
} from "../DocumentStorage/DocumentStorage";
|
|
18
|
+
import { DocumentStorageProvider } from "../DocumentStorage/DocumentStorageProvider";
|
|
19
|
+
|
|
20
|
+
let dashboards: { name: string; path: string; title?: string }[] = [];
|
|
21
|
+
let notebooks: { path: string; title?: string }[] = [];
|
|
22
|
+
const listDashboards = mock((_e: string, _p: string, _v?: string) =>
|
|
23
|
+
Promise.resolve({ data: dashboards }),
|
|
24
|
+
);
|
|
25
|
+
const listNotebooks = mock((_e: string, _p: string, _v?: string) =>
|
|
26
|
+
Promise.resolve({ data: notebooks }),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
mockServerProvider(
|
|
30
|
+
{
|
|
31
|
+
packages: { getPackage: pending },
|
|
32
|
+
notebooks: { listNotebooks, getNotebook: pending },
|
|
33
|
+
models: { listModels: () => Promise.resolve({ data: [] }) },
|
|
34
|
+
databases: { listDatabases: () => Promise.resolve({ data: [] }) },
|
|
35
|
+
dataApps: { listDataApps: () => Promise.resolve({ data: [] }) },
|
|
36
|
+
dashboards: { listDashboards },
|
|
37
|
+
materializations: {
|
|
38
|
+
listMaterializations: () => Promise.resolve({ data: [] }),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{ mutable: true },
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const { default: Package } = await import("./Package");
|
|
45
|
+
|
|
46
|
+
const onClick = mock((_to: string) => {});
|
|
47
|
+
|
|
48
|
+
function mount(storage?: DocumentStorage) {
|
|
49
|
+
const wrap = ({ children }: { children: ReactNode }) =>
|
|
50
|
+
serverWrapper({
|
|
51
|
+
children: storage ? (
|
|
52
|
+
<DocumentStorageProvider documentStorage={storage}>
|
|
53
|
+
{children}
|
|
54
|
+
</DocumentStorageProvider>
|
|
55
|
+
) : (
|
|
56
|
+
children
|
|
57
|
+
),
|
|
58
|
+
});
|
|
59
|
+
return render(
|
|
60
|
+
<Package
|
|
61
|
+
resourceUri="publisher://environments/env/packages/pkg"
|
|
62
|
+
onClickPackageFile={onClick}
|
|
63
|
+
/>,
|
|
64
|
+
{ wrapper: wrap },
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The artifact rows' text, top to bottom. */
|
|
69
|
+
const rows = async () => {
|
|
70
|
+
await screen.findByRole("heading", { name: "Artifacts" });
|
|
71
|
+
const section = screen.getByRole("region", { name: "Artifacts" });
|
|
72
|
+
return Array.from(section.querySelectorAll('[role="button"]'))
|
|
73
|
+
.map((row) => row.textContent ?? "")
|
|
74
|
+
.filter((text) => text !== "New");
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
beforeEach(() => {
|
|
78
|
+
clearCache();
|
|
79
|
+
dashboards = [];
|
|
80
|
+
notebooks = [];
|
|
81
|
+
onClick.mockClear();
|
|
82
|
+
listDashboards.mockClear();
|
|
83
|
+
listNotebooks.mockClear();
|
|
84
|
+
});
|
|
85
|
+
afterEach(cleanup);
|
|
86
|
+
|
|
87
|
+
it("lists a dashboard and a notebook in one section, ordered by what is shown", async () => {
|
|
88
|
+
dashboards = [
|
|
89
|
+
{ name: "overview", path: "dashboards/overview.malloy", title: "Zebra" },
|
|
90
|
+
];
|
|
91
|
+
notebooks = [
|
|
92
|
+
{ path: "notebooks/tour.malloy", title: "Aardvark" },
|
|
93
|
+
{ path: "notebooks/plain.malloy", title: "notebooks/plain.malloy" },
|
|
94
|
+
];
|
|
95
|
+
mount();
|
|
96
|
+
|
|
97
|
+
expect(await rows()).toEqual(["Aardvark", "plain", "Zebra"]);
|
|
98
|
+
expect(screen.queryByRole("heading", { name: "Dashboards" })).toBeNull();
|
|
99
|
+
expect(screen.queryByRole("heading", { name: "Notebooks" })).toBeNull();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("shows the folder only to tell two files with one slug apart, and opens each by its kind", async () => {
|
|
103
|
+
dashboards = [{ name: "story", path: "dashboards/story.malloy" }];
|
|
104
|
+
notebooks = [
|
|
105
|
+
{ path: "notebooks/story.malloy" },
|
|
106
|
+
{ path: "notebooks/solo.malloy" },
|
|
107
|
+
];
|
|
108
|
+
mount();
|
|
109
|
+
|
|
110
|
+
expect(await rows()).toEqual([
|
|
111
|
+
"solo",
|
|
112
|
+
"story" + "dashboards/story.malloy",
|
|
113
|
+
"story" + "notebooks/story.malloy",
|
|
114
|
+
]);
|
|
115
|
+
fireEvent.click(screen.getByText("dashboards/story.malloy"));
|
|
116
|
+
fireEvent.click(screen.getByText("notebooks/story.malloy"));
|
|
117
|
+
expect(onClick.mock.calls.map((call) => call[0])).toEqual([
|
|
118
|
+
"/env/pkg/dashboards/story",
|
|
119
|
+
"/env/pkg/notebooks/story",
|
|
120
|
+
]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("keeps a titled .malloynb's path as its secondary text", async () => {
|
|
124
|
+
notebooks = [{ path: "orders.malloynb", title: "Orders" }];
|
|
125
|
+
mount();
|
|
126
|
+
|
|
127
|
+
expect(await rows()).toEqual(["Ordersorders.malloynb"]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("says so when either list fails, and still lists the other", async () => {
|
|
131
|
+
dashboards = [{ name: "overview", path: "dashboards/overview.malloy" }];
|
|
132
|
+
listNotebooks.mockImplementationOnce(() =>
|
|
133
|
+
Promise.reject({ response: { status: 501 } }),
|
|
134
|
+
);
|
|
135
|
+
mount();
|
|
136
|
+
|
|
137
|
+
expect(
|
|
138
|
+
await screen.findByText(/Could not list some artifacts/),
|
|
139
|
+
).toBeDefined();
|
|
140
|
+
expect(await rows()).toEqual(["overview"]);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("treats a 404 on the notebooks list as none, without an error", async () => {
|
|
144
|
+
dashboards = [{ name: "overview", path: "dashboards/overview.malloy" }];
|
|
145
|
+
listNotebooks.mockImplementationOnce(() =>
|
|
146
|
+
Promise.reject({ response: { status: 404 } }),
|
|
147
|
+
);
|
|
148
|
+
mount();
|
|
149
|
+
|
|
150
|
+
expect(await rows()).toEqual(["overview"]);
|
|
151
|
+
expect(screen.queryByText(/Could not list/)).toBeNull();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("lists host drafts of both kinds, each opening its own editor", async () => {
|
|
155
|
+
const draft = (
|
|
156
|
+
type: "dashboard" | "notebook",
|
|
157
|
+
slug: string,
|
|
158
|
+
): DocumentLocator => ({
|
|
159
|
+
workspace: "browser",
|
|
160
|
+
type,
|
|
161
|
+
path: `env/pkg/${type}s/${slug}.malloy`,
|
|
162
|
+
});
|
|
163
|
+
const stored = [draft("dashboard", "d-one"), draft("notebook", "n-one")];
|
|
164
|
+
const storage: DocumentStorage = {
|
|
165
|
+
listWorkspaces: async () => [
|
|
166
|
+
{ name: "browser", writeable: true, description: "This browser" },
|
|
167
|
+
],
|
|
168
|
+
listDocuments: async (_workspace, type) =>
|
|
169
|
+
stored.filter((locator) => locator.type === type),
|
|
170
|
+
getDocument: async () => {
|
|
171
|
+
throw new Error("absent");
|
|
172
|
+
},
|
|
173
|
+
saveDocument: async () => {},
|
|
174
|
+
deleteDocument: async () => {},
|
|
175
|
+
moveDocument: async () => {},
|
|
176
|
+
};
|
|
177
|
+
dashboards = [{ name: "overview", path: "dashboards/overview.malloy" }];
|
|
178
|
+
mount(storage);
|
|
179
|
+
|
|
180
|
+
fireEvent.click(await screen.findByText("d-one"));
|
|
181
|
+
fireEvent.click(await screen.findByText("n-one"));
|
|
182
|
+
expect(onClick.mock.calls.map((call) => call[0])).toEqual([
|
|
183
|
+
"/env/pkg/dashboards/d-one/edit",
|
|
184
|
+
"/env/pkg/notebooks/n-one/edit",
|
|
185
|
+
]);
|
|
186
|
+
});
|