@malloy-publisher/sdk 0.9.1 → 0.9.2
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/{Dashboard-H1kJlDFo.es.js → DashboardTile-BFcxdv7R.es.js} +15918 -17760
- package/dist/DashboardTile-sg8LjUk8.cjs.js +137 -0
- package/dist/RenderedResult-B48wAjM8.cjs.js +141 -0
- package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-CBLHr32C.es.js} +193 -183
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-DCV8BUWD.es.js} +529 -521
- package/dist/ServerProvider-HRqT3w1C.cjs.js +1 -0
- package/dist/builder/index.cjs.js +146 -58
- package/dist/builder/index.es.js +9076 -6479
- package/dist/builder-entry.d.ts +4 -0
- package/dist/client/api.d.ts +77 -47
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +84 -82
- package/dist/components/Dashboard/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +23 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +10 -1
- package/dist/components/Dashboard/DashboardView.d.ts +36 -0
- package/dist/components/Dashboard/TileCard.d.ts +15 -4
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/index.d.ts +3 -0
- package/dist/components/Dashboard/telemetry.d.ts +15 -3
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -1
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +16 -5
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +48 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -4
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +2 -10
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +3 -1
- package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
- package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +27 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +19 -7
- package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +7 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +14 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +11 -3
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -0
- package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
- package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
- package/dist/components/DashboardBuilder/controls.d.ts +2 -2
- package/dist/components/DashboardBuilder/document.d.ts +42 -26
- package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -5
- package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
- package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
- package/dist/components/DashboardBuilder/preview.d.ts +24 -4
- package/dist/components/DashboardBuilder/readDocument.d.ts +4 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +14 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +13 -13
- package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
- package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
- package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
- package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +89 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +17 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
- package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
- package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
- package/dist/components/DocumentCreate/events.d.ts +10 -0
- package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
- package/dist/components/DocumentCreate/guards.d.ts +12 -0
- package/dist/components/DocumentCreate/index.d.ts +6 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +1 -0
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +4 -0
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/given/GivensPanel.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9714 -7072
- package/dist/text/index.cjs.js +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.es.js +6 -0
- package/dist/text-entry-BJwltZiy.cjs.js +7 -0
- package/dist/text-entry-CbbBcZl8.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- package/dist/utils/clock.d.ts +2 -0
- package/package.json +10 -1
- package/src/builder-entry.ts +35 -0
- package/src/components/Dashboard/Dashboard.tsx +27 -278
- package/src/components/Dashboard/DashboardGrid.tsx +68 -7
- package/src/components/Dashboard/DashboardTile.spec.tsx +24 -0
- package/src/components/Dashboard/DashboardTile.tsx +31 -4
- package/src/components/Dashboard/DashboardView.spec.tsx +212 -0
- package/src/components/Dashboard/DashboardView.tsx +352 -0
- package/src/components/Dashboard/RowsDialog.tsx +1 -1
- package/src/components/Dashboard/TileCard.tsx +44 -10
- package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
- package/src/components/Dashboard/TileFilterTag.tsx +78 -0
- package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
- package/src/components/Dashboard/index.ts +3 -0
- package/src/components/Dashboard/telemetry.ts +16 -5
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +137 -111
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +85 -27
- package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
- package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
- package/src/components/DashboardBuilder/ChartPicker.tsx +153 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +192 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +329 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +363 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +194 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +157 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +124 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +103 -78
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +177 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +610 -315
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +58 -8
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +191 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +316 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +56 -10
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +5 -22
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +96 -14
- package/src/components/DashboardBuilder/DashboardEditor.tsx +482 -332
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +25 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +5 -24
- package/src/components/DashboardBuilder/DrillDialog.tsx +1 -1
- package/src/components/DashboardBuilder/FilterDialog.tsx +10 -3
- package/src/components/DashboardBuilder/FilterStrip.tsx +26 -4
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +184 -0
- package/src/components/DashboardBuilder/InlineText.tsx +106 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SaveNotice.tsx +113 -0
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +87 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +225 -67
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +28 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +89 -115
- package/src/components/DashboardBuilder/TileMenu.tsx +168 -90
- package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
- package/src/components/DashboardBuilder/annotationText.ts +17 -0
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +41 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -0
- package/src/components/DashboardBuilder/catalog.ts +61 -21
- package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
- package/src/components/DashboardBuilder/changedTile.ts +28 -0
- package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
- package/src/components/DashboardBuilder/chartLine.ts +121 -0
- package/src/components/DashboardBuilder/controls.spec.ts +21 -10
- package/src/components/DashboardBuilder/controls.ts +22 -8
- package/src/components/DashboardBuilder/document.ts +53 -5
- package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
- package/src/components/DashboardBuilder/documentSession.ts +257 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
- package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
- package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
- package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
- package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
- package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +48 -0
- package/src/components/DashboardBuilder/malloyText.ts +181 -27
- package/src/components/DashboardBuilder/malloyTree.ts +155 -7
- package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
- package/src/components/DashboardBuilder/newDashboard.ts +30 -3
- package/src/components/DashboardBuilder/openDraft.ts +52 -0
- package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
- package/src/components/DashboardBuilder/preview.spec.ts +159 -12
- package/src/components/DashboardBuilder/preview.ts +83 -9
- package/src/components/DashboardBuilder/readDocument.spec.ts +139 -27
- package/src/components/DashboardBuilder/readDocument.ts +130 -44
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +47 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +65 -0
- package/src/components/DashboardBuilder/sortable.tsx +2 -12
- package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
- package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
- package/src/components/DashboardBuilder/spliceDocument.ts +762 -130
- package/src/components/DashboardBuilder/spliceResult.ts +15 -0
- package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
- package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
- package/src/components/DashboardBuilder/tagParse.ts +103 -0
- package/src/components/DashboardBuilder/telemetry.ts +47 -0
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +197 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +718 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +335 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +292 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +65 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +36 -10
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +54 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
- package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
- package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
- package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
- package/src/components/DocumentCreate/canRetry.ts +19 -0
- package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
- package/src/components/DocumentCreate/createDocument.ts +159 -0
- package/src/components/DocumentCreate/documentPath.ts +40 -0
- package/src/components/DocumentCreate/events.ts +15 -0
- package/src/components/DocumentCreate/exportedSources.ts +25 -0
- package/src/components/DocumentCreate/guards.ts +45 -0
- package/src/components/DocumentCreate/index.ts +27 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
- package/src/components/DocumentCreate/newNotebook.ts +44 -0
- package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
- package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
- package/src/components/Model/ModelExplorer.spec.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -4
- package/src/components/NarrowEditGate.spec.tsx +73 -0
- package/src/components/NarrowEditGate.tsx +29 -0
- package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
- package/src/components/Notebook/Notebook.tsx +66 -27
- package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
- package/src/components/Package/NewDocumentDialog.tsx +401 -0
- package/src/components/Package/Package.artifacts.spec.tsx +190 -0
- package/src/components/Package/Package.create.spec.tsx +380 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +366 -171
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +13 -0
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/RenderedResult/RenderedResult.tsx +18 -1
- package/src/components/RenderedResult/ResultContainer.tsx +44 -11
- package/src/components/RenderedResult/ResultPanel.tsx +4 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
- package/src/components/RenderedResult/resultSizing.ts +14 -3
- package/src/components/ServerProvider.tsx +2 -1
- package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
- package/src/components/UnsavedChangesDialog.tsx +49 -0
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +3 -3
- package/src/components/index.ts +2 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useNarrowScreen.ts +21 -0
- package/src/hooks/useQueryResult.ts +16 -0
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +118 -0
- package/src/utils/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/vite.config.ts +4 -0
- package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
- package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
- package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
- package/dist/components/DashboardBuilder/useTileResize.d.ts +0 -29
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +0 -121
- package/src/components/DashboardBuilder/useTileResize.ts +0 -110
- package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
- package/src/components/Package/NewDashboardDialog.tsx +0 -265
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import AddIcon from "@mui/icons-material/Add";
|
|
4
5
|
import DragIndicatorIcon from "@mui/icons-material/DragIndicator";
|
|
5
6
|
import MoreVertIcon from "@mui/icons-material/MoreVert";
|
|
6
7
|
import { Box, IconButton, Typography } from "@mui/material";
|
|
7
|
-
import type {
|
|
8
|
+
import type { ReactNode } from "react";
|
|
8
9
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
9
10
|
import { GRID_GAP_PX } from "../Dashboard/DashboardGrid";
|
|
10
|
-
import {
|
|
11
|
-
|
|
11
|
+
import {
|
|
12
|
+
TileCard,
|
|
13
|
+
TileHeading,
|
|
14
|
+
type TileHeadingSlots,
|
|
15
|
+
} from "../Dashboard/TileCard";
|
|
16
|
+
import {
|
|
17
|
+
tileKey,
|
|
18
|
+
tileLabel,
|
|
19
|
+
type DashboardTile,
|
|
20
|
+
type QueryTile,
|
|
21
|
+
} from "./document";
|
|
12
22
|
import { gapId } from "./layout";
|
|
13
23
|
import { GapDroppable, TileSortable } from "./sortable";
|
|
14
24
|
|
|
15
25
|
/**
|
|
16
26
|
* Everything the builder draws AROUND a tile: the selection outline, the grip,
|
|
17
|
-
* the menu button
|
|
27
|
+
* the menu button and, in a notebook, the insert button. The tile
|
|
18
28
|
* itself is `children` — the host's real `DashboardTile`, or a placeholder
|
|
19
29
|
* saying what the tile will run.
|
|
20
30
|
*/
|
|
@@ -22,29 +32,24 @@ export function TileFrame({
|
|
|
22
32
|
tile,
|
|
23
33
|
index,
|
|
24
34
|
selected,
|
|
35
|
+
flash = false,
|
|
25
36
|
menuOpen,
|
|
26
|
-
|
|
27
|
-
columns,
|
|
37
|
+
onInsertAfter,
|
|
28
38
|
onSelect,
|
|
29
39
|
onOpenMenu,
|
|
30
|
-
onResizeStart,
|
|
31
|
-
onResizeMove,
|
|
32
|
-
onResizeEnd,
|
|
33
40
|
children,
|
|
34
41
|
}: {
|
|
35
42
|
tile: DashboardTile;
|
|
36
43
|
index: number;
|
|
37
44
|
selected: boolean;
|
|
45
|
+
/** Briefly lit: the tile an undo or redo just changed. */
|
|
46
|
+
flash?: boolean;
|
|
38
47
|
/** Whether this tile's menu is open, which keeps its button showing. */
|
|
39
48
|
menuOpen: boolean;
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
columns: number;
|
|
49
|
+
/** Offers a "+" on the bottom edge that adds a tile after this one; set where tiles stack in one column. */
|
|
50
|
+
onInsertAfter?: () => void;
|
|
43
51
|
onSelect: () => void;
|
|
44
52
|
onOpenMenu: (anchor: HTMLElement) => void;
|
|
45
|
-
onResizeStart: (event: PointerEvent<HTMLDivElement>) => void;
|
|
46
|
-
onResizeMove: (event: PointerEvent<HTMLDivElement>) => void;
|
|
47
|
-
onResizeEnd: (event: PointerEvent<HTMLDivElement>) => void;
|
|
48
53
|
children: ReactNode;
|
|
49
54
|
}) {
|
|
50
55
|
const { theme } = usePublisherTheme();
|
|
@@ -62,8 +67,10 @@ export function TileFrame({
|
|
|
62
67
|
}}
|
|
63
68
|
aria-label={`Tile ${tile.name}`}
|
|
64
69
|
aria-current={selected}
|
|
70
|
+
data-tile-key={tileKey(tile)}
|
|
71
|
+
data-flash={flash || undefined}
|
|
65
72
|
sx={{
|
|
66
|
-
// Anchors the
|
|
73
|
+
// Anchors the grip, menu and insert buttons to
|
|
67
74
|
// this tile.
|
|
68
75
|
position: "relative",
|
|
69
76
|
// Same again: this wrapper sits BETWEEN
|
|
@@ -94,6 +101,10 @@ export function TileFrame({
|
|
|
94
101
|
? `2px solid ${theme.drillLink}`
|
|
95
102
|
: `2px solid transparent`,
|
|
96
103
|
outlineOffset: 2,
|
|
104
|
+
...(flash && {
|
|
105
|
+
outlineColor: theme.drillLink,
|
|
106
|
+
boxShadow: `0 0 0 6px color-mix(in srgb, ${theme.drillLink} 25%, transparent)`,
|
|
107
|
+
}),
|
|
97
108
|
transition:
|
|
98
109
|
"outline-color 120ms, opacity 120ms, box-shadow 120ms",
|
|
99
110
|
// The handles, grip and menu are invisible
|
|
@@ -152,7 +163,7 @@ export function TileFrame({
|
|
|
152
163
|
<Box
|
|
153
164
|
ref={handleRef}
|
|
154
165
|
className="builder-affordance"
|
|
155
|
-
aria-label={`Move ${tile
|
|
166
|
+
aria-label={`Move ${tileLabel(tile)}`}
|
|
156
167
|
sx={{
|
|
157
168
|
position: "absolute",
|
|
158
169
|
top: "2px",
|
|
@@ -181,119 +192,68 @@ export function TileFrame({
|
|
|
181
192
|
<DragIndicatorIcon sx={{ fontSize: 16 }} />
|
|
182
193
|
</Box>
|
|
183
194
|
|
|
184
|
-
{/* The tile's menu: its
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
195
|
+
{/* The tile's menu: its chart, width and drill-through.
|
|
196
|
+
A press here is never the start of a drag: the
|
|
197
|
+
sensor refuses to activate from a button. */}
|
|
198
|
+
<IconButton
|
|
199
|
+
className="builder-affordance"
|
|
200
|
+
size="small"
|
|
201
|
+
aria-label={`Settings for ${tileLabel(tile)}`}
|
|
202
|
+
onClick={(event) => {
|
|
203
|
+
event.stopPropagation();
|
|
204
|
+
onOpenMenu(event.currentTarget);
|
|
205
|
+
}}
|
|
206
|
+
sx={{
|
|
207
|
+
position: "absolute",
|
|
208
|
+
top: "2px",
|
|
209
|
+
right: "2px",
|
|
210
|
+
width: 22,
|
|
211
|
+
height: 22,
|
|
212
|
+
zIndex: 2,
|
|
213
|
+
color: theme.tileTitle,
|
|
214
|
+
bgcolor: theme.tile,
|
|
215
|
+
opacity: selected || menuOpen ? 0.9 : 0,
|
|
216
|
+
transition: "opacity 120ms",
|
|
217
|
+
"&:hover": {
|
|
218
|
+
opacity: 1,
|
|
219
|
+
bgcolor: theme.tile,
|
|
220
|
+
},
|
|
221
|
+
}}
|
|
222
|
+
>
|
|
223
|
+
<MoreVertIcon sx={{ fontSize: 16 }} />
|
|
224
|
+
</IconButton>
|
|
225
|
+
|
|
226
|
+
{onInsertAfter && (
|
|
190
227
|
<IconButton
|
|
191
228
|
className="builder-affordance"
|
|
192
229
|
size="small"
|
|
193
|
-
aria-label={`
|
|
230
|
+
aria-label={`Insert tile after ${tileLabel(tile)}`}
|
|
194
231
|
onClick={(event) => {
|
|
195
232
|
event.stopPropagation();
|
|
196
|
-
|
|
233
|
+
onInsertAfter();
|
|
197
234
|
}}
|
|
198
235
|
sx={{
|
|
199
236
|
position: "absolute",
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
237
|
+
bottom: "-18px",
|
|
238
|
+
left: "50%",
|
|
239
|
+
transform: "translateX(-50%)",
|
|
240
|
+
width: 20,
|
|
241
|
+
height: 20,
|
|
242
|
+
zIndex: 3,
|
|
205
243
|
color: theme.tileTitle,
|
|
206
244
|
bgcolor: theme.tile,
|
|
207
|
-
|
|
245
|
+
border: theme.cardBorder,
|
|
246
|
+
opacity: 0,
|
|
208
247
|
transition: "opacity 120ms",
|
|
209
|
-
"&:hover": {
|
|
248
|
+
"&:hover, &:focus-visible": {
|
|
210
249
|
opacity: 1,
|
|
211
250
|
bgcolor: theme.tile,
|
|
212
251
|
},
|
|
213
252
|
}}
|
|
214
253
|
>
|
|
215
|
-
<
|
|
254
|
+
<AddIcon sx={{ fontSize: 14 }} />
|
|
216
255
|
</IconButton>
|
|
217
256
|
)}
|
|
218
|
-
|
|
219
|
-
{/* A tile's width and share of the dashboard,
|
|
220
|
-
reported while you drag it, as the best builders do.
|
|
221
|
-
Height is not ours to show, but the span and
|
|
222
|
-
its share are exactly what a flow grid leaves
|
|
223
|
-
you guessing at. */}
|
|
224
|
-
{resizeSpan !== undefined && (
|
|
225
|
-
<Box
|
|
226
|
-
aria-hidden
|
|
227
|
-
sx={{
|
|
228
|
-
position: "absolute",
|
|
229
|
-
top: "6px",
|
|
230
|
-
right: "6px",
|
|
231
|
-
px: 0.75,
|
|
232
|
-
py: 0.25,
|
|
233
|
-
borderRadius: "4px",
|
|
234
|
-
bgcolor: theme.drillLink,
|
|
235
|
-
color: theme.tile,
|
|
236
|
-
fontSize: 11,
|
|
237
|
-
fontVariantNumeric: "tabular-nums",
|
|
238
|
-
zIndex: 4,
|
|
239
|
-
pointerEvents: "none",
|
|
240
|
-
}}
|
|
241
|
-
>
|
|
242
|
-
{resizeSpan} of {columns} ·{" "}
|
|
243
|
-
{Math.round((resizeSpan / columns) * 100)}%
|
|
244
|
-
</Box>
|
|
245
|
-
)}
|
|
246
|
-
|
|
247
|
-
{/* The right edge, draggable — but only on a
|
|
248
|
-
tile whose tags this file owns. An inherited
|
|
249
|
-
tile's tags live on the model's view, which
|
|
250
|
-
the builder does not write, so a drag here
|
|
251
|
-
could not be saved. Its own pointer handling
|
|
252
|
-
stops the press reaching the sortable, and
|
|
253
|
-
the sensor refuses a separator regardless. */}
|
|
254
|
-
{tile.declaration.kind !== "inherited" && (
|
|
255
|
-
<Box
|
|
256
|
-
className="builder-affordance"
|
|
257
|
-
role="separator"
|
|
258
|
-
aria-orientation="vertical"
|
|
259
|
-
aria-label={`Resize ${tile.label ?? tile.name}`}
|
|
260
|
-
onPointerDown={onResizeStart}
|
|
261
|
-
onPointerMove={onResizeMove}
|
|
262
|
-
onPointerUp={onResizeEnd}
|
|
263
|
-
onPointerCancel={onResizeEnd}
|
|
264
|
-
sx={{
|
|
265
|
-
position: "absolute",
|
|
266
|
-
top: 0,
|
|
267
|
-
bottom: 0,
|
|
268
|
-
// Straddles the edge, so the target
|
|
269
|
-
// is a usable width without eating
|
|
270
|
-
// into the tile's content.
|
|
271
|
-
right: "-5px",
|
|
272
|
-
width: "10px",
|
|
273
|
-
cursor: "col-resize",
|
|
274
|
-
touchAction: "none",
|
|
275
|
-
zIndex: 1,
|
|
276
|
-
// Invisible until wanted: a rule down
|
|
277
|
-
// every tile edge would read as a
|
|
278
|
-
// table, and the tile already draws
|
|
279
|
-
// an edge of its own.
|
|
280
|
-
opacity: resizeSpan !== undefined || selected ? 1 : 0,
|
|
281
|
-
transition: "opacity 120ms",
|
|
282
|
-
"&:hover": { opacity: 1 },
|
|
283
|
-
"&::after": {
|
|
284
|
-
content: '""',
|
|
285
|
-
position: "absolute",
|
|
286
|
-
top: "50%",
|
|
287
|
-
left: "50%",
|
|
288
|
-
transform: "translate(-50%, -50%)",
|
|
289
|
-
width: "4px",
|
|
290
|
-
height: "28px",
|
|
291
|
-
borderRadius: "2px",
|
|
292
|
-
bgcolor: theme.drillLink,
|
|
293
|
-
},
|
|
294
|
-
}}
|
|
295
|
-
/>
|
|
296
|
-
)}
|
|
297
257
|
</Box>
|
|
298
258
|
)}
|
|
299
259
|
</TileSortable>
|
|
@@ -304,14 +264,28 @@ export function TileFrame({
|
|
|
304
264
|
* No host-supplied tile: say what this one will run, so the surface is still
|
|
305
265
|
* legible without a server.
|
|
306
266
|
*/
|
|
307
|
-
export function TilePlaceholder({
|
|
267
|
+
export function TilePlaceholder({
|
|
268
|
+
tile,
|
|
269
|
+
heading,
|
|
270
|
+
note,
|
|
271
|
+
}: {
|
|
272
|
+
tile: QueryTile;
|
|
273
|
+
heading?: TileHeadingSlots;
|
|
274
|
+
/** Why there is no preview, in place of an empty body. */
|
|
275
|
+
note?: string;
|
|
276
|
+
}) {
|
|
308
277
|
const { theme } = usePublisherTheme();
|
|
309
278
|
return (
|
|
310
279
|
<TileCard sx={{ minHeight: 140 }}>
|
|
311
280
|
<TileHeading
|
|
312
|
-
title={tile.label ?? tile.name}
|
|
313
|
-
subtitle={tile.subtitle}
|
|
281
|
+
title={heading?.title ?? tile.label ?? tile.name}
|
|
282
|
+
subtitle={heading ? heading.subtitle : tile.subtitle}
|
|
314
283
|
/>
|
|
284
|
+
{note && (
|
|
285
|
+
<Typography variant="body2" sx={{ color: theme.tileTitle, py: 2 }}>
|
|
286
|
+
{note}
|
|
287
|
+
</Typography>
|
|
288
|
+
)}
|
|
315
289
|
<Typography
|
|
316
290
|
variant="caption"
|
|
317
291
|
sx={{ display: "block", color: theme.tileTitle, opacity: 0.7 }}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
Divider,
|
|
7
|
-
Popover,
|
|
8
|
-
Stack,
|
|
9
|
-
TextField,
|
|
10
|
-
Typography,
|
|
11
|
-
} from "@mui/material";
|
|
4
|
+
import { Button, Divider, Popover, Stack, Typography } from "@mui/material";
|
|
5
|
+
import { useId } from "react";
|
|
12
6
|
import { useDraft } from "./useDraft";
|
|
13
7
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
14
|
-
import type {
|
|
8
|
+
import type { CatalogView } from "./catalog";
|
|
9
|
+
import { isQueryTile, type DashboardTile, type QueryTile } from "./document";
|
|
10
|
+
import { presetSpan } from "../Dashboard/DashboardGrid";
|
|
11
|
+
import { ChartPicker } from "./ChartPicker";
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* A tile's own settings, on the tile: a popover off its menu button, so
|
|
18
|
-
* editing it never means scrolling away from it. Its
|
|
19
|
-
*
|
|
15
|
+
* editing it never means scrolling away from it. Its chart, width presets,
|
|
16
|
+
* clickable cells and removal; its title and subtitle are edited on the tile. Its row is set by dragging it — a drop
|
|
20
17
|
* into the empty end of a row is what "start a new row" means — and its card
|
|
21
18
|
* is the reader's to decide, so neither is a toggle here. Which controls it
|
|
22
19
|
* answers to is not here either: filters are configured in one place, the
|
|
23
20
|
* strip under the header. Edits commit on close (`useDraft`).
|
|
21
|
+
*
|
|
22
|
+
* A text tile has only a width (when the grid has more than one column) and
|
|
23
|
+
* Remove: its words are written on the tile itself.
|
|
24
24
|
*/
|
|
25
25
|
export interface TileMenuProps {
|
|
26
26
|
anchor: HTMLElement | null;
|
|
@@ -30,10 +30,65 @@ export interface TileMenuProps {
|
|
|
30
30
|
onCommit: (next: DashboardTile) => void;
|
|
31
31
|
/** Take the tile off the dashboard. Offered on every tile: order is this file's. */
|
|
32
32
|
onRemove: () => void;
|
|
33
|
+
/** Why removing is refused, shown beside a Remove that stays focusable; absent when it is allowed. */
|
|
34
|
+
removeBlocked?: string;
|
|
33
35
|
/** The grid's width, which the width presets are fractions of. */
|
|
34
36
|
columns: number;
|
|
35
37
|
/** Open the clickable-cells window for this tile's source. */
|
|
36
38
|
onDrills: () => void;
|
|
39
|
+
/** The catalog's view the tile shows, when the catalog knows it: what decides which charts are offered. */
|
|
40
|
+
view?: Pick<CatalogView, "chart" | "aggregateOnly">;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const customChart = (lines: string[] | undefined) =>
|
|
44
|
+
lines && lines.length === 1
|
|
45
|
+
? `This tile's chart line (${lines[0]}) is not one the builder models, so its chart cannot be changed here.`
|
|
46
|
+
: `This tile has ${lines?.length ?? "several"} chart lines${lines ? ` (${lines.join(" and ")})` : ""}, so its chart cannot be changed here.`;
|
|
47
|
+
const INHERITED_CHART =
|
|
48
|
+
"This tile's view is declared on its source, so its chart is set in the model.";
|
|
49
|
+
|
|
50
|
+
/** Width presets, as fractions of this grid. A tile's width is otherwise a column count, which cannot say "a third". */
|
|
51
|
+
function WidthPresets({
|
|
52
|
+
columns,
|
|
53
|
+
colspan,
|
|
54
|
+
onPick,
|
|
55
|
+
}: {
|
|
56
|
+
columns: number;
|
|
57
|
+
colspan: number | undefined;
|
|
58
|
+
onPick: (span: number) => void;
|
|
59
|
+
}) {
|
|
60
|
+
const { theme } = usePublisherTheme();
|
|
61
|
+
return (
|
|
62
|
+
<Stack direction="row" sx={{ gap: 0.5, alignItems: "center" }}>
|
|
63
|
+
<Typography variant="caption" sx={{ color: theme.tileTitle, mr: 0.5 }}>
|
|
64
|
+
Width
|
|
65
|
+
</Typography>
|
|
66
|
+
{(
|
|
67
|
+
[
|
|
68
|
+
["Full", 1],
|
|
69
|
+
["½", 2],
|
|
70
|
+
["⅓", 3],
|
|
71
|
+
["¼", 4],
|
|
72
|
+
] as const
|
|
73
|
+
).map(([label, share]) => {
|
|
74
|
+
const span = presetSpan(columns, share);
|
|
75
|
+
const active = (colspan ?? 1) === span;
|
|
76
|
+
return (
|
|
77
|
+
<Button
|
|
78
|
+
key={label}
|
|
79
|
+
size="small"
|
|
80
|
+
variant={active ? "contained" : "outlined"}
|
|
81
|
+
aria-label={`Width ${label}`}
|
|
82
|
+
aria-pressed={active}
|
|
83
|
+
onClick={() => onPick(span)}
|
|
84
|
+
sx={{ minWidth: 40, px: 1 }}
|
|
85
|
+
>
|
|
86
|
+
{label}
|
|
87
|
+
</Button>
|
|
88
|
+
);
|
|
89
|
+
})}
|
|
90
|
+
</Stack>
|
|
91
|
+
);
|
|
37
92
|
}
|
|
38
93
|
|
|
39
94
|
export function TileMenu({
|
|
@@ -42,9 +97,12 @@ export function TileMenu({
|
|
|
42
97
|
onClose,
|
|
43
98
|
onCommit,
|
|
44
99
|
onRemove,
|
|
100
|
+
removeBlocked,
|
|
45
101
|
columns,
|
|
46
102
|
onDrills,
|
|
103
|
+
view,
|
|
47
104
|
}: TileMenuProps) {
|
|
105
|
+
const removeReasonId = useId();
|
|
48
106
|
const { theme } = usePublisherTheme();
|
|
49
107
|
const { draft, patch, close, discard } = useDraft(
|
|
50
108
|
tile,
|
|
@@ -53,8 +111,15 @@ export function TileMenu({
|
|
|
53
111
|
onClose,
|
|
54
112
|
);
|
|
55
113
|
|
|
114
|
+
const query = draft !== undefined && isQueryTile(draft) ? draft : undefined;
|
|
56
115
|
const editable =
|
|
57
|
-
|
|
116
|
+
query !== undefined && query.declaration.kind !== "inherited";
|
|
117
|
+
// The draft is a query tile whenever the controls that call this are shown.
|
|
118
|
+
const patchQuery = (change: (t: QueryTile) => void) =>
|
|
119
|
+
patch((t) => {
|
|
120
|
+
if (isQueryTile(t)) change(t);
|
|
121
|
+
});
|
|
122
|
+
const originalChart = tile && isQueryTile(tile) ? tile.chart : undefined;
|
|
58
123
|
|
|
59
124
|
return (
|
|
60
125
|
<Popover
|
|
@@ -71,93 +136,85 @@ export function TileMenu({
|
|
|
71
136
|
variant="overline"
|
|
72
137
|
sx={{ color: theme.tileTitle, lineHeight: 1.5 }}
|
|
73
138
|
>
|
|
74
|
-
{
|
|
139
|
+
{query
|
|
140
|
+
? `${query.source} → ${query.name}`
|
|
141
|
+
: `Text · ${draft.name}`}
|
|
75
142
|
</Typography>
|
|
76
143
|
|
|
77
|
-
{
|
|
144
|
+
{!query && columns > 1 && (
|
|
145
|
+
<WidthPresets
|
|
146
|
+
columns={columns}
|
|
147
|
+
colspan={draft.colspan}
|
|
148
|
+
onPick={(span) =>
|
|
149
|
+
patch((t) => {
|
|
150
|
+
t.colspan = span;
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
/>
|
|
154
|
+
)}
|
|
155
|
+
|
|
156
|
+
{query && editable && (
|
|
78
157
|
<>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
158
|
+
<ChartPicker
|
|
159
|
+
state={query.chart ?? "default"}
|
|
160
|
+
view={view}
|
|
161
|
+
cellLabel={`${query.source} ${query.name}`}
|
|
162
|
+
{...(query.chart === "custom"
|
|
163
|
+
? { disabledReason: customChart(query.chartLines) }
|
|
164
|
+
: {})}
|
|
165
|
+
onChange={(next) =>
|
|
166
|
+
patchQuery((t) => {
|
|
167
|
+
const was = originalChart;
|
|
168
|
+
// Back to where it started is no edit, so the draft must not differ from the tile.
|
|
169
|
+
if (next === (was ?? "default")) {
|
|
170
|
+
if (was === undefined) delete t.chart;
|
|
171
|
+
else t.chart = was;
|
|
172
|
+
delete t.chartCarried;
|
|
173
|
+
} else {
|
|
174
|
+
t.chart = next;
|
|
175
|
+
if (view)
|
|
176
|
+
t.chartCarried = view.chart
|
|
177
|
+
? [view.chart]
|
|
178
|
+
: [];
|
|
179
|
+
else delete t.chartCarried;
|
|
180
|
+
}
|
|
90
181
|
})
|
|
91
182
|
}
|
|
92
183
|
/>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
sx={{ gap: 0.5, alignItems: "center" }}
|
|
184
|
+
{columns > 1 && (
|
|
185
|
+
<WidthPresets
|
|
186
|
+
columns={columns}
|
|
187
|
+
colspan={query.colspan}
|
|
188
|
+
onPick={(span) =>
|
|
189
|
+
patchQuery((t) => {
|
|
190
|
+
t.colspan = span;
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
/>
|
|
194
|
+
)}
|
|
195
|
+
</>
|
|
196
|
+
)}
|
|
197
|
+
{query && !editable && (
|
|
198
|
+
<>
|
|
199
|
+
<Typography
|
|
200
|
+
variant="body2"
|
|
201
|
+
sx={{ color: theme.tileTitle }}
|
|
112
202
|
>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
["⅓", 3],
|
|
124
|
-
["¼", 4],
|
|
125
|
-
] as const
|
|
126
|
-
).map(([label, share]) => {
|
|
127
|
-
const span = Math.max(
|
|
128
|
-
1,
|
|
129
|
-
Math.round(columns / share),
|
|
130
|
-
);
|
|
131
|
-
const active = (draft.colspan ?? 1) === span;
|
|
132
|
-
return (
|
|
133
|
-
<Button
|
|
134
|
-
key={label}
|
|
135
|
-
size="small"
|
|
136
|
-
variant={active ? "contained" : "outlined"}
|
|
137
|
-
aria-label={`Width ${label}`}
|
|
138
|
-
aria-pressed={active}
|
|
139
|
-
onClick={() =>
|
|
140
|
-
patch((t) => {
|
|
141
|
-
t.colspan = span;
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
sx={{ minWidth: 40, px: 1 }}
|
|
145
|
-
>
|
|
146
|
-
{label}
|
|
147
|
-
</Button>
|
|
148
|
-
);
|
|
149
|
-
})}
|
|
150
|
-
</Stack>
|
|
203
|
+
Declared on its source, so its title and layout are set
|
|
204
|
+
in the model. It can still be moved.
|
|
205
|
+
</Typography>
|
|
206
|
+
<ChartPicker
|
|
207
|
+
state="default"
|
|
208
|
+
view={view}
|
|
209
|
+
cellLabel={`${query.source} ${query.name}`}
|
|
210
|
+
disabledReason={INHERITED_CHART}
|
|
211
|
+
onChange={() => {}}
|
|
212
|
+
/>
|
|
151
213
|
</>
|
|
152
|
-
) : (
|
|
153
|
-
<Typography variant="body2" sx={{ color: theme.tileTitle }}>
|
|
154
|
-
Declared on its source, so its title and layout are set in
|
|
155
|
-
the model. It can still be moved.
|
|
156
|
-
</Typography>
|
|
157
214
|
)}
|
|
158
|
-
{
|
|
215
|
+
{query?.declaration.kind === "opaque" && (
|
|
159
216
|
<Typography variant="body2" sx={{ color: theme.tileTitle }}>
|
|
160
|
-
Its body is {
|
|
217
|
+
Its body is {query.declaration.why}, so a filter has no
|
|
161
218
|
single place to go. Everything else here is editable.
|
|
162
219
|
</Typography>
|
|
163
220
|
)}
|
|
@@ -171,7 +228,7 @@ export function TileMenu({
|
|
|
171
228
|
onDrills();
|
|
172
229
|
}}
|
|
173
230
|
>
|
|
174
|
-
|
|
231
|
+
Drill-through…
|
|
175
232
|
</Button>
|
|
176
233
|
) : (
|
|
177
234
|
<span />
|
|
@@ -179,7 +236,19 @@ export function TileMenu({
|
|
|
179
236
|
<Button
|
|
180
237
|
color="error"
|
|
181
238
|
size="small"
|
|
239
|
+
// aria-disabled, not disabled, so the reason stays reachable by keyboard.
|
|
240
|
+
aria-disabled={removeBlocked !== undefined || undefined}
|
|
241
|
+
aria-describedby={
|
|
242
|
+
removeBlocked !== undefined ? removeReasonId : undefined
|
|
243
|
+
}
|
|
244
|
+
disableRipple={removeBlocked !== undefined}
|
|
245
|
+
sx={
|
|
246
|
+
removeBlocked !== undefined
|
|
247
|
+
? { opacity: 0.5, cursor: "default" }
|
|
248
|
+
: undefined
|
|
249
|
+
}
|
|
182
250
|
onClick={() => {
|
|
251
|
+
if (removeBlocked !== undefined) return;
|
|
183
252
|
discard();
|
|
184
253
|
onRemove();
|
|
185
254
|
}}
|
|
@@ -187,6 +256,15 @@ export function TileMenu({
|
|
|
187
256
|
Remove tile
|
|
188
257
|
</Button>
|
|
189
258
|
</Stack>
|
|
259
|
+
{removeBlocked !== undefined && (
|
|
260
|
+
<Typography
|
|
261
|
+
id={removeReasonId}
|
|
262
|
+
variant="caption"
|
|
263
|
+
sx={{ color: theme.tileTitle }}
|
|
264
|
+
>
|
|
265
|
+
{removeBlocked}
|
|
266
|
+
</Typography>
|
|
267
|
+
)}
|
|
190
268
|
</Stack>
|
|
191
269
|
)}
|
|
192
270
|
</Popover>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { AUTHORIZE_TAG_LIKE as SERVER_AUTHORIZE_TAG_LIKE } from "../../../../server/src/service/authorize";
|
|
6
|
+
import { annotationTextProblem, AUTHORIZE_TAG_LIKE } from "./annotationText";
|
|
7
|
+
|
|
8
|
+
describe("annotationTextProblem", () => {
|
|
9
|
+
it("is the server's pattern, character for character", () => {
|
|
10
|
+
expect(AUTHORIZE_TAG_LIKE).toBe(SERVER_AUTHORIZE_TAG_LIKE);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("refuses a line break and what reads as an access-control tag", () => {
|
|
14
|
+
expect(annotationTextProblem("tile label", "a\nb")).toContain(
|
|
15
|
+
"tile label is one line",
|
|
16
|
+
);
|
|
17
|
+
expect(annotationTextProblem("tile label", "a\rb")).toContain("one line");
|
|
18
|
+
for (const text of [
|
|
19
|
+
"# authorize",
|
|
20
|
+
"x ##(row_authorize) y",
|
|
21
|
+
"#| access_filter",
|
|
22
|
+
])
|
|
23
|
+
expect(annotationTextProblem("tile label", text)).toContain(
|
|
24
|
+
"access-control",
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("accepts ordinary titles", () => {
|
|
29
|
+
expect(
|
|
30
|
+
annotationTextProblem("tile label", "Revenue (authorized) by region"),
|
|
31
|
+
).toBeUndefined();
|
|
32
|
+
});
|
|
33
|
+
});
|