@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.
Files changed (292) hide show
  1. package/dist/{Dashboard-H1kJlDFo.es.js → DashboardTile-BFcxdv7R.es.js} +15918 -17760
  2. package/dist/DashboardTile-sg8LjUk8.cjs.js +137 -0
  3. package/dist/RenderedResult-B48wAjM8.cjs.js +141 -0
  4. package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-CBLHr32C.es.js} +193 -183
  5. package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-DCV8BUWD.es.js} +529 -521
  6. package/dist/ServerProvider-HRqT3w1C.cjs.js +1 -0
  7. package/dist/builder/index.cjs.js +146 -58
  8. package/dist/builder/index.es.js +9076 -6479
  9. package/dist/builder-entry.d.ts +4 -0
  10. package/dist/client/api.d.ts +77 -47
  11. package/dist/client/configuration.d.ts +1 -1
  12. package/dist/client/index.cjs.js +1 -1
  13. package/dist/client/index.d.ts +1 -1
  14. package/dist/client/index.es.js +84 -82
  15. package/dist/components/Dashboard/Dashboard.d.ts +8 -15
  16. package/dist/components/Dashboard/DashboardGrid.d.ts +23 -6
  17. package/dist/components/Dashboard/DashboardTile.d.ts +10 -1
  18. package/dist/components/Dashboard/DashboardView.d.ts +36 -0
  19. package/dist/components/Dashboard/TileCard.d.ts +15 -4
  20. package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
  21. package/dist/components/Dashboard/index.d.ts +3 -0
  22. package/dist/components/Dashboard/telemetry.d.ts +15 -3
  23. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -1
  24. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +16 -5
  25. package/dist/components/DashboardBuilder/ChartPicker.d.ts +29 -0
  26. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +48 -21
  27. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -4
  28. package/dist/components/DashboardBuilder/DiffDialog.d.ts +2 -10
  29. package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
  30. package/dist/components/DashboardBuilder/FilterStrip.d.ts +3 -1
  31. package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
  32. package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
  33. package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
  34. package/dist/components/DashboardBuilder/SaveNotice.d.ts +27 -0
  35. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +19 -7
  36. package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
  37. package/dist/components/DashboardBuilder/TextTileBody.d.ts +7 -0
  38. package/dist/components/DashboardBuilder/TileFrame.d.ts +14 -12
  39. package/dist/components/DashboardBuilder/TileMenu.d.ts +11 -3
  40. package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
  41. package/dist/components/DashboardBuilder/catalog.d.ts +4 -0
  42. package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
  43. package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
  44. package/dist/components/DashboardBuilder/controls.d.ts +2 -2
  45. package/dist/components/DashboardBuilder/document.d.ts +42 -26
  46. package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
  47. package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
  48. package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
  49. package/dist/components/DashboardBuilder/malloyText.d.ts +45 -5
  50. package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
  51. package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
  52. package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
  53. package/dist/components/DashboardBuilder/preview.d.ts +24 -4
  54. package/dist/components/DashboardBuilder/readDocument.d.ts +4 -1
  55. package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
  56. package/dist/components/DashboardBuilder/sortable.d.ts +14 -0
  57. package/dist/components/DashboardBuilder/spliceDocument.d.ts +13 -13
  58. package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
  59. package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
  60. package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
  61. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
  62. package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
  63. package/dist/components/DashboardBuilder/useBuilderSession.d.ts +89 -0
  64. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
  65. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +17 -55
  66. package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
  67. package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
  68. package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
  69. package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
  70. package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
  71. package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
  72. package/dist/components/DocumentCreate/events.d.ts +10 -0
  73. package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
  74. package/dist/components/DocumentCreate/guards.d.ts +12 -0
  75. package/dist/components/DocumentCreate/index.d.ts +6 -0
  76. package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
  77. package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
  78. package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
  79. package/dist/components/NarrowEditGate.d.ts +8 -0
  80. package/dist/components/Notebook/Notebook.d.ts +1 -1
  81. package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
  82. package/dist/components/Package/Package.d.ts +1 -0
  83. package/dist/components/Package/documentLocation.d.ts +28 -0
  84. package/dist/components/Package/index.d.ts +4 -0
  85. package/dist/components/Package/useDocumentLocation.d.ts +12 -0
  86. package/dist/components/PackageSection.d.ts +2 -2
  87. package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
  88. package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
  89. package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
  90. package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
  91. package/dist/components/ServerProvider.d.ts +2 -1
  92. package/dist/components/UnsavedChangesDialog.d.ts +9 -0
  93. package/dist/components/given/GivensPanel.d.ts +2 -2
  94. package/dist/components/index.d.ts +2 -0
  95. package/dist/hooks/index.d.ts +1 -0
  96. package/dist/hooks/useNarrowScreen.d.ts +4 -0
  97. package/dist/hooks/useQueryResult.d.ts +2 -0
  98. package/dist/hooks/useSettled.d.ts +14 -0
  99. package/dist/index.cjs.js +23 -24
  100. package/dist/index.es.js +9714 -7072
  101. package/dist/text/index.cjs.js +1 -0
  102. package/dist/text/index.d.ts +2 -0
  103. package/dist/text/index.es.js +6 -0
  104. package/dist/text-entry-BJwltZiy.cjs.js +7 -0
  105. package/dist/text-entry-CbbBcZl8.es.js +196 -0
  106. package/dist/text-entry.d.ts +2 -0
  107. package/dist/utils/clock.d.ts +2 -0
  108. package/package.json +10 -1
  109. package/src/builder-entry.ts +35 -0
  110. package/src/components/Dashboard/Dashboard.tsx +27 -278
  111. package/src/components/Dashboard/DashboardGrid.tsx +68 -7
  112. package/src/components/Dashboard/DashboardTile.spec.tsx +24 -0
  113. package/src/components/Dashboard/DashboardTile.tsx +31 -4
  114. package/src/components/Dashboard/DashboardView.spec.tsx +212 -0
  115. package/src/components/Dashboard/DashboardView.tsx +352 -0
  116. package/src/components/Dashboard/RowsDialog.tsx +1 -1
  117. package/src/components/Dashboard/TileCard.tsx +44 -10
  118. package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
  119. package/src/components/Dashboard/TileFilterTag.tsx +78 -0
  120. package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
  121. package/src/components/Dashboard/index.ts +3 -0
  122. package/src/components/Dashboard/telemetry.ts +16 -5
  123. package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
  124. package/src/components/DashboardBuilder/AddTileDialog.tsx +137 -111
  125. package/src/components/DashboardBuilder/BuilderToolbar.tsx +85 -27
  126. package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
  127. package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
  128. package/src/components/DashboardBuilder/ChartPicker.tsx +153 -0
  129. package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
  130. package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +192 -0
  131. package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +329 -0
  132. package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +363 -0
  133. package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +194 -0
  134. package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +157 -0
  135. package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +124 -0
  136. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +103 -78
  137. package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +177 -0
  138. package/src/components/DashboardBuilder/DashboardBuilder.tsx +610 -315
  139. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +58 -8
  140. package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +191 -0
  141. package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
  142. package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +316 -0
  143. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +56 -10
  144. package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +5 -22
  145. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +96 -14
  146. package/src/components/DashboardBuilder/DashboardEditor.tsx +482 -332
  147. package/src/components/DashboardBuilder/DiffDialog.spec.tsx +25 -0
  148. package/src/components/DashboardBuilder/DiffDialog.tsx +5 -24
  149. package/src/components/DashboardBuilder/DrillDialog.tsx +1 -1
  150. package/src/components/DashboardBuilder/FilterDialog.tsx +10 -3
  151. package/src/components/DashboardBuilder/FilterStrip.tsx +26 -4
  152. package/src/components/DashboardBuilder/InlineMarkdown.tsx +184 -0
  153. package/src/components/DashboardBuilder/InlineText.tsx +106 -0
  154. package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
  155. package/src/components/DashboardBuilder/SaveNotice.tsx +113 -0
  156. package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +87 -0
  157. package/src/components/DashboardBuilder/SettingsPopover.tsx +225 -67
  158. package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
  159. package/src/components/DashboardBuilder/TextTileBody.tsx +28 -0
  160. package/src/components/DashboardBuilder/TileFrame.tsx +89 -115
  161. package/src/components/DashboardBuilder/TileMenu.tsx +168 -90
  162. package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
  163. package/src/components/DashboardBuilder/annotationText.ts +17 -0
  164. package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
  165. package/src/components/DashboardBuilder/artifactTagParity.spec.ts +41 -0
  166. package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
  167. package/src/components/DashboardBuilder/catalog.spec.ts +2 -0
  168. package/src/components/DashboardBuilder/catalog.ts +61 -21
  169. package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
  170. package/src/components/DashboardBuilder/changedTile.ts +28 -0
  171. package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
  172. package/src/components/DashboardBuilder/chartLine.ts +121 -0
  173. package/src/components/DashboardBuilder/controls.spec.ts +21 -10
  174. package/src/components/DashboardBuilder/controls.ts +22 -8
  175. package/src/components/DashboardBuilder/document.ts +53 -5
  176. package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
  177. package/src/components/DashboardBuilder/documentSession.ts +257 -0
  178. package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
  179. package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
  180. package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
  181. package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
  182. package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
  183. package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
  184. package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
  185. package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
  186. package/src/components/DashboardBuilder/malloyText.spec.ts +48 -0
  187. package/src/components/DashboardBuilder/malloyText.ts +181 -27
  188. package/src/components/DashboardBuilder/malloyTree.ts +155 -7
  189. package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
  190. package/src/components/DashboardBuilder/newDashboard.ts +30 -3
  191. package/src/components/DashboardBuilder/openDraft.ts +52 -0
  192. package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
  193. package/src/components/DashboardBuilder/preview.spec.ts +159 -12
  194. package/src/components/DashboardBuilder/preview.ts +83 -9
  195. package/src/components/DashboardBuilder/readDocument.spec.ts +139 -27
  196. package/src/components/DashboardBuilder/readDocument.ts +130 -44
  197. package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
  198. package/src/components/DashboardBuilder/readForEditor.ts +47 -0
  199. package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
  200. package/src/components/DashboardBuilder/sortable.spec.ts +65 -0
  201. package/src/components/DashboardBuilder/sortable.tsx +2 -12
  202. package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
  203. package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
  204. package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
  205. package/src/components/DashboardBuilder/spliceDocument.ts +762 -130
  206. package/src/components/DashboardBuilder/spliceResult.ts +15 -0
  207. package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
  208. package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
  209. package/src/components/DashboardBuilder/tagParse.ts +103 -0
  210. package/src/components/DashboardBuilder/telemetry.ts +47 -0
  211. package/src/components/DashboardBuilder/testing/artifactTagParity.json +197 -0
  212. package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
  213. package/src/components/DashboardBuilder/testing/inline.ts +25 -0
  214. package/src/components/DashboardBuilder/textTiles.spec.ts +718 -0
  215. package/src/components/DashboardBuilder/useBuilderSession.spec.ts +335 -0
  216. package/src/components/DashboardBuilder/useBuilderSession.ts +292 -0
  217. package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +65 -0
  218. package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
  219. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +36 -10
  220. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
  221. package/src/components/DashboardBuilder/useDashboardEditor.ts +54 -181
  222. package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
  223. package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
  224. package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
  225. package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
  226. package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
  227. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
  228. package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
  229. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
  230. package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
  231. package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
  232. package/src/components/DocumentCreate/canRetry.ts +19 -0
  233. package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
  234. package/src/components/DocumentCreate/createDocument.ts +159 -0
  235. package/src/components/DocumentCreate/documentPath.ts +40 -0
  236. package/src/components/DocumentCreate/events.ts +15 -0
  237. package/src/components/DocumentCreate/exportedSources.ts +25 -0
  238. package/src/components/DocumentCreate/guards.ts +45 -0
  239. package/src/components/DocumentCreate/index.ts +27 -0
  240. package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
  241. package/src/components/DocumentCreate/newNotebook.ts +44 -0
  242. package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
  243. package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
  244. package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
  245. package/src/components/Model/ModelExplorer.spec.tsx +2 -2
  246. package/src/components/Model/SourcesExplorer.tsx +2 -4
  247. package/src/components/NarrowEditGate.spec.tsx +73 -0
  248. package/src/components/NarrowEditGate.tsx +29 -0
  249. package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
  250. package/src/components/Notebook/Notebook.tsx +66 -27
  251. package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
  252. package/src/components/Package/NewDocumentDialog.tsx +401 -0
  253. package/src/components/Package/Package.artifacts.spec.tsx +190 -0
  254. package/src/components/Package/Package.create.spec.tsx +380 -0
  255. package/src/components/Package/Package.notebooks.spec.tsx +18 -0
  256. package/src/components/Package/Package.tsx +366 -171
  257. package/src/components/Package/documentLocation.spec.ts +81 -0
  258. package/src/components/Package/documentLocation.ts +55 -0
  259. package/src/components/Package/index.ts +13 -0
  260. package/src/components/Package/useDocumentLocation.ts +59 -0
  261. package/src/components/PackageSection.tsx +2 -2
  262. package/src/components/RenderedResult/RenderedResult.tsx +18 -1
  263. package/src/components/RenderedResult/ResultContainer.tsx +44 -11
  264. package/src/components/RenderedResult/ResultPanel.tsx +4 -0
  265. package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
  266. package/src/components/RenderedResult/resultSizing.ts +14 -3
  267. package/src/components/ServerProvider.tsx +2 -1
  268. package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
  269. package/src/components/UnsavedChangesDialog.tsx +49 -0
  270. package/src/components/given/GivensPanel.spec.tsx +6 -6
  271. package/src/components/given/GivensPanel.tsx +3 -3
  272. package/src/components/index.ts +2 -0
  273. package/src/hooks/index.ts +3 -0
  274. package/src/hooks/useNarrowScreen.ts +21 -0
  275. package/src/hooks/useQueryResult.ts +16 -0
  276. package/src/hooks/useSettled.spec.ts +41 -0
  277. package/src/hooks/useSettled.ts +27 -0
  278. package/src/mainEntry.spec.ts +145 -0
  279. package/src/text-entry.ts +12 -0
  280. package/src/textEntry.spec.ts +118 -0
  281. package/src/utils/clock.spec.ts +12 -0
  282. package/src/utils/clock.ts +6 -0
  283. package/vite.config.ts +4 -0
  284. package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
  285. package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
  286. package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
  287. package/dist/components/DashboardBuilder/useTileResize.d.ts +0 -29
  288. package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
  289. package/src/components/DashboardBuilder/useTileResize.spec.tsx +0 -121
  290. package/src/components/DashboardBuilder/useTileResize.ts +0 -110
  291. package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
  292. package/src/components/Package/NewDashboardDialog.tsx +0 -265
