@malloy-publisher/sdk 0.3.1 → 0.4.1

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.
Files changed (136) hide show
  1. package/README.md +33 -9
  2. package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorage-BiFqO15i.es.js} +7126 -6943
  3. package/dist/DocumentStorage-CMyLifsz.cjs.js +134 -0
  4. package/dist/RenderedResult-CZzE8wv-.cjs.js +115 -0
  5. package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-CvrmYyr5.es.js} +64 -57
  6. package/dist/{ServerProvider-X2Ma0HRs.es.js → ServerProvider-BWOEKg0O.es.js} +1217 -1244
  7. package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
  8. package/dist/builder/index.cjs.js +52 -52
  9. package/dist/builder/index.es.js +3961 -3960
  10. package/dist/client/api.d.ts +100 -42
  11. package/dist/client/index.cjs.js +1 -1
  12. package/dist/client/index.es.js +1 -1
  13. package/dist/components/AppDialog.d.ts +30 -0
  14. package/dist/components/BackLink.d.ts +32 -0
  15. package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
  16. package/dist/components/Dashboard/telemetry.d.ts +24 -7
  17. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
  18. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +20 -2
  19. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +21 -11
  20. package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
  21. package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
  22. package/dist/components/DocumentStorage/DocumentStorage.d.ts +69 -5
  23. package/dist/components/DocumentStorage/index.d.ts +1 -0
  24. package/dist/components/ItemRow.d.ts +38 -0
  25. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
  26. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
  27. package/dist/components/Materializations/Materializations.d.ts +7 -3
  28. package/dist/components/Materializations/ScopeButton.d.ts +18 -0
  29. package/dist/components/Materializations/SectionLabel.d.ts +7 -4
  30. package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
  31. package/dist/components/Materializations/index.d.ts +0 -1
  32. package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
  33. package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
  34. package/dist/components/Package/index.d.ts +0 -1
  35. package/dist/components/PackageSection.d.ts +23 -0
  36. package/dist/components/buttons.d.ts +53 -0
  37. package/dist/components/index.d.ts +5 -0
  38. package/dist/components/styles.d.ts +49 -40
  39. package/dist/hooks/useCrudMutation.d.ts +42 -0
  40. package/dist/index.cjs.js +22 -26
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.es.js +17431 -20676
  43. package/dist/telemetry/consoleEvents.d.ts +60 -0
  44. package/dist/utils/sha256.d.ts +2 -0
  45. package/package.json +1 -1
  46. package/src/components/AppDialog.tsx +115 -0
  47. package/src/components/BackLink.tsx +83 -0
  48. package/src/components/Connections/AddConnectionDialog.tsx +50 -70
  49. package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
  50. package/src/components/Connections/EditConnectionDialog.tsx +54 -73
  51. package/src/components/Dashboard/DashboardBar.tsx +88 -0
  52. package/src/components/Dashboard/telemetry.ts +24 -5
  53. package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
  54. package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
  55. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
  56. package/src/components/DashboardBuilder/DashboardBuilder.tsx +202 -171
  57. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +706 -0
  58. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
  59. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
  60. package/src/components/DashboardBuilder/DashboardEditor.tsx +442 -94
  61. package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
  62. package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
  63. package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
  64. package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
  65. package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
  66. package/src/components/DashboardBuilder/newDashboard.ts +48 -0
  67. package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
  68. package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
  69. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
  70. package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
  71. package/src/components/DocumentStorage/BrowserDocumentStorage.ts +7 -6
  72. package/src/components/DocumentStorage/DocumentStorage.ts +78 -5
  73. package/src/components/DocumentStorage/index.ts +1 -0
  74. package/src/components/Environment/About.tsx +14 -28
  75. package/src/components/Environment/AddPackageDialog.tsx +85 -154
  76. package/src/components/Environment/Connections.tsx +125 -205
  77. package/src/components/Environment/DeletePackageDialog.tsx +32 -77
  78. package/src/components/Environment/EditPackageDialog.tsx +46 -58
  79. package/src/components/Environment/Environment.tsx +34 -36
  80. package/src/components/Environment/Packages.tsx +63 -128
  81. package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
  82. package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
  83. package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
  84. package/src/components/Home/Home.tsx +101 -214
  85. package/src/components/ItemRow.tsx +165 -0
  86. package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
  87. package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
  88. package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
  89. package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
  90. package/src/components/Materializations/Materializations.tsx +137 -140
  91. package/src/components/Materializations/ScopeButton.tsx +85 -0
  92. package/src/components/Materializations/SectionLabel.tsx +7 -4
  93. package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
  94. package/src/components/Materializations/TriggerLabel.tsx +36 -0
  95. package/src/components/Materializations/cron.spec.ts +113 -0
  96. package/src/components/Materializations/index.ts +0 -1
  97. package/src/components/Materializations/utils.spec.ts +182 -0
  98. package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
  99. package/src/components/Package/ContentTypeIcon.tsx +10 -12
  100. package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
  101. package/src/components/Package/NewDashboardDialog.tsx +265 -0
  102. package/src/components/Package/Package.tsx +184 -238
  103. package/src/components/Package/index.ts +0 -1
  104. package/src/components/PackageSection.tsx +85 -0
  105. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
  106. package/src/components/RenderedResult/RenderedResult.tsx +22 -8
  107. package/src/components/ResultsDialog.tsx +8 -32
  108. package/src/components/buttons.tsx +114 -0
  109. package/src/components/designSystem.spec.tsx +316 -0
  110. package/src/components/given/paramCodec.spec.ts +1 -1
  111. package/src/components/index.ts +10 -0
  112. package/src/components/styles.ts +49 -85
  113. package/src/hooks/useCrudMutation.spec.tsx +119 -0
  114. package/src/hooks/useCrudMutation.tsx +85 -0
  115. package/src/index.ts +9 -0
  116. package/src/telemetry/consoleEvents.spec.ts +130 -0
  117. package/src/telemetry/consoleEvents.ts +124 -0
  118. package/src/theme/defaults.ts +34 -23
  119. package/src/theme/resolveTheme.spec.ts +9 -4
  120. package/src/theme/resolveTheme.ts +12 -8
  121. package/src/utils/sha256.ts +13 -0
  122. package/test/README.md +1 -1
  123. package/test/serverProvider.tsx +5 -2
  124. package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
  125. package/dist/RenderedResult-CPi6uQWq.cjs.js +0 -115
  126. package/dist/ServerProvider-CH71GsoL.cjs.js +0 -1
  127. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
  128. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
  129. package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
  130. package/dist/components/Materializations/TriggerChip.d.ts +0 -10
  131. package/dist/components/Package/Models.d.ts +0 -6
  132. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
  133. package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
  134. package/src/components/Materializations/ScheduleCard.tsx +0 -231
  135. package/src/components/Materializations/TriggerChip.tsx +0 -44
  136. package/src/components/Package/Models.tsx +0 -71
