@malloy-publisher/sdk 0.9.9 → 0.9.11
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-BlNoIiSi.cjs.js +153 -0
- package/dist/{RenderedResult-BHuJpdSn.es.js → RenderedResult-Cmx8sX8d.es.js} +102 -102
- package/dist/ServerProvider-BOgiW8MX.cjs.js +1 -0
- package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-azXLkk1q.es.js} +619 -586
- package/dist/builder/index.cjs.js +78 -130
- package/dist/builder/index.es.js +7440 -6727
- package/dist/builder-entry.d.ts +3 -0
- package/dist/client/api.d.ts +26 -22
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +9 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
- package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
- package/dist/components/Dashboard/DashboardView.d.ts +22 -23
- package/dist/components/Dashboard/TileCard.d.ts +10 -3
- package/dist/components/Dashboard/useStuck.d.ts +22 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -5
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
- package/dist/components/Package/PackageProblems.d.ts +14 -0
- package/dist/components/RemoveBadge.d.ts +40 -0
- package/dist/components/Report/Report.d.ts +13 -4
- package/dist/components/Report/ReportPage.d.ts +60 -0
- package/dist/components/Report/layoutRules.d.ts +32 -0
- package/dist/components/Report/reportQuery.d.ts +30 -0
- package/dist/components/Report/telemetry.d.ts +0 -2
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
- package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
- package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
- package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
- package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
- package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -6
- package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
- package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
- package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
- package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
- package/dist/components/ReportBuilder/TileMenu.d.ts +19 -11
- package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
- package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
- package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
- package/dist/components/ReportBuilder/catalog.d.ts +2 -4
- package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
- package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
- package/dist/components/ReportBuilder/preview.d.ts +17 -2
- package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
- package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
- package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
- package/dist/components/ReportBuilder/sortable.d.ts +4 -3
- package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
- package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
- package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
- package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
- package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
- package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
- package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
- package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
- package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
- package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
- package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
- package/dist/components/ServerProvider.d.ts +9 -0
- package/dist/components/controlTokens.d.ts +45 -0
- package/dist/components/drill/markDrillableCells.d.ts +1 -1
- package/dist/components/given/FilterButton.d.ts +35 -0
- package/dist/components/given/GivensPanel.d.ts +2 -1
- package/dist/components/given/filterEditing.d.ts +54 -0
- package/dist/components/given/filterSummary.d.ts +9 -0
- package/dist/components/given/paramCodec.d.ts +11 -0
- package/dist/components/given/required.d.ts +25 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/legacy/index.d.ts +1 -1
- package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
- package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
- package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
- package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
- package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
- package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
- package/dist/components/styles.d.ts +0 -2
- package/dist/hooks/useQueryResult.d.ts +7 -0
- package/dist/index.cjs.js +16 -19
- package/dist/index.es.js +8324 -7769
- package/dist/theme/ThemeContext.d.ts +8 -1
- package/dist/theme/classes.d.ts +49 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/ui.d.ts +75 -0
- package/dist/{useCompiledDocument-1dgF5CC9.es.js → useCompiledDocument-7j5cBjQd.es.js} +8768 -7912
- package/dist/useCompiledDocument-B21sVbb4.cjs.js +141 -0
- package/package.json +2 -2
- package/src/builder-entry.ts +9 -0
- package/src/components/AppDialog.tsx +23 -0
- package/src/components/Dashboard/DashboardGrid.tsx +39 -17
- package/src/components/Dashboard/DashboardTile.tsx +19 -2
- package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
- package/src/components/Dashboard/DashboardView.tsx +136 -105
- package/src/components/Dashboard/RowsDialog.tsx +1 -2
- package/src/components/Dashboard/TileCard.tsx +28 -10
- package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
- package/src/components/Dashboard/useStuck.ts +49 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +8 -6
- package/src/components/DocumentCreate/newNotebook.ts +26 -12
- package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
- package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
- package/src/components/Package/NewDocumentDialog.tsx +383 -119
- package/src/components/Package/Package.artifacts.spec.tsx +1 -1
- package/src/components/Package/Package.create.spec.tsx +7 -6
- package/src/components/Package/Package.tsx +10 -7
- package/src/components/Package/PackageProblems.spec.tsx +41 -0
- package/src/components/Package/PackageProblems.tsx +95 -0
- package/src/components/Prose.tsx +12 -7
- package/src/components/RemoveBadge.tsx +94 -0
- package/src/components/RenderedResult/RenderedResult.tsx +5 -9
- package/src/components/RenderedResult/ResultPanel.tsx +59 -3
- package/src/components/Report/Report.spec.tsx +50 -32
- package/src/components/Report/Report.telemetry.spec.tsx +0 -45
- package/src/components/Report/Report.tsx +45 -77
- package/src/components/Report/ReportPage.tsx +168 -0
- package/src/components/Report/layoutRules.spec.ts +35 -0
- package/src/components/Report/layoutRules.ts +55 -0
- package/src/components/Report/reportQuery.ts +53 -0
- package/src/components/Report/telemetry.ts +0 -2
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
- package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
- package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
- package/src/components/ReportBuilder/BuilderDialogs.tsx +30 -39
- package/src/components/ReportBuilder/BuilderGrid.tsx +43 -31
- package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
- package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
- package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
- package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
- package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
- package/src/components/ReportBuilder/FilterStrip.tsx +129 -150
- package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
- package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -16
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
- package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
- package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +41 -36
- package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
- package/src/components/ReportBuilder/ReportBuilder.tsx +292 -116
- package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
- package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
- package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
- package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
- package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
- package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
- package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
- package/src/components/ReportBuilder/TileFrame.tsx +212 -75
- package/src/components/ReportBuilder/TileMenu.tsx +248 -142
- package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
- package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
- package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
- package/src/components/ReportBuilder/builderControls.ts +164 -0
- package/src/components/ReportBuilder/builderReport.ts +1 -2
- package/src/components/ReportBuilder/catalog.ts +10 -26
- package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
- package/src/components/ReportBuilder/localGiven.ts +56 -0
- package/src/components/ReportBuilder/newDashboard.spec.ts +2 -3
- package/src/components/ReportBuilder/preview.spec.ts +125 -5
- package/src/components/ReportBuilder/preview.ts +60 -44
- package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
- package/src/components/ReportBuilder/readDocument.ts +14 -11
- package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
- package/src/components/ReportBuilder/readForEditor.ts +4 -26
- package/src/components/ReportBuilder/reportTag.ts +28 -7
- package/src/components/ReportBuilder/sortable.tsx +15 -7
- package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
- package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
- package/src/components/ReportBuilder/testing/inline.ts +25 -5
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
- package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
- package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
- package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
- package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
- package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
- package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
- package/src/components/ReportBuilder/useExitGuard.ts +16 -0
- package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
- package/src/components/ReportBuilder/useFilterForm.ts +5 -1
- package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
- package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
- package/src/components/ReportBuilder/useReportDraft.ts +292 -0
- package/src/components/ReportBuilder/useReportEditor.ts +3 -12
- package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
- package/src/components/ReportBuilder/useTileEditing.ts +43 -12
- package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
- package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
- package/src/components/ReportBuilder/widthLabel.ts +26 -0
- package/src/components/ServerProvider.tsx +11 -0
- package/src/components/controlTokens.ts +47 -0
- package/src/components/drill/markDrillableCells.ts +2 -1
- package/src/components/given/FilterButton.spec.tsx +143 -0
- package/src/components/given/FilterButton.tsx +478 -0
- package/src/components/given/GivenInput.spec.tsx +47 -0
- package/src/components/given/GivenInput.tsx +20 -2
- package/src/components/given/GivensPanel.spec.tsx +11 -3
- package/src/components/given/GivensPanel.tsx +45 -44
- package/src/components/given/filterEditing.ts +60 -0
- package/src/components/given/filterSummary.spec.ts +108 -0
- package/src/components/given/filterSummary.ts +109 -0
- package/src/components/given/paramCodec.ts +1 -1
- package/src/components/given/required.spec.ts +60 -0
- package/src/components/given/required.ts +78 -0
- package/src/components/index.ts +9 -0
- package/src/components/legacy/Dashboard.spec.tsx +3 -1
- package/src/components/legacy/index.ts +1 -1
- package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
- package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
- package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
- package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
- package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
- package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
- package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
- package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
- package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
- package/src/components/legacy/malloynb/cellKind.ts +24 -0
- package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
- package/src/components/styles.ts +0 -18
- package/src/hooks/useGivensState.ts +7 -3
- package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
- package/src/hooks/useQueryResult.ts +26 -1
- package/src/theme/ThemeContext.tsx +21 -1
- package/src/theme/classes.ts +52 -0
- package/src/theme/index.ts +8 -0
- package/src/theme/resolveTheme.ts +3 -0
- package/src/theme/types.ts +7 -0
- package/src/theme/ui.spec.tsx +91 -0
- package/src/theme/ui.ts +115 -0
- package/dist/RenderedResult-Bw7EQc42.cjs.js +0 -153
- package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
- package/dist/components/Notebook/cellKind.d.ts +0 -20
- package/dist/components/Report/LinearReport.d.ts +0 -18
- package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
- package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
- package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
- package/dist/useCompiledDocument-BKyRnXmA.cjs.js +0 -141
- package/src/components/Notebook/cellKind.spec.ts +0 -199
- package/src/components/Notebook/cellKind.ts +0 -74
- package/src/components/Report/LinearReport.tsx +0 -71
- package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
- package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
- package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
- package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
- package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
- package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
- package/src/components/legacy/Notebook.served.spec.tsx +0 -183
- /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
|
@@ -18,6 +18,8 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
|
18
18
|
import { Database, type AgentSummary } from "../../client";
|
|
19
19
|
import { useNarrowScreen } from "../../hooks/useNarrowScreen";
|
|
20
20
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
21
|
+
import { AddButton } from "../buttons";
|
|
22
|
+
import { PackageProblems } from "./PackageProblems";
|
|
21
23
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
22
24
|
import { Loading } from "../Loading";
|
|
23
25
|
import { chooseWorkspace } from "../ReportBuilder/documentSession";
|
|
@@ -362,6 +364,8 @@ export default function Package({
|
|
|
362
364
|
)}
|
|
363
365
|
</Box>
|
|
364
366
|
|
|
367
|
+
<PackageProblems warnings={pkgQuery.data?.data?.warnings} />
|
|
368
|
+
|
|
365
369
|
{isLoading && <Loading text="Loading package..." />}
|
|
366
370
|
|
|
367
371
|
{createTarget && (
|
|
@@ -438,14 +442,13 @@ export default function Package({
|
|
|
438
442
|
count={artifacts.length}
|
|
439
443
|
{...(canNew
|
|
440
444
|
? {
|
|
445
|
+
// The section heading's add button, as every
|
|
446
|
+
// other section's: "+ Report".
|
|
441
447
|
action: (
|
|
442
|
-
<
|
|
443
|
-
|
|
444
|
-
size="small"
|
|
448
|
+
<AddButton
|
|
449
|
+
label="Report"
|
|
445
450
|
onClick={() => setCreating(true)}
|
|
446
|
-
|
|
447
|
-
New report
|
|
448
|
-
</Button>
|
|
451
|
+
/>
|
|
449
452
|
),
|
|
450
453
|
}
|
|
451
454
|
: {})}
|
|
@@ -456,7 +459,7 @@ export default function Package({
|
|
|
456
459
|
{...(canNew
|
|
457
460
|
? {
|
|
458
461
|
action: {
|
|
459
|
-
label: "
|
|
462
|
+
label: "Add report",
|
|
460
463
|
onClick: () => setCreating(true),
|
|
461
464
|
},
|
|
462
465
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
6
|
+
import { PackageProblems } from "./PackageProblems";
|
|
7
|
+
|
|
8
|
+
const KIND_REMOVED = {
|
|
9
|
+
model: "notebooks/overview.malloy",
|
|
10
|
+
code: "report-kind-removed",
|
|
11
|
+
severity: "error" as const,
|
|
12
|
+
message:
|
|
13
|
+
"Line 11: `kind=notebook` is no longer read, so this file is not a report.",
|
|
14
|
+
};
|
|
15
|
+
const NOTE = {
|
|
16
|
+
model: "old.malloynb",
|
|
17
|
+
code: "deprecated-malloynb-notebook",
|
|
18
|
+
severity: "warn" as const,
|
|
19
|
+
message: "A .malloynb notebook is deprecated.",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe("PackageProblems", () => {
|
|
23
|
+
it("draws nothing for a clean package", () => {
|
|
24
|
+
const { container } = render(<PackageProblems warnings={undefined} />);
|
|
25
|
+
expect(container.textContent).toBe("");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("says why a file is not a report, naming the file", () => {
|
|
29
|
+
render(<PackageProblems warnings={[KIND_REMOVED]} />);
|
|
30
|
+
expect(screen.getByText("1 problem in this package")).toBeDefined();
|
|
31
|
+
expect(screen.getByText("notebooks/overview.malloy")).toBeDefined();
|
|
32
|
+
expect(screen.getByText(/is no longer read/)).toBeDefined();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("folds warn-level findings away until asked", () => {
|
|
36
|
+
render(<PackageProblems warnings={[KIND_REMOVED, NOTE]} />);
|
|
37
|
+
expect(screen.queryByText(/is deprecated/)).toBeNull();
|
|
38
|
+
fireEvent.click(screen.getByRole("button", { name: "Show 1 note" }));
|
|
39
|
+
expect(screen.getByText(/is deprecated/)).toBeDefined();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Alert,
|
|
6
|
+
AlertTitle,
|
|
7
|
+
Box,
|
|
8
|
+
Button,
|
|
9
|
+
Stack,
|
|
10
|
+
Typography,
|
|
11
|
+
} from "@mui/material";
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
import type { PackageWarningsInner } from "../../client";
|
|
14
|
+
import { MONO_FONT_FAMILY } from "../styles";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* What the server found wrong with a package when it loaded it, on the
|
|
18
|
+
* package page.
|
|
19
|
+
*
|
|
20
|
+
* Without it a broken file simply moved: a report whose artifact tag the
|
|
21
|
+
* server no longer reads stopped listing under Reports and listed under
|
|
22
|
+
* Models instead, with nothing on the page saying why. Errors (a file that
|
|
23
|
+
* should have been a report and is not, a tile that cannot load) are shown;
|
|
24
|
+
* `warn` findings, which still work, are counted and folded away.
|
|
25
|
+
*/
|
|
26
|
+
export function PackageProblems({
|
|
27
|
+
warnings,
|
|
28
|
+
}: {
|
|
29
|
+
warnings: PackageWarningsInner[] | undefined;
|
|
30
|
+
}) {
|
|
31
|
+
const [showNotes, setShowNotes] = useState(false);
|
|
32
|
+
const errors = (warnings ?? []).filter((w) => w.severity === "error");
|
|
33
|
+
const notes = (warnings ?? []).filter((w) => w.severity !== "error");
|
|
34
|
+
if (errors.length === 0 && notes.length === 0) return null;
|
|
35
|
+
return (
|
|
36
|
+
<Stack sx={{ gap: 1, mb: 4 }}>
|
|
37
|
+
{errors.length > 0 && (
|
|
38
|
+
<Alert severity="warning">
|
|
39
|
+
<AlertTitle>
|
|
40
|
+
{errors.length === 1
|
|
41
|
+
? "1 problem in this package"
|
|
42
|
+
: `${errors.length} problems in this package`}
|
|
43
|
+
</AlertTitle>
|
|
44
|
+
<FindingList findings={errors} />
|
|
45
|
+
</Alert>
|
|
46
|
+
)}
|
|
47
|
+
{notes.length > 0 && (
|
|
48
|
+
<Box>
|
|
49
|
+
<Button
|
|
50
|
+
size="small"
|
|
51
|
+
aria-expanded={showNotes}
|
|
52
|
+
onClick={() => setShowNotes((open) => !open)}
|
|
53
|
+
sx={{ px: 0.5, color: "text.secondary" }}
|
|
54
|
+
>
|
|
55
|
+
{showNotes ? "Hide" : "Show"} {notes.length}{" "}
|
|
56
|
+
{notes.length === 1 ? "note" : "notes"}
|
|
57
|
+
</Button>
|
|
58
|
+
{showNotes && (
|
|
59
|
+
<Box sx={{ pl: 0.5, pt: 0.5 }}>
|
|
60
|
+
<FindingList findings={notes} />
|
|
61
|
+
</Box>
|
|
62
|
+
)}
|
|
63
|
+
</Box>
|
|
64
|
+
)}
|
|
65
|
+
</Stack>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function FindingList({ findings }: { findings: PackageWarningsInner[] }) {
|
|
70
|
+
return (
|
|
71
|
+
<Stack component="ul" sx={{ m: 0, p: 0, listStyle: "none", gap: 0.75 }}>
|
|
72
|
+
{findings.map((finding, index) => (
|
|
73
|
+
<Typography
|
|
74
|
+
component="li"
|
|
75
|
+
key={`${finding.model ?? ""}:${finding.code ?? ""}:${index}`}
|
|
76
|
+
variant="body2"
|
|
77
|
+
>
|
|
78
|
+
{finding.model && (
|
|
79
|
+
<Box
|
|
80
|
+
component="span"
|
|
81
|
+
sx={{
|
|
82
|
+
fontFamily: MONO_FONT_FAMILY,
|
|
83
|
+
fontSize: "0.85em",
|
|
84
|
+
mr: 1,
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
{finding.model}
|
|
88
|
+
</Box>
|
|
89
|
+
)}
|
|
90
|
+
{finding.message}
|
|
91
|
+
</Typography>
|
|
92
|
+
))}
|
|
93
|
+
</Stack>
|
|
94
|
+
);
|
|
95
|
+
}
|
package/src/components/Prose.tsx
CHANGED
|
@@ -5,8 +5,10 @@ import { Box, type SxProps, type Theme } from "@mui/material";
|
|
|
5
5
|
import Markdown from "markdown-to-jsx";
|
|
6
6
|
import type { ReactNode } from "react";
|
|
7
7
|
import { usePublisherTheme } from "../theme/ThemeContext";
|
|
8
|
+
import type { ReportUi } from "../theme/ui";
|
|
8
9
|
import type { NavigationClick } from "./click_helper";
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
import { PROSE_MAX_WIDTH } from "./controlTokens";
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Markdown authored inside a package — a dashboard's `##"` description, a
|
|
@@ -119,7 +121,8 @@ function ProseLink({
|
|
|
119
121
|
);
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
|
|
124
|
+
/** Each variant's styles, set in the host's prose type (`ui.type.prose`). */
|
|
125
|
+
const stylesFor = (ui: ReportUi): Record<ProseVariant, SxProps<Theme>> => ({
|
|
123
126
|
document: {
|
|
124
127
|
// Flush at both ends, as a caption is: the space around a block of
|
|
125
128
|
// prose is the layout's (the gap between tiles), not its first and last
|
|
@@ -136,11 +139,13 @@ const STYLES: Record<ProseVariant, SxProps<Theme>> = {
|
|
|
136
139
|
"& h1": { fontSize: "28px" },
|
|
137
140
|
"& h2": { fontSize: "24px" },
|
|
138
141
|
"& h3": { fontSize: "20px" },
|
|
142
|
+
// A readable line rather than the grid's width: prose ran 180
|
|
143
|
+
// characters across a wide tile, too long to read.
|
|
139
144
|
"& p, & ul, & ol": {
|
|
140
145
|
color: "text.primary",
|
|
141
|
-
|
|
146
|
+
...ui.type.prose,
|
|
142
147
|
mb: 1,
|
|
143
|
-
|
|
148
|
+
maxWidth: PROSE_MAX_WIDTH,
|
|
144
149
|
},
|
|
145
150
|
"& li": { mb: 0.5 },
|
|
146
151
|
},
|
|
@@ -161,9 +166,9 @@ const STYLES: Record<ProseVariant, SxProps<Theme>> = {
|
|
|
161
166
|
},
|
|
162
167
|
"& p": { m: "0.5em 0" },
|
|
163
168
|
"& ul, & ol": { m: "0.5em 0", pl: 3 },
|
|
164
|
-
"& code": { fontFamily:
|
|
169
|
+
"& code": { fontFamily: ui.font.mono, fontSize: "0.9em" },
|
|
165
170
|
},
|
|
166
|
-
};
|
|
171
|
+
});
|
|
167
172
|
|
|
168
173
|
function ProseImageAlt({ alt }: { alt?: string }) {
|
|
169
174
|
return <>{alt}</>;
|
|
@@ -181,7 +186,7 @@ export function Prose({
|
|
|
181
186
|
return (
|
|
182
187
|
<Box
|
|
183
188
|
sx={[
|
|
184
|
-
|
|
189
|
+
stylesFor(theme.ui)[variant],
|
|
185
190
|
// After the variant: `caption`'s `typography: body2` sets a face too.
|
|
186
191
|
{ fontFamily: theme.font.family },
|
|
187
192
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
5
|
+
import { IconButton, Tooltip } from "@mui/material";
|
|
6
|
+
import { MOTION_FAST, reducedMotionSx } from "../theme/motion";
|
|
7
|
+
import { usePublisherTheme } from "../theme/ThemeContext";
|
|
8
|
+
import { edgeColor, hoverEdgeColor } from "./controlTokens";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The class on a remove badge. Its container shows it while hovered or
|
|
12
|
+
* focused: `"& .remove-badge": { opacity: 0 }` and
|
|
13
|
+
* `"&:hover .remove-badge, &:focus-within .remove-badge": { opacity: 1 }`,
|
|
14
|
+
* as {@link removeBadgeRevealSx} writes.
|
|
15
|
+
*/
|
|
16
|
+
export const REMOVE_BADGE_CLASS = "remove-badge";
|
|
17
|
+
|
|
18
|
+
/** The container rules that reveal its remove badge on hover and focus, and always on touch. */
|
|
19
|
+
export const removeBadgeRevealSx = {
|
|
20
|
+
[`& .${REMOVE_BADGE_CLASS}`]: { opacity: 0 },
|
|
21
|
+
[`&:hover .${REMOVE_BADGE_CLASS}, &:focus-within .${REMOVE_BADGE_CLASS}`]: {
|
|
22
|
+
opacity: 1,
|
|
23
|
+
},
|
|
24
|
+
"@media (hover: none)": {
|
|
25
|
+
[`& .${REMOVE_BADGE_CLASS}`]: { opacity: 1 },
|
|
26
|
+
},
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Take something off the page: a small round × on its top-right corner. The
|
|
31
|
+
* one removal control in the builder, for a filter and a tile alike, so
|
|
32
|
+
* removing looks and works the same wherever it is. The container must be
|
|
33
|
+
* `position: relative` and spread {@link removeBadgeRevealSx}.
|
|
34
|
+
*
|
|
35
|
+
* With `disabledReason`, the badge stays focusable (aria-disabled, not
|
|
36
|
+
* disabled) and says why on hover and to a screen reader, rather than
|
|
37
|
+
* vanishing or greying out without explanation.
|
|
38
|
+
*/
|
|
39
|
+
export function RemoveBadge({
|
|
40
|
+
label,
|
|
41
|
+
onRemove,
|
|
42
|
+
disabledReason,
|
|
43
|
+
/** How far outside the container's edge the badge's centre sits, in px. */
|
|
44
|
+
inset = 0,
|
|
45
|
+
}: {
|
|
46
|
+
/** The accessible name: "Remove filter BRAND", "Remove Revenue by month". */
|
|
47
|
+
label: string;
|
|
48
|
+
onRemove: () => void;
|
|
49
|
+
disabledReason?: string;
|
|
50
|
+
inset?: number;
|
|
51
|
+
}) {
|
|
52
|
+
const { theme } = usePublisherTheme();
|
|
53
|
+
const disabled = disabledReason !== undefined;
|
|
54
|
+
const badge = (
|
|
55
|
+
<IconButton
|
|
56
|
+
className={REMOVE_BADGE_CLASS}
|
|
57
|
+
aria-label={label}
|
|
58
|
+
aria-disabled={disabled || undefined}
|
|
59
|
+
{...(disabled ? { "aria-description": disabledReason } : {})}
|
|
60
|
+
onClick={(event) => {
|
|
61
|
+
// Never also the tile's or filter's own press.
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
if (!disabled) onRemove();
|
|
64
|
+
}}
|
|
65
|
+
onPointerDown={(event) => event.stopPropagation()}
|
|
66
|
+
sx={(mui) => ({
|
|
67
|
+
position: "absolute",
|
|
68
|
+
top: -8 - inset,
|
|
69
|
+
right: -8 - inset,
|
|
70
|
+
zIndex: 3,
|
|
71
|
+
width: 18,
|
|
72
|
+
height: 18,
|
|
73
|
+
p: 0,
|
|
74
|
+
borderRadius: "50%",
|
|
75
|
+
border: `1px solid ${edgeColor(theme.cardBorder)}`,
|
|
76
|
+
bgcolor: mui.palette.background.paper,
|
|
77
|
+
color: mui.palette.text.secondary,
|
|
78
|
+
cursor: disabled ? "default" : "pointer",
|
|
79
|
+
transition: `opacity ${MOTION_FAST}`,
|
|
80
|
+
...reducedMotionSx,
|
|
81
|
+
"&:hover": {
|
|
82
|
+
bgcolor: mui.palette.background.paper,
|
|
83
|
+
color: disabled
|
|
84
|
+
? mui.palette.text.secondary
|
|
85
|
+
: mui.palette.text.primary,
|
|
86
|
+
borderColor: hoverEdgeColor(theme.cardBorder, theme.tileTitle),
|
|
87
|
+
},
|
|
88
|
+
})}
|
|
89
|
+
>
|
|
90
|
+
<CloseIcon sx={{ fontSize: 12 }} />
|
|
91
|
+
</IconButton>
|
|
92
|
+
);
|
|
93
|
+
return disabled ? <Tooltip title={disabledReason}>{badge}</Tooltip> : badge;
|
|
94
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { Box
|
|
4
|
+
import { Box } from "@mui/material";
|
|
5
5
|
import React, {
|
|
6
6
|
Suspense,
|
|
7
7
|
useCallback,
|
|
@@ -443,18 +443,14 @@ function RenderedResultInner({
|
|
|
443
443
|
// bails, so overlapping renders can't leave two charts or leak a viz.
|
|
444
444
|
const renderGenRef = useRef(0);
|
|
445
445
|
const { theme: baseTheme, layers, mode } = usePublisherTheme();
|
|
446
|
-
// The
|
|
447
|
-
//
|
|
448
|
-
// cards take it from here; see DashboardTile, which is the other one.
|
|
449
|
-
const cardRadius = useTheme().shape.borderRadius;
|
|
450
|
-
// Memoized because it is a dependency of the render effect below, and a fresh
|
|
451
|
-
// object each render would re-render the chart on every render.
|
|
446
|
+
// The report surfaces' tile radius, the one TileCard draws the composite
|
|
447
|
+
// tile with, so the renderer's own cards and ours are the same shape.
|
|
452
448
|
const cardGeometry = useMemo<DashboardCardGeometry>(
|
|
453
449
|
() => ({
|
|
454
|
-
radius:
|
|
450
|
+
radius: baseTheme.ui.radius.tile,
|
|
455
451
|
padding: `${DASHBOARD_CARD_PADDING_PX}px`,
|
|
456
452
|
}),
|
|
457
|
-
[
|
|
453
|
+
[baseTheme.ui.radius.tile],
|
|
458
454
|
);
|
|
459
455
|
|
|
460
456
|
// Dispose the last live viz on unmount only. Deliberately NOT done in the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { Box } from "@mui/material";
|
|
4
|
+
import { Box, LinearProgress } from "@mui/material";
|
|
5
5
|
import { useEffect, useMemo } from "react";
|
|
6
6
|
import type { QueryResultState } from "../../hooks/useQueryResult";
|
|
7
7
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
@@ -50,7 +50,8 @@ export function ResultPanel({
|
|
|
50
50
|
fill,
|
|
51
51
|
transform,
|
|
52
52
|
}: ResultPanelProps) {
|
|
53
|
-
const { data, isSuccess, isError, error, fetchStatus } =
|
|
53
|
+
const { data, isSuccess, isError, error, fetchStatus, isPlaceholderData } =
|
|
54
|
+
state;
|
|
54
55
|
// Fetch the renderer while the query runs, so the first chart does not wait
|
|
55
56
|
// on it after the rows arrive. Not before: a tile still waiting to scroll
|
|
56
57
|
// into view has asked for nothing, and neither should its renderer.
|
|
@@ -79,7 +80,7 @@ export function ResultPanel({
|
|
|
79
80
|
text={fetchStatus === "idle" ? LOADING_COPY.loading : loadingText}
|
|
80
81
|
/>
|
|
81
82
|
);
|
|
82
|
-
|
|
83
|
+
const shown = (
|
|
83
84
|
<ResultContainer
|
|
84
85
|
result={result}
|
|
85
86
|
maxHeight={maxHeight}
|
|
@@ -89,4 +90,59 @@ export function ResultPanel({
|
|
|
89
90
|
fill={fill}
|
|
90
91
|
/>
|
|
91
92
|
);
|
|
93
|
+
// The previous answer, while the new one runs: it stays where it is, eased
|
|
94
|
+
// back after a beat so a quick run never flickers, with a thin bar along
|
|
95
|
+
// the top saying work is under way, and is replaced in place when the rows
|
|
96
|
+
// land. The wrapper is always there, so going stale and back never moves
|
|
97
|
+
// the result in the tree, which would remount (and redraw) the chart.
|
|
98
|
+
return (
|
|
99
|
+
<Box
|
|
100
|
+
aria-busy={isPlaceholderData || undefined}
|
|
101
|
+
sx={{
|
|
102
|
+
position: "relative",
|
|
103
|
+
// Both layers pass the parent's flex column through: the result
|
|
104
|
+
// sizes itself as a flex child (a basis from its own height, or the
|
|
105
|
+
// cell's height under `fill`), and an ordinary block between it and
|
|
106
|
+
// its parent left it zero tall.
|
|
107
|
+
display: "flex",
|
|
108
|
+
flexDirection: "column",
|
|
109
|
+
flex: "1 1 auto",
|
|
110
|
+
minHeight: 0,
|
|
111
|
+
minWidth: 0,
|
|
112
|
+
...(fill ? { height: "100%" } : {}),
|
|
113
|
+
"& > .result-body": {
|
|
114
|
+
display: "flex",
|
|
115
|
+
flexDirection: "column",
|
|
116
|
+
flex: "1 1 auto",
|
|
117
|
+
minHeight: 0,
|
|
118
|
+
minWidth: 0,
|
|
119
|
+
...(fill ? { height: "100%" } : {}),
|
|
120
|
+
opacity: isPlaceholderData ? 0.55 : 1,
|
|
121
|
+
transition: isPlaceholderData
|
|
122
|
+
? "opacity 160ms ease 200ms"
|
|
123
|
+
: "opacity 120ms ease",
|
|
124
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
125
|
+
transition: "none",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
{isPlaceholderData && (
|
|
131
|
+
<LinearProgress
|
|
132
|
+
aria-label={loadingText}
|
|
133
|
+
sx={{
|
|
134
|
+
position: "absolute",
|
|
135
|
+
top: 0,
|
|
136
|
+
left: 0,
|
|
137
|
+
right: 0,
|
|
138
|
+
height: 2,
|
|
139
|
+
zIndex: 1,
|
|
140
|
+
bgcolor: "transparent",
|
|
141
|
+
borderRadius: 1,
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
)}
|
|
145
|
+
<Box className="result-body">{shown}</Box>
|
|
146
|
+
</Box>
|
|
147
|
+
);
|
|
92
148
|
}
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
serverWrapper,
|
|
19
19
|
} from "../../../test/serverProvider";
|
|
20
20
|
import type { ReportManifest } from "../../client";
|
|
21
|
+
import { globalQueryClient } from "../../utils/queryClient";
|
|
21
22
|
|
|
22
23
|
let manifest = {} as ReportManifest;
|
|
23
24
|
const getReport = mock(
|
|
@@ -116,6 +117,44 @@ describe("the manifest fetch", () => {
|
|
|
116
117
|
]);
|
|
117
118
|
});
|
|
118
119
|
|
|
120
|
+
it("asks again on every mount unless the host says otherwise", async () => {
|
|
121
|
+
manifest = { ...TILES, layout: "grid" };
|
|
122
|
+
const first = render(
|
|
123
|
+
<Report resourceUri={URI} path="sales/q3.malloy" />,
|
|
124
|
+
{
|
|
125
|
+
wrapper: serverWrapper,
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
await waitFor(() => expect(getReport).toHaveBeenCalledTimes(1));
|
|
129
|
+
first.unmount();
|
|
130
|
+
render(<Report resourceUri={URI} path="sales/q3.malloy" />, {
|
|
131
|
+
wrapper: serverWrapper,
|
|
132
|
+
});
|
|
133
|
+
await waitFor(() => expect(getReport).toHaveBeenCalledTimes(2));
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("leaves the read's staleness to the host's default for the report key", async () => {
|
|
137
|
+
// A host that reads the manifest itself first, then mounts the report
|
|
138
|
+
// over the same entry, keeps that entry fresh with one default.
|
|
139
|
+
globalQueryClient.setQueryDefaults(["report"], { staleTime: Infinity });
|
|
140
|
+
try {
|
|
141
|
+
manifest = { ...TILES, layout: "grid" };
|
|
142
|
+
const first = render(
|
|
143
|
+
<Report resourceUri={URI} path="sales/q3.malloy" />,
|
|
144
|
+
{ wrapper: serverWrapper },
|
|
145
|
+
);
|
|
146
|
+
await waitFor(() => expect(getReport).toHaveBeenCalledTimes(1));
|
|
147
|
+
first.unmount();
|
|
148
|
+
render(<Report resourceUri={URI} path="sales/q3.malloy" />, {
|
|
149
|
+
wrapper: serverWrapper,
|
|
150
|
+
});
|
|
151
|
+
await screen.findAllByText("Third quarter");
|
|
152
|
+
expect(getReport).toHaveBeenCalledTimes(1);
|
|
153
|
+
} finally {
|
|
154
|
+
globalQueryClient.setQueryDefaults(["report"], {});
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
119
158
|
it("says so, rather than throwing, for a URI that names no package", () => {
|
|
120
159
|
render(
|
|
121
160
|
<Report resourceUri="publisher://environments/env" path="x.malloy" />,
|
|
@@ -146,7 +185,7 @@ describe("rendering by layout", () => {
|
|
|
146
185
|
expect(container.querySelector('[data-chrome="none"]')).toBeNull();
|
|
147
186
|
});
|
|
148
187
|
|
|
149
|
-
it("draws a linear report's tiles
|
|
188
|
+
it("draws a linear report's query tiles in cards, as a grid does", async () => {
|
|
150
189
|
manifest = { ...TILES, layout: "linear" };
|
|
151
190
|
const { container } = render(
|
|
152
191
|
<Report resourceUri={URI} path="sales/q3.malloy" />,
|
|
@@ -157,53 +196,32 @@ describe("rendering by layout", () => {
|
|
|
157
196
|
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
158
197
|
expect(executeQueryModel.mock.calls[0][2]).toBe("sales/q3.malloy");
|
|
159
198
|
await waitFor(() =>
|
|
160
|
-
expect(container.querySelector('[data-chrome="
|
|
199
|
+
expect(container.querySelector('[data-chrome="card"]')).not.toBeNull(),
|
|
161
200
|
);
|
|
162
|
-
expect(container.querySelector('[data-chrome="card"]')).toBeNull();
|
|
163
201
|
});
|
|
164
202
|
|
|
165
|
-
it("runs
|
|
203
|
+
it("runs no cells: a manifest carrying `run:` cells draws no cells", async () => {
|
|
166
204
|
manifest = {
|
|
167
205
|
path: "review.malloy",
|
|
168
206
|
name: "review",
|
|
169
207
|
layout: "linear",
|
|
208
|
+
title: "Review",
|
|
170
209
|
editable: false,
|
|
171
210
|
notebook: {
|
|
172
211
|
format: "malloy",
|
|
173
212
|
notebookCells: [
|
|
174
213
|
{ type: "markdown", kind: "markdown", text: "Cell prose" },
|
|
175
|
-
{
|
|
176
|
-
type: "code",
|
|
177
|
-
kind: "query",
|
|
178
|
-
text: "run: orders -> by_month",
|
|
179
|
-
},
|
|
214
|
+
{ type: "code", kind: "query", text: "run: orders -> by_month" },
|
|
180
215
|
],
|
|
181
216
|
},
|
|
182
217
|
} as ReportManifest;
|
|
183
|
-
render(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
wrapper: serverWrapper,
|
|
187
|
-
},
|
|
188
|
-
);
|
|
218
|
+
render(<Report resourceUri={URI} path="review.malloy" />, {
|
|
219
|
+
wrapper: serverWrapper,
|
|
220
|
+
});
|
|
189
221
|
|
|
190
|
-
expect(await screen.findByText("
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
// governed path every grid tile takes.
|
|
194
|
-
expect(
|
|
195
|
-
executeQueryModel.mock.calls.map((call) => call.slice(0, 4)),
|
|
196
|
-
).toEqual([
|
|
197
|
-
[
|
|
198
|
-
"env",
|
|
199
|
-
"pkg",
|
|
200
|
-
"review.malloy",
|
|
201
|
-
{ query: "run: orders -> by_month", givens: {}, versionId: "v4" },
|
|
202
|
-
],
|
|
203
|
-
]);
|
|
204
|
-
expect(executeNotebookCell).not.toHaveBeenCalled();
|
|
205
|
-
// The cells came with the manifest; nothing reads them again.
|
|
206
|
-
expect(getNotebook).not.toHaveBeenCalled();
|
|
222
|
+
expect(await screen.findByText("Review")).toBeTruthy();
|
|
223
|
+
expect(screen.queryByText("Cell prose")).toBeNull();
|
|
224
|
+
expect(executeQueryModel).not.toHaveBeenCalled();
|
|
207
225
|
});
|
|
208
226
|
|
|
209
227
|
// DEPRECATED FEATURE COVERAGE — delete together with
|
|
@@ -136,22 +136,6 @@ describe("opening a report", () => {
|
|
|
136
136
|
});
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
it("reports a run:-cell report's open as linear, counting its cells", async () => {
|
|
140
|
-
manifest = CELLS;
|
|
141
|
-
const onEvent = mock((_event: ReportEvent) => {});
|
|
142
|
-
render(
|
|
143
|
-
<Report resourceUri={URI} path="review.malloy" onEvent={onEvent} />,
|
|
144
|
-
{ wrapper: serverWrapper },
|
|
145
|
-
);
|
|
146
|
-
expect(await screen.findByText("Cell prose")).toBeTruthy();
|
|
147
|
-
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
148
|
-
type: "report.opened",
|
|
149
|
-
path: "review.malloy",
|
|
150
|
-
layout: "linear",
|
|
151
|
-
tiles: 2,
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
139
|
it("reports a failed read as load_failed with a category, never the message, and no open", async () => {
|
|
156
140
|
reportFailure = Object.assign(
|
|
157
141
|
new Error("no such report: secret.malloy"),
|
|
@@ -260,33 +244,4 @@ describe("a failed query", () => {
|
|
|
260
244
|
},
|
|
261
245
|
]);
|
|
262
246
|
});
|
|
263
|
-
|
|
264
|
-
it("reports a cell's failure to the host instead of the console", async () => {
|
|
265
|
-
manifest = CELLS;
|
|
266
|
-
queryFailure = { response: { status: 403 } };
|
|
267
|
-
const onEvent = mock((_event: ReportEvent) => {});
|
|
268
|
-
render(
|
|
269
|
-
<Report resourceUri={URI} path="review.malloy" onEvent={onEvent} />,
|
|
270
|
-
{ wrapper: serverWrapper },
|
|
271
|
-
);
|
|
272
|
-
await waitFor(() =>
|
|
273
|
-
expect(typesOf(onEvent.mock.calls)).toContain("report.query_failed"),
|
|
274
|
-
);
|
|
275
|
-
expect(
|
|
276
|
-
onEvent.mock.calls
|
|
277
|
-
.map(([event]) => event)
|
|
278
|
-
.find((event) => event.type === "report.query_failed"),
|
|
279
|
-
).toMatchObject({ tile: 1, category: "forbidden", layout: "linear" });
|
|
280
|
-
expect(errorSpy).not.toHaveBeenCalled();
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it("logs a cell's failure to the console when no host listens", async () => {
|
|
284
|
-
manifest = CELLS;
|
|
285
|
-
queryFailure = { response: { status: 500 } };
|
|
286
|
-
render(<Report resourceUri={URI} path="review.malloy" />, {
|
|
287
|
-
wrapper: serverWrapper,
|
|
288
|
-
});
|
|
289
|
-
await waitFor(() => expect(errorSpy).toHaveBeenCalled());
|
|
290
|
-
expect(String(errorSpy.mock.calls[0][0])).toContain("cell 1");
|
|
291
|
-
});
|
|
292
247
|
});
|