@@ -1,13 +1,18 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
+ import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
4
5
  import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
5
6
  import OpenInNewIcon from "@mui/icons-material/OpenInNew";
6
7
  import {
7
8
  Alert,
8
9
  Box,
10
+ Button,
9
11
  Container,
10
12
  IconButton,
13
+ Menu,
14
+ MenuItem,
15
+ Stack,
11
16
  Table,
12
17
  TableBody,
13
18
  TableCell,
@@ -17,37 +22,52 @@ import {
17
22
  Typography,
18
23
  } from "@mui/material";
19
24
  import { useQueryClient } from "@tanstack/react-query";
20
- import React, { useCallback, useEffect, useState } from "react";
25
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
21
26
  import { Database } from "../../client";
27
+ import { useNarrowScreen } from "../../hooks/useNarrowScreen";
22
28
  import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
23
29
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
24
30
  import { Loading } from "../Loading";
25
- import type { DocumentLocator } from "../DocumentStorage/DocumentStorage";
31
+ import { chooseWorkspace } from "../DashboardBuilder/documentSession";
32
+ import { createRoute, type CreateTarget } from "../DocumentCreate";
33
+ import type {
34
+ DocumentLocator,
35
+ DocumentType,
36
+ Workspace,
37
+ } from "../DocumentStorage/DocumentStorage";
26
38
  import { useOptionalDocumentStorage } from "../DocumentStorage/DocumentStorageProvider";
27
39
  import { Notebook } from "../Notebook";
28
40
  import { useServer } from "../ServerProvider";
29
- import { NewDashboardDialog } from "./NewDashboardDialog";
41
+ import { NewDocumentDialog } from "./NewDocumentDialog";
30
42
  import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
31
43
  import { serverBaseUrl } from "../../utils/dataAppEmbed";
32
44
  import ContentTypeIcon, {
33
45
  CONTENT_TINT,
34
46
  type ContentType,
35
47
  } from "./ContentTypeIcon";
36
- import { AddButton } from "../buttons";
37
48
  import { AppDialog } from "../AppDialog";
38
49
  import { BackLink } from "../BackLink";
39
50
  import { ItemRow } from "../ItemRow";
40
51
  import { Materializations } from "../Materializations";
41
52
  import { PackageSection } from "../PackageSection";
53
+ import {
54
+ documentRoute,
55
+ documentSlug,
56
+ type DocumentKind,
57
+ } from "./documentLocation";
42
58
 
43
59
  // The pinned README: the root `.malloynb`, or a served notebook named README in `notebooks/`.
44
60
  const README_NOTEBOOK = "README.malloynb";
45
61
  const isServedReadme = (path: string | undefined) =>
46
62
  path?.toLowerCase() === "notebooks/readme.malloy";
47
63
 
64
+ const draftPrefix = (
65
+ environmentName: string,
66
+ packageName: string,
67
+ kind: DocumentType,
68
+ ) => `${environmentName}/${packageName}/${kind}s/`;
69
+
48
70
  /** A served notebook opens by slug, like a dashboard; a `.malloynb` opens by path. */
49
- const servedNotebookSlug = (path: string | undefined) =>
50
- /^notebooks\/([^/]+)\.malloy$/.exec(path ?? "")?.[1];
51
71
 
52
72
  interface PackageProps {
53
73
  onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
@@ -69,35 +89,56 @@ export default function Package({
69
89
  parseResourceUri(resourceUri);
70
90
 
71
91
  const [schemaDatabase, setSchemaDatabase] = useState<Database | null>(null);
72
- const [creating, setCreating] = useState(false);
92
+ const [creating, setCreating] = useState<DocumentType | undefined>(
93
+ undefined,
94
+ );
95
+ const [newMenu, setNewMenu] = useState<HTMLElement | null>(null);
96
+ const narrow = useNarrowScreen();
73
97
 
74
- // Dashboards the host keeps for this package and the package does not have:
75
- // the builder's drafts, listed so they are found rather than stumbled on.
98
+ // Dashboards and notebooks the host keeps for this package and the package
99
+ // does not have: the builder's drafts, listed so they are found rather than
100
+ // stumbled on.
76
101
  // Each carries the workspace's own description, because where a document is
77
102
  // kept is the backend's to say and only one host's answer is "this browser".
78
103
  const storage = useOptionalDocumentStorage()?.documentStorage;
79
104
  const [drafts, setDrafts] = useState<
80
105
  { locator: DocumentLocator; where: string }[]
81
106
  >([]);
82
- const draftPrefix = `${environmentName}/${packageName}/dashboards/`;
107
+ // Where a create may land is the chosen workspace's to say, so New waits
108
+ // for the answer; a host whose workspaces cannot be listed gets no New
109
+ // rather than a guess that could write the package under its record.
110
+ const [workspace, setWorkspace] = useState<
111
+ { state: "pending" | "failed" } | { state: "ready"; chosen?: Workspace }
112
+ >({ state: storage ? "pending" : "ready" });
83
113
  const refreshDrafts = useCallback(async () => {
84
114
  if (!storage) return;
85
- const workspaces = await storage.listWorkspaces(true);
115
+ let workspaces: Workspace[];
116
+ try {
117
+ workspaces = await storage.listWorkspaces(false);
118
+ } catch {
119
+ setWorkspace({ state: "failed" });
120
+ return;
121
+ }
122
+ setWorkspace({ state: "ready", chosen: chooseWorkspace(workspaces) });
86
123
  const found: { locator: DocumentLocator; where: string }[] = [];
87
- for (const workspace of workspaces)
88
- for (const locator of await storage.listDocuments(
89
- workspace,
90
- "dashboard",
91
- ))
92
- if (locator.path.startsWith(draftPrefix))
93
- found.push({ locator, where: workspace.description });
124
+ for (const candidate of workspaces.filter((w) => w.writeable))
125
+ for (const kind of ["dashboard", "notebook"] as const)
126
+ for (const locator of await storage.listDocuments(candidate, kind))
127
+ if (
128
+ locator.path.startsWith(
129
+ draftPrefix(environmentName, packageName, kind),
130
+ )
131
+ )
132
+ found.push({ locator, where: candidate.description });
94
133
  setDrafts(found);
95
- }, [storage, draftPrefix]);
134
+ }, [storage, environmentName, packageName]);
96
135
  useEffect(() => {
97
136
  void refreshDrafts();
98
137
  }, [refreshDrafts]);
99
138
  const draftSlug = (locator: DocumentLocator) =>
100
- locator.path.slice(draftPrefix.length).replace(/\.malloy$/, "");
139
+ locator.path
140
+ .slice(draftPrefix(environmentName, packageName, locator.type).length)
141
+ .replace(/\.malloy$/, "");
101
142
 
102
143
  const pkgQuery = useQueryWithApiError({
103
144
  queryKey: ["package", environmentName, packageName, versionId],
@@ -112,12 +153,26 @@ export default function Package({
112
153
 
113
154
  const notebooksQuery = useQueryWithApiError({
114
155
  queryKey: ["notebooks", environmentName, packageName, versionId],
115
- queryFn: () =>
116
- apiClients.notebooks.listNotebooks(
117
- environmentName,
118
- packageName,
119
- versionId,
120
- ),
156
+ queryFn: async () => {
157
+ try {
158
+ return await apiClients.notebooks.listNotebooks(
159
+ environmentName,
160
+ packageName,
161
+ versionId,
162
+ );
163
+ } catch (e) {
164
+ // Non-fatal like the dashboards list: an older Publisher without
165
+ // the route has no notebooks to list.
166
+ const status = (e as { response?: { status?: number } })?.response
167
+ ?.status;
168
+ if (status === 404 || status === undefined) {
169
+ return { data: [] } as Awaited<
170
+ ReturnType<typeof apiClients.notebooks.listNotebooks>
171
+ >;
172
+ }
173
+ throw e;
174
+ }
175
+ },
121
176
  });
122
177
 
123
178
  const modelsQuery = useQueryWithApiError({
@@ -195,28 +250,12 @@ export default function Package({
195
250
  }
196
251
  },
197
252
  });
198
- // Sorted by the string the row actually SHOWS, not by the slug or the path
199
- // underneath it. A list labelled by title and ordered by filename reads as
200
- // unsorted: `overview` titled "Business Overview" sorts ahead of `regions`
201
- // titled "Regional Sales". Notebooks acquired that mismatch here too, when
202
- // they started being listed by title while still being ordered by path.
203
- const dashboardLabel = (dashboard: { name?: string; title?: string }) =>
204
- dashboard.title && dashboard.title !== dashboard.name
205
- ? dashboard.title
206
- : (dashboard.name ?? "");
207
- const notebookLabel = (notebook: { path?: string; title?: string }) =>
208
- notebook.title && notebook.title !== notebook.path
209
- ? notebook.title
210
- : (notebook.path ?? "");
211
-
212
- const dashboards = (dashboardsQuery.data?.data ?? [])
213
- .slice()
214
- .sort((a, b) => dashboardLabel(a).localeCompare(dashboardLabel(b)));
215
-
253
+ const dashboards = dashboardsQuery.data?.data ?? [];
216
254
  const notebooks = (notebooksQuery.data?.data ?? [])
217
255
  .slice()
218
- .sort((a, b) => notebookLabel(a).localeCompare(notebookLabel(b)));
219
- // A dashboard is listed once, under Dashboards. Its file is a model like any
256
+ .sort((a, b) => (a.path ?? "").localeCompare(b.path ?? ""));
257
+ const artifacts = artifactRows(dashboards, notebooks);
258
+ // A dashboard is listed once, under Artifacts. Its file is a model like any
220
259
  // other, so it would otherwise appear a second time under Semantic Models
221
260
  // where clicking it opens the Explorer rather than the dashboard. Untagged
222
261
  // shared includes in `dashboards/` are not dashboards and stay in the model
@@ -234,6 +273,74 @@ export default function Package({
234
273
  .slice()
235
274
  .sort((a, b) => a.path.localeCompare(b.path));
236
275
 
276
+ // A non-authoritative browser workspace is never a create target: a
277
+ // document made there would look saved and exist for one reader only.
278
+ const route =
279
+ workspace.state === "ready"
280
+ ? createRoute({
281
+ authoritative: workspace.chosen?.authoritative === true,
282
+ mutable,
283
+ canStore: workspace.chosen?.writeable === true,
284
+ ...(versionId === undefined ? {} : { versionId }),
285
+ })
286
+ : undefined;
287
+ // A name is chosen against the listings, so New waits for all three rather than offering names a still-loading listing would have taken.
288
+ const listingsSettled = [dashboardsQuery, notebooksQuery, modelsQuery].every(
289
+ (q) => q.isSuccess || q.isError,
290
+ );
291
+ const canCreate = route !== undefined && listingsSettled;
292
+ // The editors step aside on a narrow screen, so no entry point to one is offered there.
293
+ const canNew = canCreate && !narrow;
294
+ const createTarget = useMemo((): CreateTarget | undefined => {
295
+ if (!canCreate) return undefined;
296
+ const existing = [
297
+ ...(dashboardsQuery.data?.data ?? []).flatMap((d) =>
298
+ d.path ? [d.path] : [],
299
+ ),
300
+ ...(notebooksQuery.data?.data ?? []).flatMap((n) =>
301
+ n.path ? [n.path] : [],
302
+ ),
303
+ ...(modelsQuery.data?.data ?? []).flatMap((m) =>
304
+ m.path ? [m.path] : [],
305
+ ),
306
+ ];
307
+ if (route === "storage" && storage && workspace.state === "ready") {
308
+ if (!workspace.chosen) return undefined;
309
+ return {
310
+ route,
311
+ storage,
312
+ workspace: workspace.chosen,
313
+ environmentName,
314
+ packageName,
315
+ existing,
316
+ };
317
+ }
318
+ if (route !== "package") return undefined;
319
+ return {
320
+ route,
321
+ existing,
322
+ write: async (path, source) => {
323
+ await apiClients.models.updateModelSource(
324
+ environmentName,
325
+ packageName,
326
+ path,
327
+ { source },
328
+ );
329
+ },
330
+ };
331
+ }, [
332
+ canCreate,
333
+ route,
334
+ storage,
335
+ workspace,
336
+ environmentName,
337
+ packageName,
338
+ apiClients,
339
+ dashboardsQuery.data,
340
+ notebooksQuery.data,
341
+ modelsQuery.data,
342
+ ]);
343
+
237
344
  const description = pkgQuery.data?.data?.description ?? "";
238
345
  // The root `.malloynb` wins when both exist, so a listing order never flips the pin.
239
346
  const readmePath = (
@@ -311,111 +418,156 @@ export default function Package({
311
418
 
312
419
  {isLoading && <Loading text="Loading package..." />}
313
420
 
314
- <NewDashboardDialog
315
- open={creating}
316
- environmentName={environmentName}
317
- packageName={packageName}
318
- models={models
319
- .map((model) => model.path)
320
- .filter(
321
- (path): path is string =>
322
- typeof path === "string" &&
323
- path.endsWith(".malloy") &&
324
- !path.startsWith("dashboards/"),
325
- )}
326
- existing={dashboards
327
- .map((dashboard) => dashboard.name)
328
- .filter((name): name is string => typeof name === "string")}
329
- onClose={() => setCreating(false)}
330
- onCreated={(slug) => {
331
- setCreating(false);
332
- void queryClient.invalidateQueries({ queryKey: ["dashboards"] });
333
- onClick(
334
- `/${environmentName}/${packageName}/dashboards/${encodeURIComponent(slug)}/edit`,
335
- );
336
- }}
337
- />
421
+ <Menu
422
+ anchorEl={newMenu}
423
+ open={newMenu !== null}
424
+ onClose={() => setNewMenu(null)}
425
+ >
426
+ {(["dashboard", "notebook"] as const).map((kind) => (
427
+ <MenuItem
428
+ key={kind}
429
+ onClick={() => {
430
+ setNewMenu(null);
431
+ setCreating(kind);
432
+ }}
433
+ >
434
+ {kind === "dashboard" ? "Dashboard" : "Notebook"}
435
+ </MenuItem>
436
+ ))}
437
+ </Menu>
438
+
439
+ {createTarget && (
440
+ <NewDocumentDialog
441
+ open={creating !== undefined}
442
+ kind={creating ?? "dashboard"}
443
+ environmentName={environmentName}
444
+ packageName={packageName}
445
+ {...(versionId !== undefined ? { versionId } : {})}
446
+ models={models
447
+ .map((model) => model.path)
448
+ .filter(
449
+ (path): path is string =>
450
+ typeof path === "string" &&
451
+ path.endsWith(".malloy") &&
452
+ !path.startsWith("dashboards/") &&
453
+ !path.startsWith("notebooks/"),
454
+ )}
455
+ modelsLoading={modelsQuery.isPending}
456
+ {...(modelsQuery.isError
457
+ ? { modelsError: modelsQuery.error }
458
+ : {})}
459
+ onRetryModels={() => void modelsQuery.refetch()}
460
+ target={createTarget}
461
+ onClose={() => setCreating(undefined)}
462
+ onCreated={(created) => {
463
+ setCreating(undefined);
464
+ for (const key of ["dashboards", "notebooks", "models"])
465
+ void queryClient.invalidateQueries({ queryKey: [key] });
466
+ onClick(
467
+ `${documentRoute(environmentName, packageName, created.kind, created.slug)}/edit`,
468
+ );
469
+ }}
470
+ />
471
+ )}
338
472
 
339
473
  {!isLoading && (
340
474
  <>
341
- {/* First: the at-a-glance artifact a visitor most likely wants,
342
- ahead of the notebooks and models it is built on. Hidden when
343
- empty, like Data Apps. */}
344
475
  {/* A listing that FAILED renders identically to a package with
345
- no dashboards: `dashboards` falls back to `[]` and the
346
- section hides itself. Only `pkgQuery` reaches the error page,
347
- so nothing else here would say a word. Now that the listing
348
- carries a `versionId`, a host that resolves it on some routes
349
- and refuses it on others has a new way in, and "this package
350
- has no dashboards" is the wrong thing to conclude from a
351
- transport error. The 404 above stays swallowed: that one is
352
- an older Publisher with no route, which genuinely has none. */}
353
- {dashboardsQuery.isError && (
476
+ none: the list falls back to `[]` and the section hides
477
+ itself. Only `pkgQuery` reaches the error page, so nothing
478
+ else here would say a word, and one failed list hides only
479
+ half the artifacts. The 404 swallowed in each query is an
480
+ older Publisher with no route, which genuinely has none. */}
481
+ {(dashboardsQuery.isError || notebooksQuery.isError) && (
354
482
  <Box sx={{ mb: 4 }}>
355
483
  <Alert severity="warning">
356
- Could not list this package&apos;s dashboards, so any it
357
- has are missing from this page.
484
+ Could not list some artifacts, so any this package has
485
+ are missing from this page.
358
486
  </Alert>
359
487
  </Box>
360
488
  )}
361
- {(dashboards.length > 0 || mutable) && (
489
+ {(artifacts.length > 0 || canCreate) && (
362
490
  <PackageSection
363
- title="Dashboards"
364
- count={dashboards.length}
365
- action={
366
- mutable ? (
367
- <AddButton
368
- label="Dashboard"
369
- onClick={() => setCreating(true)}
370
- />
371
- ) : undefined
372
- }
491
+ title="Artifacts"
492
+ count={artifacts.length}
493
+ {...(canNew
494
+ ? {
495
+ action: (
496
+ <Button
497
+ variant="outlined"
498
+ size="small"
499
+ endIcon={<ArrowDropDownIcon />}
500
+ aria-haspopup="menu"
501
+ aria-label="New"
502
+ onClick={(event) =>
503
+ setNewMenu(event.currentTarget)
504
+ }
505
+ >
506
+ New
507
+ </Button>
508
+ ),
509
+ }
510
+ : {})}
373
511
  >
374
- {dashboards.length === 0 && (
375
- <EmptyRow label="No dashboards yet" />
512
+ {artifacts.length === 0 && (
513
+ <EmptyRow
514
+ label="No artifacts yet"
515
+ {...(canNew
516
+ ? {
517
+ action: {
518
+ label: "New artifact",
519
+ onClick: (event) =>
520
+ setNewMenu(event.currentTarget),
521
+ },
522
+ }
523
+ : {})}
524
+ />
376
525
  )}
377
- {dashboards.map((dashboard) => {
378
- // A title equal to the slug is what the server falls
379
- // back to when the file names itself neither way, so
380
- // showing both would print the same word twice.
381
- const hasTitle =
382
- !!dashboard.title &&
383
- dashboard.title !== dashboard.name;
384
- return (
385
- <PackageItemRow
386
- key={dashboard.name}
387
- type="dashboard"
388
- label={
389
- hasTitle ? dashboard.title! : dashboard.name!
390
- }
391
- rightLabel={hasTitle ? dashboard.name : undefined}
392
- onClick={(event) =>
393
- onClick(
394
- `/${environmentName}/${packageName}/dashboards/` +
395
- // The slug comes from a filename, which
396
- // can hold characters that would read as
397
- // structure in a path. The server encodes
398
- // it in `resource` for the same reason.
399
- encodeURIComponent(dashboard.name ?? ""),
400
- event,
401
- )
402
- }
403
- />
404
- );
405
- })}
526
+ {artifacts.map((artifact) => (
527
+ <PackageItemRow
528
+ key={`${artifact.kind}:${artifact.path}`}
529
+ type={
530
+ artifact.kind === "dashboard"
531
+ ? "dashboard"
532
+ : "report"
533
+ }
534
+ label={artifact.label}
535
+ {...(artifact.secondary === undefined
536
+ ? {}
537
+ : { description: artifact.secondary })}
538
+ rightLabel={KIND_BADGE[artifact.kind]}
539
+ onClick={(event) =>
540
+ onClick(
541
+ artifact.slug === undefined
542
+ ? `/${environmentName}/${packageName}/${artifact.path}`
543
+ : documentRoute(
544
+ environmentName,
545
+ packageName,
546
+ artifact.kind,
547
+ artifact.slug,
548
+ ),
549
+ event,
550
+ )
551
+ }
552
+ />
553
+ ))}
406
554
  </PackageSection>
407
555
  )}
408
556
  {drafts.length > 0 && (
409
557
  <PackageSection title="Drafts" count={drafts.length}>
410
558
  {drafts.map(({ locator, where }) => (
411
559
  <PackageItemRow
412
- key={locator.path}
413
- type="dashboard"
560
+ key={`${locator.type}:${locator.path}`}
561
+ type={
562
+ locator.type === "dashboard"
563
+ ? "dashboard"
564
+ : "report"
565
+ }
414
566
  label={draftSlug(locator)}
415
567
  rightLabel={where}
416
568
  onClick={(event) =>
417
569
  onClick(
418
- `/${environmentName}/${packageName}/dashboards/${encodeURIComponent(draftSlug(locator))}/edit`,
570
+ `${documentRoute(environmentName, packageName, locator.type, draftSlug(locator))}/edit`,
419
571
  event,
420
572
  )
421
573
  }
@@ -440,40 +592,6 @@ export default function Package({
440
592
  </PackageSection>
441
593
  )}
442
594
 
443
- {/* Hidden when empty, like Dashboards and Data Apps. A package
444
- that holds no notebooks is not a package missing them, and a
445
- heading over the words "No notebooks" is a row of furniture
446
- saying nothing. */}
447
- {notebooks.length > 0 && (
448
- <PackageSection title="Notebooks" count={notebooks.length}>
449
- {notebooks.map((notebook) => {
450
- // Named the way dashboards and data apps are: a notebook
451
- // that titles itself is listed by that title, with the
452
- // filename kept as the secondary label so the path a
453
- // reader needs to find the file is never lost.
454
- const hasTitle =
455
- !!notebook.title && notebook.title !== notebook.path;
456
- const slug = servedNotebookSlug(notebook.path);
457
- return (
458
- <PackageItemRow
459
- key={notebook.path}
460
- type="report"
461
- label={hasTitle ? notebook.title! : notebook.path}
462
- rightLabel={hasTitle ? notebook.path : undefined}
463
- onClick={(event) =>
464
- onClick(
465
- slug === undefined
466
- ? `/${environmentName}/${packageName}/${notebook.path}`
467
- : `/${environmentName}/${packageName}/notebooks/${encodeURIComponent(slug)}`,
468
- event,
469
- )
470
- }
471
- />
472
- );
473
- })}
474
- </PackageSection>
475
- )}
476
-
477
595
  {dataApps.length > 0 && (
478
596
  <PackageSection title="Data Apps" count={dataApps.length}>
479
597
  {dataApps.map((dataApp) => {
@@ -628,12 +746,14 @@ export default function Package({
628
746
  function PackageItemRow({
629
747
  type,
630
748
  label,
749
+ description,
631
750
  rightLabel,
632
751
  onClick,
633
752
  trailingAction,
634
753
  }: {
635
754
  type: ContentType;
636
755
  label: string;
756
+ description?: string;
637
757
  rightLabel?: string;
638
758
  onClick?: (event: React.MouseEvent) => void;
639
759
  /** Optional element rendered at the end of the row (e.g. an
@@ -647,6 +767,7 @@ function PackageItemRow({
647
767
  tint={CONTENT_TINT[type]}
648
768
  label={label}
649
769
  mono
770
+ {...(description === undefined ? {} : { description })}
650
771
  {...(rightLabel === undefined ? {} : { rightLabel })}
651
772
  {...(onClick === undefined ? {} : { onClick })}
652
773
  {...(trailingAction === undefined ? {} : { trailingAction })}
@@ -654,15 +775,89 @@ function PackageItemRow({
654
775
  );
655
776
  }
656
777
 
657
- function EmptyRow({ label }: { label: string }) {
778
+ const KIND_BADGE: Record<DocumentKind, string> = {
779
+ dashboard: "Dashboard",
780
+ notebook: "Notebook",
781
+ };
782
+
783
+ interface ArtifactRow {
784
+ kind: DocumentKind;
785
+ path: string;
786
+ /** Absent for a `.malloynb`, which opens by path. */
787
+ slug: string | undefined;
788
+ label: string;
789
+ /** The path, when the label alone does not say which file this is. */
790
+ secondary: string | undefined;
791
+ }
792
+
793
+ /** Dashboards and notebooks as one list: the title when set, else the slug, ordered by what is shown. */
794
+ function artifactRows(
795
+ dashboards: readonly { name?: string; path?: string; title?: string }[],
796
+ notebooks: readonly { path?: string; title?: string }[],
797
+ ): ArtifactRow[] {
798
+ const rows = [
799
+ ...dashboards.map((d) => ({
800
+ kind: "dashboard" as const,
801
+ path: d.path ?? "",
802
+ slug: d.name ?? documentSlug(d.path),
803
+ title: d.title,
804
+ })),
805
+ ...notebooks.map((n) => ({
806
+ kind: "notebook" as const,
807
+ path: n.path ?? "",
808
+ slug: documentSlug(n.path),
809
+ title: n.title,
810
+ })),
811
+ ];
812
+ const slugCount = new Map<string, number>();
813
+ for (const row of rows)
814
+ if (row.slug !== undefined)
815
+ slugCount.set(row.slug, (slugCount.get(row.slug) ?? 0) + 1);
816
+ return rows
817
+ .map(({ title, ...row }): ArtifactRow => {
818
+ // A title equal to the slug or path is the server's fallback for a file that names itself neither way.
819
+ const hasTitle = !!title && title !== row.slug && title !== row.path;
820
+ const ambiguous =
821
+ row.slug !== undefined && (slugCount.get(row.slug) ?? 0) > 1;
822
+ return {
823
+ ...row,
824
+ label: hasTitle ? title : (row.slug ?? row.path),
825
+ secondary: (row.slug === undefined ? hasTitle : ambiguous)
826
+ ? row.path
827
+ : undefined,
828
+ };
829
+ })
830
+ .sort(
831
+ (a, b) =>
832
+ a.label.localeCompare(b.label) || a.path.localeCompare(b.path),
833
+ );
834
+ }
835
+
836
+ function EmptyRow({
837
+ label,
838
+ action,
839
+ }: {
840
+ label: string;
841
+ action?: {
842
+ label: string;
843
+ onClick: (event: React.MouseEvent<HTMLElement>) => void;
844
+ };
845
+ }) {
658
846
  return (
659
- <Typography
660
- variant="body2"
661
- color="text.secondary"
662
- sx={{ py: 1, fontStyle: "italic" }}
663
- >
664
- {label}
665
- </Typography>
847
+ <Stack direction="row" sx={{ alignItems: "center", gap: 1, py: 1 }}>
848
+ <Typography
849
+ variant="body2"
850
+ color="text.secondary"
851
+ sx={{ fontStyle: "italic" }}
852
+ >
853
+ {label}
854
+ </Typography>
855
+ {action && (
856
+ <Button size="small" onClick={action.onClick}>
857
+ {action.label}
858
+ </Button>
859
+ )}
860
+ </Stack>
666
861
  );
667
862
  }
668
863