@malloy-publisher/sdk 0.9.7 → 0.9.8
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/README.md +117 -17
- package/dist/{RenderedResult-qnpbr4tc.cjs.js → RenderedResult-BrvrMDAP.cjs.js} +1 -1
- package/dist/{RenderedResult-CkUS04tl.es.js → RenderedResult-DZj-FnOJ.es.js} +2 -2
- package/dist/{ServerProvider-DnLLeXEX.es.js → ServerProvider-B_bPAsu2.es.js} +583 -398
- package/dist/ServerProvider-DuEOzwPc.cjs.js +1 -0
- package/dist/builder/index.cjs.js +93 -93
- package/dist/builder/index.es.js +4630 -4562
- package/dist/builder-entry.d.ts +13 -12
- package/dist/client/api.d.ts +472 -94
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +105 -95
- package/dist/components/Dashboard/DashboardTile.d.ts +3 -1
- package/dist/components/Dashboard/DashboardView.d.ts +1 -3
- package/dist/components/Dashboard/index.d.ts +0 -2
- package/dist/components/DocumentCreate/createDocument.d.ts +29 -9
- package/dist/components/DocumentCreate/documentPath.d.ts +21 -6
- package/dist/components/DocumentCreate/guards.d.ts +2 -3
- package/dist/components/DocumentCreate/index.d.ts +2 -3
- package/dist/components/DocumentCreate/newNotebook.d.ts +14 -5
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +6 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +52 -24
- package/dist/components/Loading.d.ts +1 -1
- package/dist/components/Package/DataSchemaDialog.d.ts +26 -0
- package/dist/components/Package/NewDocumentDialog.d.ts +19 -10
- package/dist/components/Package/Package.d.ts +14 -9
- package/dist/components/Package/documentLocation.d.ts +66 -23
- package/dist/components/Package/index.d.ts +3 -2
- package/dist/components/Package/reportQueries.d.ts +8 -0
- package/dist/components/Package/useDocumentLocation.d.ts +36 -6
- package/dist/components/Package/useDraftLayout.d.ts +20 -0
- package/dist/components/Report/CellReport.d.ts +89 -0
- package/dist/components/Report/LinearReport.d.ts +18 -0
- package/dist/components/Report/Report.d.ts +62 -0
- package/dist/components/Report/index.d.ts +2 -0
- package/dist/components/Report/telemetry.d.ts +163 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.d.ts +5 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/EditorSurface.d.ts +10 -7
- package/dist/components/{DashboardBuilder/DashboardBuilder.d.ts → ReportBuilder/ReportBuilder.d.ts} +17 -8
- package/dist/components/{DashboardBuilder/DashboardEditor.d.ts → ReportBuilder/ReportEditor.d.ts} +41 -14
- package/dist/components/ReportBuilder/builderReport.d.ts +14 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/catalog.d.ts +8 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/document.d.ts +3 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/documentSession.d.ts +1 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/imports.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/malloyTree.d.ts +9 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/newDashboard.d.ts +7 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/readDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/readForEditor.d.ts +1 -1
- package/dist/components/ReportBuilder/reportTag.d.ts +52 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/spliceDocument.d.ts +1 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/useControlBindings.d.ts +2 -2
- package/dist/components/ReportBuilder/useEditorCatalog.d.ts +25 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/useHostCopy.d.ts +5 -3
- package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder/useDashboardEditor.d.ts → ReportBuilder/useReportEditor.d.ts} +3 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.d.ts +6 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/useTileEditing.d.ts +2 -2
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +8 -1
- package/dist/components/drill/useDrillSelf.d.ts +4 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/{Dashboard → legacy}/Dashboard.d.ts +15 -9
- package/dist/components/legacy/MalloynbCells.d.ts +13 -0
- package/dist/components/legacy/Notebook.d.ts +15 -0
- package/dist/components/{DashboardBuilder → legacy}/NotebookEditor.d.ts +3 -3
- package/dist/components/legacy/builderNames.d.ts +10 -0
- package/dist/components/legacy/index.d.ts +11 -0
- package/dist/components/legacy/kindAdapter.d.ts +11 -0
- package/dist/components/legacy/kindTypedDrafts.d.ts +10 -0
- package/dist/components/legacy/nameAlias.d.ts +44 -0
- package/dist/components/legacy/queryKeys.d.ts +8 -0
- package/dist/index.cjs.js +19 -19
- package/dist/index.es.js +7984 -7452
- package/dist/text/index.es.js +2 -2
- package/dist/{text-entry-CA0LZ1xL.es.js → text-entry-72YFLeNk.es.js} +10 -10
- package/dist/useCompiledDocument-oocN5cGE.cjs.js +141 -0
- package/dist/{useCompiledDocument-Bf72Ob5v.es.js → useCompiledDocument-x0B2RAH3.es.js} +4593 -4395
- package/package.json +2 -2
- package/src/builder-entry.ts +32 -24
- package/src/components/Dashboard/DashboardTile.tsx +17 -0
- package/src/components/Dashboard/DashboardView.spec.tsx +0 -21
- package/src/components/Dashboard/DashboardView.tsx +8 -24
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +1 -4
- package/src/components/Dashboard/index.ts +0 -2
- package/src/components/DocumentCreate/createDocument.spec.ts +346 -53
- package/src/components/DocumentCreate/createDocument.ts +143 -63
- package/src/components/DocumentCreate/documentPath.ts +41 -12
- package/src/components/DocumentCreate/guards.ts +7 -15
- package/src/components/DocumentCreate/index.ts +3 -7
- package/src/components/DocumentCreate/newNotebook.spec.ts +113 -43
- package/src/components/DocumentCreate/newNotebook.ts +32 -10
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +130 -28
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +78 -40
- package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +426 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +57 -24
- package/src/components/Home/AddEnvironmentDialog.tsx +1 -1
- package/src/components/Home/Home.tsx +1 -1
- package/src/components/Loading.tsx +1 -1
- package/src/components/Model/SourcesExplorer.tsx +1 -1
- package/src/components/Notebook/NotebookCell.tsx +6 -5
- package/src/components/Notebook/cellKind.spec.ts +15 -7
- package/src/components/Package/DataSchemaDialog.spec.tsx +85 -0
- package/src/components/Package/DataSchemaDialog.tsx +367 -0
- package/src/components/Package/NewDocumentDialog.spec.tsx +145 -88
- package/src/components/Package/NewDocumentDialog.tsx +93 -48
- package/src/components/Package/Package.artifacts.spec.tsx +79 -60
- package/src/components/Package/Package.create.spec.tsx +126 -112
- package/src/components/Package/Package.notebooks.spec.tsx +46 -27
- package/src/components/Package/Package.spec.tsx +43 -30
- package/src/components/Package/Package.tsx +173 -292
- package/src/components/Package/documentLocation.spec.ts +145 -50
- package/src/components/Package/documentLocation.ts +118 -39
- package/src/components/Package/index.ts +12 -3
- package/src/components/Package/reportQueries.ts +25 -0
- package/src/components/Package/useDocumentLocation.spec.ts +58 -0
- package/src/components/Package/useDocumentLocation.ts +90 -32
- package/src/components/Package/useDraftLayout.spec.tsx +143 -0
- package/src/components/Package/useDraftLayout.ts +81 -0
- package/src/components/Prose.spec.tsx +3 -3
- package/src/components/RenderedResult/RenderedResult.tsx +1 -1
- package/src/components/Report/CellReport.spec.tsx +155 -0
- package/src/components/{Notebook/Notebook.tsx → Report/CellReport.tsx} +178 -220
- package/src/components/Report/LinearReport.tsx +71 -0
- package/src/components/Report/Report.spec.tsx +238 -0
- package/src/components/Report/Report.telemetry.spec.tsx +292 -0
- package/src/components/Report/Report.tsx +277 -0
- package/src/components/Report/index.ts +12 -0
- package/src/components/Report/telemetry.spec.ts +90 -0
- package/src/components/Report/telemetry.ts +250 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.tsx +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.tsx +6 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.tsx +33 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/DrillDialog.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/EditorSurface.tsx +67 -107
- package/src/components/{DashboardBuilder → ReportBuilder}/FilterDialog.tsx +3 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.charts.spec.tsx → ReportBuilder/ReportBuilder.charts.spec.tsx} +4 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.exit.spec.tsx → ReportBuilder/ReportBuilder.exit.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.inline.spec.tsx → ReportBuilder/ReportBuilder.inline.spec.tsx} +4 -4
- package/src/components/ReportBuilder/ReportBuilder.layoutSwitch.spec.tsx +145 -0
- package/src/components/{DashboardBuilder/DashboardBuilder.notebook.spec.tsx → ReportBuilder/ReportBuilder.notebook.spec.tsx} +22 -21
- package/src/components/{DashboardBuilder/DashboardBuilder.openDraft.spec.tsx → ReportBuilder/ReportBuilder.openDraft.spec.tsx} +3 -3
- package/src/components/{DashboardBuilder/DashboardBuilder.sources.spec.tsx → ReportBuilder/ReportBuilder.sources.spec.tsx} +19 -8
- package/src/components/{DashboardBuilder/DashboardBuilder.spec.tsx → ReportBuilder/ReportBuilder.spec.tsx} +34 -34
- package/src/components/{DashboardBuilder/DashboardBuilder.textTiles.spec.tsx → ReportBuilder/ReportBuilder.textTiles.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.tsx → ReportBuilder/ReportBuilder.tsx} +46 -21
- package/src/components/{DashboardBuilder/DashboardEditor.authoritative.spec.tsx → ReportBuilder/ReportEditor.authoritative.spec.tsx} +28 -20
- package/src/components/{DashboardBuilder/DashboardEditor.emptyStart.spec.tsx → ReportBuilder/ReportEditor.emptyStart.spec.tsx} +19 -11
- package/src/components/{DashboardBuilder/DashboardEditor.filterTag.spec.tsx → ReportBuilder/ReportEditor.filterTag.spec.tsx} +7 -7
- package/src/components/{DashboardBuilder/DashboardEditor.notebook.spec.tsx → ReportBuilder/ReportEditor.notebook.spec.tsx} +70 -49
- package/src/components/{DashboardBuilder/DashboardEditor.package.spec.tsx → ReportBuilder/ReportEditor.package.spec.tsx} +52 -8
- package/src/components/{DashboardBuilder/DashboardEditor.resourceUri.spec.tsx → ReportBuilder/ReportEditor.resourceUri.spec.tsx} +50 -18
- package/src/components/{DashboardBuilder/DashboardEditor.spec.tsx → ReportBuilder/ReportEditor.spec.tsx} +65 -20
- package/src/components/{DashboardBuilder/DashboardEditor.textSource.spec.tsx → ReportBuilder/ReportEditor.textSource.spec.tsx} +6 -6
- package/src/components/{DashboardBuilder/DashboardEditor.tsx → ReportBuilder/ReportEditor.tsx} +92 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/addTile.compile.spec.ts +1 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/artifactBlock.spec.ts +21 -29
- package/src/components/ReportBuilder/builderReport.ts +53 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.spec.ts +28 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.ts +17 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/controls.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/document.ts +4 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.spec.ts +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.spec.ts +6 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.ts +8 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.chart.spec.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.convert.spec.ts +9 -13
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.read.spec.ts +15 -15
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.ts +7 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.ts +25 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.spec.ts +12 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.ts +11 -24
- package/src/components/{DashboardBuilder → ReportBuilder}/preview.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.spec.ts +64 -36
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.ts +33 -32
- package/src/components/ReportBuilder/readForEditor.spec.ts +96 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readForEditor.ts +3 -11
- package/src/components/ReportBuilder/reportTag.ts +108 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.imports.spec.ts +28 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.spec.ts +32 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.ts +37 -60
- package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.spec.ts +3 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/testing/artifactTagParity.json +2 -2
- package/src/components/ReportBuilder/testing/drillResolution.json +279 -0
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +125 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/textTiles.spec.ts +66 -143
- package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.ts +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/useControlBindings.ts +2 -2
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +156 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +119 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/useHostCopy.ts +7 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.ts +56 -35
- package/src/components/{DashboardBuilder/useDashboardEditor.spec.ts → ReportBuilder/useReportEditor.spec.ts} +6 -6
- package/src/components/{DashboardBuilder/useDashboardEditor.ts → ReportBuilder/useReportEditor.ts} +6 -17
- package/src/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.ts +36 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/useTileEditing.ts +2 -2
- package/src/components/ServerProvider.tsx +2 -0
- package/src/components/drill/resolveDrill.ts +9 -2
- package/src/components/drill/useDrill.tsx +1 -0
- package/src/components/drill/useDrillSelf.spec.tsx +60 -7
- package/src/components/drill/useDrillSelf.ts +29 -12
- package/src/components/index.ts +2 -1
- package/src/components/{Dashboard → legacy}/Dashboard.spec.tsx +1 -1
- package/src/components/{Dashboard → legacy}/Dashboard.tsx +40 -28
- package/src/components/legacy/MalloynbCells.tsx +88 -0
- package/src/components/{Notebook → legacy}/Notebook.served.spec.tsx +17 -13
- package/src/components/{Notebook → legacy}/Notebook.spec.tsx +24 -20
- package/src/components/legacy/Notebook.tsx +44 -0
- package/src/components/{DashboardBuilder → legacy}/NotebookEditor.tsx +7 -4
- package/src/components/legacy/builderNames.ts +25 -0
- package/src/components/legacy/index.ts +20 -0
- package/src/components/legacy/kindAdapter.ts +19 -0
- package/src/components/legacy/kindTypedDrafts.ts +34 -0
- package/src/components/legacy/nameAlias.spec.ts +124 -0
- package/src/components/legacy/nameAlias.ts +95 -0
- package/src/components/legacy/queryKeys.ts +26 -0
- package/src/hooks/useGivensState.spec.ts +9 -9
- package/src/mainEntry.spec.ts +1 -1
- package/src/textEntry.spec.ts +9 -9
- package/src/utils/formatting.spec.ts +5 -5
- package/src/utils/parsing.spec.ts +1 -1
- package/src/utils/parsing.ts +1 -1
- package/dist/ServerProvider-Gj-im5VD.cjs.js +0 -1
- package/dist/components/Dashboard/telemetry.d.ts +0 -73
- package/dist/components/DashboardBuilder/builderReport.d.ts +0 -13
- package/dist/components/DashboardBuilder/telemetry.d.ts +0 -43
- package/dist/components/DocumentCreate/events.d.ts +0 -10
- package/dist/components/Notebook/Notebook.d.ts +0 -52
- package/dist/components/Notebook/index.d.ts +0 -1
- package/dist/useCompiledDocument-tBejqZ7s.cjs.js +0 -142
- package/src/components/Dashboard/telemetry.ts +0 -75
- package/src/components/DashboardBuilder/builderReport.ts +0 -74
- package/src/components/DashboardBuilder/readForEditor.spec.ts +0 -80
- package/src/components/DashboardBuilder/telemetry.ts +0 -47
- package/src/components/DashboardBuilder/testing/documentKindRule.json +0 -40
- package/src/components/DocumentCreate/events.ts +0 -15
- package/src/components/Notebook/index.ts +0 -4
- /package/dist/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/ChartPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/DrillDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterStrip.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TextTileBody.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileFrame.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileMenu.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/annotationText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/changedTile.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/chartLine.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/controls.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/inlineEdit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/layout.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/loadMalloy.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/openDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/preview.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/sortable.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/spliceResult.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tagParse.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/inline.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/resize.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useExitGuard.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useFilterForm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileReorder.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileResize.d.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.render.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/FilterStrip.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineText.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TextTileBody.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileFrame.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileMenu.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/__test__/inventory.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/artifactTagParity.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/catalog.aggregate.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/controls.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/emptyStart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/inlineEdit.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/invariants.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/keepRowStructure.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/layout.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/moveIntoGap.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/openDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.shapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/scannerShapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.chart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceResult.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/statementExtent.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/inline.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/resize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/urlRenderTags.json +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.overlay.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.existing.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/withGaps.spec.ts +0 -0
- /package/src/components/{Notebook → legacy}/Notebook.layout.spec.tsx +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
5
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
6
|
+
import type { ReportEvent } from "../Report/telemetry";
|
|
7
|
+
import { ReportBuilder } from "./ReportBuilder";
|
|
8
|
+
import { openDocument } from "./testing/fixtures";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The layout switch: one editor for both layouts, and switching rewrites the
|
|
12
|
+
* tag's `layout=` and nothing else (docs/reports-design.md §2, §10).
|
|
13
|
+
*/
|
|
14
|
+
const LINEAR = `## artifact { layout=linear title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] }
|
|
15
|
+
import "../data_app.malloy"
|
|
16
|
+
|
|
17
|
+
source: a is scoped_orders extend {
|
|
18
|
+
# label="By category"
|
|
19
|
+
view: by_cat is by_category
|
|
20
|
+
|
|
21
|
+
view: by_brand is by_brand_view
|
|
22
|
+
}`;
|
|
23
|
+
|
|
24
|
+
const GRID = `## artifact { layout=grid title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] } dashboard { columns=12 }
|
|
25
|
+
import "../data_app.malloy"
|
|
26
|
+
|
|
27
|
+
source: a is scoped_orders extend {
|
|
28
|
+
# colspan=6
|
|
29
|
+
# label="By category"
|
|
30
|
+
view: by_cat is by_category
|
|
31
|
+
|
|
32
|
+
# colspan=6
|
|
33
|
+
view: by_brand is by_brand_view
|
|
34
|
+
}`;
|
|
35
|
+
|
|
36
|
+
const button = (name: string | RegExp) =>
|
|
37
|
+
screen.getByRole("button", { name, hidden: true });
|
|
38
|
+
|
|
39
|
+
const mount = async (
|
|
40
|
+
source: string,
|
|
41
|
+
onSave: (source: string) => Promise<void> | void,
|
|
42
|
+
textHeld = false,
|
|
43
|
+
) =>
|
|
44
|
+
render(
|
|
45
|
+
<ReportBuilder
|
|
46
|
+
source={source}
|
|
47
|
+
document={await openDocument(source)}
|
|
48
|
+
onSave={onSave}
|
|
49
|
+
{...(textHeld ? { visibleSources: ["scoped_orders"] } : {})}
|
|
50
|
+
/>,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
describe("the layout switch", () => {
|
|
54
|
+
it("shows Linear and Grid for a file, the file's own layout pressed", async () => {
|
|
55
|
+
await mount(LINEAR, () => {});
|
|
56
|
+
expect(button("Linear layout").getAttribute("aria-pressed")).toBe("true");
|
|
57
|
+
expect(button("Grid layout").getAttribute("aria-pressed")).toBe("false");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("is not offered when the host turns it off with allowLayoutChange={false}", async () => {
|
|
61
|
+
render(
|
|
62
|
+
<ReportBuilder
|
|
63
|
+
source={GRID}
|
|
64
|
+
document={await openDocument(GRID)}
|
|
65
|
+
onSave={() => {}}
|
|
66
|
+
allowLayoutChange={false}
|
|
67
|
+
/>,
|
|
68
|
+
);
|
|
69
|
+
expect(
|
|
70
|
+
screen.queryByRole("button", { name: "Grid layout", hidden: true }),
|
|
71
|
+
).toBeNull();
|
|
72
|
+
expect(
|
|
73
|
+
screen.queryByRole("button", { name: "Linear layout", hidden: true }),
|
|
74
|
+
).toBeNull();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("is not offered for a document held as text, whose layout is the host's record", async () => {
|
|
78
|
+
await mount(LINEAR, () => {}, true);
|
|
79
|
+
expect(
|
|
80
|
+
screen.queryByRole("button", { name: "Grid layout", hidden: true }),
|
|
81
|
+
).toBeNull();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("switches linear to grid by rewriting layout= and nothing else", async () => {
|
|
85
|
+
const onSave = mock((_source: string) => Promise.resolve());
|
|
86
|
+
await mount(LINEAR, onSave);
|
|
87
|
+
fireEvent.click(button("Grid layout"));
|
|
88
|
+
await waitFor(() =>
|
|
89
|
+
expect(button("Grid layout").getAttribute("aria-pressed")).toBe(
|
|
90
|
+
"true",
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
fireEvent.click(button("Save"));
|
|
94
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
95
|
+
expect(onSave.mock.calls[0][0]).toBe(
|
|
96
|
+
LINEAR.replace("layout=linear", "layout=grid"),
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// KNOWN BUG, not yet fixed in source: the switch sets only the document's
|
|
101
|
+
// kind, and the splice refuses a linear document whose `columns` is still
|
|
102
|
+
// set ("one column"), so a grid report with `dashboard { columns=N }`
|
|
103
|
+
// cannot be switched to linear. The design keeps the file's own
|
|
104
|
+
// `dashboard { columns=N }` and changes only `layout=`.
|
|
105
|
+
it("switches grid to linear by rewriting layout= and nothing else, keeping the file's width", async () => {
|
|
106
|
+
const onSave = mock((_source: string) => Promise.resolve());
|
|
107
|
+
await mount(GRID, onSave);
|
|
108
|
+
fireEvent.click(button("Linear layout"));
|
|
109
|
+
fireEvent.click(button("Save"));
|
|
110
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
111
|
+
expect(onSave.mock.calls[0][0]).toBe(
|
|
112
|
+
GRID.replace("layout=grid", "layout=linear"),
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("reports a switch once, and the save after it under the new layout", async () => {
|
|
117
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
118
|
+
render(
|
|
119
|
+
<ReportBuilder
|
|
120
|
+
source={LINEAR}
|
|
121
|
+
document={await openDocument(LINEAR)}
|
|
122
|
+
onSave={() => Promise.resolve()}
|
|
123
|
+
modelPath="store/front.malloy"
|
|
124
|
+
onEvent={onEvent}
|
|
125
|
+
/>,
|
|
126
|
+
);
|
|
127
|
+
fireEvent.click(button("Grid layout"));
|
|
128
|
+
// The layout already pressed is not a switch.
|
|
129
|
+
fireEvent.click(button("Grid layout"));
|
|
130
|
+
fireEvent.click(button("Save"));
|
|
131
|
+
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(2));
|
|
132
|
+
expect(onEvent.mock.calls[0][0]).toEqual({
|
|
133
|
+
type: "report.layout_changed",
|
|
134
|
+
path: "store/front.malloy",
|
|
135
|
+
layout: "grid",
|
|
136
|
+
from: "linear",
|
|
137
|
+
to: "grid",
|
|
138
|
+
});
|
|
139
|
+
expect(onEvent.mock.calls[1][0]).toMatchObject({
|
|
140
|
+
type: "report.saved",
|
|
141
|
+
path: "store/front.malloy",
|
|
142
|
+
layout: "grid",
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
import { afterEach, describe, expect, it, mock } from "bun:test";
|
|
13
13
|
import * as fs from "fs";
|
|
14
14
|
import * as path from "path";
|
|
15
|
-
import {
|
|
15
|
+
import { ReportBuilder } from "./ReportBuilder";
|
|
16
16
|
import { readForEditor } from "./readForEditor";
|
|
17
17
|
import { openDocument } from "./testing/fixtures";
|
|
18
|
-
import type {
|
|
18
|
+
import type { ReportEvent } from "../Report/telemetry";
|
|
19
19
|
import { editInline } from "./testing/inline";
|
|
20
20
|
|
|
21
|
-
const NOTEBOOK = `## artifact {
|
|
21
|
+
const NOTEBOOK = `## artifact { layout=linear title="Review" tiles=[intro { kind=text }, "a -> by_cat"] }
|
|
22
22
|
import "../data_app.malloy"
|
|
23
23
|
|
|
24
24
|
##|(markdown) intro
|
|
@@ -59,7 +59,7 @@ const catalog = {
|
|
|
59
59
|
const REPO = path.resolve(import.meta.dir, "../../../../..");
|
|
60
60
|
const LEGACY = fs
|
|
61
61
|
.readFileSync(
|
|
62
|
-
path.join(REPO, "examples/storefront/
|
|
62
|
+
path.join(REPO, "examples/storefront/category-review.malloy"),
|
|
63
63
|
"utf8",
|
|
64
64
|
)
|
|
65
65
|
.replace(/\r\n/g, "\n");
|
|
@@ -73,12 +73,12 @@ const mountText = async (
|
|
|
73
73
|
source: string,
|
|
74
74
|
options: {
|
|
75
75
|
onSave?: (source: string) => void;
|
|
76
|
-
onEvent?: (event:
|
|
76
|
+
onEvent?: (event: ReportEvent) => void;
|
|
77
77
|
withCatalog?: boolean;
|
|
78
78
|
} = {},
|
|
79
79
|
) =>
|
|
80
80
|
render(
|
|
81
|
-
<
|
|
81
|
+
<ReportBuilder
|
|
82
82
|
source={source}
|
|
83
83
|
document={await openDocument(source)}
|
|
84
84
|
{...(options.withCatalog ? { catalog } : {})}
|
|
@@ -87,7 +87,7 @@ const mountText = async (
|
|
|
87
87
|
/>,
|
|
88
88
|
);
|
|
89
89
|
|
|
90
|
-
describe("
|
|
90
|
+
describe("ReportBuilder: a notebook is one column", () => {
|
|
91
91
|
it("draws its text and description bare, as the notebook reader does", async () => {
|
|
92
92
|
await mountText(NOTEBOOK);
|
|
93
93
|
for (const card of document.querySelectorAll("[data-chrome]"))
|
|
@@ -195,23 +195,24 @@ describe("DashboardBuilder: a notebook is one column", () => {
|
|
|
195
195
|
expect(screen.queryByLabelText("Add tile at the end")).toBeNull();
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
-
it("reports
|
|
199
|
-
const onEvent = mock((_event:
|
|
198
|
+
it("reports a save with the cell count, the path and the linear layout", async () => {
|
|
199
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
200
200
|
await mountText(NOTEBOOK, { onSave: () => {}, onEvent });
|
|
201
201
|
editInline("By cat", "Tile title", "Categories");
|
|
202
202
|
fireEvent.click(button("Save"));
|
|
203
203
|
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
|
|
204
204
|
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
205
|
-
type: "
|
|
206
|
-
|
|
205
|
+
type: "report.saved",
|
|
206
|
+
layout: "linear",
|
|
207
|
+
tiles: 2,
|
|
207
208
|
structural: false,
|
|
208
|
-
converted: false,
|
|
209
209
|
where: "package",
|
|
210
210
|
});
|
|
211
|
+
expect(onEvent.mock.calls[0][0]).not.toHaveProperty("converted");
|
|
211
212
|
});
|
|
212
213
|
});
|
|
213
214
|
|
|
214
|
-
describe("
|
|
215
|
+
describe("ReportBuilder: a document's kind", () => {
|
|
215
216
|
it("is fixed once created: there is no switch between dashboard and notebook", async () => {
|
|
216
217
|
await mountText(DASHBOARD, { onSave: () => {} });
|
|
217
218
|
expect(screen.queryByRole("button", { name: "Settings" })).toBeNull();
|
|
@@ -219,11 +220,11 @@ describe("DashboardBuilder: a document's kind", () => {
|
|
|
219
220
|
});
|
|
220
221
|
});
|
|
221
222
|
|
|
222
|
-
describe("
|
|
223
|
+
describe("ReportBuilder: a notebook in the cell format", () => {
|
|
223
224
|
const open = async (
|
|
224
225
|
options: {
|
|
225
226
|
onSave?: (source: string) => void;
|
|
226
|
-
onEvent?: (event:
|
|
227
|
+
onEvent?: (event: ReportEvent) => void;
|
|
227
228
|
onDirtyChange?: (dirty: boolean) => void;
|
|
228
229
|
} = {},
|
|
229
230
|
) => {
|
|
@@ -231,7 +232,7 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
|
231
232
|
if (result.ok === false) throw new Error(result.reason);
|
|
232
233
|
if (!result.conversion) throw new Error("expected a conversion");
|
|
233
234
|
render(
|
|
234
|
-
<
|
|
235
|
+
<ReportBuilder
|
|
235
236
|
source={LEGACY}
|
|
236
237
|
document={result.document}
|
|
237
238
|
conversion={result.conversion}
|
|
@@ -246,7 +247,7 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
|
246
247
|
await open({ onSave: () => {}, onDirtyChange });
|
|
247
248
|
expect(
|
|
248
249
|
screen.getByText(
|
|
249
|
-
/This
|
|
250
|
+
/This report is in the cell format\. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view\./,
|
|
250
251
|
),
|
|
251
252
|
).toBeDefined();
|
|
252
253
|
expect(button("Save")).toBeDefined();
|
|
@@ -267,7 +268,7 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
|
267
268
|
fireEvent.click(button("Save"));
|
|
268
269
|
expect(
|
|
269
270
|
await screen.findByText(
|
|
270
|
-
/Saving rewrites this
|
|
271
|
+
/Saving rewrites this report in the tile layout/,
|
|
271
272
|
),
|
|
272
273
|
).toBeDefined();
|
|
273
274
|
expect(writes).toHaveLength(0);
|
|
@@ -287,7 +288,7 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
|
287
288
|
|
|
288
289
|
it("saves the conversion exactly as converted", async () => {
|
|
289
290
|
const writes: string[] = [];
|
|
290
|
-
const onEvent = mock((_event:
|
|
291
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
291
292
|
const conversion = await open({
|
|
292
293
|
onSave: (source) => void writes.push(source),
|
|
293
294
|
onEvent,
|
|
@@ -300,11 +301,11 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
|
300
301
|
// Nothing was edited, so the file written is the conversion itself.
|
|
301
302
|
expect(writes[0]).toBe(conversion.to);
|
|
302
303
|
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
303
|
-
type: "
|
|
304
|
+
type: "report.saved",
|
|
304
305
|
converted: true,
|
|
305
306
|
});
|
|
306
307
|
expect(
|
|
307
|
-
screen.queryByText(/This
|
|
308
|
+
screen.queryByText(/This report is in the cell format/),
|
|
308
309
|
).toBeNull();
|
|
309
310
|
});
|
|
310
311
|
});
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
waitFor,
|
|
10
10
|
} from "@testing-library/react";
|
|
11
11
|
import { afterEach, describe, expect, it, mock } from "bun:test";
|
|
12
|
-
import {
|
|
12
|
+
import { ReportBuilder } from "./ReportBuilder";
|
|
13
13
|
import { openDocument } from "./testing/fixtures";
|
|
14
14
|
|
|
15
15
|
const SOURCE = `## artifact { title="Storefront" tiles=["a -> by_cat"] } dashboard { columns=12 }
|
|
@@ -29,7 +29,7 @@ const mount = async (
|
|
|
29
29
|
) => {
|
|
30
30
|
const document = await openDocument(SOURCE);
|
|
31
31
|
return render(
|
|
32
|
-
<
|
|
32
|
+
<ReportBuilder
|
|
33
33
|
source={SOURCE}
|
|
34
34
|
document={document}
|
|
35
35
|
{...(options.onSave ? { onSave: options.onSave } : {})}
|
|
@@ -53,7 +53,7 @@ const type = (field: HTMLElement, value: string) =>
|
|
|
53
53
|
|
|
54
54
|
afterEach(cleanup);
|
|
55
55
|
|
|
56
|
-
describe("
|
|
56
|
+
describe("ReportBuilder: an open inline draft", () => {
|
|
57
57
|
it("is clean again once the committed draft is saved, and stays open", async () => {
|
|
58
58
|
const onDirtyChange = mock((_dirty: boolean) => {});
|
|
59
59
|
const onSave = mock(async (_source: string) => {});
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
within,
|
|
11
11
|
} from "@testing-library/react";
|
|
12
12
|
import { afterEach, describe, expect, it } from "bun:test";
|
|
13
|
-
import {
|
|
13
|
+
import { ReportBuilder } from "./ReportBuilder";
|
|
14
14
|
import { openDocument } from "./testing/fixtures";
|
|
15
15
|
|
|
16
|
-
const NOTEBOOK = `## artifact {
|
|
16
|
+
const NOTEBOOK = `## artifact { layout=linear title="Review" tiles=["a -> by_cat"] }
|
|
17
17
|
import { scoped_orders } from "../data_app.malloy"
|
|
18
18
|
import { spare } from "../spare.malloy"
|
|
19
19
|
|
|
@@ -41,13 +41,17 @@ const catalog = {
|
|
|
41
41
|
],
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
// One folder down, which is what its `../` imports say; `atRoot` is the same
|
|
45
|
+
// report at the package root, reading its models from beside it.
|
|
46
|
+
const AT_ROOT = NOTEBOOK.replace(/"\.\.\//g, '"');
|
|
47
|
+
const mount = async (onSave: (source: string) => void, atRoot = false) =>
|
|
45
48
|
render(
|
|
46
|
-
<
|
|
47
|
-
source={NOTEBOOK}
|
|
48
|
-
document={await openDocument(NOTEBOOK)}
|
|
49
|
+
<ReportBuilder
|
|
50
|
+
source={atRoot ? AT_ROOT : NOTEBOOK}
|
|
51
|
+
document={await openDocument(atRoot ? AT_ROOT : NOTEBOOK)}
|
|
49
52
|
catalog={catalog}
|
|
50
53
|
onSave={onSave}
|
|
54
|
+
modelPath={atRoot ? "review.malloy" : "notebooks/review.malloy"}
|
|
51
55
|
/>,
|
|
52
56
|
);
|
|
53
57
|
|
|
@@ -73,11 +77,11 @@ const addTileOn = (name: string) => {
|
|
|
73
77
|
);
|
|
74
78
|
};
|
|
75
79
|
|
|
76
|
-
const written = async (pick: string) => {
|
|
80
|
+
const written = async (pick: string, atRoot = false) => {
|
|
77
81
|
let text: string | undefined;
|
|
78
82
|
await mount((source) => {
|
|
79
83
|
text = source;
|
|
80
|
-
});
|
|
84
|
+
}, atRoot);
|
|
81
85
|
addTileOn(pick);
|
|
82
86
|
save();
|
|
83
87
|
await waitFor(() => expect(text).toBeDefined());
|
|
@@ -110,6 +114,13 @@ describe("adding a tile brings its source in", () => {
|
|
|
110
114
|
);
|
|
111
115
|
});
|
|
112
116
|
|
|
117
|
+
it("writes the import relative to a report at the package root, with no leading ../", async () => {
|
|
118
|
+
const text = await written("reports", true);
|
|
119
|
+
expect(text).toContain(
|
|
120
|
+
'import { spare } from "spare.malloy"\nimport { reports } from "reports.malloy"\n',
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
113
124
|
it("joins an import of a model that re-exports the source rather than adding another model's", async () => {
|
|
114
125
|
const text = await written("events");
|
|
115
126
|
expect(text).toContain('import { spare, events } from "../spare.malloy"');
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
within,
|
|
11
11
|
} from "@testing-library/react";
|
|
12
12
|
import { describe, expect, it, mock } from "bun:test";
|
|
13
|
-
import type {
|
|
14
|
-
import {
|
|
13
|
+
import type { ReportEvent } from "../Report/telemetry";
|
|
14
|
+
import { ReportBuilder } from "./ReportBuilder";
|
|
15
15
|
import { openDocument } from "./testing/fixtures";
|
|
16
16
|
import { closeMenu, editInline } from "./testing/inline";
|
|
17
17
|
import { dragEdge } from "./testing/resize";
|
|
@@ -31,11 +31,11 @@ source: a is scoped_orders extend {
|
|
|
31
31
|
|
|
32
32
|
const mount = async (
|
|
33
33
|
onSave?: (source: string) => Promise<void> | void,
|
|
34
|
-
onEvent?: (event:
|
|
34
|
+
onEvent?: (event: ReportEvent) => void,
|
|
35
35
|
) => {
|
|
36
36
|
const document = await openDocument(SOURCE);
|
|
37
37
|
return render(
|
|
38
|
-
<
|
|
38
|
+
<ReportBuilder
|
|
39
39
|
source={SOURCE}
|
|
40
40
|
document={document}
|
|
41
41
|
{...(onSave ? { onSave } : {})}
|
|
@@ -101,7 +101,7 @@ const itemStyleOf = (name: string): string => {
|
|
|
101
101
|
return declarations.join(" ");
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
describe("
|
|
104
|
+
describe("ReportBuilder", () => {
|
|
105
105
|
it("shows a tile per entry, titled as a reader would see it", async () => {
|
|
106
106
|
await mount();
|
|
107
107
|
// The labelled tile shows its label; the unlabelled one falls back to the
|
|
@@ -155,7 +155,7 @@ describe("DashboardBuilder", () => {
|
|
|
155
155
|
it("hands the whole tile to renderTile, adding no heading of its own", async () => {
|
|
156
156
|
const document = await openDocument(SOURCE);
|
|
157
157
|
render(
|
|
158
|
-
<
|
|
158
|
+
<ReportBuilder
|
|
159
159
|
source={SOURCE}
|
|
160
160
|
document={document}
|
|
161
161
|
renderTile={(each) => <article>a real {each.name}</article>}
|
|
@@ -173,7 +173,7 @@ describe("DashboardBuilder", () => {
|
|
|
173
173
|
it("marks selection without resizing the tile", async () => {
|
|
174
174
|
const document = await openDocument(SOURCE);
|
|
175
175
|
render(
|
|
176
|
-
<
|
|
176
|
+
<ReportBuilder
|
|
177
177
|
source={SOURCE}
|
|
178
178
|
document={document}
|
|
179
179
|
renderTile={(each) => <article>a real {each.name}</article>}
|
|
@@ -205,11 +205,11 @@ describe("DashboardBuilder", () => {
|
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
207
|
|
|
208
|
-
describe("
|
|
208
|
+
describe("ReportBuilder: the dashboard's filters", () => {
|
|
209
209
|
// The convention, end to end through the surface: a filter added here is a
|
|
210
210
|
// declaration in THIS file plus a binding on each ticked tile, and the save
|
|
211
211
|
// writes exactly that.
|
|
212
|
-
it("adds a filter declared in this
|
|
212
|
+
it("adds a filter declared in this report and writes it to the file", async () => {
|
|
213
213
|
let written: string | undefined;
|
|
214
214
|
await mount((source) => {
|
|
215
215
|
written = source;
|
|
@@ -255,7 +255,7 @@ describe("DashboardBuilder: the dashboard's filters", () => {
|
|
|
255
255
|
let written: string | undefined;
|
|
256
256
|
const document = await openDocument(SOURCE);
|
|
257
257
|
render(
|
|
258
|
-
<
|
|
258
|
+
<ReportBuilder
|
|
259
259
|
source={SOURCE}
|
|
260
260
|
document={document}
|
|
261
261
|
givens={[
|
|
@@ -295,7 +295,7 @@ describe("DashboardBuilder: the dashboard's filters", () => {
|
|
|
295
295
|
);
|
|
296
296
|
const document = await openDocument(source);
|
|
297
297
|
render(
|
|
298
|
-
<
|
|
298
|
+
<ReportBuilder
|
|
299
299
|
source={source}
|
|
300
300
|
document={document}
|
|
301
301
|
onSave={(next) => {
|
|
@@ -319,7 +319,7 @@ describe("DashboardBuilder: the dashboard's filters", () => {
|
|
|
319
319
|
);
|
|
320
320
|
const document = await openDocument(source);
|
|
321
321
|
render(
|
|
322
|
-
<
|
|
322
|
+
<ReportBuilder
|
|
323
323
|
source={source}
|
|
324
324
|
document={document}
|
|
325
325
|
onSave={(next) => {
|
|
@@ -346,7 +346,7 @@ describe("DashboardBuilder: the dashboard's filters", () => {
|
|
|
346
346
|
});
|
|
347
347
|
});
|
|
348
348
|
|
|
349
|
-
describe("
|
|
349
|
+
describe("ReportBuilder: fields, when the package is known", () => {
|
|
350
350
|
const catalog = {
|
|
351
351
|
sources: [
|
|
352
352
|
{
|
|
@@ -378,7 +378,7 @@ describe("DashboardBuilder: fields, when the package is known", () => {
|
|
|
378
378
|
const mountWithCatalog = async () => {
|
|
379
379
|
const document = await openDocument(SOURCE);
|
|
380
380
|
return render(
|
|
381
|
-
<
|
|
381
|
+
<ReportBuilder
|
|
382
382
|
source={SOURCE}
|
|
383
383
|
document={document}
|
|
384
384
|
catalog={catalog}
|
|
@@ -449,7 +449,7 @@ describe("DashboardBuilder: fields, when the package is known", () => {
|
|
|
449
449
|
);
|
|
450
450
|
const document = await openDocument(source);
|
|
451
451
|
render(
|
|
452
|
-
<
|
|
452
|
+
<ReportBuilder
|
|
453
453
|
source={source}
|
|
454
454
|
document={document}
|
|
455
455
|
catalog={catalog}
|
|
@@ -460,7 +460,7 @@ describe("DashboardBuilder: fields, when the package is known", () => {
|
|
|
460
460
|
});
|
|
461
461
|
});
|
|
462
462
|
|
|
463
|
-
describe("
|
|
463
|
+
describe("ReportBuilder: a control the model declares", () => {
|
|
464
464
|
// Its declaration is not ours to delete, but a control is a given some tile
|
|
465
465
|
// binds, so taking it off the dashboard is unbinding every tile.
|
|
466
466
|
it("can still be taken off the dashboard", async () => {
|
|
@@ -481,7 +481,7 @@ describe("DashboardBuilder: a control the model declares", () => {
|
|
|
481
481
|
});
|
|
482
482
|
});
|
|
483
483
|
|
|
484
|
-
describe("
|
|
484
|
+
describe("ReportBuilder: tiles added and removed", () => {
|
|
485
485
|
// A catalog whose source the fixture's extension is built on, with a view
|
|
486
486
|
// to put on the page. `scoped_orders` is reachable because `a` extends it.
|
|
487
487
|
const catalogWithViews = {
|
|
@@ -504,7 +504,7 @@ describe("DashboardBuilder: tiles added and removed", () => {
|
|
|
504
504
|
const mountWithCatalog = async (onSave: (source: string) => void) => {
|
|
505
505
|
const document = await openDocument(SOURCE);
|
|
506
506
|
return render(
|
|
507
|
-
<
|
|
507
|
+
<ReportBuilder
|
|
508
508
|
source={SOURCE}
|
|
509
509
|
document={document}
|
|
510
510
|
catalog={catalogWithViews}
|
|
@@ -562,7 +562,7 @@ describe("DashboardBuilder: tiles added and removed", () => {
|
|
|
562
562
|
});
|
|
563
563
|
});
|
|
564
564
|
|
|
565
|
-
describe("
|
|
565
|
+
describe("ReportBuilder: the last tile", () => {
|
|
566
566
|
it("cannot be removed while the saved dashboard has tiles, and says why on screen", async () => {
|
|
567
567
|
await mount();
|
|
568
568
|
fireEvent.click(screen.getByLabelText("Settings for By category"));
|
|
@@ -571,7 +571,7 @@ describe("DashboardBuilder: the last tile", () => {
|
|
|
571
571
|
const remove = screen.getByRole("button", { name: /^Delete/ });
|
|
572
572
|
expect(remove.getAttribute("aria-disabled")).toBe("true");
|
|
573
573
|
const reason = screen.getByText(
|
|
574
|
-
"A saved
|
|
574
|
+
"A saved report needs at least one tile.",
|
|
575
575
|
);
|
|
576
576
|
expect(remove.getAttribute("aria-describedby")).toBe(reason.id);
|
|
577
577
|
fireEvent.click(remove);
|
|
@@ -579,7 +579,7 @@ describe("DashboardBuilder: the last tile", () => {
|
|
|
579
579
|
});
|
|
580
580
|
});
|
|
581
581
|
|
|
582
|
-
describe("
|
|
582
|
+
describe("ReportBuilder: a tile's own settings", () => {
|
|
583
583
|
it("retitles a tile where it is shown, one history entry per commit", async () => {
|
|
584
584
|
await mount();
|
|
585
585
|
editInline("By category", "Tile title", "Revenue by category");
|
|
@@ -606,7 +606,7 @@ describe("DashboardBuilder: a tile's own settings", () => {
|
|
|
606
606
|
it("offers no title to a tile the model owns", async () => {
|
|
607
607
|
const source = `## artifact { title="T" tiles=["orders -> by_brand"] }\nimport { orders } from '../orders.malloy'`;
|
|
608
608
|
const document = await openDocument(source);
|
|
609
|
-
render(<
|
|
609
|
+
render(<ReportBuilder source={source} document={document} />);
|
|
610
610
|
fireEvent.click(screen.getByLabelText("Settings for by_brand"));
|
|
611
611
|
expect(screen.queryByLabelText("Tile title")).toBeNull();
|
|
612
612
|
expect(screen.getByText(/Declared on its source/)).toBeDefined();
|
|
@@ -616,7 +616,7 @@ describe("DashboardBuilder: a tile's own settings", () => {
|
|
|
616
616
|
});
|
|
617
617
|
});
|
|
618
618
|
|
|
619
|
-
describe("
|
|
619
|
+
describe("ReportBuilder: widths and the page's own settings", () => {
|
|
620
620
|
it("steps a tile's width from the keyboard on its edge, one undo step each", async () => {
|
|
621
621
|
await mount();
|
|
622
622
|
const edge = screen.getByRole("separator", {
|
|
@@ -659,7 +659,7 @@ describe("DashboardBuilder: widths and the page's own settings", () => {
|
|
|
659
659
|
fireEvent.keyDown(description, { key: "Escape" });
|
|
660
660
|
expect(screen.getByText("What sold, and where.")).toBeDefined();
|
|
661
661
|
|
|
662
|
-
editInline("Storefront", "
|
|
662
|
+
editInline("Storefront", "Report title", "Storefront, weekly");
|
|
663
663
|
expect(screen.getByText("Storefront, weekly")).toBeDefined();
|
|
664
664
|
|
|
665
665
|
fireEvent.click(button("Save"));
|
|
@@ -675,7 +675,7 @@ describe("DashboardBuilder: widths and the page's own settings", () => {
|
|
|
675
675
|
});
|
|
676
676
|
});
|
|
677
677
|
|
|
678
|
-
describe("
|
|
678
|
+
describe("ReportBuilder: clickable cells", () => {
|
|
679
679
|
const WITH_DIMENSION = `## artifact { title="T" tiles=["a -> x"] } dashboard { columns=12 }
|
|
680
680
|
import "../data_app.malloy"
|
|
681
681
|
|
|
@@ -691,7 +691,7 @@ source: a is scoped_orders extend {
|
|
|
691
691
|
let saved = "";
|
|
692
692
|
const doc = await openDocument(WITH_DIMENSION);
|
|
693
693
|
render(
|
|
694
|
-
<
|
|
694
|
+
<ReportBuilder
|
|
695
695
|
source={WITH_DIMENSION}
|
|
696
696
|
document={doc}
|
|
697
697
|
dashboards={["regions"]}
|
|
@@ -708,7 +708,7 @@ source: a is scoped_orders extend {
|
|
|
708
708
|
screen.getByRole("combobox", { name: /Clicks go to/, hidden: true }),
|
|
709
709
|
);
|
|
710
710
|
fireEvent.click(
|
|
711
|
-
screen.getByRole("option", { name: /This
|
|
711
|
+
screen.getByRole("option", { name: /This report/, hidden: true }),
|
|
712
712
|
);
|
|
713
713
|
fireEvent.click(
|
|
714
714
|
screen.getByRole("option", { name: /regions/, hidden: true }),
|
|
@@ -745,7 +745,7 @@ source: a is scoped_orders extend {
|
|
|
745
745
|
});
|
|
746
746
|
});
|
|
747
747
|
|
|
748
|
-
describe("
|
|
748
|
+
describe("ReportBuilder: keyboard", () => {
|
|
749
749
|
it("undoes and redoes from the keyboard, and never from inside a text field", async () => {
|
|
750
750
|
await mount();
|
|
751
751
|
retitle("By category", "Renamed");
|
|
@@ -804,7 +804,7 @@ describe("DashboardBuilder: keyboard", () => {
|
|
|
804
804
|
});
|
|
805
805
|
});
|
|
806
806
|
|
|
807
|
-
describe("
|
|
807
|
+
describe("ReportBuilder: history", () => {
|
|
808
808
|
it("enables undo only once there is something to undo", async () => {
|
|
809
809
|
await mount();
|
|
810
810
|
expect(button("Undo")).toHaveProperty("disabled", true);
|
|
@@ -825,7 +825,7 @@ describe("DashboardBuilder: history", () => {
|
|
|
825
825
|
});
|
|
826
826
|
});
|
|
827
827
|
|
|
828
|
-
describe("
|
|
828
|
+
describe("ReportBuilder: saving", () => {
|
|
829
829
|
it("offers no save button when there is nowhere to save", async () => {
|
|
830
830
|
await mount();
|
|
831
831
|
expect(screen.queryByRole("button", { name: /Save|Saved/ })).toBeNull();
|
|
@@ -833,7 +833,7 @@ describe("DashboardBuilder: saving", () => {
|
|
|
833
833
|
|
|
834
834
|
it("writes the change into the file, comment and all, and says so", async () => {
|
|
835
835
|
let written: string | undefined;
|
|
836
|
-
const onEvent = mock((_event:
|
|
836
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
837
837
|
await mount((source) => {
|
|
838
838
|
written = source;
|
|
839
839
|
}, onEvent);
|
|
@@ -855,7 +855,7 @@ describe("DashboardBuilder: saving", () => {
|
|
|
855
855
|
await waitFor(() => expect(button("Saved")).toBeDefined());
|
|
856
856
|
expect(onEvent).toHaveBeenCalledTimes(1);
|
|
857
857
|
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
858
|
-
type: "
|
|
858
|
+
type: "report.saved",
|
|
859
859
|
tiles: 2,
|
|
860
860
|
structural: false,
|
|
861
861
|
// Where it went: a save into the package is a change every reader of
|
|
@@ -869,7 +869,7 @@ describe("DashboardBuilder: saving", () => {
|
|
|
869
869
|
// The rule the writer rests on, shown through the surface: the work stays on
|
|
870
870
|
// screen and the reason is visible.
|
|
871
871
|
it("keeps the edit on screen when a save is refused, and says why", async () => {
|
|
872
|
-
const onEvent = mock((_event:
|
|
872
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
873
873
|
await mount(() => {
|
|
874
874
|
throw new Error("disk full");
|
|
875
875
|
}, onEvent);
|
|
@@ -880,7 +880,7 @@ describe("DashboardBuilder: saving", () => {
|
|
|
880
880
|
expect(screen.getByRole("alert").textContent).toContain("disk full"),
|
|
881
881
|
);
|
|
882
882
|
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
883
|
-
type: "
|
|
883
|
+
type: "report.save_refused",
|
|
884
884
|
reason: expect.stringContaining("disk full"),
|
|
885
885
|
});
|
|
886
886
|
// The edit is still on screen and still unsaved.
|