@malloy-publisher/sdk 0.9.14 → 0.9.16
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-5hOs5XnV.cjs.js +171 -0
- package/dist/RenderedResult-DxmHGZNQ.es.js +671 -0
- package/dist/{ServerProvider-BV7IoDMR.es.js → ServerProvider-D7neZcTk.es.js} +283 -265
- package/dist/ServerProvider-e2369oom.cjs.js +1 -0
- package/dist/builder/index.cjs.js +80 -79
- package/dist/builder/index.es.js +7732 -6717
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +31 -7
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +51 -1
- package/dist/components/Dashboard/DashboardTile.d.ts +7 -2
- package/dist/components/Dashboard/DashboardView.d.ts +9 -2
- package/dist/components/Dashboard/index.d.ts +1 -1
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +5 -7
- package/dist/components/Dashboard/useStuck.d.ts +18 -12
- package/dist/components/RenderedResult/RenderedResult.d.ts +3 -2
- package/dist/components/RenderedResult/ResultContainer.d.ts +18 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +7 -1
- package/dist/components/RenderedResult/chartPresentation.d.ts +15 -0
- package/dist/components/RenderedResult/chartShapeProblem.d.ts +55 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +47 -6
- package/dist/components/Report/Report.d.ts +7 -1
- package/dist/components/Report/ReportPage.d.ts +7 -0
- package/dist/components/Report/layoutRules.d.ts +45 -0
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +2 -1
- package/dist/components/ReportBuilder/ArrangeMenu.d.ts +9 -0
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +15 -4
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +3 -1
- package/dist/components/ReportBuilder/ChartPicker.d.ts +4 -2
- package/dist/components/ReportBuilder/EditorSurface.d.ts +10 -1
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +1 -1
- package/dist/components/ReportBuilder/TileFrame.d.ts +54 -10
- package/dist/components/ReportBuilder/TileMenu.d.ts +5 -2
- package/dist/components/ReportBuilder/builderControls.d.ts +19 -0
- package/dist/components/ReportBuilder/catalog.d.ts +23 -0
- package/dist/components/ReportBuilder/chartLine.d.ts +38 -5
- package/dist/components/ReportBuilder/controls.d.ts +2 -2
- package/dist/components/ReportBuilder/document.d.ts +53 -5
- package/dist/components/ReportBuilder/imports.d.ts +7 -0
- package/dist/components/ReportBuilder/placement.d.ts +121 -0
- package/dist/components/ReportBuilder/preview.d.ts +59 -10
- package/dist/components/ReportBuilder/sortable.d.ts +12 -1
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +1 -1
- package/dist/components/ReportBuilder/useBuilderShortcuts.d.ts +9 -1
- package/dist/components/ReportBuilder/useEdgeResize.d.ts +84 -0
- package/dist/components/ReportBuilder/useTileReorder.d.ts +30 -3
- package/dist/index.cjs.js +7 -7
- package/dist/index.es.js +3349 -3307
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-72YFLeNk.es.js → text-entry-YKJZbRPo.es.js} +2 -2
- package/dist/theme/classes.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +15 -0
- package/dist/{useCompiledDocument-B4QF1mIl.es.js → useCompiledDocument-CaYP_OYG.es.js} +6353 -6047
- package/dist/useCompiledDocument-zYEfLogf.cjs.js +142 -0
- package/dist/utils/blankQuoted.d.ts +15 -0
- package/package.json +1 -1
- package/src/builder-entry.ts +1 -0
- package/src/components/Dashboard/DashboardGrid.tsx +129 -10
- package/src/components/Dashboard/DashboardTile.tsx +15 -1
- package/src/components/Dashboard/DashboardView.tsx +64 -10
- package/src/components/Dashboard/TileCard.tsx +6 -0
- package/src/components/Dashboard/index.ts +1 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +19 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +15 -36
- package/src/components/Dashboard/tileHeight.spec.ts +72 -0
- package/src/components/Dashboard/useStuck.ts +76 -28
- package/src/components/Package/NewDocumentDialog.spec.tsx +20 -16
- package/src/components/Package/NewDocumentDialog.tsx +10 -11
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +167 -2
- package/src/components/RenderedResult/RenderedResult.tsx +39 -6
- package/src/components/RenderedResult/ResultContainer.tsx +99 -10
- package/src/components/RenderedResult/ResultPanel.tsx +25 -1
- package/src/components/RenderedResult/chartPresentation.spec.ts +153 -0
- package/src/components/RenderedResult/chartPresentation.ts +166 -0
- package/src/components/RenderedResult/chartShapeProblem.spec.tsx +245 -0
- package/src/components/RenderedResult/chartShapeProblem.ts +219 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +75 -3
- package/src/components/RenderedResult/resultSizing.ts +71 -11
- package/src/components/Report/Report.spec.tsx +19 -0
- package/src/components/Report/Report.tsx +8 -1
- package/src/components/Report/ReportPage.tsx +13 -1
- package/src/components/Report/layoutRules.spec.ts +43 -3
- package/src/components/Report/layoutRules.ts +70 -0
- package/src/components/Report/tileOverflow.spec.tsx +162 -0
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +2 -2
- package/src/components/ReportBuilder/AddTileDialog.tsx +11 -6
- package/src/components/ReportBuilder/ArrangeMenu.tsx +80 -0
- package/src/components/ReportBuilder/BuilderBar.tsx +5 -1
- package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -1
- package/src/components/ReportBuilder/BuilderGrid.tsx +142 -35
- package/src/components/ReportBuilder/BuilderToolbar.tsx +4 -0
- package/src/components/ReportBuilder/ChartPicker.spec.ts +91 -4
- package/src/components/ReportBuilder/ChartPicker.tsx +45 -10
- package/src/components/ReportBuilder/DrillDialog.tsx +8 -2
- package/src/components/ReportBuilder/EditorSurface.tsx +101 -20
- package/src/components/ReportBuilder/FilterDialog.tsx +17 -8
- package/src/components/ReportBuilder/FilterStrip.tsx +2 -1
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +193 -2
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +2 -2
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +242 -2
- package/src/components/ReportBuilder/ReportBuilder.tsx +161 -27
- package/src/components/ReportBuilder/ReportEditor.fileModel.spec.tsx +178 -0
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +3 -5
- package/src/components/ReportBuilder/ReportEditor.readOnlyTitle.spec.tsx +92 -0
- package/src/components/ReportBuilder/ReportEditor.tsx +13 -0
- package/src/components/ReportBuilder/TileFrame.tsx +366 -170
- package/src/components/ReportBuilder/TileMenu.tsx +259 -20
- package/src/components/ReportBuilder/ViewPicker.tsx +4 -3
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +34 -0
- package/src/components/ReportBuilder/addTileToDocument.ts +26 -1
- package/src/components/ReportBuilder/builderControls.ts +34 -0
- package/src/components/ReportBuilder/catalog.aggregate.spec.ts +137 -1
- package/src/components/ReportBuilder/catalog.ts +90 -37
- package/src/components/ReportBuilder/chartLine.spec.ts +42 -5
- package/src/components/ReportBuilder/chartLine.ts +80 -2
- package/src/components/ReportBuilder/controls.ts +4 -3
- package/src/components/ReportBuilder/document.ts +65 -7
- package/src/components/ReportBuilder/emptyStart.spec.ts +1 -1
- package/src/components/ReportBuilder/entryLayout.spec.ts +151 -0
- package/src/components/ReportBuilder/imports.ts +1 -1
- package/src/components/ReportBuilder/invariants.spec.ts +18 -10
- package/src/components/ReportBuilder/layout.ts +3 -0
- package/src/components/ReportBuilder/placement.spec.ts +401 -0
- package/src/components/ReportBuilder/placement.ts +416 -0
- package/src/components/ReportBuilder/preview.shapes.spec.ts +46 -6
- package/src/components/ReportBuilder/preview.spec.ts +151 -11
- package/src/components/ReportBuilder/preview.ts +203 -40
- package/src/components/ReportBuilder/preview.unsaved.compile.spec.ts +190 -0
- package/src/components/ReportBuilder/readDocument.spec.ts +53 -19
- package/src/components/ReportBuilder/readDocument.ts +197 -29
- package/src/components/ReportBuilder/scannerShapes.spec.ts +10 -10
- package/src/components/ReportBuilder/sortable.tsx +30 -2
- package/src/components/ReportBuilder/spliceDocument.chart.spec.ts +1 -1
- package/src/components/ReportBuilder/spliceDocument.color.spec.ts +80 -0
- package/src/components/ReportBuilder/spliceDocument.colspan.spec.ts +78 -0
- package/src/components/ReportBuilder/spliceDocument.spec.ts +110 -58
- package/src/components/ReportBuilder/spliceDocument.ts +139 -91
- package/src/components/ReportBuilder/statementExtent.spec.ts +3 -3
- package/src/components/ReportBuilder/testing/reportGivenOrder.json +42 -0
- package/src/components/ReportBuilder/textTiles.spec.ts +2 -2
- package/src/components/ReportBuilder/tileDisplayTitle.ts +2 -2
- package/src/components/ReportBuilder/useBuilderSession.ts +7 -2
- package/src/components/ReportBuilder/useBuilderShortcuts.ts +25 -1
- package/src/components/ReportBuilder/useEdgeResize.spec.tsx +324 -0
- package/src/components/ReportBuilder/useEdgeResize.ts +397 -0
- package/src/components/ReportBuilder/useTileEditing.ts +16 -3
- package/src/components/ReportBuilder/useTileReorder.ts +143 -6
- package/src/components/given/FilterButton.spec.tsx +27 -11
- package/src/components/given/FilterButton.tsx +19 -6
- package/src/theme/classes.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +72 -1
- package/src/theme/resolveTheme.ts +43 -0
- package/src/utils/blankQuoted.spec.ts +50 -0
- package/src/utils/blankQuoted.ts +32 -0
- package/src/utils/malloyText.ts +2 -1
- package/dist/RenderedResult-DnBtf-cI.es.js +0 -593
- package/dist/RenderedResult-DtQtNV0d.cjs.js +0 -153
- package/dist/ServerProvider-BIFPCzTD.cjs.js +0 -1
- package/dist/components/ReportBuilder/useTileResize.d.ts +0 -32
- package/dist/useCompiledDocument-D0OAMejE.cjs.js +0 -142
- package/src/components/ReportBuilder/useTileResize.spec.tsx +0 -146
- package/src/components/ReportBuilder/useTileResize.ts +0 -133
|
@@ -5,6 +5,7 @@ import { ListItemText, MenuItem, TextField } from "@mui/material";
|
|
|
5
5
|
import { useId } from "react";
|
|
6
6
|
import type { CatalogView } from "./catalog";
|
|
7
7
|
import type { ChartPick, ChartState } from "./chartLine";
|
|
8
|
+
import { chartShapeGap } from "../RenderedResult/chartShapeProblem";
|
|
8
9
|
|
|
9
10
|
export interface ChartChoice {
|
|
10
11
|
value: ChartState;
|
|
@@ -12,8 +13,14 @@ export interface ChartChoice {
|
|
|
12
13
|
/** Listed but not pickable; `reason` says what the view would need. */
|
|
13
14
|
disabled?: boolean;
|
|
14
15
|
reason?: string;
|
|
16
|
+
/** A quiet second line on a choice that can be picked: what it means. */
|
|
17
|
+
hint?: string;
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
/** The reason a chart that plots rows cannot draw a view with no group-by: said in the reader's words, not the renderer's. */
|
|
21
|
+
const NO_X_AXIS = (chart: string) =>
|
|
22
|
+
`This view has no field for the x-axis: ${chart.toLowerCase()} needs a group by, such as a date or a category`;
|
|
23
|
+
|
|
17
24
|
/** Why a view is absent, so the reason on a disabled choice says whether to wait or to pick another. */
|
|
18
25
|
export type ViewStatus = "loading" | "unlisted";
|
|
19
26
|
|
|
@@ -24,6 +31,7 @@ const LABELS: Record<ChartPick, string> = {
|
|
|
24
31
|
scatter_chart: "Scatter",
|
|
25
32
|
shape_map: "Shape map",
|
|
26
33
|
segment_map: "Segment map",
|
|
34
|
+
combo_chart: "Bar and line",
|
|
27
35
|
};
|
|
28
36
|
|
|
29
37
|
/**
|
|
@@ -31,7 +39,7 @@ const LABELS: Record<ChartPick, string> = {
|
|
|
31
39
|
* Whatever the cell has now stays selectable, so the select never shows a value it does not offer.
|
|
32
40
|
*/
|
|
33
41
|
export function chartChoices(
|
|
34
|
-
view: Pick<CatalogView, "chart" | "aggregateOnly"> | undefined,
|
|
42
|
+
view: Pick<CatalogView, "chart" | "aggregateOnly" | "shape"> | undefined,
|
|
35
43
|
current: ChartState,
|
|
36
44
|
viewStatus?: ViewStatus,
|
|
37
45
|
): ChartChoice[] {
|
|
@@ -39,21 +47,45 @@ export function chartChoices(
|
|
|
39
47
|
view !== undefined
|
|
40
48
|
? undefined
|
|
41
49
|
: viewStatus === "loading"
|
|
42
|
-
? "Still loading this
|
|
50
|
+
? "Still loading this tile's details"
|
|
43
51
|
: viewStatus === "unlisted"
|
|
44
|
-
? "Not
|
|
52
|
+
? "Not in the model's list, so its shape is unknown"
|
|
45
53
|
: undefined;
|
|
54
|
+
const shape = view?.shape;
|
|
46
55
|
const reasonFor = (pick: ChartPick): string | undefined => {
|
|
47
56
|
if (current === pick) return undefined;
|
|
48
57
|
if (pick === "big_value")
|
|
49
58
|
return view?.aggregateOnly === true
|
|
50
59
|
? undefined
|
|
51
|
-
:
|
|
60
|
+
: shape && shape.groupBys > 0
|
|
61
|
+
? "This view has a group by, so it is more than one row; big numbers need a view of totals only"
|
|
62
|
+
: (unknown ?? "Needs results that are only totals (no group by)");
|
|
52
63
|
if (pick === "shape_map" || pick === "segment_map")
|
|
53
64
|
return view?.chart === pick
|
|
54
65
|
? undefined
|
|
55
|
-
: (unknown ?? "Needs a
|
|
56
|
-
return undefined;
|
|
66
|
+
: (unknown ?? "Needs a map chart set in the model");
|
|
67
|
+
if (view?.chart === pick) return undefined;
|
|
68
|
+
// The charts that plot rows, by the same rule the result panel applies.
|
|
69
|
+
// An unknown shape leaves them pickable, since nothing says they cannot
|
|
70
|
+
// draw, except a bar and line chart, which few views can fill: a bare
|
|
71
|
+
// `# combo_chart` draws the first total as bars on the left axis and the
|
|
72
|
+
// second as a line on the right, and any other count is an error.
|
|
73
|
+
if (!shape)
|
|
74
|
+
return pick === "combo_chart"
|
|
75
|
+
? (unknown ??
|
|
76
|
+
"Needs a view with a group by and exactly two totals: the first is drawn as bars, the second as a line")
|
|
77
|
+
: undefined;
|
|
78
|
+
const chart = `A ${LABELS[pick].toLowerCase()} chart`;
|
|
79
|
+
switch (chartShapeGap(pick, shape)) {
|
|
80
|
+
case "no_x_axis":
|
|
81
|
+
return NO_X_AXIS(chart);
|
|
82
|
+
case "combo_totals":
|
|
83
|
+
return `A bar and line chart needs exactly two totals, the first drawn as bars and the second as a line; this view has ${shape.totals}`;
|
|
84
|
+
case "no_y_axis":
|
|
85
|
+
return `This view has no total for the y-axis: ${chart.toLowerCase()} needs at least one aggregate`;
|
|
86
|
+
default:
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
57
89
|
};
|
|
58
90
|
const picks: ChartPick[] = [
|
|
59
91
|
"line_chart",
|
|
@@ -62,9 +94,10 @@ export function chartChoices(
|
|
|
62
94
|
"scatter_chart",
|
|
63
95
|
"shape_map",
|
|
64
96
|
"segment_map",
|
|
97
|
+
"combo_chart",
|
|
65
98
|
];
|
|
66
99
|
return [
|
|
67
|
-
{ value: "default", label: "
|
|
100
|
+
{ value: "default", label: "Default", hint: "As set in the model" },
|
|
68
101
|
{ value: "none", label: "Table" },
|
|
69
102
|
...picks.map((pick): ChartChoice => {
|
|
70
103
|
const reason = reasonFor(pick);
|
|
@@ -92,7 +125,7 @@ export function ChartPicker({
|
|
|
92
125
|
}: {
|
|
93
126
|
state: ChartState;
|
|
94
127
|
/** The catalog's view this cell runs, when it is one the catalog knows. */
|
|
95
|
-
view: Pick<CatalogView, "chart" | "aggregateOnly"> | undefined;
|
|
128
|
+
view: Pick<CatalogView, "chart" | "aggregateOnly" | "shape"> | undefined;
|
|
96
129
|
/** Why `view` is absent, worded into the reasons on the charts that need its shape. */
|
|
97
130
|
viewStatus?: ViewStatus;
|
|
98
131
|
/** Which cell this is, so the control is named apart from its neighbours. */
|
|
@@ -125,7 +158,7 @@ export function ChartPicker({
|
|
|
125
158
|
FormHelperTextProps={{ id: reasonId }}
|
|
126
159
|
SelectProps={{
|
|
127
160
|
...(onOpen ? { onOpen } : {}),
|
|
128
|
-
// The menu items carry a reason line; the closed field shows the label alone.
|
|
161
|
+
// The menu items carry a reason or hint line; the closed field shows the label alone.
|
|
129
162
|
renderValue: (value) =>
|
|
130
163
|
choices.find((choice) => choice.value === value)?.label ??
|
|
131
164
|
String(value),
|
|
@@ -147,7 +180,9 @@ export function ChartPicker({
|
|
|
147
180
|
>
|
|
148
181
|
<ListItemText
|
|
149
182
|
primary={choice.label}
|
|
150
|
-
{...(choice.reason
|
|
183
|
+
{...((choice.reason ?? choice.hint)
|
|
184
|
+
? { secondary: choice.reason ?? choice.hint }
|
|
185
|
+
: {})}
|
|
151
186
|
/>
|
|
152
187
|
</MenuItem>
|
|
153
188
|
))}
|
|
@@ -153,8 +153,14 @@ export function DrillDialog({
|
|
|
153
153
|
{tileLabel} ·{" "}
|
|
154
154
|
</Box>
|
|
155
155
|
)}
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
{/* The renderer reports a click on a table cell and on nothing
|
|
157
|
+
a chart draws, and the builder renders its tiles with no
|
|
158
|
+
click handling at all, because a press there selects the
|
|
159
|
+
tile. Both are said here, or the setting looks broken. */}
|
|
160
|
+
A click on a table cell sets a filter to its value, on this
|
|
161
|
+
report or on the one it opens. Bars, lines and points on a chart
|
|
162
|
+
do not respond to a click. Clicks work in the report, not while
|
|
163
|
+
you edit it.
|
|
158
164
|
</>
|
|
159
165
|
}
|
|
160
166
|
actions={
|
|
@@ -18,7 +18,14 @@ import { tileIgnoredFilterLabels } from "../Dashboard/TileFilterTag";
|
|
|
18
18
|
import { documentPreamble } from "../Dashboard/textSource";
|
|
19
19
|
import { GivensPanel } from "../given";
|
|
20
20
|
import { Loading } from "../Loading";
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
isPlaced,
|
|
23
|
+
PLACED_DEFAULT_ROWSPAN,
|
|
24
|
+
tileHeightPx,
|
|
25
|
+
} from "../Dashboard/DashboardGrid";
|
|
26
|
+
import { layoutRules } from "../Report/layoutRules";
|
|
27
|
+
import type { CompiledModel } from "../../client";
|
|
28
|
+
import { documentViewsOf } from "./catalog";
|
|
22
29
|
import { useReportListing } from "../Package/useDocumentLocation";
|
|
23
30
|
import {
|
|
24
31
|
BUILDER_HANDOFF_STALE_MS,
|
|
@@ -36,6 +43,8 @@ import type { FixedFilter } from "./FilterStrip";
|
|
|
36
43
|
import type { ReportLayout } from "../Package/documentLocation";
|
|
37
44
|
import {
|
|
38
45
|
isQueryTile,
|
|
46
|
+
isReadOnlyTile,
|
|
47
|
+
tileExpression,
|
|
39
48
|
tileKey,
|
|
40
49
|
type DashboardDocument,
|
|
41
50
|
type DashboardTile as DocumentTile,
|
|
@@ -47,6 +56,7 @@ import {
|
|
|
47
56
|
previewGivens,
|
|
48
57
|
previewTileQuery,
|
|
49
58
|
tileExpressionKey,
|
|
59
|
+
unsavedSources,
|
|
50
60
|
type PreviewTileQuery,
|
|
51
61
|
} from "./preview";
|
|
52
62
|
import type { TextSourceOptions } from "./ReportEditor";
|
|
@@ -91,7 +101,16 @@ export function EditorSurface({
|
|
|
91
101
|
savesTo,
|
|
92
102
|
saveLabel,
|
|
93
103
|
note,
|
|
104
|
+
fileModel,
|
|
94
105
|
}: {
|
|
106
|
+
/**
|
|
107
|
+
* The file's own compiled model as the package serves it, for the shapes
|
|
108
|
+
* of the views it declares (which charts each tile can take). Absent for a
|
|
109
|
+
* document held as text, whose compile answer carries no per-view shapes,
|
|
110
|
+
* and whenever the opened text is not the one this model compiled (a kept
|
|
111
|
+
* draft, the host's record, a held-back version): the catalog answers then.
|
|
112
|
+
*/
|
|
113
|
+
fileModel?: CompiledModel;
|
|
95
114
|
textSource?: TextSourceOptions;
|
|
96
115
|
environmentName: string;
|
|
97
116
|
packageName: string;
|
|
@@ -244,17 +263,21 @@ export function EditorSurface({
|
|
|
244
263
|
: undefined,
|
|
245
264
|
[catalog, textSource, runModelPath],
|
|
246
265
|
);
|
|
247
|
-
const
|
|
248
|
-
() =>
|
|
266
|
+
const documentViews = useMemo(
|
|
267
|
+
() => (fileModel ? documentViewsOf(fileModel) : undefined),
|
|
268
|
+
[fileModel],
|
|
269
|
+
);
|
|
270
|
+
const offered = useMemo(() => {
|
|
271
|
+
const scoped =
|
|
249
272
|
catalog && runSources
|
|
250
273
|
? {
|
|
251
274
|
sources: catalog.sources.filter((s) =>
|
|
252
275
|
runSources.includes(s.name),
|
|
253
276
|
),
|
|
254
277
|
}
|
|
255
|
-
: catalog
|
|
256
|
-
|
|
257
|
-
);
|
|
278
|
+
: catalog;
|
|
279
|
+
return scoped && documentViews ? { ...scoped, documentViews } : scoped;
|
|
280
|
+
}, [catalog, runSources, documentViews]);
|
|
258
281
|
|
|
259
282
|
const [doc, setDoc] = useState(opened.document);
|
|
260
283
|
useEffect(() => setDoc(opened.document), [opened.document]);
|
|
@@ -304,6 +327,21 @@ export function EditorSurface({
|
|
|
304
327
|
),
|
|
305
328
|
[manifest],
|
|
306
329
|
);
|
|
330
|
+
// The served tiles' labels, keyed the same way. A tile the builder shows
|
|
331
|
+
// read-only (its view in the model, or a named query) carries no label in
|
|
332
|
+
// the document, since its `# label` sits on a declaration the builder does
|
|
333
|
+
// not read; the reader titles it from the server's label, and so does this.
|
|
334
|
+
const servedLabels = useMemo(
|
|
335
|
+
() =>
|
|
336
|
+
new Map(
|
|
337
|
+
(manifest?.tiles ?? []).flatMap((tile) =>
|
|
338
|
+
tile.kind !== "text" && tile.query && tile.label
|
|
339
|
+
? [[tileExpressionKey(tile.query), tile.label] as const]
|
|
340
|
+
: [],
|
|
341
|
+
),
|
|
342
|
+
),
|
|
343
|
+
[manifest],
|
|
344
|
+
);
|
|
307
345
|
// Givens a tile reads through the model (a source's own `where:`), not a
|
|
308
346
|
// binding in this file: shown, so the row matches the reader's, but the
|
|
309
347
|
// model's to change.
|
|
@@ -312,8 +350,8 @@ export function EditorSurface({
|
|
|
312
350
|
[doc, opened.document, servedReads],
|
|
313
351
|
);
|
|
314
352
|
const specs = useMemo(
|
|
315
|
-
() => previewGivens(doc, modelSpecs, modelReads),
|
|
316
|
-
[doc, modelSpecs, modelReads],
|
|
353
|
+
() => previewGivens(doc, modelSpecs, modelReads, servedReads),
|
|
354
|
+
[doc, modelSpecs, modelReads, servedReads],
|
|
317
355
|
);
|
|
318
356
|
// A filter in the row the builder can show and set but not change: say
|
|
319
357
|
// where it is set instead. Not always the model: a report's own `source:`
|
|
@@ -414,6 +452,12 @@ export function EditorSurface({
|
|
|
414
452
|
),
|
|
415
453
|
[opened.document],
|
|
416
454
|
);
|
|
455
|
+
// Extensions this session added, which the model the tiles run on does not
|
|
456
|
+
// have until the file is saved and served: a tile on one runs on its base.
|
|
457
|
+
const unsaved = useMemo(
|
|
458
|
+
() => unsavedSources(doc, opened.document, modelPath, !!textSource),
|
|
459
|
+
[doc, opened.document, modelPath, textSource],
|
|
460
|
+
);
|
|
417
461
|
const renderTile = useMemo(
|
|
418
462
|
() =>
|
|
419
463
|
function LiveTile(
|
|
@@ -421,13 +465,17 @@ export function EditorSurface({
|
|
|
421
465
|
heading?: TileHeadingSlots,
|
|
422
466
|
chrome: TileChrome = "card",
|
|
423
467
|
) {
|
|
468
|
+
const title =
|
|
469
|
+
(isReadOnlyTile(tile)
|
|
470
|
+
? servedLabels.get(tileExpressionKey(tileExpression(tile)))
|
|
471
|
+
: undefined) ?? tileDisplayTitle(tile);
|
|
424
472
|
// The bindings a tile runs with come from the manifest; running before it lands queries every tile once unbound and again bound.
|
|
425
473
|
// Until then the tile's own card and heading stand, so nothing pops in when it runs.
|
|
426
474
|
if (notCompiled)
|
|
427
475
|
return (
|
|
428
476
|
<TileCard chrome={chrome}>
|
|
429
477
|
<TileHeading
|
|
430
|
-
title={heading?.title ??
|
|
478
|
+
title={heading?.title ?? title}
|
|
431
479
|
subtitle={heading ? heading.subtitle : tile.subtitle}
|
|
432
480
|
/>
|
|
433
481
|
<Typography
|
|
@@ -442,14 +490,14 @@ export function EditorSurface({
|
|
|
442
490
|
return (
|
|
443
491
|
<TileCard chrome={chrome}>
|
|
444
492
|
<TileHeading
|
|
445
|
-
title={heading?.title ??
|
|
493
|
+
title={heading?.title ?? title}
|
|
446
494
|
subtitle={heading ? heading.subtitle : tile.subtitle}
|
|
447
495
|
/>
|
|
448
496
|
<Loading text="Running…" />
|
|
449
497
|
</TileCard>
|
|
450
498
|
);
|
|
451
499
|
const servedReadsOf = servedReads.get(
|
|
452
|
-
tileExpressionKey(
|
|
500
|
+
tileExpressionKey(tileExpression(tile)),
|
|
453
501
|
);
|
|
454
502
|
// A tile not yet edited runs the served view with the served
|
|
455
503
|
// tile's givens: the request the reader sends, so it shares the
|
|
@@ -462,20 +510,30 @@ export function EditorSurface({
|
|
|
462
510
|
sameTile(openedTiles.get(tileKey(tile)), tile);
|
|
463
511
|
const query: PreviewTileQuery = untouched
|
|
464
512
|
? {
|
|
465
|
-
expression:
|
|
513
|
+
expression: tileExpression(tile),
|
|
466
514
|
givenNames: [...servedReadsOf],
|
|
467
515
|
reads: [...servedReadsOf],
|
|
468
516
|
}
|
|
469
|
-
: previewTileQuery(
|
|
517
|
+
: previewTileQuery(
|
|
518
|
+
doc,
|
|
519
|
+
tile,
|
|
520
|
+
runnable,
|
|
521
|
+
applied,
|
|
522
|
+
servedReadsOf,
|
|
523
|
+
unsaved,
|
|
524
|
+
);
|
|
525
|
+
const rules = layoutRules(doc.layout, doc.columns);
|
|
470
526
|
return (
|
|
471
527
|
<DashboardTile
|
|
472
528
|
environmentName={environmentName}
|
|
473
529
|
packageName={packageName}
|
|
474
530
|
versionId={queryVersionId}
|
|
475
|
-
modelPath={runModelPath}
|
|
476
|
-
{...(preamble !== undefined
|
|
531
|
+
modelPath={query.modelPath ?? runModelPath}
|
|
532
|
+
{...(preamble !== undefined && query.modelPath === undefined
|
|
533
|
+
? { preamble }
|
|
534
|
+
: {})}
|
|
477
535
|
{...(restrictedTiles.has(
|
|
478
|
-
tileExpressionKey(
|
|
536
|
+
tileExpressionKey(tileExpression(tile)),
|
|
479
537
|
)
|
|
480
538
|
? { restricted: true }
|
|
481
539
|
: {})}
|
|
@@ -483,7 +541,7 @@ export function EditorSurface({
|
|
|
483
541
|
{...(query.annotation
|
|
484
542
|
? { annotation: query.annotation }
|
|
485
543
|
: {})}
|
|
486
|
-
label={
|
|
544
|
+
label={title}
|
|
487
545
|
chrome={chrome}
|
|
488
546
|
subtitle={tile.subtitle}
|
|
489
547
|
{...(heading ? { heading } : {})}
|
|
@@ -502,7 +560,22 @@ export function EditorSurface({
|
|
|
502
560
|
: {};
|
|
503
561
|
})()}
|
|
504
562
|
ignoredFilters={tileIgnoredFilterLabels(query.reads, specs)}
|
|
505
|
-
|
|
563
|
+
// Its own rows when it has them (a rowspan, or a placed
|
|
564
|
+
// report's fixed rows, placed yet or not); otherwise the
|
|
565
|
+
// layout's cap.
|
|
566
|
+
height={
|
|
567
|
+
tile.rowspan !== undefined || isPlaced(doc.tiles)
|
|
568
|
+
? tileHeightPx(
|
|
569
|
+
tile.rowspan ?? PLACED_DEFAULT_ROWSPAN.query,
|
|
570
|
+
)
|
|
571
|
+
: rules.tileMaxHeight
|
|
572
|
+
}
|
|
573
|
+
tableMaxHeight={rules.tableMaxHeight}
|
|
574
|
+
// As the reader does: every tile of a placed report sits
|
|
575
|
+
// in fixed rows, placed yet or not.
|
|
576
|
+
fixedHeight={
|
|
577
|
+
tile.rowspan !== undefined || isPlaced(doc.tiles)
|
|
578
|
+
}
|
|
506
579
|
/>
|
|
507
580
|
);
|
|
508
581
|
},
|
|
@@ -514,11 +587,13 @@ export function EditorSurface({
|
|
|
514
587
|
missing,
|
|
515
588
|
runnable,
|
|
516
589
|
servedReads,
|
|
590
|
+
servedLabels,
|
|
517
591
|
environmentName,
|
|
518
592
|
packageName,
|
|
519
593
|
queryVersionId,
|
|
520
594
|
runModelPath,
|
|
521
595
|
preamble,
|
|
596
|
+
unsaved,
|
|
522
597
|
restrictedTiles,
|
|
523
598
|
applied,
|
|
524
599
|
tileHostGivens,
|
|
@@ -659,8 +734,8 @@ function sameTile(
|
|
|
659
734
|
}
|
|
660
735
|
|
|
661
736
|
/**
|
|
662
|
-
* A tile less what only frames its result: its title, subtitle, width, row
|
|
663
|
-
* and card are drawn by the tile around the result, not sent with the query.
|
|
737
|
+
* A tile less what only frames its result: its title, subtitle, width, row,
|
|
738
|
+
* rowspan and card are drawn by the tile around the result, not sent with the query.
|
|
664
739
|
* Retitling a tile re-ran it before, and its chart blinked as the same rows
|
|
665
740
|
* were drawn again.
|
|
666
741
|
*/
|
|
@@ -670,6 +745,9 @@ function whatRuns(tile: DocumentTile): DocumentTile {
|
|
|
670
745
|
subtitle: _subtitle,
|
|
671
746
|
colspan: _colspan,
|
|
672
747
|
break: _break,
|
|
748
|
+
rowspan: _rowspan,
|
|
749
|
+
row: _row,
|
|
750
|
+
col: _col,
|
|
673
751
|
borderless: _borderless,
|
|
674
752
|
...runs
|
|
675
753
|
} = tile as DocumentTile & {
|
|
@@ -677,6 +755,9 @@ function whatRuns(tile: DocumentTile): DocumentTile {
|
|
|
677
755
|
subtitle?: unknown;
|
|
678
756
|
colspan?: unknown;
|
|
679
757
|
break?: unknown;
|
|
758
|
+
rowspan?: unknown;
|
|
759
|
+
row?: unknown;
|
|
760
|
+
col?: unknown;
|
|
680
761
|
borderless?: unknown;
|
|
681
762
|
};
|
|
682
763
|
return runs as DocumentTile;
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
} from "./controls";
|
|
54
54
|
import {
|
|
55
55
|
isQueryTile,
|
|
56
|
+
tileKey,
|
|
56
57
|
type DashboardDocument,
|
|
57
58
|
type DashboardTile,
|
|
58
59
|
type LocalGiven,
|
|
@@ -205,9 +206,10 @@ function FieldPicker({
|
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
/**
|
|
208
|
-
* Why a tile cannot take a binding. A tile declared on its source
|
|
209
|
-
* declared HERE in a body with no single block for a `where
|
|
210
|
-
* situations, and saying "from the model" about the
|
|
209
|
+
* Why a tile cannot take a binding. A tile declared on its source, one
|
|
210
|
+
* declared HERE in a body with no single block for a `where:`, and one naming a
|
|
211
|
+
* query are different situations, and saying "from the model" about the others
|
|
212
|
+
* is untrue.
|
|
211
213
|
*/
|
|
212
214
|
const unbindable = (tile: DashboardTile | undefined) =>
|
|
213
215
|
tile && isQueryTile(tile) && tile.declaration.kind === "opaque"
|
|
@@ -215,10 +217,17 @@ const unbindable = (tile: DashboardTile | undefined) =>
|
|
|
215
217
|
label: "Not bindable",
|
|
216
218
|
reason: `Its body is ${tile.declaration.why}, so a filter has no single place to go.`,
|
|
217
219
|
}
|
|
218
|
-
:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
: tile && isQueryTile(tile) && tile.declaration.kind === "query"
|
|
221
|
+
? {
|
|
222
|
+
label: "Not bindable",
|
|
223
|
+
reason:
|
|
224
|
+
"It names a query, whose filters live in that query's own definition.",
|
|
225
|
+
}
|
|
226
|
+
: {
|
|
227
|
+
label: "From the model",
|
|
228
|
+
reason:
|
|
229
|
+
"Declared on its source, which this report does not write.",
|
|
230
|
+
};
|
|
222
231
|
|
|
223
232
|
export function FilterDialog({
|
|
224
233
|
open,
|
|
@@ -709,7 +718,7 @@ export function FilterDialog({
|
|
|
709
718
|
: undefined;
|
|
710
719
|
return (
|
|
711
720
|
<Stack
|
|
712
|
-
key={
|
|
721
|
+
key={tileKey(tile)}
|
|
713
722
|
direction="row"
|
|
714
723
|
sx={{
|
|
715
724
|
gap: 1,
|
|
@@ -78,7 +78,8 @@ export function FilterStrip({
|
|
|
78
78
|
if (fixed !== undefined) {
|
|
79
79
|
const { modelPath } = fixed;
|
|
80
80
|
return {
|
|
81
|
-
|
|
81
|
+
// Declared here or in the model: a report's own source can fix one of its own.
|
|
82
|
+
origin: byName.get(name)?.origin ?? "model",
|
|
82
83
|
fixed: fixed.reason,
|
|
83
84
|
...(modelPath !== undefined && onOpenModel
|
|
84
85
|
? { openModel: () => onOpenModel(modelPath) }
|