@@ -6,10 +6,6 @@ import {
6
6
  Box,
7
7
  Button,
8
8
  Checkbox,
9
- Dialog,
10
- DialogActions,
11
- DialogContent,
12
- DialogTitle,
13
9
  MenuItem,
14
10
  Stack,
15
11
  TextField,
@@ -32,6 +28,7 @@ import {
32
28
  type MappingRow,
33
29
  } from "./controls";
34
30
  import type { DashboardDocument, DashboardTile, LocalGiven } from "./document";
31
+ import { AppDialog } from "../AppDialog";
35
32
 
36
33
  /**
37
34
  * A filter control: what it is, and which tiles it drives.
@@ -245,15 +242,13 @@ export function FilterDialog({
245
242
  );
246
243
 
247
244
  return (
248
- <Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
249
- <DialogTitle sx={{ pb: 0.5 }}>
250
- {editing ? (shown.label ?? shown.name) : "Add a filter"}
251
- {editing && (
252
- <Typography
253
- component="div"
254
- variant="caption"
255
- sx={{ color: theme.tileTitle, mt: 0.25 }}
256
- >
245
+ <AppDialog
246
+ open={open}
247
+ onClose={onClose}
248
+ title={editing ? (shown.label ?? shown.name) : "Add a filter"}
249
+ description={
250
+ editing ? (
251
+ <>
257
252
  <Box
258
253
  component="span"
259
254
  sx={{ fontFamily: "ui-monospace, monospace" }}
@@ -263,319 +258,305 @@ export function FilterDialog({
263
258
  {fromModel
264
259
  ? " · declared in the model, so its label and options are set there"
265
260
  : " · declared in this dashboard"}
266
- </Typography>
267
- )}
268
- </DialogTitle>
269
- <DialogContent>
270
- {/* Top margin on the stack, not padding on the content: MUI zeroes
271
- a DialogContent's top padding after a DialogTitle with a rule
272
- that outranks `sx`, and the fields' floating labels need the
273
- room or they clip. */}
274
- <Stack sx={{ gap: 2.5, pt: 1 }}>
275
- {/* WHAT the filter is. */}
276
- {!editing && available.length > 0 && (
277
- <ToggleButtonGroup
278
- exclusive
279
- size="small"
280
- value={source.kind}
281
- onChange={(_, value: "new" | "existing" | null) => {
282
- if (value === "new") setSource({ kind: "new" });
283
- else if (value === "existing" && available[0])
284
- pickExisting(available[0]);
285
- }}
286
- aria-label="Where the filter comes from"
261
+ </>
262
+ ) : (
263
+ "A control on the page, and the tiles it filters."
264
+ )
265
+ }
266
+ actions={
267
+ <>
268
+ {editing && (
269
+ <Button
270
+ color="error"
271
+ onClick={() => onRemove(shown.name)}
272
+ aria-label={`Remove control ${shown.name}`}
273
+ sx={{ mr: "auto" }}
287
274
  >
288
- <ToggleButton value="new">
289
- New in this dashboard
290
- </ToggleButton>
291
- <ToggleButton value="existing">
292
- From the model
293
- </ToggleButton>
294
- </ToggleButtonGroup>
275
+ Remove from dashboard
276
+ </Button>
295
277
  )}
278
+ <Button onClick={onClose}>Cancel</Button>
279
+ <Tooltip
280
+ title={
281
+ canApply || target === undefined
282
+ ? ""
283
+ : "A ticked tile has no field, or names one its source does not have."
284
+ }
285
+ >
286
+ <span>
287
+ <Button
288
+ variant="contained"
289
+ onClick={apply}
290
+ disabled={!canApply}
291
+ >
292
+ {editing ? "Apply" : "Add filter"}
293
+ </Button>
294
+ </span>
295
+ </Tooltip>
296
+ </>
297
+ }
298
+ >
299
+ <Stack sx={{ gap: 2.5, pt: 1 }}>
300
+ {/* WHAT the filter is. */}
301
+ {!editing && available.length > 0 && (
302
+ <ToggleButtonGroup
303
+ exclusive
304
+ size="small"
305
+ value={source.kind}
306
+ onChange={(_, value: "new" | "existing" | null) => {
307
+ if (value === "new") setSource({ kind: "new" });
308
+ else if (value === "existing" && available[0])
309
+ pickExisting(available[0]);
310
+ }}
311
+ aria-label="Where the filter comes from"
312
+ >
313
+ <ToggleButton value="new">New in this dashboard</ToggleButton>
314
+ <ToggleButton value="existing">From the model</ToggleButton>
315
+ </ToggleButtonGroup>
316
+ )}
317
+
318
+ {!editing && source.kind === "existing" ? (
319
+ <TextField
320
+ select
321
+ size="small"
322
+ label="Control"
323
+ value={source.name}
324
+ onChange={(event) => {
325
+ const picked = available.find(
326
+ (g) => g.name === event.target.value,
327
+ );
328
+ if (picked) pickExisting(picked);
329
+ }}
330
+ >
331
+ {available.map((given) => (
332
+ <MenuItem key={given.name} value={given.name}>
333
+ {given.label ?? given.name}
334
+ <Typography
335
+ component="span"
336
+ variant="caption"
337
+ sx={{ ml: 1, opacity: 0.6 }}
338
+ >
339
+ ${given.name}
340
+ </Typography>
341
+ </MenuItem>
342
+ ))}
343
+ </TextField>
344
+ ) : null}
296
345
 
