@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
@@ -147,7 +147,25 @@ export interface DashboardBuilderProps {
147
147
  /** Saves and refusals, for the host to log; see `DashboardEvent`. */
148
148
  onEvent?: DashboardEventHandler;
149
149
  /**
150
- * The host's own actions for the edit bar — Export, Done — rendered beside
150
+ * Whether the document differs from what was last saved, on every change
151
+ * and on mount.
152
+ *
153
+ * For a host that has to decide whether it may replace what is open — a
154
+ * newer version arriving from its store, a navigation away. `onChange`
155
+ * cannot answer that: the saved baseline lives in this hook, so a parent
156
+ * comparing the document it is handed against the one it passed in reads
157
+ * dirty immediately after a successful save.
158
+ */
159
+ onDirtyChange?: (dirty: boolean) => void;
160
+ /**
161
+ * Where `onSave` puts the file, for the event it reports. The builder
162
+ * cannot tell — it is handed a function — and a save into the package, into
163
+ * this browser, and into a host store that holds the record are not the
164
+ * same event.
165
+ */
166
+ savesTo?: "package" | "browser" | "host";
167
+ /**
168
+ * The host's own actions for the edit bar — Done — rendered beside
151
169
  * undo, redo and save. The builder owns the edits; where the file goes
152
170
  * afterwards is the host's, so its buttons sit in the host's slot.
153
171
  */
@@ -159,6 +177,7 @@ export function DashboardBuilder({
159
177
  document,
160
178
  onSave,
161
179
  onChange,
180
+ onDirtyChange,
162
181
  renderTile,
163
182
  controls,
164
183
  givens,
@@ -166,6 +185,7 @@ export function DashboardBuilder({
166
185
  toolbar,
167
186
  dashboards,
168
187
  onEvent,
188
+ savesTo = "package",
169
189
  }: DashboardBuilderProps) {
170
190
  const editor = useDashboardEditor({
171
191
  source,
@@ -218,6 +238,11 @@ export function DashboardBuilder({
218
238
  useEffect(() => {
219
239
  onChange?.(editor.document);
220
240
  }, [editor.document, onChange]);
241
+ // Also on mount, so a host that remounted the builder on new text is told
242
+ // the slate is clean rather than carrying the previous mount's answer.
243
+ useEffect(() => {
244
+ onDirtyChange?.(editor.dirty);
245
+ }, [editor.dirty, onDirtyChange]);
221
246
  // One object per document, or the popover's draft would reset on every
222
247
  // render of the builder while it is open.
223
248
  const settings = useMemo(
@@ -315,6 +340,7 @@ export function DashboardBuilder({
315
340
  type: "dashboard.saved",
316
341
  tiles,
317
342
  structural,
343
+ where: savesTo,
318
344
  durationMs: now() - started,
319
345
  });
320
346
  else
@@ -324,7 +350,7 @@ export function DashboardBuilder({
324
350
  });
325
351
  })
326
352
  .finally(() => setSaving(false));
327
- }, [editor, onEvent]);
353
+ }, [editor, onEvent, savesTo]);
328
354
  const save = useCallback(() => {
329
355
  if (!onSave || !editor.dirty || saving) return;
330
356
  if (!editor.structural) {
@@ -376,15 +402,6 @@ export function DashboardBuilder({
376
402
  setSelected(editor.document.tiles.length);
377
403
  };
378
404
 
379
- /** Every tile this file owns, to one fraction of the grid. */
380
- const quickLayout = (share: 1 | 2 | 3 | 4) => {
381
- const span = Math.max(1, Math.round(columns / share));
382
- editor.update((draft) => {
383
- for (const tile of draft.tiles)
384
- if (tile.declaration.kind !== "inherited") tile.colspan = span;
385
- });
386
- };
387
-
388
405
  const removeTile = (index: number) => {
389
406
  setMenu(undefined);
390
407
  setSelected(undefined);
@@ -470,9 +487,11 @@ export function DashboardBuilder({
470
487
  // grid alone, so the header, the control row and the tiles all inset
471
488
  // together and stay aligned with each other. 4px = the ring's 2px offset
472
489
  // plus its 2px width.
473
- <Stack sx={{ gap: 2, p: "4px" }}>
474
- {/* The reader's own header, from the component the dashboard renders:
475
- the surface whose job is showing the author what a reader gets. */}
490
+ // The bar carries its own gap to what it sits over, so the surface adds
491
+ // none between the two.
492
+ <Stack sx={{ gap: 0 }}>
493
+ {/* Outside the ring's inset, so the bar lines up to the pixel with the
494
+ reader's — the whole point of it being the same bar. */}
476
495
  <BuilderToolbar
477
496
  canUndo={editor.canUndo}
478
497
  canRedo={editor.canRedo}
@@ -484,170 +503,182 @@ export function DashboardBuilder({
484
503
  {...(toolbar ? { actions: toolbar } : {})}
485
504
  {...(catalog ? { onAddTile: () => setAddingTile(true) } : {})}
486
505
  onSettings={setSettingsAnchor}
487
- onQuickLayout={quickLayout}
488
506
  />
489
507
 
490
- <DashboardProse
491
- title={editor.document.title || "Untitled dashboard"}
492
- {...(editor.document.description
493
- ? { description: editor.document.description }
494
- : {})}
495
- />
508
+ {/* The ring's inset, minus the top: nothing at the top of this stack
509
+ can be selected (the prose and the control row are not tiles), and
510
+ 4px there would put the title 4px further from the bar than the
511
+ reader's is. */}
512
+ <Stack sx={{ gap: 2, px: "4px", pb: "4px" }}>
513
+ <DashboardProse
514
+ title={editor.document.title || "Untitled dashboard"}
515
+ {...(editor.document.description
516
+ ? { description: editor.document.description }
517
+ : {})}
518
+ />
496
519
 
497
- <FilterStrip
498
- controls={controlList}
499
- tileCount={editor.document.tiles.length}
500
- unknownFieldsOf={unknownFieldsOf}
501
- onEdit={(control) => setFilterDialog({ control })}
502
- onAdd={() => setFilterDialog({})}
503
- >
504
- {controls}
505
- </FilterStrip>
520
+ <FilterStrip
521
+ controls={controlList}
522
+ tileCount={editor.document.tiles.length}
523
+ unknownFieldsOf={unknownFieldsOf}
524
+ onEdit={(control) => setFilterDialog({ control })}
525
+ onAdd={() => setFilterDialog({})}
526
+ >
527
+ {controls}
528
+ </FilterStrip>
506
529
 
507
- {editor.error && (
508
- // The edit is still here; the message says what stopped it reaching
509
- // the file, which is a different thing from losing the work.
510
- <Alert severity="warning">{editor.error}</Alert>
511
- )}
530
+ {editor.error && (
531
+ // The edit is still here; the message says what stopped it reaching
532
+ // the file, which is a different thing from losing the work.
533
+ <Alert severity="warning">{editor.error}</Alert>
534
+ )}
512
535
 
513
- <DragDropProvider
514
- sensors={builderSensors}
515
- onDragStart={onDragStart}
516
- onDragOver={onDragOver}
517
- onDragEnd={onDragEnd}
518
- >
519
- <Box ref={gridBox} sx={{ position: "relative" }}>
520
- {(resize !== undefined || dragging) && (
521
- <GridGuides columns={columns} />
522
- )}
536
+ <DragDropProvider
537
+ sensors={builderSensors}
538
+ onDragStart={onDragStart}
539
+ onDragOver={onDragOver}
540
+ onDragEnd={onDragEnd}
541
+ >
542
+ <Box ref={gridBox} sx={{ position: "relative" }}>
543
+ {(resize !== undefined || dragging) && (
544
+ <GridGuides columns={columns} />
545
+ )}
523
546
 
524
- <DashboardGrid
525
- tiles={entries}
526
- columns={columns}
527
- keyOf={(entry) =>
528
- entry.kind === "gap"
529
- ? gapId(entry.after)
530
- : tileKey(entry.tile)
531
- }
532
- renderTile={(entry) => {
533
- if (entry.kind === "gap")
534
- return <GapTarget after={entry.after} />;
535
- const { tile: each, index } = entry;
536
- return (
537
- <TileFrame
538
- tile={each}
539
- index={index}
540
- selected={index === selected}
541
- menuOpen={menu?.index === index}
542
- resizeSpan={
543
- resize?.index === index ? resize.span : undefined
544
- }
545
- columns={columns}
546
- onSelect={() => setSelected(index)}
547
- onOpenMenu={(anchor) => {
548
- setSelected(index);
549
- setMenu({ anchor, index });
550
- }}
551
- onResizeStart={(event) => startResize(event, index)}
552
- onResizeMove={onResize}
553
- onResizeEnd={endResize}
554
- >
555
- {renderTile ? (
556
- renderTile(each)
557
- ) : (
558
- <TilePlaceholder tile={each} />
559
- )}
560
- </TileFrame>
547
+ <DashboardGrid
548
+ tiles={entries}
549
+ columns={columns}
550
+ keyOf={(entry) =>
551
+ entry.kind === "gap"
552
+ ? gapId(entry.after)
553
+ : tileKey(entry.tile)
554
+ }
555
+ renderTile={(entry) => {
556
+ if (entry.kind === "gap")
557
+ return <GapTarget after={entry.after} />;
558
+ const { tile: each, index } = entry;
559
+ return (
560
+ <TileFrame
561
+ tile={each}
562
+ index={index}
563
+ selected={index === selected}
564
+ menuOpen={menu?.index === index}
565
+ resizeSpan={
566
+ resize?.index === index
567
+ ? resize.span
568
+ : undefined
569
+ }
570
+ columns={columns}
571
+ onSelect={() => setSelected(index)}
572
+ onOpenMenu={(anchor) => {
573
+ setSelected(index);
574
+ setMenu({ anchor, index });
575
+ }}
576
+ onResizeStart={(event) =>
577
+ startResize(event, index)
578
+ }
579
+ onResizeMove={onResize}
580
+ onResizeEnd={endResize}
581
+ >
582
+ {renderTile ? (
583
+ renderTile(each)
584
+ ) : (
585
+ <TilePlaceholder tile={each} />
586
+ )}
587
+ </TileFrame>
588
+ );
589
+ }}
590
+ />
591
+ </Box>
592
+ </DragDropProvider>
593
+ <FilterDialog
594
+ open={filterDialog !== undefined}
595
+ document={editor.document}
596
+ {...(filterDialog?.control
597
+ ? { control: filterDialog.control }
598
+ : {})}
599
+ available={available}
600
+ {...(catalog ? { fieldsFor } : {})}
601
+ onClose={() => setFilterDialog(undefined)}
602
+ onApply={applyFilter}
603
+ onRemove={dropControl}
604
+ />
605
+ <TileMenu
606
+ anchor={menu?.anchor ?? null}
607
+ tile={
608
+ menu === undefined
609
+ ? undefined
610
+ : editor.document.tiles[menu.index]
611
+ }
612
+ onClose={() => setMenu(undefined)}
613
+ onCommit={(next) => {
614
+ const at = menu?.index;
615
+ if (at === undefined) return;
616
+ editor.update((draft) => {
617
+ draft.tiles[at] = next;
618
+ });
619
+ }}
620
+ onRemove={() => {
621
+ if (menu !== undefined) removeTile(menu.index);
622
+ }}
623
+ columns={columns}
624
+ onDrills={() => {
625
+ if (menu !== undefined)
626
+ setDrillSource(editor.document.tiles[menu.index]?.source);
627
+ }}
628
+ />
629
+ <DrillDialog
630
+ open={drillSource !== undefined}
631
+ document={editor.document}
632
+ source={editor.document.sources.find(
633
+ (s) => s.name === drillSource,
634
+ )}
635
+ givenNames={controlList.map((c) => c.name)}
636
+ dashboards={dashboards ?? []}
637
+ onClose={() => setDrillSource(undefined)}
638
+ onApply={(drills) =>
639
+ editor.update((draft) => {
640
+ const kept = (draft.drills ?? []).filter(
641
+ (d) => d.source !== drillSource,
561
642
  );
562
- }}
563
- />
564
- </Box>
565
- </DragDropProvider>
566
- <FilterDialog
567
- open={filterDialog !== undefined}
568
- document={editor.document}
569
- {...(filterDialog?.control
570
- ? { control: filterDialog.control }
571
- : {})}
572
- available={available}
573
- {...(catalog ? { fieldsFor } : {})}
574
- onClose={() => setFilterDialog(undefined)}
575
- onApply={applyFilter}
576
- onRemove={dropControl}
577
- />
578
- <TileMenu
579
- anchor={menu?.anchor ?? null}
580
- tile={
581
- menu === undefined
582
- ? undefined
583
- : editor.document.tiles[menu.index]
584
- }
585
- onClose={() => setMenu(undefined)}
586
- onCommit={(next) => {
587
- const at = menu?.index;
588
- if (at === undefined) return;
589
- editor.update((draft) => {
590
- draft.tiles[at] = next;
591
- });
592
- }}
593
- onRemove={() => {
594
- if (menu !== undefined) removeTile(menu.index);
595
- }}
596
- columns={columns}
597
- onDrills={() => {
598
- if (menu !== undefined)
599
- setDrillSource(editor.document.tiles[menu.index]?.source);
600
- }}
601
- />
602
- <DrillDialog
603
- open={drillSource !== undefined}
604
- document={editor.document}
605
- source={editor.document.sources.find((s) => s.name === drillSource)}
606
- givenNames={controlList.map((c) => c.name)}
607
- dashboards={dashboards ?? []}
608
- onClose={() => setDrillSource(undefined)}
609
- onApply={(drills) =>
610
- editor.update((draft) => {
611
- const kept = (draft.drills ?? []).filter(
612
- (d) => d.source !== drillSource,
613
- );
614
- const next = [...kept, ...drills];
615
- if (next.length === 0) delete draft.drills;
616
- else draft.drills = next;
617
- })
618
- }
619
- />
620
- <SettingsPopover
621
- anchor={settingsAnchor}
622
- settings={settings}
623
- onClose={() => setSettingsAnchor(null)}
624
- onCommit={(next) =>
625
- editor.update((draft) => {
626
- draft.title = next.title;
627
- if (next.description === undefined) delete draft.description;
628
- else draft.description = next.description;
629
- if (next.columns === undefined) delete draft.columns;
630
- else draft.columns = next.columns;
631
- if (next.autorun === undefined) delete draft.autorun;
632
- else draft.autorun = next.autorun;
633
- })
634
- }
635
- />
636
- <AddTileDialog
637
- open={addingTile}
638
- document={editor.document}
639
- catalog={catalog}
640
- columns={columns}
641
- onClose={() => setAddingTile(false)}
642
- onAdd={addTile}
643
- />
644
- <DiffDialog
645
- open={pendingSave !== undefined}
646
- before={pendingSave?.before ?? ""}
647
- after={pendingSave?.after ?? ""}
648
- onConfirm={commitSave}
649
- onClose={() => setPendingSave(undefined)}
650
- />
643
+ const next = [...kept, ...drills];
644
+ if (next.length === 0) delete draft.drills;
645
+ else draft.drills = next;
646
+ })
647
+ }
648
+ />
649
+ <SettingsPopover
650
+ anchor={settingsAnchor}
651
+ settings={settings}
652
+ onClose={() => setSettingsAnchor(null)}
653
+ onCommit={(next) =>
654
+ editor.update((draft) => {
655
+ draft.title = next.title;
656
+ if (next.description === undefined)
657
+ delete draft.description;
658
+ else draft.description = next.description;
659
+ if (next.columns === undefined) delete draft.columns;
660
+ else draft.columns = next.columns;
661
+ if (next.autorun === undefined) delete draft.autorun;
662
+ else draft.autorun = next.autorun;
663
+ })
664
+ }
665
+ />
666
+ <AddTileDialog
667
+ open={addingTile}
668
+ document={editor.document}
669
+ catalog={catalog}
670
+ columns={columns}
671
+ onClose={() => setAddingTile(false)}
672
+ onAdd={addTile}
673
+ />
674
+ <DiffDialog
675
+ open={pendingSave !== undefined}
676
+ before={pendingSave?.before ?? ""}
677
+ after={pendingSave?.after ?? ""}
678
+ onConfirm={commitSave}
679
+ onClose={() => setPendingSave(undefined)}
680
+ />
681
+ </Stack>
651
682
  </Stack>
652
683
  );
653
684
  }