@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,749 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
5
|
+
import { beforeEach, describe, expect, it, mock } from "bun:test";
|
|
6
|
+
import {
|
|
7
|
+
cacheKeys,
|
|
8
|
+
clearCache,
|
|
9
|
+
mockServerProvider,
|
|
10
|
+
pending,
|
|
11
|
+
serverWrapper,
|
|
12
|
+
TEST_SERVER,
|
|
13
|
+
} from "../../../test/serverProvider";
|
|
14
|
+
import type { CreateTarget } from "../DocumentCreate";
|
|
15
|
+
import {
|
|
16
|
+
DocumentNotFoundError,
|
|
17
|
+
type DocumentLocator,
|
|
18
|
+
type DocumentStorage,
|
|
19
|
+
type Workspace,
|
|
20
|
+
} from "../DocumentStorage/DocumentStorage";
|
|
21
|
+
|
|
22
|
+
const info = (names: string[]) =>
|
|
23
|
+
JSON.stringify({
|
|
24
|
+
entries: names.map((name) => ({ kind: "source", name })),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const MODELS: Record<string, unknown> = {
|
|
28
|
+
"storefront.malloy": {
|
|
29
|
+
modelPath: "storefront.malloy",
|
|
30
|
+
modelInfo: info(["order_items", "products"]),
|
|
31
|
+
sources: [
|
|
32
|
+
{
|
|
33
|
+
name: "order_items",
|
|
34
|
+
views: [{ name: "by_category" }, { name: "by_brand" }],
|
|
35
|
+
},
|
|
36
|
+
{ name: "products", views: [] },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
"other.malloy": { modelPath: "other.malloy", sources: [] },
|
|
40
|
+
// Imports `order_items` whole-file: it is in `sources` but not exported, so `import { order_items } from "../mid.malloy"` would not compile.
|
|
41
|
+
"mid.malloy": {
|
|
42
|
+
modelPath: "mid.malloy",
|
|
43
|
+
modelInfo: info(["mid_src"]),
|
|
44
|
+
sources: [
|
|
45
|
+
{ name: "order_items", views: [{ name: "by_category" }] },
|
|
46
|
+
{ name: "mid_src", views: [{ name: "overview" }] },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const serve = (
|
|
51
|
+
_env: string,
|
|
52
|
+
_pkg: string,
|
|
53
|
+
path: string,
|
|
54
|
+
_versionId?: string,
|
|
55
|
+
): Promise<{ data: unknown }> => Promise.resolve({ data: MODELS[path] });
|
|
56
|
+
const getModel = mock(serve);
|
|
57
|
+
mockServerProvider({ models: { getModel } });
|
|
58
|
+
|
|
59
|
+
const { NewDocumentDialog } = await import("./NewDocumentDialog");
|
|
60
|
+
|
|
61
|
+
type Dialog = Parameters<typeof NewDocumentDialog>[0];
|
|
62
|
+
|
|
63
|
+
const packageTarget = (
|
|
64
|
+
existing: string[] = [],
|
|
65
|
+
write: (path: string, source: string) => Promise<void> = async () => {},
|
|
66
|
+
): CreateTarget => ({ route: "package", existing, write });
|
|
67
|
+
|
|
68
|
+
const mount = (props: Partial<Dialog> = {}) =>
|
|
69
|
+
render(
|
|
70
|
+
<NewDocumentDialog
|
|
71
|
+
open
|
|
72
|
+
kind="dashboard"
|
|
73
|
+
environmentName="env"
|
|
74
|
+
packageName="pkg"
|
|
75
|
+
models={["storefront.malloy", "other.malloy"]}
|
|
76
|
+
target={packageTarget()}
|
|
77
|
+
onClose={() => {}}
|
|
78
|
+
onCreated={() => {}}
|
|
79
|
+
{...props}
|
|
80
|
+
/>,
|
|
81
|
+
{ wrapper: serverWrapper },
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const titleFilled = (value: string, label = "Dashboard title") =>
|
|
85
|
+
waitFor(() =>
|
|
86
|
+
expect(screen.getByLabelText(label)).toHaveProperty("value", value),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
beforeEach(() => {
|
|
90
|
+
clearCache();
|
|
91
|
+
getModel.mockClear();
|
|
92
|
+
getModel.mockImplementation(serve);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const failing = (status?: number) =>
|
|
96
|
+
Promise.reject(
|
|
97
|
+
Object.assign(
|
|
98
|
+
new Error("Request failed"),
|
|
99
|
+
status === undefined ? {} : { response: { status } },
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const createButton = (name: string | RegExp) =>
|
|
104
|
+
screen.getByRole("button", { name });
|
|
105
|
+
|
|
106
|
+
const isDisabled = (element: HTMLElement) => element.hasAttribute("disabled");
|
|
107
|
+
|
|
108
|
+
describe("NewDocumentDialog", () => {
|
|
109
|
+
it("writes a dashboard with the picked view as its first tile and hands back where it went", async () => {
|
|
110
|
+
const write = mock((_path: string, _source: string) => Promise.resolve());
|
|
111
|
+
const onCreated = mock((_created: unknown) => {});
|
|
112
|
+
const onEvent = mock((_event: unknown) => {});
|
|
113
|
+
mount({ target: packageTarget([], write), onCreated, onEvent });
|
|
114
|
+
await titleFilled("by category");
|
|
115
|
+
|
|
116
|
+
// A source with no views is not on the list, so a pair that cannot be written cannot be picked.
|
|
117
|
+
fireEvent.mouseDown(screen.getByRole("combobox", { name: /First tile/ }));
|
|
118
|
+
expect(
|
|
119
|
+
screen.getAllByRole("option").map((option) => option.textContent),
|
|
120
|
+
).toEqual(["order_items → by_category", "order_items → by_brand"]);
|
|
121
|
+
fireEvent.click(
|
|
122
|
+
screen.getByRole("option", { name: "order_items → by_brand" }),
|
|
123
|
+
);
|
|
124
|
+
fireEvent.change(screen.getByLabelText("Dashboard title"), {
|
|
125
|
+
target: { value: "Sales by Region" },
|
|
126
|
+
});
|
|
127
|
+
expect(
|
|
128
|
+
screen.getByText(/Written as dashboards\/sales-by-region\.malloy/),
|
|
129
|
+
).toBeDefined();
|
|
130
|
+
|
|
131
|
+
fireEvent.click(screen.getByRole("button", { name: "Create dashboard" }));
|
|
132
|
+
await waitFor(() => expect(onCreated).toHaveBeenCalledTimes(1));
|
|
133
|
+
expect(onCreated.mock.calls[0][0]).toEqual({
|
|
134
|
+
kind: "dashboard",
|
|
135
|
+
path: "dashboards/sales-by-region.malloy",
|
|
136
|
+
slug: "sales-by-region",
|
|
137
|
+
});
|
|
138
|
+
const [path, source] = write.mock.calls[0];
|
|
139
|
+
expect(path).toBe("dashboards/sales-by-region.malloy");
|
|
140
|
+
expect(source).toContain('tiles=["order_items_tiles -> by_brand_tile"]');
|
|
141
|
+
expect(source).toContain(
|
|
142
|
+
'import { order_items } from "../storefront.malloy"',
|
|
143
|
+
);
|
|
144
|
+
expect(onEvent.mock.calls).toEqual([
|
|
145
|
+
[{ type: "dashboard.created", where: "package" }],
|
|
146
|
+
]);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("writes a notebook under notebooks/ with its first query", async () => {
|
|
150
|
+
const write = mock((_path: string, _source: string) => Promise.resolve());
|
|
151
|
+
const onCreated = mock((_created: unknown) => {});
|
|
152
|
+
mount({
|
|
153
|
+
kind: "notebook",
|
|
154
|
+
target: packageTarget([], write),
|
|
155
|
+
onCreated,
|
|
156
|
+
});
|
|
157
|
+
await titleFilled("by category", "Notebook title");
|
|
158
|
+
expect(
|
|
159
|
+
screen.getByRole("combobox", { name: /First query/ }),
|
|
160
|
+
).toBeDefined();
|
|
161
|
+
|
|
162
|
+
fireEvent.click(screen.getByRole("button", { name: "Create notebook" }));
|
|
163
|
+
await waitFor(() => expect(onCreated).toHaveBeenCalledTimes(1));
|
|
164
|
+
expect(onCreated.mock.calls[0][0]).toEqual({
|
|
165
|
+
kind: "notebook",
|
|
166
|
+
path: "notebooks/by-category.malloy",
|
|
167
|
+
slug: "by-category",
|
|
168
|
+
});
|
|
169
|
+
const [path, source] = write.mock.calls[0];
|
|
170
|
+
expect(path).toBe("notebooks/by-category.malloy");
|
|
171
|
+
expect(source).toContain("kind=notebook");
|
|
172
|
+
expect(source).toContain("view: by_category_tile is by_category");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("switches kind in place, keeping the choices already read", async () => {
|
|
176
|
+
mount();
|
|
177
|
+
await titleFilled("by category");
|
|
178
|
+
fireEvent.mouseDown(screen.getByRole("combobox", { name: /Type/ }));
|
|
179
|
+
fireEvent.click(screen.getByRole("option", { name: "Notebook" }));
|
|
180
|
+
expect(
|
|
181
|
+
screen.getByRole("button", { name: "Create notebook" }),
|
|
182
|
+
).toBeDefined();
|
|
183
|
+
expect(screen.getByLabelText("Notebook title")).toBeDefined();
|
|
184
|
+
expect(getModel).toHaveBeenCalledTimes(2);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("takes the next free name when the package already has the title's file", async () => {
|
|
188
|
+
const write = mock((_path: string, _source: string) => Promise.resolve());
|
|
189
|
+
mount({
|
|
190
|
+
target: packageTarget(
|
|
191
|
+
["dashboards/overview.malloy", "dashboards/overview-2.malloy"],
|
|
192
|
+
write,
|
|
193
|
+
),
|
|
194
|
+
});
|
|
195
|
+
await titleFilled("by category");
|
|
196
|
+
fireEvent.change(screen.getByLabelText("Dashboard title"), {
|
|
197
|
+
target: { value: "Overview" },
|
|
198
|
+
});
|
|
199
|
+
expect(
|
|
200
|
+
screen.getByText(/Written as dashboards\/overview-3\.malloy/),
|
|
201
|
+
).toBeDefined();
|
|
202
|
+
fireEvent.click(screen.getByRole("button", { name: "Create dashboard" }));
|
|
203
|
+
await waitFor(() => expect(write).toHaveBeenCalledTimes(1));
|
|
204
|
+
expect(write.mock.calls[0][0]).toBe("dashboards/overview-3.malloy");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("does not offer a notebook name a dashboard already took, and the reverse", async () => {
|
|
208
|
+
mount({
|
|
209
|
+
kind: "notebook",
|
|
210
|
+
target: packageTarget(["dashboards/by-category.malloy"]),
|
|
211
|
+
});
|
|
212
|
+
await titleFilled("by category", "Notebook title");
|
|
213
|
+
expect(
|
|
214
|
+
screen.getByText(/Written as notebooks\/by-category\.malloy/),
|
|
215
|
+
).toBeDefined();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("shows what a failed write said and stays open", async () => {
|
|
219
|
+
const onCreated = mock((_created: unknown) => {});
|
|
220
|
+
mount({
|
|
221
|
+
target: packageTarget([], () =>
|
|
222
|
+
Promise.reject(
|
|
223
|
+
Object.assign(new Error("x"), {
|
|
224
|
+
response: { data: { message: "File already exists" } },
|
|
225
|
+
}),
|
|
226
|
+
),
|
|
227
|
+
),
|
|
228
|
+
onCreated,
|
|
229
|
+
});
|
|
230
|
+
await titleFilled("by category");
|
|
231
|
+
fireEvent.click(screen.getByRole("button", { name: "Create dashboard" }));
|
|
232
|
+
expect(await screen.findByText("File already exists")).toBeDefined();
|
|
233
|
+
expect(onCreated).not.toHaveBeenCalled();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("offers only the sources a model exports, not the ones it imports", async () => {
|
|
237
|
+
mount({ models: ["mid.malloy"] });
|
|
238
|
+
await titleFilled("overview");
|
|
239
|
+
fireEvent.mouseDown(screen.getByRole("combobox", { name: /First tile/ }));
|
|
240
|
+
expect(
|
|
241
|
+
screen.getAllByRole("option").map((option) => option.textContent),
|
|
242
|
+
).toEqual(["mid_src → overview"]);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("offers nothing from a model whose exports are not stated", async () => {
|
|
246
|
+
MODELS["bare.malloy"] = {
|
|
247
|
+
modelPath: "bare.malloy",
|
|
248
|
+
sources: [{ name: "s", views: [{ name: "v" }] }],
|
|
249
|
+
};
|
|
250
|
+
mount({ models: ["bare.malloy"] });
|
|
251
|
+
expect(
|
|
252
|
+
await screen.findByText(/no model in this package declares one yet/),
|
|
253
|
+
).toBeDefined();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it("says what to do when the package has no models", () => {
|
|
257
|
+
mount({ models: [] });
|
|
258
|
+
expect(screen.getByText(/This package has no models yet/)).toBeDefined();
|
|
259
|
+
expect(getModel).not.toHaveBeenCalled();
|
|
260
|
+
expect(
|
|
261
|
+
screen
|
|
262
|
+
.getByRole("button", {
|
|
263
|
+
name: "Create dashboard: No model view to start from yet",
|
|
264
|
+
})
|
|
265
|
+
.hasAttribute("disabled"),
|
|
266
|
+
).toBe(true);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("says what to do when no model declares a view", async () => {
|
|
270
|
+
mount({ models: ["other.malloy"] });
|
|
271
|
+
expect(
|
|
272
|
+
await screen.findByText(/no model in this package declares one yet/),
|
|
273
|
+
).toBeDefined();
|
|
274
|
+
expect(screen.getByText(/Add a view to a source/)).toBeDefined();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe("requests", () => {
|
|
278
|
+
it("reads nothing until it is opened, then one model each under its own key", async () => {
|
|
279
|
+
const view = mount({ open: false });
|
|
280
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
281
|
+
expect(getModel).not.toHaveBeenCalled();
|
|
282
|
+
|
|
283
|
+
view.rerender(
|
|
284
|
+
<NewDocumentDialog
|
|
285
|
+
open
|
|
286
|
+
kind="dashboard"
|
|
287
|
+
environmentName="env"
|
|
288
|
+
packageName="pkg"
|
|
289
|
+
models={["storefront.malloy", "other.malloy"]}
|
|
290
|
+
target={packageTarget()}
|
|
291
|
+
onClose={() => {}}
|
|
292
|
+
onCreated={() => {}}
|
|
293
|
+
/>,
|
|
294
|
+
);
|
|
295
|
+
await titleFilled("by category");
|
|
296
|
+
expect(getModel).toHaveBeenCalledTimes(2);
|
|
297
|
+
expect(cacheKeys("new-document-model")).toEqual([
|
|
298
|
+
`["new-document-model","env","pkg",null,"storefront.malloy","${TEST_SERVER}"]`,
|
|
299
|
+
`["new-document-model","env","pkg",null,"other.malloy","${TEST_SERVER}"]`,
|
|
300
|
+
]);
|
|
301
|
+
|
|
302
|
+
// Closing and reopening reads the cache, not the server.
|
|
303
|
+
view.rerender(
|
|
304
|
+
<NewDocumentDialog
|
|
305
|
+
open={false}
|
|
306
|
+
kind="dashboard"
|
|
307
|
+
environmentName="env"
|
|
308
|
+
packageName="pkg"
|
|
309
|
+
models={["storefront.malloy", "other.malloy"]}
|
|
310
|
+
target={packageTarget()}
|
|
311
|
+
onClose={() => {}}
|
|
312
|
+
onCreated={() => {}}
|
|
313
|
+
/>,
|
|
314
|
+
);
|
|
315
|
+
view.rerender(
|
|
316
|
+
<NewDocumentDialog
|
|
317
|
+
open
|
|
318
|
+
kind="notebook"
|
|
319
|
+
environmentName="env"
|
|
320
|
+
packageName="pkg"
|
|
321
|
+
models={["storefront.malloy", "other.malloy"]}
|
|
322
|
+
target={packageTarget()}
|
|
323
|
+
onClose={() => {}}
|
|
324
|
+
onCreated={() => {}}
|
|
325
|
+
/>,
|
|
326
|
+
);
|
|
327
|
+
await titleFilled("by category", "Notebook title");
|
|
328
|
+
expect(getModel).toHaveBeenCalledTimes(2);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
describe("on the storage route", () => {
|
|
333
|
+
const WORKSPACE: Workspace = {
|
|
334
|
+
name: "record",
|
|
335
|
+
writeable: true,
|
|
336
|
+
description: "The record",
|
|
337
|
+
authoritative: true,
|
|
338
|
+
};
|
|
339
|
+
const saved: string[] = [];
|
|
340
|
+
const storage: DocumentStorage = {
|
|
341
|
+
listWorkspaces: async () => [WORKSPACE],
|
|
342
|
+
// A stale listing: it does not know about the file the store has.
|
|
343
|
+
listDocuments: async () => [],
|
|
344
|
+
getDocument: async (locator: DocumentLocator) => {
|
|
345
|
+
if (locator.path === "env/pkg/notebooks/overview.malloy")
|
|
346
|
+
return "someone else's";
|
|
347
|
+
throw new DocumentNotFoundError("absent");
|
|
348
|
+
},
|
|
349
|
+
saveDocument: async (locator: DocumentLocator) => {
|
|
350
|
+
saved.push(locator.path);
|
|
351
|
+
},
|
|
352
|
+
deleteDocument: async () => {},
|
|
353
|
+
moveDocument: async () => {},
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
it("saves into the store under a name the store does not have", async () => {
|
|
357
|
+
saved.length = 0;
|
|
358
|
+
const onCreated = mock((_created: unknown) => {});
|
|
359
|
+
mount({
|
|
360
|
+
kind: "notebook",
|
|
361
|
+
target: {
|
|
362
|
+
route: "storage",
|
|
363
|
+
storage,
|
|
364
|
+
workspace: WORKSPACE,
|
|
365
|
+
environmentName: "env",
|
|
366
|
+
packageName: "pkg",
|
|
367
|
+
},
|
|
368
|
+
onCreated,
|
|
369
|
+
});
|
|
370
|
+
await titleFilled("by category", "Notebook title");
|
|
371
|
+
fireEvent.change(screen.getByLabelText("Notebook title"), {
|
|
372
|
+
target: { value: "Overview" },
|
|
373
|
+
});
|
|
374
|
+
fireEvent.click(
|
|
375
|
+
screen.getByRole("button", { name: "Create notebook" }),
|
|
376
|
+
);
|
|
377
|
+
await waitFor(() => expect(onCreated).toHaveBeenCalledTimes(1));
|
|
378
|
+
expect(saved).toEqual(["env/pkg/notebooks/overview-2.malloy"]);
|
|
379
|
+
expect(onCreated.mock.calls[0][0]).toMatchObject({
|
|
380
|
+
slug: "overview-2",
|
|
381
|
+
locator: { workspace: "record", type: "notebook" },
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
describe("NewDocumentDialog: what a model read is cached under", () => {
|
|
388
|
+
it("reads each model at the package's version, under a key that names the version and the server", async () => {
|
|
389
|
+
mount({ versionId: "v3" });
|
|
390
|
+
await titleFilled("by category");
|
|
391
|
+
expect(getModel.mock.calls[0]).toEqual([
|
|
392
|
+
"env",
|
|
393
|
+
"pkg",
|
|
394
|
+
"storefront.malloy",
|
|
395
|
+
"v3",
|
|
396
|
+
]);
|
|
397
|
+
const [key] = cacheKeys("new-document-model");
|
|
398
|
+
expect(key).toContain('"v3"');
|
|
399
|
+
expect(key).toContain(TEST_SERVER);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
describe("NewDocumentDialog: a model it could not read", () => {
|
|
404
|
+
it("names it, keeps the rest, and offers a retry that brings its views back", async () => {
|
|
405
|
+
let healthy = false;
|
|
406
|
+
getModel.mockImplementation((env, pkg, path, versionId) =>
|
|
407
|
+
path === "storefront.malloy" && !healthy
|
|
408
|
+
? failing(503)
|
|
409
|
+
: serve(env, pkg, path, versionId),
|
|
410
|
+
);
|
|
411
|
+
mount();
|
|
412
|
+
expect(
|
|
413
|
+
await screen.findByText(
|
|
414
|
+
"Couldn't read storefront.malloy, so its views aren't listed.",
|
|
415
|
+
),
|
|
416
|
+
).toBeDefined();
|
|
417
|
+
expect(
|
|
418
|
+
screen.queryByText(/no model in this package declares/),
|
|
419
|
+
).toBeNull();
|
|
420
|
+
expect(
|
|
421
|
+
isDisabled(
|
|
422
|
+
createButton(
|
|
423
|
+
"Create dashboard: Couldn't read the model views to start from",
|
|
424
|
+
),
|
|
425
|
+
),
|
|
426
|
+
).toBe(true);
|
|
427
|
+
|
|
428
|
+
healthy = true;
|
|
429
|
+
fireEvent.click(screen.getByRole("button", { name: "Retry" }));
|
|
430
|
+
await titleFilled("by category");
|
|
431
|
+
expect(screen.queryByText(/Couldn't read storefront\.malloy/)).toBeNull();
|
|
432
|
+
expect(isDisabled(createButton("Create dashboard"))).toBe(false);
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it("names every model it could not read", async () => {
|
|
436
|
+
getModel.mockImplementation(() => failing(500));
|
|
437
|
+
mount();
|
|
438
|
+
expect(
|
|
439
|
+
await screen.findByText(
|
|
440
|
+
"Couldn't read storefront.malloy, other.malloy, so their views aren't listed.",
|
|
441
|
+
),
|
|
442
|
+
).toBeDefined();
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it("lets Create through when another model still offers a view", async () => {
|
|
446
|
+
getModel.mockImplementation((env, pkg, path, versionId) =>
|
|
447
|
+
path === "other.malloy"
|
|
448
|
+
? failing(500)
|
|
449
|
+
: serve(env, pkg, path, versionId),
|
|
450
|
+
);
|
|
451
|
+
mount();
|
|
452
|
+
await titleFilled("by category");
|
|
453
|
+
expect(
|
|
454
|
+
await screen.findByText(
|
|
455
|
+
"Couldn't read other.malloy, so its views aren't listed.",
|
|
456
|
+
),
|
|
457
|
+
).toBeDefined();
|
|
458
|
+
expect(isDisabled(createButton("Create dashboard"))).toBe(false);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
for (const [status, retry] of [
|
|
462
|
+
[401, false],
|
|
463
|
+
[403, false],
|
|
464
|
+
[404, false],
|
|
465
|
+
[500, true],
|
|
466
|
+
[503, true],
|
|
467
|
+
[undefined, true],
|
|
468
|
+
] as const)
|
|
469
|
+
it(`${retry ? "offers" : "offers no"} Retry after ${status ?? "no response"}`, async () => {
|
|
470
|
+
getModel.mockImplementation(() => failing(status));
|
|
471
|
+
mount({ models: ["storefront.malloy"] });
|
|
472
|
+
await screen.findByText(/Couldn't read storefront\.malloy/);
|
|
473
|
+
expect(screen.queryByRole("button", { name: "Retry" }) !== null).toBe(
|
|
474
|
+
retry,
|
|
475
|
+
);
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
describe("NewDocumentDialog: why Create is off", () => {
|
|
480
|
+
it("while the views load, in its name and its tooltip", async () => {
|
|
481
|
+
getModel.mockImplementation(() => pending());
|
|
482
|
+
mount();
|
|
483
|
+
const button = createButton("Create dashboard: Loading model views");
|
|
484
|
+
expect(isDisabled(button)).toBe(true);
|
|
485
|
+
fireEvent.mouseOver(button.parentElement!);
|
|
486
|
+
expect((await screen.findByRole("tooltip")).textContent).toBe(
|
|
487
|
+
"Loading model views",
|
|
488
|
+
);
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
it("while the host still lists the models, not that the package has none", () => {
|
|
492
|
+
mount({ models: [], modelsLoading: true });
|
|
493
|
+
expect(screen.queryByText(/This package has no models yet/)).toBeNull();
|
|
494
|
+
expect(
|
|
495
|
+
isDisabled(createButton("Create dashboard: Loading model views")),
|
|
496
|
+
).toBe(true);
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
it("when the host could not list the models, with its Retry", () => {
|
|
500
|
+
const onRetryModels = mock(() => {});
|
|
501
|
+
mount({
|
|
502
|
+
models: [],
|
|
503
|
+
modelsError: Object.assign(new Error("x"), {
|
|
504
|
+
response: { status: 502 },
|
|
505
|
+
}),
|
|
506
|
+
onRetryModels,
|
|
507
|
+
});
|
|
508
|
+
expect(screen.queryByText(/This package has no models yet/)).toBeNull();
|
|
509
|
+
expect(
|
|
510
|
+
screen.getByText(/Couldn't read this package's models/),
|
|
511
|
+
).toBeDefined();
|
|
512
|
+
expect(
|
|
513
|
+
isDisabled(
|
|
514
|
+
createButton(
|
|
515
|
+
"Create dashboard: Couldn't read the model views to start from",
|
|
516
|
+
),
|
|
517
|
+
),
|
|
518
|
+
).toBe(true);
|
|
519
|
+
fireEvent.click(screen.getByRole("button", { name: "Retry" }));
|
|
520
|
+
expect(onRetryModels).toHaveBeenCalledTimes(1);
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
it("offers no Retry for a models listing a retry cannot fix", () => {
|
|
524
|
+
mount({
|
|
525
|
+
models: [],
|
|
526
|
+
modelsError: { status: 403 },
|
|
527
|
+
onRetryModels: () => {},
|
|
528
|
+
});
|
|
529
|
+
expect(
|
|
530
|
+
screen.getByText(/Couldn't read this package's models/),
|
|
531
|
+
).toBeDefined();
|
|
532
|
+
expect(screen.queryByRole("button", { name: "Retry" })).toBeNull();
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
it("when every model failed to read", async () => {
|
|
536
|
+
getModel.mockImplementation(() => failing(500));
|
|
537
|
+
mount();
|
|
538
|
+
await screen.findByText(/Couldn't read storefront\.malloy/);
|
|
539
|
+
expect(
|
|
540
|
+
isDisabled(
|
|
541
|
+
createButton(
|
|
542
|
+
"Create dashboard: Couldn't read the model views to start from",
|
|
543
|
+
),
|
|
544
|
+
),
|
|
545
|
+
).toBe(true);
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
it("when no model has a view", async () => {
|
|
549
|
+
mount({ models: ["other.malloy"] });
|
|
550
|
+
await screen.findByText(/no model in this package declares one yet/);
|
|
551
|
+
expect(
|
|
552
|
+
isDisabled(
|
|
553
|
+
createButton("Create dashboard: No model view to start from yet"),
|
|
554
|
+
),
|
|
555
|
+
).toBe(true);
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
it("not for a blank title, whose problem it shows on press", async () => {
|
|
559
|
+
const write = mock((_path: string, _source: string) => Promise.resolve());
|
|
560
|
+
mount({ target: packageTarget([], write) });
|
|
561
|
+
await titleFilled("by category");
|
|
562
|
+
fireEvent.change(screen.getByLabelText("Dashboard title"), {
|
|
563
|
+
target: { value: " " },
|
|
564
|
+
});
|
|
565
|
+
expect(screen.queryByText("A title cannot be empty.")).toBeNull();
|
|
566
|
+
const button = createButton("Create dashboard");
|
|
567
|
+
expect(isDisabled(button)).toBe(false);
|
|
568
|
+
fireEvent.click(button);
|
|
569
|
+
expect(screen.getByText("A title cannot be empty.")).toBeDefined();
|
|
570
|
+
expect(
|
|
571
|
+
screen.getByLabelText("Dashboard title").getAttribute("aria-invalid"),
|
|
572
|
+
).toBe("true");
|
|
573
|
+
expect(write).not.toHaveBeenCalled();
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it("not for a title that cannot be written, whose problem shows as it is typed", async () => {
|
|
577
|
+
mount({ kind: "notebook" });
|
|
578
|
+
await titleFilled("by category", "Notebook title");
|
|
579
|
+
fireEvent.change(screen.getByLabelText("Notebook title"), {
|
|
580
|
+
target: { value: "a |## b" },
|
|
581
|
+
});
|
|
582
|
+
expect(screen.getByText(/A title cannot contain `\|##`/)).toBeDefined();
|
|
583
|
+
expect(isDisabled(createButton("Create notebook"))).toBe(false);
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
describe("NewDocumentDialog: the picked view", () => {
|
|
588
|
+
const base = MODELS["storefront.malloy"] as Record<string, unknown>;
|
|
589
|
+
const versions: Record<string, unknown> = {
|
|
590
|
+
reordered: {
|
|
591
|
+
...base,
|
|
592
|
+
sources: [
|
|
593
|
+
{
|
|
594
|
+
name: "order_items",
|
|
595
|
+
views: [{ name: "by_brand" }, { name: "by_category" }],
|
|
596
|
+
},
|
|
597
|
+
],
|
|
598
|
+
},
|
|
599
|
+
dropped: {
|
|
600
|
+
...base,
|
|
601
|
+
sources: [{ name: "order_items", views: [{ name: "by_category" }] }],
|
|
602
|
+
},
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
const reread = (view: ReturnType<typeof mount>, versionId: string) =>
|
|
606
|
+
view.rerender(
|
|
607
|
+
<NewDocumentDialog
|
|
608
|
+
open
|
|
609
|
+
kind="dashboard"
|
|
610
|
+
environmentName="env"
|
|
611
|
+
packageName="pkg"
|
|
612
|
+
versionId={versionId}
|
|
613
|
+
models={["storefront.malloy"]}
|
|
614
|
+
target={packageTarget()}
|
|
615
|
+
onClose={() => {}}
|
|
616
|
+
onCreated={() => {}}
|
|
617
|
+
/>,
|
|
618
|
+
);
|
|
619
|
+
|
|
620
|
+
const firstTile = () => screen.getByRole("combobox", { name: /First tile/ });
|
|
621
|
+
|
|
622
|
+
const pickBrand = async () => {
|
|
623
|
+
await titleFilled("by category");
|
|
624
|
+
fireEvent.mouseDown(firstTile());
|
|
625
|
+
fireEvent.click(
|
|
626
|
+
screen.getByRole("option", { name: "order_items → by_brand" }),
|
|
627
|
+
);
|
|
628
|
+
expect(firstTile().textContent).toBe("order_items → by_brand");
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
beforeEach(() => {
|
|
632
|
+
getModel.mockImplementation((env, pkg, path, versionId) =>
|
|
633
|
+
versionId !== undefined && versions[versionId] !== undefined
|
|
634
|
+
? Promise.resolve({ data: versions[versionId] })
|
|
635
|
+
: serve(env, pkg, path, versionId),
|
|
636
|
+
);
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
it("stays picked when the views are read again in another order", async () => {
|
|
640
|
+
const view = mount({ models: ["storefront.malloy"], versionId: "first" });
|
|
641
|
+
await pickBrand();
|
|
642
|
+
reread(view, "reordered");
|
|
643
|
+
await waitFor(() => expect(getModel).toHaveBeenCalledTimes(2));
|
|
644
|
+
await waitFor(() =>
|
|
645
|
+
expect(firstTile().textContent).toBe("order_items → by_brand"),
|
|
646
|
+
);
|
|
647
|
+
expect(isDisabled(createButton("Create dashboard"))).toBe(false);
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
it("is not swapped for another when it leaves the list", async () => {
|
|
651
|
+
const view = mount({ models: ["storefront.malloy"], versionId: "first" });
|
|
652
|
+
await pickBrand();
|
|
653
|
+
reread(view, "dropped");
|
|
654
|
+
expect(
|
|
655
|
+
await screen.findByText(
|
|
656
|
+
"The view you picked is no longer in this model; pick another.",
|
|
657
|
+
),
|
|
658
|
+
).toBeDefined();
|
|
659
|
+
expect(firstTile().textContent).not.toContain("by_category");
|
|
660
|
+
expect(
|
|
661
|
+
isDisabled(
|
|
662
|
+
createButton("Create dashboard: Pick a view to start from"),
|
|
663
|
+
),
|
|
664
|
+
).toBe(true);
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
describe("NewDocumentDialog: while it creates", () => {
|
|
669
|
+
it("says so, and neither Cancel, Escape nor the backdrop closes it", async () => {
|
|
670
|
+
let finish: () => void = () => {};
|
|
671
|
+
const write = mock(
|
|
672
|
+
(_path: string, _source: string) =>
|
|
673
|
+
new Promise<void>((resolve) => {
|
|
674
|
+
finish = resolve;
|
|
675
|
+
}),
|
|
676
|
+
);
|
|
677
|
+
const onClose = mock(() => {});
|
|
678
|
+
const onCreated = mock((_created: unknown) => {});
|
|
679
|
+
mount({ target: packageTarget([], write), onClose, onCreated });
|
|
680
|
+
await titleFilled("by category");
|
|
681
|
+
fireEvent.click(createButton("Create dashboard"));
|
|
682
|
+
|
|
683
|
+
const creating = await screen.findByRole("button", {
|
|
684
|
+
name: "Creating dashboard…",
|
|
685
|
+
});
|
|
686
|
+
expect(isDisabled(creating)).toBe(true);
|
|
687
|
+
expect(isDisabled(screen.getByRole("button", { name: "Cancel" }))).toBe(
|
|
688
|
+
true,
|
|
689
|
+
);
|
|
690
|
+
fireEvent.keyDown(screen.getByRole("dialog"), { key: "Escape" });
|
|
691
|
+
fireEvent.click(document.querySelector(".MuiBackdrop-root")!);
|
|
692
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
693
|
+
|
|
694
|
+
finish();
|
|
695
|
+
await waitFor(() => expect(onCreated).toHaveBeenCalledTimes(1));
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
it("names the notebook kind while it creates one", async () => {
|
|
699
|
+
mount({ kind: "notebook", target: packageTarget([], () => pending()) });
|
|
700
|
+
await titleFilled("by category", "Notebook title");
|
|
701
|
+
fireEvent.click(createButton("Create notebook"));
|
|
702
|
+
expect(
|
|
703
|
+
await screen.findByRole("button", { name: "Creating notebook…" }),
|
|
704
|
+
).toBeDefined();
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
describe("NewDocumentDialog: what the host decides", () => {
|
|
709
|
+
it("closes from Cancel and from Escape", async () => {
|
|
710
|
+
const onClose = mock(() => {});
|
|
711
|
+
mount({ onClose });
|
|
712
|
+
await titleFilled("by category");
|
|
713
|
+
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
|
|
714
|
+
fireEvent.keyDown(screen.getByRole("dialog"), { key: "Escape" });
|
|
715
|
+
expect(onClose).toHaveBeenCalledTimes(2);
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
it("offers no kind to switch to when allowKindChange is false", async () => {
|
|
719
|
+
mount({ kind: "notebook", allowKindChange: false });
|
|
720
|
+
await titleFilled("by category", "Notebook title");
|
|
721
|
+
expect(screen.queryByRole("combobox", { name: /Type/ })).toBeNull();
|
|
722
|
+
expect(createButton("Create notebook")).toBeDefined();
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
it("says where the host saves it, in the host's words", async () => {
|
|
726
|
+
mount({
|
|
727
|
+
target: {
|
|
728
|
+
route: "storage",
|
|
729
|
+
storage: {} as DocumentStorage,
|
|
730
|
+
workspace: {
|
|
731
|
+
name: "w",
|
|
732
|
+
writeable: true,
|
|
733
|
+
description: "",
|
|
734
|
+
authoritative: true,
|
|
735
|
+
},
|
|
736
|
+
environmentName: "env",
|
|
737
|
+
packageName: "pkg",
|
|
738
|
+
existing: [],
|
|
739
|
+
},
|
|
740
|
+
savedAs: "Saved to your workspace, and opened in the builder.",
|
|
741
|
+
});
|
|
742
|
+
await titleFilled("by category");
|
|
743
|
+
expect(
|
|
744
|
+
screen.getByText(
|
|
745
|
+
"Saved to your workspace, and opened in the builder.",
|
|
746
|
+
),
|
|
747
|
+
).toBeDefined();
|
|
748
|
+
});
|
|
749
|
+
});
|