297
- {!editing && source.kind === "existing" ? (
346
+ <Stack direction="row" sx={{ gap: 1.5, flexWrap: "wrap" }}>
347
+ {/* Hidden while per-tile fields are open: they speak for
348
+ themselves then, and a box above them that applied to
349
+ nothing would read as one more thing to fill. */}
350
+ {!perTile && (
351
+ <FieldPicker
352
+ value={field}
353
+ onChange={pickField}
354
+ fields={commonFields}
355
+ accepts={accepts}
356
+ label="Field to filter"
357
+ ariaLabel="Field to filter"
358
+ placeholder="category"
359
+ autoFocus={!editing}
360
+ error={commonProblem !== undefined}
361
+ helperText={
362
+ commonProblem ??
363
+ (!editing && newName
364
+ ? `Declared as $${newName}`
365
+ : undefined)
366
+ }
367
+ sx={{ flex: 1, minWidth: 200 }}
368
+ />
369
+ )}
370
+ {!fromModel && (
371
+ <TextField
372
+ size="small"
373
+ label="Label"
374
+ placeholder={newName ? titleCase(newName) : ""}
375
+ value={label}
376
+ onChange={(event) => setLabel(event.target.value)}
377
+ inputProps={{ "aria-label": "Control label" }}
378
+ sx={{ flex: 1, minWidth: 160 }}
379
+ />
380
+ )}
381
+ {valueTyped &&
382
+ !perTile &&
383
+ operatorField(commonOp, setCommonOp, "Comparison")}
384
+ </Stack>
385
+ {!editing && source.kind === "new" && (
386
+ <Stack direction="row" sx={{ gap: 1.5 }}>
298
387
  <TextField
299
388
  select
300
389
  size="small"
301
390
  label="Control"
302
- value={source.name}
303
- onChange={(event) => {
304
- const picked = available.find(
305
- (g) => g.name === event.target.value,
306
- );
307
- if (picked) pickExisting(picked);
391
+ value={kind}
392
+ onChange={(event) =>
393
+ pickKind(event.target.value as ControlKind)
394
+ }
395
+ inputProps={{ "aria-label": "Kind of control" }}
396
+ slotProps={{
397
+ select: {
398
+ renderValue: (value) =>
399
+ CONTROL_KINDS.find((k) => k.kind === value)
400
+ ?.label ?? String(value),
401
+ },
308
402
  }}
403
+ sx={{ flex: 1 }}
309
404
  >
310
- {available.map((given) => (
311
- <MenuItem key={given.name} value={given.name}>
312
- {given.label ?? given.name}
405
+ {CONTROL_KINDS.map((option) => (
406
+ <MenuItem key={option.kind} value={option.kind}>
407
+ {option.label}
313
408
  <Typography
314
409
  component="span"
315
410
  variant="caption"
316
411
  sx={{ ml: 1, opacity: 0.6 }}
317
412
  >
318
- ${given.name}
413
+ {option.hint}
319
414
  </Typography>
320
415
  </MenuItem>
321
416
  ))}
322
417
  </TextField>
323
- ) : null}
324
-
325
- <Stack direction="row" sx={{ gap: 1.5, flexWrap: "wrap" }}>
326
- {/* Hidden while per-tile fields are open: they speak for
327
- themselves then, and a box above them that applied to
328
- nothing would read as one more thing to fill. */}
329
- {!perTile && (
330
- <FieldPicker
331
- value={field}
332
- onChange={pickField}
333
- fields={commonFields}
334
- accepts={accepts}
335
- label="Field to filter"
336
- ariaLabel="Field to filter"
337
- placeholder="category"
338
- autoFocus={!editing}
339
- error={commonProblem !== undefined}
340
- helperText={
341
- commonProblem ??
342
- (!editing && newName
343
- ? `Declared as $${newName}`
344
- : undefined)
345
- }
346
- sx={{ flex: 1, minWidth: 200 }}
347
- />
348
- )}
349
- {!fromModel && (
418
+ {kind === "date" && (
350
419
  <TextField
351
420
  size="small"
352
- label="Label"
353
- placeholder={newName ? titleCase(newName) : ""}
354
- value={label}
355
- onChange={(event) => setLabel(event.target.value)}
356
- inputProps={{ "aria-label": "Control label" }}
357
- sx={{ flex: 1, minWidth: 160 }}
421
+ type="date"
422
+ label="Starts at"
423
+ value={dateDefault}
424
+ onChange={(event) => setDateDefault(event.target.value)}
425
+ InputLabelProps={{ shrink: true }}
426
+ sx={{ flex: 1 }}
358
427
  />
359
428
  )}
360
- {valueTyped &&
361
- !perTile &&
362
- operatorField(commonOp, setCommonOp, "Comparison")}
363
429
  </Stack>
364
- {!editing && source.kind === "new" && (
365
- <Stack direction="row" sx={{ gap: 1.5 }}>
366
- <TextField
367
- select
368
- size="small"
369
- label="Control"
370
- value={kind}
371
- onChange={(event) =>
372
- pickKind(event.target.value as ControlKind)
373
- }
374
- inputProps={{ "aria-label": "Kind of control" }}
375
- slotProps={{
376
- select: {
377
- renderValue: (value) =>
378
- CONTROL_KINDS.find((k) => k.kind === value)
379
- ?.label ?? String(value),
380
- },
381
- }}
382
- sx={{ flex: 1 }}
383
- >
384
- {CONTROL_KINDS.map((option) => (
385
- <MenuItem key={option.kind} value={option.kind}>
386
- {option.label}
387
- <Typography
388
- component="span"
389
- variant="caption"
390
- sx={{ ml: 1, opacity: 0.6 }}
391
- >
392
- {option.hint}
393
- </Typography>
394
- </MenuItem>
395
- ))}
396
- </TextField>
397
- {kind === "date" && (
398
- <TextField
399
- size="small"
400
- type="date"
401
- label="Starts at"
402
- value={dateDefault}
403
- onChange={(event) =>
404
- setDateDefault(event.target.value)
405
- }
406
- InputLabelProps={{ shrink: true }}
407
- sx={{ flex: 1 }}
408
- />
409
- )}
410
- </Stack>
411
- )}
430
+ )}
412
431
 
413
- {/* WHICH tiles. */}
414
- <Box>
415
- <Stack
416
- direction="row"
417
- sx={{ alignItems: "center", gap: 0.5 }}
432
+ {/* WHICH tiles. */}
433
+ <Box>
434
+ <Stack direction="row" sx={{ alignItems: "center", gap: 0.5 }}>
435
+ <Checkbox
436
+ size="small"
437
+ checked={bindableCount > 0 && included === bindableCount}
438
+ indeterminate={included > 0 && included < bindableCount}
439
+ disabled={bindableCount === 0}
440
+ onChange={(event) => setAll(event.target.checked)}
441
+ inputProps={{ "aria-label": "All tiles" }}
442
+ />
443
+ <Typography variant="subtitle2" sx={{ flex: 1 }}>
444
+ Applies to {included} of {document.tiles.length} tiles
445
+ </Typography>
446
+ <Button
447
+ size="small"
448
+ onClick={() => {
449
+ // Opening per-tile starts every row from the common
450
+ // field; closing it goes back to one box for all.
451
+ if (!perTile)
452
+ setRows((previous) =>
453
+ previous.map((row) => ({ ...row, field })),
454
+ );
455
+ setPerTile((was) => !was);
456
+ }}
418
457
  >
419
- <Checkbox
420
- size="small"
421
- checked={
422
- bindableCount > 0 && included === bindableCount
423
- }
424
- indeterminate={included > 0 && included < bindableCount}
425
- disabled={bindableCount === 0}
426
- onChange={(event) => setAll(event.target.checked)}
427
- inputProps={{ "aria-label": "All tiles" }}
428
- />
429
- <Typography variant="subtitle2" sx={{ flex: 1 }}>
430
- Applies to {included} of {document.tiles.length} tiles
431
- </Typography>
432
- <Button
433
- size="small"
434
- onClick={() => {
435
- // Opening per-tile starts every row from the common
436
- // field; closing it goes back to one box for all.
437
- if (!perTile)
438
- setRows((previous) =>
439
- previous.map((row) => ({ ...row, field })),
440
- );
441
- setPerTile((was) => !was);
442
- }}
443
- >
444
- {perTile ? "Same field for all" : "Adjust per tile"}
445
- </Button>
446
- </Stack>
447
- <Stack sx={{ gap: perTile ? 1 : 0 }}>
448
- {document.tiles.map((tile, index) => {
449
- const row = rows[index];
450
- const title = tile.label ?? tile.name;
451
- const problem = perTile
452
- ? rowProblems[index]
453
- : undefined;
454
- return (
455
- <Stack
456
- key={`${tile.source}.${tile.name}`}
457
- direction="row"
458
+ {perTile ? "Same field for all" : "Adjust per tile"}
459
+ </Button>
460
+ </Stack>
461
+ <Stack sx={{ gap: perTile ? 1 : 0 }}>
462
+ {document.tiles.map((tile, index) => {
463
+ const row = rows[index];
464
+ const title = tile.label ?? tile.name;
465
+ const problem = perTile ? rowProblems[index] : undefined;
466
+ return (
467
+ <Stack
468
+ key={`${tile.source}.${tile.name}`}
469
+ direction="row"
470
+ sx={{
471
+ gap: 1,
472
+ alignItems: perTile ? "flex-start" : "center",
473
+ opacity: bindable[index] ? 1 : 0.6,
474
+ }}
475
+ >
476
+ <Checkbox
477
+ size="small"
478
+ disabled={!bindable[index]}
479
+ checked={
480
+ (row?.include ?? false) && bindable[index]
481
+ }
482
+ inputProps={{
483
+ "aria-label": `Filter ${title}`,
484
+ }}
485
+ onChange={(event) =>
486
+ setRow(index, {
487
+ include: event.target.checked,
488
+ })
489
+ }
490
+ />
491
+ <Typography
492
+ variant="body2"
458
493
  sx={{
459
- gap: 1,
460
- alignItems: perTile ? "flex-start" : "center",
461
- opacity: bindable[index] ? 1 : 0.6,
494
+ flex: 1,
495
+ minWidth: 0,
496
+ pt: perTile ? 1 : 0,
462
497
  }}
498
+ noWrap
463
499
  >
464
- <Checkbox
465
- size="small"
466
- disabled={!bindable[index]}
467
- checked={
468
- (row?.include ?? false) && bindable[index]
469
- }
470
- inputProps={{
471
- "aria-label": `Filter ${title}`,
472
- }}
473
- onChange={(event) =>
474
- setRow(index, {
475
- include: event.target.checked,
476
- })
500
+ {title}
501
+ </Typography>
502
+ {!bindable[index] ? (
503
+ <Tooltip
504
+ title={
505
+ tile.declaration.kind === "inherited"
506
+ ? "Declared on its source, which this dashboard does not write."
507
+ : "Its query is written out here rather than named, so a filter cannot be added to it."
477
508
  }
478
- />
479
- <Typography
480
- variant="body2"
481
- sx={{
482
- flex: 1,
483
- minWidth: 0,
484
- pt: perTile ? 1 : 0,
485
- }}
486
- noWrap
487
509
  >
488
- {title}
489
- </Typography>
490
- {!bindable[index] ? (
491
- <Tooltip
492
- title={
493
- tile.declaration.kind === "inherited"
494
- ? "Declared on its source, which this dashboard does not write."
495
- : "Its query is written out here rather than named, so a filter cannot be added to it."
496
- }
510
+ <Typography
511
+ variant="caption"
512
+ sx={{ color: theme.tileTitle }}
497
513
  >
498
- <Typography
499
- variant="caption"
500
- sx={{ color: theme.tileTitle }}
501
- >
502
- {tile.declaration.kind === "inherited"
503
- ? "From the model"
504
- : "Inline query"}
505
- </Typography>
506
- </Tooltip>
507
- ) : (
508
- perTile && (
509
- <>
510
- {valueTyped &&
511
- operatorField(
512
- row?.op,
513
- (op) => setRow(index, { op }),
514
- `Comparison for ${title}`,
515
- )}
516
- <FieldPicker
517
- value={row?.field ?? ""}
518
- onChange={(next) =>
519
- setRow(index, { field: next })
520
- }
521
- fields={fieldsFor?.(tile)}
522
- accepts={accepts}
523
- label="Field"
524
- ariaLabel={`Field for ${title}`}
525
- disabled={!row?.include}
526
- error={problem !== undefined}
527
- helperText={problem}
528
- sx={{ width: 220 }}
529
- />
530
- </>
531
- )
532
- )}
533
- </Stack>
534
- );
535
- })}
536
- </Stack>
537
- {included === 0 && (
538
- <Typography
539
- variant="caption"
540
- sx={{ color: "warning.main", display: "block", mt: 1 }}
541
- >
542
- No tile is ticked, so this control will not appear on
543
- the dashboard.
544
- </Typography>
545
- )}
546
- </Box>
547
- </Stack>
548
- </DialogContent>
549
- <DialogActions sx={{ px: 3, py: 1.5 }}>
550
- {editing && (
551
- <Button
552
- color="error"
553
- onClick={() => onRemove(shown.name)}
554
- aria-label={`Remove control ${shown.name}`}
555
- sx={{ mr: "auto" }}
556
- >
557
- Remove from dashboard
558
- </Button>
559
- )}
560
- <Button onClick={onClose}>Cancel</Button>
561
- <Tooltip
562
- title={
563
- canApply || target === undefined
564
- ? ""
565
- : "A ticked tile has no field, or names one its source does not have."
566
- }
567
- >
568
- <span>
569
- <Button
570
- variant="contained"
571
- onClick={apply}
572
- disabled={!canApply}
514
+ {tile.declaration.kind === "inherited"
515
+ ? "From the model"
516
+ : "Inline query"}
517
+ </Typography>
518
+ </Tooltip>
519
+ ) : (
520
+ perTile && (
521
+ <>
522
+ {valueTyped &&
523
+ operatorField(
524
+ row?.op,
525
+ (op) => setRow(index, { op }),
526
+ `Comparison for ${title}`,
527
+ )}
528
+ <FieldPicker
529
+ value={row?.field ?? ""}
530
+ onChange={(next) =>
531
+ setRow(index, { field: next })
532
+ }
533
+ fields={fieldsFor?.(tile)}
534
+ accepts={accepts}
535
+ label="Field"
536
+ ariaLabel={`Field for ${title}`}
537
+ disabled={!row?.include}
538
+ error={problem !== undefined}
539
+ helperText={problem}
540
+ sx={{ width: 220 }}
541
+ />
542
+ </>
543
+ )
544
+ )}
545
+ </Stack>
546
+ );
547
+ })}
548
+ </Stack>
549
+ {included === 0 && (
550
+ <Typography
551
+ variant="caption"
552
+ sx={{ color: "warning.main", display: "block", mt: 1 }}
573
553
  >
574
- {editing ? "Apply" : "Add filter"}
575
- </Button>
576
- </span>
577
- </Tooltip>
578
- </DialogActions>
579
- </Dialog>
554
+ No tile is ticked, so this control will not appear on the
555
+ dashboard.
556
+ </Typography>
557
+ )}
558
+ </Box>
559
+ </Stack>
560
+ </AppDialog>
580
561
  );
581
562
  }