@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,310 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
cleanup,
|
|
6
|
+
fireEvent,
|
|
7
|
+
render,
|
|
8
|
+
screen,
|
|
9
|
+
waitFor,
|
|
10
|
+
} from "@testing-library/react";
|
|
11
|
+
import { beforeEach, describe, expect, it, mock } from "bun:test";
|
|
12
|
+
import * as fs from "fs";
|
|
13
|
+
import * as path from "path";
|
|
14
|
+
import {
|
|
15
|
+
clearCache,
|
|
16
|
+
mockServerProvider,
|
|
17
|
+
pending,
|
|
18
|
+
serverWrapper,
|
|
19
|
+
} from "../../../test/serverProvider";
|
|
20
|
+
import { sha256Hex } from "../../utils/sha256";
|
|
21
|
+
import {
|
|
22
|
+
DocumentNotFoundError,
|
|
23
|
+
type DocumentLocator,
|
|
24
|
+
type DocumentStorage,
|
|
25
|
+
type DocumentType,
|
|
26
|
+
type Workspace,
|
|
27
|
+
} from "../DocumentStorage";
|
|
28
|
+
import { DocumentStorageProvider } from "../DocumentStorage/DocumentStorageProvider";
|
|
29
|
+
import type { BuilderEvent } from "./telemetry";
|
|
30
|
+
import { editInline } from "./testing/inline";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The one editor opened as a notebook: how it reads the file, where it takes
|
|
34
|
+
* the manifest from, and what it does with a notebook in the cell format.
|
|
35
|
+
*/
|
|
36
|
+
const REPO = path.resolve(import.meta.dir, "../../../../..");
|
|
37
|
+
const LEGACY = fs
|
|
38
|
+
.readFileSync(
|
|
39
|
+
path.join(REPO, "examples/storefront/notebooks/category-review.malloy"),
|
|
40
|
+
"utf8",
|
|
41
|
+
)
|
|
42
|
+
.replace(/\r\n/g, "\n");
|
|
43
|
+
|
|
44
|
+
const LAYOUT = `## artifact { kind=notebook title="Tour" tiles=[intro { kind=text }] }
|
|
45
|
+
|
|
46
|
+
##|(markdown) intro
|
|
47
|
+
Hello.
|
|
48
|
+
|##
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const REFUSED = `## artifact { kind=notebook }
|
|
52
|
+
import { orders } from "../m.malloy"
|
|
53
|
+
|
|
54
|
+
run: orders extend { dimension: z is 1 } -> { select: z }
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
let served = LAYOUT;
|
|
58
|
+
let servedHash = await sha256Hex(LAYOUT);
|
|
59
|
+
let writes: string[] = [];
|
|
60
|
+
|
|
61
|
+
const getModel = mock(
|
|
62
|
+
async (
|
|
63
|
+
_env: string,
|
|
64
|
+
_pkg: string,
|
|
65
|
+
modelPath: string,
|
|
66
|
+
_versionId?: string,
|
|
67
|
+
_authoring?: boolean,
|
|
68
|
+
) => ({
|
|
69
|
+
data: {
|
|
70
|
+
modelPath,
|
|
71
|
+
sourceText: modelPath.endsWith("tour.malloy") ? served : served,
|
|
72
|
+
givens: [{ name: "FROM_MODEL", type: "string" }],
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
const getNotebook = mock(
|
|
77
|
+
async (_env: string, _pkg: string, modelPath: string) => ({
|
|
78
|
+
data: served.includes("tiles=")
|
|
79
|
+
? {
|
|
80
|
+
dashboard: {
|
|
81
|
+
path: modelPath,
|
|
82
|
+
kind: "notebook",
|
|
83
|
+
givens: [{ name: "FROM_MANIFEST", type: "string" }],
|
|
84
|
+
tiles: [],
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
: {},
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
const getDashboard = mock(() => pending());
|
|
91
|
+
const listModels = mock(async () => ({ data: [] }));
|
|
92
|
+
const executeQueryModel = mock(() => pending());
|
|
93
|
+
const updateModelSource = mock(
|
|
94
|
+
async (
|
|
95
|
+
_env: string,
|
|
96
|
+
_pkg: string,
|
|
97
|
+
modelPath: string,
|
|
98
|
+
body: { source: string; expectedHash?: string },
|
|
99
|
+
) => {
|
|
100
|
+
if (body.expectedHash !== servedHash)
|
|
101
|
+
throw { response: { status: 409, data: { message: "changed" } } };
|
|
102
|
+
served = body.source;
|
|
103
|
+
writes.push(body.source);
|
|
104
|
+
servedHash = `hash-${writes.length}`;
|
|
105
|
+
return { data: { path: modelPath, contentHash: servedHash } };
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const serverContext: {
|
|
110
|
+
mutable: boolean | undefined;
|
|
111
|
+
isLoadingStatus: boolean;
|
|
112
|
+
} = { mutable: true, isLoadingStatus: false };
|
|
113
|
+
mockServerProvider(
|
|
114
|
+
{
|
|
115
|
+
models: { getModel, listModels, executeQueryModel, updateModelSource },
|
|
116
|
+
notebooks: { getNotebook },
|
|
117
|
+
dashboards: {
|
|
118
|
+
getDashboard,
|
|
119
|
+
listDashboards: mock(async () => ({ data: [] })),
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
serverContext,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const { DashboardEditor } = await import("./DashboardEditor");
|
|
126
|
+
const { NotebookEditor } = await import("./NotebookEditor");
|
|
127
|
+
|
|
128
|
+
const button = (name: string | RegExp) =>
|
|
129
|
+
screen.getByRole("button", { name, hidden: true });
|
|
130
|
+
|
|
131
|
+
const mount = (
|
|
132
|
+
props: Partial<Parameters<typeof DashboardEditor>[0]> & {
|
|
133
|
+
dashboardName?: string;
|
|
134
|
+
} = {},
|
|
135
|
+
onEvent?: (event: BuilderEvent) => void,
|
|
136
|
+
) =>
|
|
137
|
+
render(
|
|
138
|
+
<DashboardEditor
|
|
139
|
+
kind="notebook"
|
|
140
|
+
environmentName="env"
|
|
141
|
+
packageName="pkg"
|
|
142
|
+
dashboardName="tour"
|
|
143
|
+
{...(onEvent ? { onEvent } : {})}
|
|
144
|
+
{...(props as object)}
|
|
145
|
+
/>,
|
|
146
|
+
{ wrapper: serverWrapper },
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
beforeEach(async () => {
|
|
150
|
+
cleanup();
|
|
151
|
+
clearCache();
|
|
152
|
+
localStorage.clear();
|
|
153
|
+
served = LAYOUT;
|
|
154
|
+
servedHash = await sha256Hex(LAYOUT);
|
|
155
|
+
writes = [];
|
|
156
|
+
serverContext.mutable = true;
|
|
157
|
+
getModel.mockClear();
|
|
158
|
+
getNotebook.mockClear();
|
|
159
|
+
getDashboard.mockClear();
|
|
160
|
+
updateModelSource.mockClear();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("DashboardEditor as a notebook", () => {
|
|
164
|
+
it("reads the file with the authoring flag, and the manifest from the notebook read", async () => {
|
|
165
|
+
const onEvent = mock((_event: BuilderEvent) => {});
|
|
166
|
+
mount({}, onEvent);
|
|
167
|
+
expect(await screen.findByText("Tour")).toBeDefined();
|
|
168
|
+
expect(getModel.mock.calls[0].slice(0, 3)).toEqual([
|
|
169
|
+
"env",
|
|
170
|
+
"pkg",
|
|
171
|
+
"notebooks/tour.malloy",
|
|
172
|
+
]);
|
|
173
|
+
expect(getModel.mock.calls[0][4]).toBe(true);
|
|
174
|
+
await waitFor(() => expect(getNotebook).toHaveBeenCalled());
|
|
175
|
+
expect(getDashboard).not.toHaveBeenCalled();
|
|
176
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
177
|
+
type: "notebook.opened",
|
|
178
|
+
from: "package",
|
|
179
|
+
cells: 1,
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("opens the file where the host says it is, not where its kind would put it", async () => {
|
|
184
|
+
mount({ path: "dashboards/tour.malloy" });
|
|
185
|
+
expect(await screen.findByText("Tour")).toBeDefined();
|
|
186
|
+
expect(getModel.mock.calls[0][2]).toBe("dashboards/tour.malloy");
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("opens the file NotebookEditor is told it is at", async () => {
|
|
190
|
+
render(
|
|
191
|
+
<NotebookEditor
|
|
192
|
+
environmentName="env"
|
|
193
|
+
packageName="pkg"
|
|
194
|
+
notebookName="tour"
|
|
195
|
+
path="dashboards/tour.malloy"
|
|
196
|
+
/>,
|
|
197
|
+
{ wrapper: serverWrapper },
|
|
198
|
+
);
|
|
199
|
+
expect(await screen.findByText("Tour")).toBeDefined();
|
|
200
|
+
expect(getModel.mock.calls[0][2]).toBe("dashboards/tour.malloy");
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("refuses a .malloynb notebook without fetching it", async () => {
|
|
204
|
+
const onEvent = mock((_event: BuilderEvent) => {});
|
|
205
|
+
mount({ dashboardName: "old.malloynb" }, onEvent);
|
|
206
|
+
expect(
|
|
207
|
+
await screen.findByText(/a \.malloynb notebook is read, not edited/),
|
|
208
|
+
).toBeDefined();
|
|
209
|
+
expect(getModel).not.toHaveBeenCalled();
|
|
210
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
211
|
+
type: "notebook.open_refused",
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("offers a notebook in the cell format as a conversion, and Save writes it exactly", async () => {
|
|
216
|
+
served = LEGACY;
|
|
217
|
+
servedHash = await sha256Hex(LEGACY);
|
|
218
|
+
const onEvent = mock((_event: BuilderEvent) => {});
|
|
219
|
+
mount({}, onEvent);
|
|
220
|
+
expect(
|
|
221
|
+
await screen.findByText(/This notebook is in the cell format/),
|
|
222
|
+
).toBeDefined();
|
|
223
|
+
expect(screen.getByLabelText("Tile revenue_by_month")).toBeDefined();
|
|
224
|
+
|
|
225
|
+
fireEvent.click(button("Save"));
|
|
226
|
+
fireEvent.click(
|
|
227
|
+
await screen.findByRole("button", { name: "Convert and save" }),
|
|
228
|
+
);
|
|
229
|
+
await waitFor(() => expect(writes).toHaveLength(1));
|
|
230
|
+
expect(writes[0]).toContain("tiles=[\n text_1 { kind=text }");
|
|
231
|
+
expect(writes[0]).toContain("view: revenue_by_month is sales_by_month");
|
|
232
|
+
await waitFor(() =>
|
|
233
|
+
expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual([
|
|
234
|
+
"notebook.opened",
|
|
235
|
+
"notebook.saved",
|
|
236
|
+
]),
|
|
237
|
+
);
|
|
238
|
+
expect(onEvent.mock.calls[1][0]).toMatchObject({ converted: true });
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("says why a notebook cannot be converted, naming the line", async () => {
|
|
242
|
+
served = REFUSED;
|
|
243
|
+
const onEvent = mock((_event: BuilderEvent) => {});
|
|
244
|
+
mount({}, onEvent);
|
|
245
|
+
const alert = await screen.findByText(/cannot be opened in the builder/);
|
|
246
|
+
expect(alert.textContent).toMatch(/line 4/i);
|
|
247
|
+
expect(
|
|
248
|
+
screen.queryByText(/This notebook is in the cell format/),
|
|
249
|
+
).toBeNull();
|
|
250
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
251
|
+
type: "notebook.open_refused",
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
describe("DashboardEditor as a notebook: the host's record", () => {
|
|
257
|
+
const RECORD: Workspace = {
|
|
258
|
+
name: "Branch",
|
|
259
|
+
writeable: true,
|
|
260
|
+
description: "Saved to the draft branch",
|
|
261
|
+
authoritative: true,
|
|
262
|
+
};
|
|
263
|
+
class Store implements DocumentStorage {
|
|
264
|
+
readonly types: DocumentType[] = [];
|
|
265
|
+
readonly saved = new Map<string, string>();
|
|
266
|
+
constructor(private readonly record: string | undefined) {}
|
|
267
|
+
async listWorkspaces(): Promise<Workspace[]> {
|
|
268
|
+
return [RECORD];
|
|
269
|
+
}
|
|
270
|
+
async listDocuments(): Promise<DocumentLocator[]> {
|
|
271
|
+
return [];
|
|
272
|
+
}
|
|
273
|
+
async getDocument(locator: DocumentLocator): Promise<string> {
|
|
274
|
+
this.types.push(locator.type);
|
|
275
|
+
if (this.record === undefined)
|
|
276
|
+
throw new DocumentNotFoundError(locator.path);
|
|
277
|
+
return this.record;
|
|
278
|
+
}
|
|
279
|
+
async saveDocument(locator: DocumentLocator, content: string) {
|
|
280
|
+
this.saved.set(locator.path, content);
|
|
281
|
+
}
|
|
282
|
+
async deleteDocument(): Promise<void> {}
|
|
283
|
+
async moveDocument(): Promise<void> {}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
it("reads and writes it under the notebook type", async () => {
|
|
287
|
+
const store = new Store(LAYOUT.replace("Hello.", "From the record."));
|
|
288
|
+
render(
|
|
289
|
+
<DocumentStorageProvider documentStorage={store}>
|
|
290
|
+
<DashboardEditor
|
|
291
|
+
kind="notebook"
|
|
292
|
+
environmentName="env"
|
|
293
|
+
packageName="pkg"
|
|
294
|
+
dashboardName="tour"
|
|
295
|
+
/>
|
|
296
|
+
</DocumentStorageProvider>,
|
|
297
|
+
{ wrapper: serverWrapper },
|
|
298
|
+
);
|
|
299
|
+
expect(await screen.findByText("From the record.")).toBeDefined();
|
|
300
|
+
expect(store.types).toEqual(["notebook"]);
|
|
301
|
+
editInline("Tour", "Notebook title", "Tour, again");
|
|
302
|
+
fireEvent.click(button("Save"));
|
|
303
|
+
await waitFor(() => expect(store.saved.size).toBe(1));
|
|
304
|
+
expect(store.saved.get("env/pkg/notebooks/tour.malloy")).toContain(
|
|
305
|
+
'title="Tour, again"',
|
|
306
|
+
);
|
|
307
|
+
// The record took the write; the package file was left alone.
|
|
308
|
+
expect(updateModelSource).not.toHaveBeenCalled();
|
|
309
|
+
});
|
|
310
|
+
});
|
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
mockServerProvider,
|
|
9
9
|
pending,
|
|
10
10
|
serverWrapper,
|
|
11
|
+
TEST_SERVER,
|
|
11
12
|
} from "../../../test/serverProvider";
|
|
13
|
+
import { globalQueryClient } from "../../utils/queryClient";
|
|
12
14
|
import { sha256Hex } from "../../utils/sha256";
|
|
13
15
|
import { BrowserDocumentStorage } from "../DocumentStorage/BrowserDocumentStorage";
|
|
14
16
|
import { DocumentStorageProvider } from "../DocumentStorage/DocumentStorageProvider";
|
|
@@ -26,6 +28,7 @@ source: a is scoped_orders extend {
|
|
|
26
28
|
# label="By category"
|
|
27
29
|
view: by_cat is by_category
|
|
28
30
|
}`;
|
|
31
|
+
import { editInline } from "./testing/inline";
|
|
29
32
|
|
|
30
33
|
const getModel = mock((_env: string, _pkg: string, path: string) =>
|
|
31
34
|
Promise.resolve({
|
|
@@ -110,12 +113,8 @@ describe("DashboardEditor, when the server takes writes", () => {
|
|
|
110
113
|
screen.getByText("Save writes the file into the package."),
|
|
111
114
|
).toBeDefined();
|
|
112
115
|
|
|
113
|
-
|
|
114
|
-
fireEvent.
|
|
115
|
-
target: { value: "Categories" },
|
|
116
|
-
});
|
|
117
|
-
fireEvent.keyDown(screen.getByLabelText("Tile title"), { key: "Escape" });
|
|
118
|
-
fireEvent.click(button("Save changes"));
|
|
116
|
+
editInline("By category", "Tile title", "Categories");
|
|
117
|
+
fireEvent.click(button("Save"));
|
|
119
118
|
|
|
120
119
|
await waitFor(() => expect(updateModelSource).toHaveBeenCalledTimes(1));
|
|
121
120
|
const [env, pkg, path, body] = updateModelSource.mock.calls[0];
|
|
@@ -147,17 +146,44 @@ describe("DashboardEditor, when the server takes writes", () => {
|
|
|
147
146
|
);
|
|
148
147
|
mount();
|
|
149
148
|
await screen.findByText("Storefront");
|
|
150
|
-
|
|
151
|
-
fireEvent.
|
|
152
|
-
target: { value: "Categories" },
|
|
153
|
-
});
|
|
154
|
-
fireEvent.keyDown(screen.getByLabelText("Tile title"), { key: "Escape" });
|
|
155
|
-
fireEvent.click(button("Save changes"));
|
|
149
|
+
editInline("By category", "Tile title", "Categories");
|
|
150
|
+
fireEvent.click(button("Save"));
|
|
156
151
|
await waitFor(() =>
|
|
157
152
|
expect(screen.getByRole("alert").textContent).toContain(
|
|
158
153
|
"changed in the package since you opened it",
|
|
159
154
|
),
|
|
160
155
|
);
|
|
161
|
-
expect(button("Save
|
|
156
|
+
expect(button("Save")).toBeDefined();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("drops the cached results of the saved file, which are keyed on query text, not content", async () => {
|
|
160
|
+
const key = (modelPath: string) => [
|
|
161
|
+
"queryResult",
|
|
162
|
+
"env",
|
|
163
|
+
"pkg",
|
|
164
|
+
undefined,
|
|
165
|
+
modelPath,
|
|
166
|
+
undefined,
|
|
167
|
+
"run: a -> by_cat",
|
|
168
|
+
undefined,
|
|
169
|
+
"{}",
|
|
170
|
+
TEST_SERVER,
|
|
171
|
+
];
|
|
172
|
+
globalQueryClient.setQueryData(key("dashboards/overview.malloy"), "old");
|
|
173
|
+
globalQueryClient.setQueryData(key("dashboards/other.malloy"), "other");
|
|
174
|
+
mount();
|
|
175
|
+
await screen.findByText("Storefront");
|
|
176
|
+
editInline("By category", "Tile title", "Categories");
|
|
177
|
+
fireEvent.click(button("Save"));
|
|
178
|
+
await waitFor(() =>
|
|
179
|
+
expect(
|
|
180
|
+
globalQueryClient.getQueryState(key("dashboards/overview.malloy"))
|
|
181
|
+
?.isInvalidated,
|
|
182
|
+
).toBe(true),
|
|
183
|
+
);
|
|
184
|
+
expect(
|
|
185
|
+
globalQueryClient.getQueryState(key("dashboards/other.malloy"))
|
|
186
|
+
?.isInvalidated,
|
|
187
|
+
).toBe(false);
|
|
162
188
|
});
|
|
163
189
|
});
|
|
@@ -33,6 +33,7 @@ source: a is scoped_orders extend {
|
|
|
33
33
|
# label="By category"
|
|
34
34
|
view: by_cat is by_category
|
|
35
35
|
}`;
|
|
36
|
+
import { editInline } from "./testing/inline";
|
|
36
37
|
|
|
37
38
|
const getModel = mock(
|
|
38
39
|
(_env: string, _pkg: string, path: string, _versionId?: string) =>
|
|
@@ -212,7 +213,7 @@ describe("versionId", () => {
|
|
|
212
213
|
// screen.
|
|
213
214
|
expect(cacheKeys("dashboard-editor-model")[0]).toContain('"v7"');
|
|
214
215
|
expect(cacheKeys("dashboard-editor-manifest")[0]).toContain('"v7"');
|
|
215
|
-
expect(cacheKeys("
|
|
216
|
+
expect(cacheKeys("dashboards")[0]).toContain('"v7"');
|
|
216
217
|
await waitFor(() =>
|
|
217
218
|
expect(cacheKeys("dashboard-editor-catalog")[0]).toContain('"v7"'),
|
|
218
219
|
);
|
|
@@ -238,14 +239,8 @@ describe("versionId", () => {
|
|
|
238
239
|
serverContext.mutable = true;
|
|
239
240
|
mountByUri();
|
|
240
241
|
await screen.findByText("Storefront");
|
|
241
|
-
|
|
242
|
-
fireEvent.
|
|
243
|
-
target: { value: "Categories" },
|
|
244
|
-
});
|
|
245
|
-
fireEvent.keyDown(screen.getByLabelText("Tile title"), {
|
|
246
|
-
key: "Escape",
|
|
247
|
-
});
|
|
248
|
-
fireEvent.click(button("Save changes"));
|
|
242
|
+
editInline("By category", "Tile title", "Categories");
|
|
243
|
+
fireEvent.click(button("Save"));
|
|
249
244
|
|
|
250
245
|
await waitFor(() => expect(updateModelSource).toHaveBeenCalledTimes(1));
|
|
251
246
|
// Four positional arguments, none of them a version: the client's
|
|
@@ -266,14 +261,8 @@ describe("versionId", () => {
|
|
|
266
261
|
(call) => call[2] === "dashboards/overview.malloy",
|
|
267
262
|
).length;
|
|
268
263
|
|
|
269
|
-
|
|
270
|
-
fireEvent.
|
|
271
|
-
target: { value: "Categories" },
|
|
272
|
-
});
|
|
273
|
-
fireEvent.keyDown(screen.getByLabelText("Tile title"), {
|
|
274
|
-
key: "Escape",
|
|
275
|
-
});
|
|
276
|
-
fireEvent.click(button("Save changes"));
|
|
264
|
+
editInline("By category", "Tile title", "Categories");
|
|
265
|
+
fireEvent.click(button("Save"));
|
|
277
266
|
await waitFor(() => expect(updateModelSource).toHaveBeenCalledTimes(1));
|
|
278
267
|
|
|
279
268
|
// Proof, not a proxy for one: the live query's key now ends in a
|
|
@@ -304,7 +293,7 @@ describe("Save, pinned to a version", () => {
|
|
|
304
293
|
),
|
|
305
294
|
).toBeDefined();
|
|
306
295
|
expect(
|
|
307
|
-
screen.queryByRole("button", { name: "Save
|
|
296
|
+
screen.queryByRole("button", { name: "Save", hidden: true }),
|
|
308
297
|
).toBeNull();
|
|
309
298
|
expect(
|
|
310
299
|
screen.queryByRole("button", { name: "Saved", hidden: true }),
|
|
@@ -318,14 +307,8 @@ describe("Save, pinned to a version", () => {
|
|
|
318
307
|
|
|
319
308
|
// Unaffected: a copy kept beside the package never goes through
|
|
320
309
|
// `updateModelSource`, so the version pin has nothing to refuse.
|
|
321
|
-
|
|
322
|
-
fireEvent.
|
|
323
|
-
target: { value: "Categories" },
|
|
324
|
-
});
|
|
325
|
-
fireEvent.keyDown(screen.getByLabelText("Tile title"), {
|
|
326
|
-
key: "Escape",
|
|
327
|
-
});
|
|
328
|
-
fireEvent.click(button("Save changes"));
|
|
310
|
+
editInline("By category", "Tile title", "Categories");
|
|
311
|
+
fireEvent.click(button("Save"));
|
|
329
312
|
await waitFor(() => expect(button("Saved")).toBeDefined());
|
|
330
313
|
});
|
|
331
314
|
});
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
act,
|
|
6
|
+
fireEvent,
|
|
7
|
+
render,
|
|
8
|
+
screen,
|
|
9
|
+
waitFor,
|
|
10
|
+
} from "@testing-library/react";
|
|
5
11
|
import { beforeEach, describe, expect, it, mock } from "bun:test";
|
|
6
12
|
import {
|
|
7
13
|
clearCache,
|
|
@@ -12,6 +18,7 @@ import {
|
|
|
12
18
|
import { BrowserDocumentStorage } from "../DocumentStorage/BrowserDocumentStorage";
|
|
13
19
|
import { DocumentStorageProvider } from "../DocumentStorage/DocumentStorageProvider";
|
|
14
20
|
import type { DashboardEvent } from "../Dashboard/telemetry";
|
|
21
|
+
import { globalQueryClient } from "../../utils/queryClient";
|
|
15
22
|
|
|
16
23
|
/**
|
|
17
24
|
* The Console's path through the builder, with the server mocked at the
|
|
@@ -26,14 +33,20 @@ source: a is scoped_orders extend {
|
|
|
26
33
|
# label="By category"
|
|
27
34
|
view: by_cat is by_category
|
|
28
35
|
}`;
|
|
36
|
+
import { editInline } from "./testing/inline";
|
|
37
|
+
|
|
38
|
+
let served = PACKAGE_FILE;
|
|
39
|
+
/** Set, and the dashboard's own file fails to fetch: a refetch the server could not answer. */
|
|
40
|
+
let fetchFailure: Error | undefined;
|
|
29
41
|
|
|
30
42
|
const getModel = mock((_env: string, _pkg: string, path: string) =>
|
|
31
|
-
path === "broken.malloy"
|
|
32
|
-
|
|
43
|
+
path === "broken.malloy" ||
|
|
44
|
+
(fetchFailure && path === "dashboards/overview.malloy")
|
|
45
|
+
? Promise.reject(fetchFailure ?? new Error("reloading"))
|
|
33
46
|
: Promise.resolve({
|
|
34
47
|
data:
|
|
35
48
|
path === "dashboards/overview.malloy"
|
|
36
|
-
? { modelPath: path, sourceText:
|
|
49
|
+
? { modelPath: path, sourceText: served }
|
|
37
50
|
: {
|
|
38
51
|
modelPath: path,
|
|
39
52
|
sources: [
|
|
@@ -76,10 +89,17 @@ const executeQueryModel = mock(() => pending());
|
|
|
76
89
|
const listModels = mock(() =>
|
|
77
90
|
Promise.resolve({ data: [{ path: "data_app.malloy" }] }),
|
|
78
91
|
);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
92
|
+
const serverContext: {
|
|
93
|
+
mutable: boolean | undefined;
|
|
94
|
+
isLoadingStatus: boolean;
|
|
95
|
+
} = { mutable: undefined, isLoadingStatus: false };
|
|
96
|
+
mockServerProvider(
|
|
97
|
+
{
|
|
98
|
+
models: { getModel, executeQueryModel, listModels },
|
|
99
|
+
dashboards: { getDashboard, listDashboards },
|
|
100
|
+
},
|
|
101
|
+
serverContext,
|
|
102
|
+
);
|
|
83
103
|
|
|
84
104
|
// Imported after the stub is registered: a static import would hoist above it.
|
|
85
105
|
const { DashboardEditor } = await import("./DashboardEditor");
|
|
@@ -90,10 +110,7 @@ const DRAFT = {
|
|
|
90
110
|
path: "env/pkg/dashboards/overview.malloy",
|
|
91
111
|
};
|
|
92
112
|
|
|
93
|
-
const mount = (
|
|
94
|
-
onExit?: () => void,
|
|
95
|
-
onEvent?: (event: DashboardEvent) => void,
|
|
96
|
-
) => {
|
|
113
|
+
const mount = (onEvent?: (event: DashboardEvent) => void) => {
|
|
97
114
|
const storage = new BrowserDocumentStorage();
|
|
98
115
|
render(
|
|
99
116
|
<DocumentStorageProvider documentStorage={storage}>
|
|
@@ -101,7 +118,6 @@ const mount = (
|
|
|
101
118
|
environmentName="env"
|
|
102
119
|
packageName="pkg"
|
|
103
120
|
dashboardName="overview"
|
|
104
|
-
{...(onExit ? { onExit } : {})}
|
|
105
121
|
{...(onEvent ? { onEvent } : {})}
|
|
106
122
|
/>
|
|
107
123
|
</DocumentStorageProvider>,
|
|
@@ -116,6 +132,11 @@ const button = (name: string | RegExp) =>
|
|
|
116
132
|
beforeEach(() => {
|
|
117
133
|
clearCache();
|
|
118
134
|
localStorage.clear();
|
|
135
|
+
served = PACKAGE_FILE;
|
|
136
|
+
fetchFailure = undefined;
|
|
137
|
+
serverContext.mutable = undefined;
|
|
138
|
+
serverContext.isLoadingStatus = false;
|
|
139
|
+
getDashboard.mockClear();
|
|
119
140
|
});
|
|
120
141
|
|
|
121
142
|
describe("DashboardEditor", () => {
|
|
@@ -136,6 +157,67 @@ describe("DashboardEditor", () => {
|
|
|
136
157
|
await screen.findByRole("button", { name: "Add tile", hidden: true });
|
|
137
158
|
});
|
|
138
159
|
|
|
160
|
+
it("opens a dashboard with no tiles without asking for a manifest the server would 404", async () => {
|
|
161
|
+
served = PACKAGE_FILE.replace('tiles=["a -> by_cat"]', "tiles=[]");
|
|
162
|
+
mount();
|
|
163
|
+
expect(
|
|
164
|
+
await screen.findByText(/not served until it has a tile/),
|
|
165
|
+
).toBeDefined();
|
|
166
|
+
expect(
|
|
167
|
+
(
|
|
168
|
+
await screen.findAllByRole("button", {
|
|
169
|
+
name: "Add tile",
|
|
170
|
+
hidden: true,
|
|
171
|
+
})
|
|
172
|
+
).length,
|
|
173
|
+
).toBe(2);
|
|
174
|
+
expect(getDashboard).not.toHaveBeenCalled();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("keeps the builder and its unsaved edit through a failed refetch", async () => {
|
|
178
|
+
mount();
|
|
179
|
+
await screen.findByText("Storefront");
|
|
180
|
+
editInline("By category", "Tile title", "Categories");
|
|
181
|
+
|
|
182
|
+
fetchFailure = new Error("the server went away");
|
|
183
|
+
await act(async () => {
|
|
184
|
+
await globalQueryClient.refetchQueries({
|
|
185
|
+
queryKey: ["dashboard-editor-model"],
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
expect(
|
|
189
|
+
await screen.findByText(/could not be re-read from the server/),
|
|
190
|
+
).toBeDefined();
|
|
191
|
+
expect(screen.getByLabelText("Tile by_cat")).toBeDefined();
|
|
192
|
+
expect(button("Save")).toBeDefined();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("does not call an undecided server writable or read-only while its status loads", async () => {
|
|
196
|
+
serverContext.isLoadingStatus = true;
|
|
197
|
+
mount();
|
|
198
|
+
expect(
|
|
199
|
+
await screen.findByText("Checking whether this server takes writes."),
|
|
200
|
+
).toBeDefined();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("says the server did not say whether it takes writes, once status has settled", async () => {
|
|
204
|
+
mount();
|
|
205
|
+
expect(
|
|
206
|
+
await screen.findByText(
|
|
207
|
+
"This server did not say whether it takes writes, so Save is off.",
|
|
208
|
+
),
|
|
209
|
+
).toBeDefined();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("says why when reading the file throws, rather than loading forever", async () => {
|
|
213
|
+
// A body the reader cannot take apart, so the read rejects instead of refusing.
|
|
214
|
+
served = 42 as unknown as string;
|
|
215
|
+
mount();
|
|
216
|
+
expect(
|
|
217
|
+
await screen.findByText(/cannot be opened in the builder/),
|
|
218
|
+
).toBeDefined();
|
|
219
|
+
});
|
|
220
|
+
|
|
139
221
|
it("keeps the catalog when one published model fails to load", async () => {
|
|
140
222
|
listModels.mockImplementationOnce(() =>
|
|
141
223
|
Promise.resolve({
|
|
@@ -155,12 +237,8 @@ describe("DashboardEditor", () => {
|
|
|
155
237
|
it("saves an edit into the browser and marks it saved", async () => {
|
|
156
238
|
const storage = mount();
|
|
157
239
|
await screen.findByText("Storefront");
|
|
158
|
-
|
|
159
|
-
fireEvent.
|
|
160
|
-
target: { value: "Categories" },
|
|
161
|
-
});
|
|
162
|
-
fireEvent.keyDown(screen.getByLabelText("Tile title"), { key: "Escape" });
|
|
163
|
-
fireEvent.click(button("Save changes"));
|
|
240
|
+
editInline("By category", "Tile title", "Categories");
|
|
241
|
+
fireEvent.click(button("Save"));
|
|
164
242
|
await waitFor(async () =>
|
|
165
243
|
expect(await storage.getDocument(DRAFT)).toContain(
|
|
166
244
|
'# label="Categories"',
|
|
@@ -180,7 +258,7 @@ describe("DashboardEditor", () => {
|
|
|
180
258
|
);
|
|
181
259
|
await new BrowserDocumentStorage().saveDocument(DRAFT, draft);
|
|
182
260
|
const onEvent = mock((_event: DashboardEvent) => {});
|
|
183
|
-
mount(
|
|
261
|
+
mount(onEvent);
|
|
184
262
|
expect(
|
|
185
263
|
await screen.findByText(
|
|
186
264
|
/edits to this dashboard saved in this browser/,
|
|
@@ -197,10 +275,9 @@ describe("DashboardEditor", () => {
|
|
|
197
275
|
expect(screen.queryByText(/saved in this browser/)).toBeNull();
|
|
198
276
|
});
|
|
199
277
|
|
|
200
|
-
it("
|
|
201
|
-
const onExit = mock(() => {});
|
|
278
|
+
it("reports the open, and offers Save rather than Close when it can save", async () => {
|
|
202
279
|
const onEvent = mock((_event: DashboardEvent) => {});
|
|
203
|
-
mount(
|
|
280
|
+
mount(onEvent);
|
|
204
281
|
await screen.findByText("Storefront");
|
|
205
282
|
await waitFor(() =>
|
|
206
283
|
expect(onEvent.mock.calls.map((call) => call[0].type)).toContain(
|
|
@@ -212,7 +289,7 @@ describe("DashboardEditor", () => {
|
|
|
212
289
|
from: "package",
|
|
213
290
|
tiles: 1,
|
|
214
291
|
});
|
|
215
|
-
|
|
216
|
-
expect(
|
|
292
|
+
expect(screen.queryByRole("button", { name: "Close" })).toBeNull();
|
|
293
|
+
expect(button("Saved")).toBeDefined();
|
|
217
294
|
});
|
|
218
295
|
});
|