@fluidgrids/fe-sdk 0.0.0-stage → 2026.1203.8

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 (323) hide show
  1. package/README.md +564 -2
  2. package/dist/ActivityOptionsFields-C2u-hY2U.js +142 -0
  3. package/dist/AiStudioPage-B_hNTj-_.js +1137 -0
  4. package/dist/ApprovalInboxPage-ClITra3n.js +1312 -0
  5. package/dist/ChoiceSelect-LkK-uS9J.js +65 -0
  6. package/dist/ConfirmActionDialog-DHWTDRbp.js +31 -0
  7. package/dist/ConnectionFormDialog-C0kDgcrZ.js +153 -0
  8. package/dist/CreateFluidgridsTagDocument-Dtp9KPLJ.js +1055 -0
  9. package/dist/DataSinkDashboardPage-b4ezeqa6.js +278 -0
  10. package/dist/DataTablesPage-C1d9YGHz.js +5575 -0
  11. package/dist/DateTimeField-B1qR4ruo.js +51 -0
  12. package/dist/Disclosure-BNKij7-v.js +45 -0
  13. package/dist/ElementLibraryPage-8jNO6YmE.js +2256 -0
  14. package/dist/ElementLibrarySequenceDocument-B-W8SPzn.js +3979 -0
  15. package/dist/EnsureThemeProvider-BvlNjAd0.js +24 -0
  16. package/dist/EntityTagBadge-1OlP6p0c.js +25 -0
  17. package/dist/EntityTagPicker-BBrU5cE0.js +137 -0
  18. package/dist/ExecuteStepDocument-B4j1mdRT.js +189 -0
  19. package/dist/ExecutionDetailDocument-D6QuM-kp.js +875 -0
  20. package/dist/ExecutionDetailPage-D4CBtFdo.js +12217 -0
  21. package/dist/ExecutionDetailPage-DvQ667OE.d.ts +10 -0
  22. package/dist/ExecutionStatusBadge-BsDVor9t.js +221 -0
  23. package/dist/ExecutionsListDocument-Dan7ZiqB.js +459 -0
  24. package/dist/ExecutionsListPage-B3XT8ITL.js +4307 -0
  25. package/dist/FailureTriagePanel-DOJMaJ0n.js +1285 -0
  26. package/dist/FileDownloadUrlDocument-CVOYKcL5.js +92 -0
  27. package/dist/FluidGridsDocsLink-bX0Hnhxr.js +66 -0
  28. package/dist/FluidGridsMark-CE2blT7K.js +74 -0
  29. package/dist/HeldLoadRegion-BtTxbvOW.js +34 -0
  30. package/dist/HistoryPage-BLoRpJ1R.d.ts +6 -0
  31. package/dist/HistoryPage-BSBISXoj.js +2835 -0
  32. package/dist/Icon-BtQ0HXLh.js +160 -0
  33. package/dist/InsightsPage-D7ybj8N9.js +11245 -0
  34. package/dist/IsolationSetting-vy911E8b.js +1153 -0
  35. package/dist/LibraryParts-DOeNgR8A.js +413 -0
  36. package/dist/ManagedAiPolicyAuthority-BxwJ3ptd.js +40 -0
  37. package/dist/ManagedAiPolicyAuthority-DM3t3wNr.d.ts +18 -0
  38. package/dist/ManagedAiPolicyAuthorityContext-CNkxIOZ1.js +10 -0
  39. package/dist/McpTriggerServers-BCPCAOWB.js +459 -0
  40. package/dist/MissingNodesInstallModal-rO_SEDrC.js +224 -0
  41. package/dist/NavigationV2Provider-DCDt35eG.js +17 -0
  42. package/dist/NodeSchemaIntrospectionDocument-C1vAIcHd.js +95 -0
  43. package/dist/NodesPage-DEbnz9iU.d.ts +6 -0
  44. package/dist/NodesPage-O7KeeKtd.js +653 -0
  45. package/dist/OfflineIcon-TwMKYWjA.js +207 -0
  46. package/dist/OpenTemplateAsCodeButton-BhWJWIF3.js +94 -0
  47. package/dist/PaidTemplateConfirm-_G3ag6S4.js +28 -0
  48. package/dist/PublishCustomNodeAction-CIySbK4c.js +134 -0
  49. package/dist/RecordTaskDialog-BkpCDvhR.js +2078 -0
  50. package/dist/RunActionsMenu-DodOgIQm.js +59 -0
  51. package/dist/RunnerStatusPill-C1v967iq.js +24 -0
  52. package/dist/RunnersPage-dB0RSdY_.js +1929 -0
  53. package/dist/SandboxRuntimeExhaustedNotice-BFOIF93C.js +120 -0
  54. package/dist/SchedulesPage-DPWr1yvf.js +1607 -0
  55. package/dist/SearchBox-BGtYjvfs.js +49 -0
  56. package/dist/SequenceEditor-CFiHeHkR.js +497 -0
  57. package/dist/SettingsPage-0CQBNPZV.js +8695 -0
  58. package/dist/StewardPages-DAJhepen.js +47 -0
  59. package/dist/StewardRunImportPanel-Kva2DO0u.js +2844 -0
  60. package/dist/StoreTemplateCardCompact-CHn5kP7A.js +2166 -0
  61. package/dist/TagFilterSelect-CyA8QrS7.js +42 -0
  62. package/dist/TaskQueuesPage-DdnDCyat.js +3571 -0
  63. package/dist/TechnicalDetails-B0Oi4aZw.js +19 -0
  64. package/dist/TemplateConfigurationModal-CdvCYJLM.js +332 -0
  65. package/dist/TemplateDetailPanel-CbiKciuB.js +222 -0
  66. package/dist/TemplatePreview-cx7-NOeG.js +868 -0
  67. package/dist/TemplatesPage-BG3H-6v6.d.ts +10 -0
  68. package/dist/TemplatesPage-BVQpGYIV.js +3251 -0
  69. package/dist/TerminateExecutionDocument-B_HKNVrN.js +581 -0
  70. package/dist/TranslationBridge-Bd4aJKMs.d.ts +11 -0
  71. package/dist/TranslationBridge-Da-TPgQm.js +68 -0
  72. package/dist/TriggerWorkflowDocument-D9Km2Vv2.js +460 -0
  73. package/dist/UiSequencePickerSequenceDocument-BSYnSDV7.js +607 -0
  74. package/dist/UiStepScreenshot-Qh4QMyUp.js +146 -0
  75. package/dist/UsageTimeSeriesDocument-DcInx9-z.js +177 -0
  76. package/dist/VariablesPage-ChfGuW22.js +2243 -0
  77. package/dist/VersionDiffDialog-Bd2AeUwf.js +1702 -0
  78. package/dist/VersionLifecycleBar-BBeWVtz-.js +143 -0
  79. package/dist/WebhookDeliveriesPage-D66bua0j.js +1563 -0
  80. package/dist/WorkflowBuilder-B6wQD1TK.js +539 -0
  81. package/dist/WorkflowBuilder-DR4ku8Tr.js +1611 -0
  82. package/dist/WorkflowDefinitionDocument-DZLbTPUZ.js +321 -0
  83. package/dist/WorkflowEmbed-BXfFGy0i.js +708 -0
  84. package/dist/WorkflowEmbed-Cbqe1s1z.d.ts +6 -0
  85. package/dist/WorkflowPinnedDataDocument-BODT5omd.js +782 -0
  86. package/dist/WorkflowProposalCard-BruukdeF.js +96 -0
  87. package/dist/WorkflowProposalDocument-BdUbsrd0.js +620 -0
  88. package/dist/WorkflowSearchRedirect-C7zJ2MKH.js +40 -0
  89. package/dist/WorkflowSettingsDrawer-MVU1BKfY.d.ts +18 -0
  90. package/dist/WorkflowSettingsDrawer-gazs97WR.js +196 -0
  91. package/dist/WorkflowShareDialog-e8jJtLjU.js +469 -0
  92. package/dist/WorkflowVersionsDocument-DRVOp8Uj.js +3213 -0
  93. package/dist/WorkflowsList--hR2_8gf.js +4593 -0
  94. package/dist/WorkflowsList-CcNDQge5.d.ts +6 -0
  95. package/dist/WorkflowsListPageDocument-CnzcQm_o.js +934 -0
  96. package/dist/addonCatalog-CbZS4deh.js +58 -0
  97. package/dist/addonCatalog-sjlonAmR.d.ts +15 -0
  98. package/dist/addons.d.ts +3 -0
  99. package/dist/addons.js +4 -0
  100. package/dist/agent-form-Bfvm32j1.js +83 -0
  101. package/dist/agent-tools.d.ts +3 -0
  102. package/dist/agent-tools.js +5 -0
  103. package/dist/agentTools-CyL7DLOF.js +320 -0
  104. package/dist/ai-usage-BrxDgvdR.js +240 -0
  105. package/dist/aiCreditsBridge-BuE92tKo.js +49 -0
  106. package/dist/api-BKq-nIOZ.js +2286 -0
  107. package/dist/api-Ol7I8NxE.js +8289 -0
  108. package/dist/apollo-type-policies.d.ts +11 -0
  109. package/dist/apollo-type-policies.js +64 -0
  110. package/dist/askAboutBridge-ByYsQams.js +106 -0
  111. package/dist/askQuestions-Cmx7VnMm.js +742 -0
  112. package/dist/assert-rules-lfYEMc99.js +318 -0
  113. package/dist/assistant.d.ts +94 -0
  114. package/dist/assistant.js +99 -0
  115. package/dist/attach-node-helpers-HDKQOtrD.js +32 -0
  116. package/dist/badge-CXfPhoMH.js +26 -0
  117. package/dist/basil.generated-BK-EHbwN.js +10 -0
  118. package/dist/browser-steps-DMpS5TyB.js +533 -0
  119. package/dist/builderTimings-pvGnK1m-.js +510 -0
  120. package/dist/button-DG7y_FVJ.js +48 -0
  121. package/dist/canvasNoteTools-BxuP_AYO.js +137 -0
  122. package/dist/card-Bomy_1UG.js +44 -0
  123. package/dist/catalogGrid-BOrfMgi-.js +41 -0
  124. package/dist/channel-CPyQ1NR1.js +212 -0
  125. package/dist/chips-CvNrYJZa.js +27 -0
  126. package/dist/client-holder-C0M5Cfwl.js +68 -0
  127. package/dist/cn-QqidFIgr.js +10 -0
  128. package/dist/code-editor-diagnostics-Zr0cIcx1.js +46 -0
  129. package/dist/code-editor-field-x_JrY8KR.js +113 -0
  130. package/dist/codec-client-DPuD6mw7.js +515 -0
  131. package/dist/conditionBuilder-DwfEF0Q-.js +1144 -0
  132. package/dist/config-DO68jw5k.js +322 -0
  133. package/dist/constants-DgbVc24O.d.ts +296 -0
  134. package/dist/constants-DlRnHBfQ.js +217 -0
  135. package/dist/convert-browser-action-pfecelF7.js +347 -0
  136. package/dist/convert-dialog-B_o22NiJ.js +382 -0
  137. package/dist/create-workflow-first-Azg3JUdX.js +120 -0
  138. package/dist/definition-canvas-Bsda-rDT.js +31 -0
  139. package/dist/dialog-BVd152GS.js +94 -0
  140. package/dist/durable-nodes-BXyYCLxT.js +91 -0
  141. package/dist/duration-CDb7-mT_.js +33 -0
  142. package/dist/edge-mapper-wEAdGVU2.js +4477 -0
  143. package/dist/element-library-DkSlg_VE.js +727 -0
  144. package/dist/entities-I_0kio3q.js +38 -0
  145. package/dist/error-advice-QLr5NCm7.js +65 -0
  146. package/dist/errors-ClKb5sEt.js +188 -0
  147. package/dist/executions.d.ts +3 -0
  148. package/dist/executions.js +5 -0
  149. package/dist/feature-flags-B2qetXKd.js +385 -0
  150. package/dist/field-label-DPZRmE_B.js +153 -0
  151. package/dist/firstWorkflow-C_h0KMB2.js +133 -0
  152. package/dist/flags.d.ts +3 -0
  153. package/dist/flags.js +4 -0
  154. package/dist/flow-builder-DIvLOhz0.js +28038 -0
  155. package/dist/flow-store-holder-CUN7Terz.js +52 -0
  156. package/dist/fluent.generated-CA_e6-4l.js +14 -0
  157. package/dist/fluidgridsEvents-bbEQbwU6.js +175 -0
  158. package/dist/fluidgridsTheme-DUhvOgoy.js +297 -0
  159. package/dist/global-client-BQPuFrFa.js +433 -0
  160. package/dist/global-operations-BG6YgxrM.js +136 -0
  161. package/dist/graphql-types-UTYtujY9.js +21358 -0
  162. package/dist/history.d.ts +3 -0
  163. package/dist/history.js +4 -0
  164. package/dist/index-AoJAa5vU.d.ts +164958 -0
  165. package/dist/index-DEMT3iAM.d.ts +120 -0
  166. package/dist/index-ROZzNGyY.d.ts +76 -0
  167. package/dist/index.d.ts +20 -0
  168. package/dist/index.js +8123 -0
  169. package/dist/ion.generated-mbajjcAg.js +10 -0
  170. package/dist/label-Lzb8ZXf_.js +29 -0
  171. package/dist/labels-rXd9gYQz.js +1236 -0
  172. package/dist/liveCanvas-D5ytXDp8.js +103 -0
  173. package/dist/logos.generated-X6_0kjVR.js +21 -0
  174. package/dist/logs-panel-Cw0DkG0l.js +468 -0
  175. package/dist/lucide.generated-B6NVd3GT.js +29 -0
  176. package/dist/marksStore-a9oIMMot.js +175 -0
  177. package/dist/mcp-trigger-D0nRdvq5.js +307 -0
  178. package/dist/mdi.generated-D1BV74d6.js +292 -0
  179. package/dist/menus-CU3hDGYl.js +160 -0
  180. package/dist/mynaui.generated-DMWr5cXz.js +66 -0
  181. package/dist/navigation-v2.d.ts +3 -0
  182. package/dist/navigation-v2.js +5 -0
  183. package/dist/node-detail-view-Cgm5H1P-.js +1372 -0
  184. package/dist/node-editor-tab-body-CZ0fVuVP.js +187 -0
  185. package/dist/node-operation-selection-CdV3KI_V.js +3534 -0
  186. package/dist/node-registry-refresh-s3okf83X.js +27 -0
  187. package/dist/node-role-TMbnkmeP.js +132 -0
  188. package/dist/node-type-icon-BZa8n4iG.js +33 -0
  189. package/dist/nodes.d.ts +3 -0
  190. package/dist/nodes.js +4 -0
  191. package/dist/notesKey-5EaREBGA.js +12 -0
  192. package/dist/observability.d.ts +3 -0
  193. package/dist/observability.js +5 -0
  194. package/dist/offset-pages-zghoClB3.js +55 -0
  195. package/dist/operations-BBmT9ToP.js +663 -0
  196. package/dist/operations-WxRJWeqO.js +3133 -0
  197. package/dist/output-files-Ba8bu5lv.js +196 -0
  198. package/dist/page-operation-DrWuhd6Y.js +129 -0
  199. package/dist/page-twins.d.ts +13 -0
  200. package/dist/page-twins.js +186 -0
  201. package/dist/pageControlSpecs-DZJ9K37m.js +134 -0
  202. package/dist/pageControlsBridge-0pX9s-3k.js +54 -0
  203. package/dist/pageControlsBridge-DAuT3w7L.d.ts +36 -0
  204. package/dist/panels-PfBBAToE.js +346 -0
  205. package/dist/parts-B7fBcw-B.js +346 -0
  206. package/dist/popover-Dms9Vz3j.js +3389 -0
  207. package/dist/preloadable-lazy-Pp47mqQ9.js +65 -0
  208. package/dist/proactive.d.ts +66 -0
  209. package/dist/proactive.js +237 -0
  210. package/dist/quick-config-panel-DFd77xho.js +451 -0
  211. package/dist/quota-DeA_CJ2e.js +175 -0
  212. package/dist/quota.d.ts +3 -0
  213. package/dist/quota.js +4 -0
  214. package/dist/read-only-context-Dt9N9SIG.js +18 -0
  215. package/dist/relative-time-Dxt8ZIIu.js +55 -0
  216. package/dist/results-CwK_yDxK.js +325 -0
  217. package/dist/rolldown-runtime-hDbaFkMy.js +18 -0
  218. package/dist/route-data.d.ts +12 -0
  219. package/dist/route-data.js +69 -0
  220. package/dist/route-match-C-0_EnAt.d.ts +5 -0
  221. package/dist/route-match-DMkUICYV.js +41 -0
  222. package/dist/route-preload-C4DlGoCd.js +120 -0
  223. package/dist/run-display-UjLAoYqQ.js +81 -0
  224. package/dist/run-history-arGiHzGU.js +285 -0
  225. package/dist/run-list-links-DJn4Mf1T.js +98 -0
  226. package/dist/run-mode-USmM0-Uo.js +82 -0
  227. package/dist/run-parity-CWXqEJqM.js +144 -0
  228. package/dist/runsQuota-B6SyTbne.js +100 -0
  229. package/dist/runsQuota-DsniKiSg.d.ts +20 -0
  230. package/dist/safe-expression-Cw7-SCsm.js +1251 -0
  231. package/dist/save-status-store-C7nEYpfb.js +631 -0
  232. package/dist/schedule-panel-B4GYXzXQ.js +13774 -0
  233. package/dist/schedule-rules-ggVKRkBH.js +358 -0
  234. package/dist/secrets-Re_wSiE3.js +153 -0
  235. package/dist/settings.d.ts +4 -0
  236. package/dist/settings.js +6 -0
  237. package/dist/shared-DAWGGMSM.js +177 -0
  238. package/dist/sidebar-node-editor-6eSSgCzc.js +178 -0
  239. package/dist/solar.generated-CGYuUQAC.js +10 -0
  240. package/dist/stableTabbedDialog-BBhrfXGe.js +20 -0
  241. package/dist/start-url-CT6Yz96K.js +24 -0
  242. package/dist/status-CessxGpm.js +55 -0
  243. package/dist/store-icon-OctYp5zP.js +155 -0
  244. package/dist/styles-WGmTnZ2n.js +26 -0
  245. package/dist/styles.css +139 -0
  246. package/dist/svg-spinners.generated-CIPT7IhM.js +10 -0
  247. package/dist/template-code-CzN6JWNV.js +191 -0
  248. package/dist/template-graph-DLF9dygU.js +20 -0
  249. package/dist/template-preview-DcIIKOOL.js +32 -0
  250. package/dist/template-price-CdUHZRMF.js +40 -0
  251. package/dist/templates.d.ts +3 -0
  252. package/dist/templates.js +5 -0
  253. package/dist/theme-provider-CntfC4_i.js +23 -0
  254. package/dist/transient-DgZfhDfN.js +57 -0
  255. package/dist/typed-calls-C5tO03wq.js +26 -0
  256. package/dist/ui-script-By74Guk3.js +1094 -0
  257. package/dist/ui-script-editor-CqPu2bCN.js +2447 -0
  258. package/dist/ui-step-fix-8uM2_Hft.js +67 -0
  259. package/dist/ui-step-fix-store-CcO1FdRx.js +19 -0
  260. package/dist/ui-step-run-context-o7bLE6KP.js +46 -0
  261. package/dist/ui-target-editor-D2JhB_lD.js +673 -0
  262. package/dist/uiMarkTools-CSznnO1i.js +1054 -0
  263. package/dist/upgradePrompt-BAFBKKW5.js +72 -0
  264. package/dist/use-bare-node-registry-O6mKJO_n.js +11498 -0
  265. package/dist/use-browser-available-hj8wc3Kb.js +241 -0
  266. package/dist/use-edge-mapper-schemas-Bonofxow.js +496 -0
  267. package/dist/use-extension-bridge-B9ZreOkQ.js +608 -0
  268. package/dist/use-mobile-BTqCUjzS.js +27 -0
  269. package/dist/use-sdk-query-C697xZVv.js +116 -0
  270. package/dist/use-workflow-code-editor-CFoRFrZ5.js +753 -0
  271. package/dist/useActionParam-B2tU2BlY.js +85 -0
  272. package/dist/useAgentTokenStream-Bko_J0d0.js +4217 -0
  273. package/dist/useBrowserClients-3v95-gSh.js +103 -0
  274. package/dist/useCodeWorkflowInsights-w0tz9Ap_.js +600 -0
  275. package/dist/useConnections-DsgEJs05.js +439 -0
  276. package/dist/useDebouncedValue-BFekcv6n.js +18 -0
  277. package/dist/useDurableParity-8fnMZmBc.js +1787 -0
  278. package/dist/useEntityTags-D0spL6Ut.js +460 -0
  279. package/dist/useExecutions-2u5nGJJk.js +681 -0
  280. package/dist/useFluidGridsAnalytics-VM8lAi2x.js +238 -0
  281. package/dist/useGlobalStoreClient-BTdhkA2I.js +24 -0
  282. package/dist/useHumanRequests-zlYDp3l1.js +221 -0
  283. package/dist/useNavigationV2-C2WeqN7d.js +29 -0
  284. package/dist/useNavigationV2-DANUmg12.d.ts +9 -0
  285. package/dist/useObservability-BRlQ0tOA.js +285 -0
  286. package/dist/useRequestedProposal-B7uPXfZB.js +51 -0
  287. package/dist/useRunHistory-CXCMUPyf.js +2759 -0
  288. package/dist/useRunLive-D0JvVZT2.js +1060 -0
  289. package/dist/useRunnerList-Dbi59i1K.js +446 -0
  290. package/dist/useRunners-URUc5quU.js +173 -0
  291. package/dist/useRunsPage-DG656UCK.js +2709 -0
  292. package/dist/useVariables-BIelxcWr.js +463 -0
  293. package/dist/useVersionHistoryData-CTjqVw7l.js +292 -0
  294. package/dist/useWorkflowCodeExport-pqxyLHD1.js +522 -0
  295. package/dist/useWorkflowListExport-hcZNvTaB.js +232 -0
  296. package/dist/useWorkflowOrganization-CpBbOrs7.js +1772 -0
  297. package/dist/useWorkflowProposal-BH0VdNMA.js +3280 -0
  298. package/dist/useWorkflows-Cvg-Z_IE.js +1606 -0
  299. package/dist/utils-fvBb5qOD.js +89 -0
  300. package/dist/webhook-deliveries-AvQujaZy.js +99 -0
  301. package/dist/workflow-builder-CJygVkVv.d.ts +2 -0
  302. package/dist/workflow-builder.d.ts +3 -0
  303. package/dist/workflow-builder.js +8 -0
  304. package/dist/workflow-code-transfer-Bsy0JKAZ.js +323 -0
  305. package/dist/workflow-embed.d.ts +3 -0
  306. package/dist/workflow-embed.js +4 -0
  307. package/dist/workflow-git-sync--K9ZsPDC.js +263 -0
  308. package/dist/workflow-host.d.ts +6 -0
  309. package/dist/workflow-host.js +11 -0
  310. package/dist/workflow-pages-D-7ByLTB.d.ts +68 -0
  311. package/dist/workflow-pages.d.ts +3 -0
  312. package/dist/workflow-pages.js +115 -0
  313. package/dist/workflow-preview-canvas-CO8yzdE3.js +848 -0
  314. package/dist/workflow-preview.d.ts +65 -0
  315. package/dist/workflow-preview.js +4 -0
  316. package/dist/workflow-route.d.ts +33 -0
  317. package/dist/workflow-route.js +4 -0
  318. package/dist/workflow-save-state-D0l-DkLf.js +767 -0
  319. package/dist/workflow-transfer-CQnQC-ke.js +104 -0
  320. package/dist/workflowRouteData-BkfVOc-O.js +169 -0
  321. package/dist/workflows-list.d.ts +10 -0
  322. package/dist/workflows-list.js +5 -0
  323. package/package.json +320 -4
@@ -0,0 +1,2835 @@
1
+ "use client";
2
+ import { t as __exportAll } from "./rolldown-runtime-hDbaFkMy.js";
3
+ import { t as Icon } from "./Icon-BtQ0HXLh.js";
4
+ import { f as useRestoreWorkflowVersion, g as useWorkflowDefinitions, y as useWorkflowVersions } from "./useWorkflows-Cvg-Z_IE.js";
5
+ import { a as VersionDiffGraph, c as useVersionComparison, i as VersionChangeList, o as plainChanges, r as JsonLineDiffView, s as summarizeGraphDiff, t as VersionDiffDialog } from "./VersionDiffDialog-Bd2AeUwf.js";
6
+ import { c as lifecycleStageOf, l as versionsOfWorkflow, o as plainDiffStatusLabel } from "./VersionLifecycleBar-BBeWVtz-.js";
7
+ import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
8
+ import { r as getFluidGridsConfig } from "./config-DO68jw5k.js";
9
+ import { n as useFluidGridsPageControls } from "./pageControlsBridge-0pX9s-3k.js";
10
+ import { n as historyControls } from "./pageControlSpecs-DZJ9K37m.js";
11
+ import { t as FluidGridsDocsLink } from "./FluidGridsDocsLink-bX0Hnhxr.js";
12
+ import { n as useNavigationV2 } from "./useNavigationV2-C2WeqN7d.js";
13
+ import { r as markBuilderNavigation } from "./builderTimings-pvGnK1m-.js";
14
+ import { _ as ViewOnlyPill, c as CompactRow, d as RowIcon, f as RowSummary, g as MoreToolsPage, h as MoreToolsHeader, l as FilterChips, m as Dot, o as ToneAlert, p as BackLink, s as CompactList, u as ListToolbar, v as WhatIsLink } from "./panels-PfBBAToE.js";
15
+ import { s as useFluidGridsPermission, t as FLUIDGRIDS_PERMISSIONS } from "./constants-DlRnHBfQ.js";
16
+ import { t as ChoiceSelect } from "./ChoiceSelect-LkK-uS9J.js";
17
+ import { t as SearchBox } from "./SearchBox-BGtYjvfs.js";
18
+ import { a as NoResultsPanel, c as ResultsPager, d as formatShortDateTime, f as MORE_TOOLS_PAGE_SIZE, g as serverWindow, h as pageSlice, m as matchesSearch, n as ListSkeleton, o as PagedBody, r as LoadErrorPanel, s as ResultsHeading, t as EmptyPanel, u as formatCount } from "./results-CwK_yDxK.js";
19
+ import { a as useNewestWindows, n as onVersionsInput, o as useOnVersionsQuery, r as useDefinitionsQuery, t as ON_COUNT_INPUT } from "./useVersionHistoryData-CTjqVw7l.js";
20
+ import { a as useClampedPage, o as useSearchDraft, r as readChoice, s as useUrlListState, t as RowMenu } from "./menus-CU3hDGYl.js";
21
+ import { o as SUB_TEXT, t as CONTROL_RING } from "./styles-WGmTnZ2n.js";
22
+ import { t as cn } from "./cn-QqidFIgr.js";
23
+ import { n as formatRelativeTime, t as formatExactTime } from "./relative-time-Dxt8ZIIu.js";
24
+ import { n as Status } from "./status-CessxGpm.js";
25
+ import { i as copyText } from "./secrets-Re_wSiE3.js";
26
+ import { t as ConfirmActionDialog } from "./ConfirmActionDialog-DHWTDRbp.js";
27
+ import { t as focusDialogOnOpen } from "./stableTabbedDialog-BBhrfXGe.js";
28
+ import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
29
+ import { Link, useHref, useLocation, useNavigate, useSearchParams } from "react-router";
30
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
31
+ import { ArrowLeft, ArrowLeftRight, Braces, Copy, ExternalLink, GitCompareArrows, History, Info, List, RefreshCw, RotateCcw, Workflow, X } from "lucide-react";
32
+ import { toast } from "sonner";
33
+ import { Badge, EmptyState, Input, ResponsiveDialog, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, ShowTechnicalDetails, Skeleton, SpinnerIcon, TabbedDialog, TabbedDialogContent, TabbedDialogFooter, TabbedDialogHeader, TabbedDialogTabs, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, useStableTabbedDialogs } from "@burdenoff/fe-libs/ui";
34
+ import { Button as Button$1 } from "@burdenoff/fe-libs/button";
35
+ import { buildActorFallback, useActorProfiles } from "@burdenoff/fe-libs/shared";
36
+
37
+ // src/modules/history/components/TechnicalDetails.tsx
38
+ /**
39
+ * TechnicalDetails: a small "Show technical details" disclosure for the raw
40
+ * text a person does not need first (an error message, an id).
41
+ *
42
+ * LOCAL PLACEHOLDER for the shared "Show technical details" piece that
43
+ * BOFF-11841 builds in fe-libs. The props are deliberately the ones that piece
44
+ * is expected to take (`label`, `hideLabel`, `children`), so it can be swapped
45
+ * for it without touching the call sites.
46
+ */
47
+ function TechnicalDetails({ label, hideLabel, children, className }) {
48
+ const [open, setOpen] = useState(false);
49
+ const panelId = useId();
50
+ return /* @__PURE__ */ jsxs("div", {
51
+ className,
52
+ "data-testid": "fluidgrids-technical-details",
53
+ children: [/* @__PURE__ */ jsxs("button", {
54
+ type: "button",
55
+ "aria-expanded": open,
56
+ "aria-controls": panelId,
57
+ onClick: () => setOpen((value) => !value),
58
+ className: "inline-flex items-center gap-1 text-xs text-text-secondary hover:text-text-primary underline-offset-2 hover:underline",
59
+ children: [/* @__PURE__ */ jsx(Icon, {
60
+ icon: open ? "mdi:chevron-down" : "mdi:chevron-right",
61
+ width: 14
62
+ }), open ? hideLabel : label]
63
+ }), /* @__PURE__ */ jsx("div", {
64
+ id: panelId,
65
+ hidden: !open,
66
+ className: "mt-1 text-xs break-words",
67
+ children
68
+ })]
69
+ });
70
+ }
71
+
72
+ // src/modules/history/components/VersionsByWorkflowFilters.tsx
73
+ /** The By-workflow history list's chips and search toolbar (BOFF-15502). */
74
+ function VersionsFilters({ chips, chip, by, people, searchDraft, onChip, onPerson, onSearch, onWantEveryone }) {
75
+ const tr = useTr();
76
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FilterChips, {
77
+ label: tr("fluidgrids.moreTools.versions.chipsLabel", "Filter workflows"),
78
+ options: chips,
79
+ value: chip,
80
+ onChange: onChip,
81
+ testId: "fluidgrids-history-chips",
82
+ className: "mb-3"
83
+ }), /* @__PURE__ */ jsxs(ListToolbar, { children: [/* @__PURE__ */ jsx("div", {
84
+ className: "flex min-w-0 flex-[1_1_16rem] sm:max-w-sm",
85
+ "data-tour": "fluidgrids-history-search",
86
+ children: /* @__PURE__ */ jsx(SearchBox, {
87
+ value: searchDraft,
88
+ onChange: onSearch,
89
+ placeholder: tr("fluidgrids.moreTools.versions.searchPlaceholder", "Search workflows"),
90
+ className: "sm:max-w-none",
91
+ testId: "fluidgrids-history-search"
92
+ })
93
+ }), /* @__PURE__ */ jsx("div", {
94
+ className: "min-w-0",
95
+ onPointerDownCapture: () => onWantEveryone(),
96
+ onFocusCapture: () => onWantEveryone(),
97
+ children: /* @__PURE__ */ jsx(ChoiceSelect, {
98
+ value: by,
99
+ onValueChange: onPerson,
100
+ options: people,
101
+ prefix: tr("fluidgrids.moreTools.versions.byPrefix", "By"),
102
+ "aria-label": tr("fluidgrids.moreTools.versions.byAria", "Changed by: who saved the newest version"),
103
+ className: "max-w-[16rem]",
104
+ "data-testid": "fluidgrids-history-by"
105
+ })
106
+ })] })] });
107
+ }
108
+
109
+ // src/modules/history/components/VersionsByWorkflowHeader.tsx
110
+ /** The By-workflow history list's header (BOFF-15502). */
111
+ function HistoryFacts({ workflowTotal, versionTotal, viewOnly }) {
112
+ const tr = useTr();
113
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
114
+ workflowTotal !== null && /* @__PURE__ */ jsx("span", {
115
+ className: "tabular-nums",
116
+ "data-testid": "fluidgrids-history-workflow-count",
117
+ children: workflowTotal === 1 ? tr("fluidgrids.moreTools.versions.workflowsOne", "1 workflow") : tr("fluidgrids.moreTools.versions.workflowsOther", "{{count}} workflows", { count: formatCount(workflowTotal) })
118
+ }),
119
+ workflowTotal !== null && versionTotal !== null && /* @__PURE__ */ jsx(Dot, {}),
120
+ versionTotal !== null && /* @__PURE__ */ jsx("span", {
121
+ className: "tabular-nums",
122
+ "data-testid": "fluidgrids-history-version-count",
123
+ children: versionTotal === 1 ? tr("fluidgrids.moreTools.versions.savedVersionsOne", "1 saved version") : tr("fluidgrids.moreTools.versions.savedVersionsOther", "{{count}} saved versions", { count: formatCount(versionTotal) })
124
+ }),
125
+ /* @__PURE__ */ jsx(WhatIsLink, {
126
+ label: tr("fluidgrids.moreTools.versions.whatIs", "What is a version?"),
127
+ title: tr("fluidgrids.moreTools.versions.whatIs", "What is a version?"),
128
+ docsTopic: "history",
129
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.moreTools.versions.about", "Saving a workflow keeps a version. The version that is On is the one that runs. Compare any two versions, or restore an older one as a new draft; nothing that exists is changed.") })
130
+ }),
131
+ viewOnly && /* @__PURE__ */ jsx(ViewOnlyPill, {})
132
+ ] });
133
+ }
134
+ function VersionsHeader({ title, workflowTotal, versionTotal, viewOnly, onRefresh }) {
135
+ const tr = useTr();
136
+ return /* @__PURE__ */ jsx("div", {
137
+ "data-tour": "fluidgrids-history-header",
138
+ children: /* @__PURE__ */ jsx(MoreToolsHeader, {
139
+ title,
140
+ titleTestId: "fluidgrids-history-title",
141
+ facts: /* @__PURE__ */ jsx(HistoryFacts, {
142
+ workflowTotal,
143
+ versionTotal,
144
+ viewOnly
145
+ }),
146
+ actions: /* @__PURE__ */ jsxs(Button$1, {
147
+ variant: "outline",
148
+ size: "sm",
149
+ onClick: onRefresh,
150
+ "data-testid": "fluidgrids-history-refresh",
151
+ children: [/* @__PURE__ */ jsx(RefreshCw, {
152
+ className: "size-4",
153
+ "aria-hidden": "true"
154
+ }), tr("fluidgrids.history.historyPage.refreshButton", "Refresh")]
155
+ })
156
+ })
157
+ });
158
+ }
159
+
160
+ // src/modules/history/utils/version-history-list.ts
161
+ /**
162
+ * Version history by workflow (BOFF-15502): the rules of the redesigned list
163
+ * and timeline, kept pure so they are tested without rendering the page.
164
+ *
165
+ * The list shows one row per workflow: its newest saved version (the
166
+ * service's `latestOnly`, newest first) next to the version that is On, read
167
+ * from a second `latestOnly` + `ACTIVE` query. The service applies the status
168
+ * filter before it picks one row per workflow, so that query answers each
169
+ * workflow's newest On version.
170
+ */
171
+ /** The status chips above the list. */
172
+ const HISTORY_CHIPS = [
173
+ "all",
174
+ "draft",
175
+ "off"
176
+ ];
177
+ function readHistoryFilters(params) {
178
+ return {
179
+ q: params.get("q") ?? "",
180
+ chip: readChoice(params, "chip", HISTORY_CHIPS, "all"),
181
+ by: params.get("by") ?? ""
182
+ };
183
+ }
184
+ /**
185
+ * True when the list has to be filtered in the browser: the service cannot
186
+ * search, filter by the newest version's status or by person yet, so these
187
+ * read every workflow's newest version and narrow it here.
188
+ */
189
+ function needsLocalFilter(filters) {
190
+ return filters.q.trim() !== "" || filters.chip !== "all" || filters.by !== "";
191
+ }
192
+ function onLookupFrom(rows, complete, keys) {
193
+ const byKey = /* @__PURE__ */ new Map();
194
+ for (const row of rows) if (!byKey.has(row.workflowKey)) byKey.set(row.workflowKey, row.version);
195
+ return keys === void 0 ? {
196
+ byKey,
197
+ complete
198
+ } : {
199
+ byKey,
200
+ complete,
201
+ keys: new Set(keys)
202
+ };
203
+ }
204
+ /**
205
+ * The version of a workflow that is On. The newest version answers itself
206
+ * when it is On; otherwise the On lookup does, and a workflow it does not
207
+ * list has nothing On only when the lookup holds every On workflow.
208
+ */
209
+ function onNowOf(row, lookup) {
210
+ if (lifecycleStageOf(row.status) === "ACTIVE") return {
211
+ kind: "on",
212
+ version: row.version
213
+ };
214
+ const version = lookup?.byKey.get(row.workflowKey);
215
+ if (version) return {
216
+ kind: "on",
217
+ version
218
+ };
219
+ if (lookup?.keys && !lookup.keys.has(row.workflowKey)) return { kind: "unknown" };
220
+ return lookup?.complete ? { kind: "none" } : { kind: "unknown" };
221
+ }
222
+ function newestIsDraft(row) {
223
+ return lifecycleStageOf(row.status) === "DRAFT";
224
+ }
225
+ /** The rows that match the chip, the person and the search, in their order. */
226
+ function filterNewestRows(rows, filters, lookup) {
227
+ return rows.filter((row) => {
228
+ if (filters.chip === "draft" && !newestIsDraft(row)) return false;
229
+ if (filters.chip === "off" && onNowOf(row, lookup).kind !== "none") return false;
230
+ if (filters.by && row.createdById !== filters.by) return false;
231
+ return matchesSearch(filters.q, row.name, row.workflowKey);
232
+ });
233
+ }
234
+ /**
235
+ * The counts on the chips, each only where it is exact: every workflow (the
236
+ * service's total), workflows with nothing On (that total minus the
237
+ * workflows with an On version), and workflows whose newest version is a
238
+ * draft (only once every workflow's newest version is loaded).
239
+ */
240
+ function chipCounts(input) {
241
+ const counts = {};
242
+ if (input.total !== null) counts.all = input.total;
243
+ if (input.total !== null && input.onTotal !== null) counts.off = Math.max(0, input.total - input.onTotal);
244
+ if (input.loadedRows && input.allLoaded) counts.draft = input.loadedRows.filter(newestIsDraft).length;
245
+ return counts;
246
+ }
247
+ /** The people who saved a newest version, each once, in list order. */
248
+ function authorIdsOf(rows) {
249
+ const ids = /* @__PURE__ */ new Set();
250
+ for (const row of rows) if (row.createdById) ids.add(row.createdById);
251
+ return [...ids];
252
+ }
253
+ /**
254
+ * The "Changed by" choices: everyone in `ids` plus the chosen person (so a
255
+ * choice from a link stays listed), by name.
256
+ */
257
+ function peopleChoices(ids, selected, nameOf) {
258
+ const all = new Set(ids);
259
+ if (selected) all.add(selected);
260
+ return [...all].map((id) => ({
261
+ value: id,
262
+ label: nameOf(id)
263
+ })).sort((a, b) => a.label.localeCompare(b.label));
264
+ }
265
+ /** The version before `index` in a newest-first list, the one it is compared with. */
266
+ function previousVersionAt(versions, index) {
267
+ return versions[index + 1]?.version ?? null;
268
+ }
269
+ function timelineFacts(versions) {
270
+ const on = versions.find((v) => lifecycleStageOf(v.status) === "ACTIVE");
271
+ const first = versions[0];
272
+ return {
273
+ count: versions.length,
274
+ on: on?.version ?? null,
275
+ newest: first && first !== on ? {
276
+ version: first.version,
277
+ stage: lifecycleStageOf(first.status)
278
+ } : null
279
+ };
280
+ }
281
+ /** The list's own filters, kept in the address while a workflow's timeline is open. */
282
+ const LIST_FILTER_PARAMS = [
283
+ "q",
284
+ "chip",
285
+ "by"
286
+ ];
287
+ const TIMELINE_INTENTS = ["compare", "restore"];
288
+ function keepListFilters(params) {
289
+ const next = new URLSearchParams();
290
+ for (const name of LIST_FILTER_PARAMS) {
291
+ const value = params.get(name);
292
+ if (value) next.set(name, value);
293
+ }
294
+ return next;
295
+ }
296
+ /** The search part of a link to the list, with its filters and page 1. */
297
+ function listSearch(params) {
298
+ const query = keepListFilters(params).toString();
299
+ return query ? `?${query}` : "";
300
+ }
301
+ /**
302
+ * The search part of a link to one workflow's versions: the list's filters
303
+ * stay (so the way back returns to them), the list's page does not (the
304
+ * timeline pages on its own), and `open` asks for the compare dialog or the
305
+ * restore confirmation.
306
+ */
307
+ function timelineSearch(params, workflowKey, open) {
308
+ const next = keepListFilters(params);
309
+ next.set("workflow", workflowKey);
310
+ if (open) next.set("open", open);
311
+ return `?${next.toString()}`;
312
+ }
313
+ /** Initials for a person's avatar: "Asha Rao" → "AR", "asha" → "A". */
314
+ function initialsOf(name) {
315
+ return name.trim().split(/\s+/).filter(Boolean).slice(0, 2).map((word) => [...word][0] ?? "").join("").toUpperCase();
316
+ }
317
+
318
+ // src/modules/history/components/versionsByWorkflowLayout.ts
319
+ /** Icon, workflow, On now, newest, changed, actions. */
320
+ const COLUMNS = "sm:grid-cols-[2rem_minmax(0,1fr)_7rem_8.5rem_5.5rem_9rem]";
321
+
322
+ // src/modules/history/components/VersionBits.tsx
323
+ /**
324
+ * Small pieces the redesigned Version history shares (BOFF-15502): the
325
+ * status words (On, Draft, Retired, Archived; the same in the list, the
326
+ * timeline and the compare dialog), a version number, and who saved it.
327
+ *
328
+ * On is the version that runs, so it reads as quiet green text; Draft is
329
+ * the normal state of a version being worked on, so it is neutral, not a
330
+ * warning.
331
+ */
332
+ /** The status word of each stage, translated. */
333
+ function useStageWords() {
334
+ const tr = useTr();
335
+ return useCallback((stage) => {
336
+ switch (stage) {
337
+ case "ACTIVE": return tr("fluidgrids.history.historyPage.statusOn", "On");
338
+ case "DEPRECATED": return tr("fluidgrids.history.historyPage.statusRetired", "Retired");
339
+ case "ARCHIVED": return tr("fluidgrids.history.historyPage.statusArchived", "Archived");
340
+ default: return tr("fluidgrids.history.historyPage.statusDraft", "Draft");
341
+ }
342
+ }, [tr]);
343
+ }
344
+ /** A version's status: On in quiet green, every other stage neutral. */
345
+ function VersionStatus({ status, className }) {
346
+ const wordOf = useStageWords();
347
+ const stage = lifecycleStageOf(status);
348
+ return /* @__PURE__ */ jsx(Status, {
349
+ tone: stage === "ACTIVE" ? "quiet" : "neutral",
350
+ className,
351
+ "data-testid": "fluidgrids-version-status",
352
+ children: wordOf(stage)
353
+ });
354
+ }
355
+ /** A version number, the way the list and the timeline show it. */
356
+ function VersionCode({ version, className }) {
357
+ return /* @__PURE__ */ jsx("code", {
358
+ className: cn("inline-block max-w-full truncate rounded-md border border-border-subtle bg-bg-sunken px-1.5 align-middle font-mono text-xs text-text-primary", className),
359
+ children: version
360
+ });
361
+ }
362
+ /** Who saved a version: their initials and name. */
363
+ function PersonChip({ name, className }) {
364
+ return /* @__PURE__ */ jsxs("span", {
365
+ className: cn("inline-flex min-w-0 items-center gap-1.5", className),
366
+ children: [/* @__PURE__ */ jsx("span", {
367
+ "aria-hidden": "true",
368
+ className: "flex size-4 shrink-0 items-center justify-center rounded-full border border-border-subtle bg-bg-sunken text-[8px] font-semibold text-text-secondary",
369
+ children: initialsOf(name)
370
+ }), /* @__PURE__ */ jsx("span", {
371
+ className: "truncate",
372
+ children: name
373
+ })]
374
+ });
375
+ }
376
+ /**
377
+ * Names for the people who saved versions, through the shared actor-profile
378
+ * lookup (workspace-scoped, cached, batched). An id it cannot resolve reads
379
+ * as the lookup's fallback, never as the raw id alone.
380
+ */
381
+ function useAuthorNames(ids) {
382
+ const config = getFluidGridsConfig();
383
+ const key = [...new Set(ids)].sort().join(",");
384
+ const actors = useMemo(() => key ? key.split(",").map((actorId) => ({
385
+ actorId,
386
+ actorType: "user"
387
+ })) : [], [key]);
388
+ const profiles = useActorProfiles(actors, {
389
+ workspaceId: config.workspaceId || void 0,
390
+ orgId: config.organizationId,
391
+ authToken: config.authToken
392
+ });
393
+ return useCallback((id) => {
394
+ if (!id) return "—";
395
+ return profiles[id]?.displayName ?? buildActorFallback({
396
+ actorId: id,
397
+ actorType: "user"
398
+ }).displayName;
399
+ }, [profiles]);
400
+ }
401
+
402
+ // src/modules/history/components/VersionsByWorkflowRow.tsx
403
+ /** One workflow's row in the By-workflow history list (BOFF-15502). */
404
+ function compareItem(tr, { row, openTimeline }) {
405
+ return {
406
+ id: "compare",
407
+ label: tr("fluidgrids.moreTools.versions.menuCompare", "Compare versions"),
408
+ icon: /* @__PURE__ */ jsx(GitCompareArrows, {
409
+ className: "size-4",
410
+ "aria-hidden": "true"
411
+ }),
412
+ onSelect: () => openTimeline(row.workflowKey, "compare")
413
+ };
414
+ }
415
+ function restoreItem(tr, { row, openTimeline }) {
416
+ return {
417
+ id: "restore",
418
+ label: tr("fluidgrids.moreTools.versions.menuRestoreOlder", "Restore an older version…"),
419
+ icon: /* @__PURE__ */ jsx(RotateCcw, {
420
+ className: "size-4",
421
+ "aria-hidden": "true"
422
+ }),
423
+ separatorBefore: true,
424
+ onSelect: () => openTimeline(row.workflowKey, "restore")
425
+ };
426
+ }
427
+ /** The row's actions menu; Compare and Restore need more than one version. */
428
+ function rowMenu(tr, actions, several) {
429
+ const { row, canRestore, openTimeline, openInBuilder } = actions;
430
+ return [
431
+ {
432
+ id: "versions",
433
+ label: tr("fluidgrids.moreTools.versions.menuAllVersions", "All versions"),
434
+ icon: /* @__PURE__ */ jsx(History, {
435
+ className: "size-4",
436
+ "aria-hidden": "true"
437
+ }),
438
+ onSelect: () => openTimeline(row.workflowKey)
439
+ },
440
+ ...several ? [compareItem(tr, actions)] : [],
441
+ {
442
+ id: "open",
443
+ label: tr("fluidgrids.history.historyPage.openInBuilderTooltip", "Open in builder"),
444
+ icon: /* @__PURE__ */ jsx(ExternalLink, {
445
+ className: "size-4",
446
+ "aria-hidden": "true"
447
+ }),
448
+ onSelect: () => openInBuilder(row.workflowKey, row.version)
449
+ },
450
+ ...canRestore && several ? [restoreItem(tr, actions)] : []
451
+ ];
452
+ }
453
+ function onSummaryText(tr, onNow) {
454
+ if (onNow.kind === "on") return tr("fluidgrids.moreTools.versions.onVersion", "On: {{version}}", { version: onNow.version });
455
+ if (onNow.kind === "none") return tr("fluidgrids.moreTools.versions.nothingOn", "Nothing on");
456
+ return null;
457
+ }
458
+ function VersionCountLabel({ count }) {
459
+ const tr = useTr();
460
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
461
+ className: "shrink-0 tabular-nums",
462
+ children: count === 1 ? tr("fluidgrids.moreTools.versions.versionsOne", "1 version") : tr("fluidgrids.moreTools.versions.versionsOther", "{{count}} versions", { count: formatCount(count) })
463
+ }), /* @__PURE__ */ jsx("span", {
464
+ "aria-hidden": "true",
465
+ children: "·"
466
+ })] });
467
+ }
468
+ function OnNowCell({ onNow }) {
469
+ const tr = useTr();
470
+ let content;
471
+ if (onNow.kind === "on") content = /* @__PURE__ */ jsxs("span", {
472
+ className: "inline-flex max-w-full items-center gap-1.5",
473
+ children: [/* @__PURE__ */ jsx(VersionCode, { version: onNow.version }), /* @__PURE__ */ jsx(VersionStatus, { status: "ACTIVE" })]
474
+ });
475
+ else if (onNow.kind === "none") content = /* @__PURE__ */ jsx("span", {
476
+ className: "text-xs text-text-muted",
477
+ children: tr("fluidgrids.moreTools.versions.nothingOn", "Nothing on")
478
+ });
479
+ else content = /* @__PURE__ */ jsx("span", {
480
+ className: "text-xs text-text-muted",
481
+ children: "—"
482
+ });
483
+ return /* @__PURE__ */ jsx("div", {
484
+ className: "min-w-0 max-sm:hidden",
485
+ "data-testid": "fluidgrids-history-on-now",
486
+ children: content
487
+ });
488
+ }
489
+ function NewestCell({ row, onIsNewest }) {
490
+ const tr = useTr();
491
+ return /* @__PURE__ */ jsx("div", {
492
+ className: "min-w-0 max-sm:hidden",
493
+ "data-testid": "fluidgrids-history-newest",
494
+ children: onIsNewest ? /* @__PURE__ */ jsx("span", {
495
+ className: "text-xs text-text-muted",
496
+ children: tr("fluidgrids.moreTools.versions.sameAsOn", "Same")
497
+ }) : /* @__PURE__ */ jsxs("span", {
498
+ className: "inline-flex max-w-full items-center gap-1.5",
499
+ children: [/* @__PURE__ */ jsx(VersionCode, { version: row.version }), /* @__PURE__ */ jsx(VersionStatus, { status: row.status })]
500
+ })
501
+ });
502
+ }
503
+ function RowActions({ name, several, compareHref, menu }) {
504
+ const tr = useTr();
505
+ return /* @__PURE__ */ jsxs("div", {
506
+ className: "relative z-[1] flex items-center justify-end gap-1",
507
+ children: [several && /* @__PURE__ */ jsx(Button$1, {
508
+ asChild: true,
509
+ variant: "outline",
510
+ size: "sm",
511
+ className: "max-sm:hidden",
512
+ children: /* @__PURE__ */ jsxs(Link, {
513
+ to: { search: compareHref },
514
+ "aria-label": tr("fluidgrids.moreTools.versions.compareAria", "Compare versions of {{name}}", { name }),
515
+ "data-testid": "fluidgrids-history-compare",
516
+ children: [/* @__PURE__ */ jsx(GitCompareArrows, {
517
+ className: "size-4",
518
+ "aria-hidden": "true"
519
+ }), /* @__PURE__ */ jsx("span", {
520
+ className: "max-md:hidden",
521
+ children: tr("fluidgrids.moreTools.versions.compare", "Compare")
522
+ })]
523
+ })
524
+ }), /* @__PURE__ */ jsx(RowMenu, {
525
+ label: tr("fluidgrids.moreTools.versions.rowMenu", "Actions for {{name}}", { name }),
526
+ items: menu,
527
+ testId: "fluidgrids-history-row-menu"
528
+ })]
529
+ });
530
+ }
531
+ function WorkflowRow(props) {
532
+ const { row, onNow, authorName, timelineHref, compareHref } = props;
533
+ const tr = useTr();
534
+ const versionCount = row.totalVersions ?? null;
535
+ const several = (versionCount ?? 0) > 1;
536
+ const changedAt = row.updatedAt || row.createdAt;
537
+ const changed = formatRelativeTime(tr, changedAt);
538
+ const onIsNewest = onNow.kind === "on" && onNow.version === row.version;
539
+ const onText = onSummaryText(tr, onNow);
540
+ return /* @__PURE__ */ jsxs(CompactRow, {
541
+ columns: COLUMNS,
542
+ testId: "fluidgrids-history-row",
543
+ children: [
544
+ /* @__PURE__ */ jsx(RowIcon, { children: /* @__PURE__ */ jsx(Workflow, {
545
+ className: "size-4",
546
+ "aria-hidden": "true"
547
+ }) }),
548
+ /* @__PURE__ */ jsxs("div", {
549
+ className: "min-w-0",
550
+ children: [
551
+ /* @__PURE__ */ jsx(Link, {
552
+ to: { search: timelineHref },
553
+ className: cn("block truncate rounded-sm text-[13.5px] font-semibold text-text-primary after:absolute after:inset-0 hover:underline", CONTROL_RING),
554
+ "data-testid": "fluidgrids-history-row-link",
555
+ children: row.name
556
+ }),
557
+ /* @__PURE__ */ jsxs("div", {
558
+ className: cn(SUB_TEXT, "mt-0.5 flex min-w-0 items-center gap-x-1.5"),
559
+ children: [versionCount !== null && /* @__PURE__ */ jsx(VersionCountLabel, { count: versionCount }), /* @__PURE__ */ jsx(PersonChip, { name: authorName(row.createdById) })]
560
+ }),
561
+ /* @__PURE__ */ jsxs(RowSummary, { children: [
562
+ onText && /* @__PURE__ */ jsx("span", { children: onText }),
563
+ onText && /* @__PURE__ */ jsx("span", {
564
+ "aria-hidden": "true",
565
+ children: "·"
566
+ }),
567
+ /* @__PURE__ */ jsx("span", { children: changed })
568
+ ] })
569
+ ]
570
+ }),
571
+ /* @__PURE__ */ jsx(OnNowCell, { onNow }),
572
+ /* @__PURE__ */ jsx(NewestCell, {
573
+ row,
574
+ onIsNewest
575
+ }),
576
+ /* @__PURE__ */ jsx("div", {
577
+ className: "truncate text-xs tabular-nums text-text-secondary max-sm:hidden",
578
+ title: formatExactTime(changedAt),
579
+ children: changed
580
+ }),
581
+ /* @__PURE__ */ jsx(RowActions, {
582
+ name: row.name,
583
+ several,
584
+ compareHref,
585
+ menu: rowMenu(tr, props, several)
586
+ })
587
+ ]
588
+ });
589
+ }
590
+
591
+ // src/modules/history/components/VersionsByWorkflowResults.tsx
592
+ /** The note shown while only the newest workflows were searched. */
593
+ function PartialNote({ rows, windows }) {
594
+ const tr = useTr();
595
+ return /* @__PURE__ */ jsxs("p", {
596
+ className: "mb-3 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-text-secondary",
597
+ "data-testid": "fluidgrids-history-partial",
598
+ children: [
599
+ tr("fluidgrids.moreTools.versions.partial", "Searching the {{count}} most recently changed workflows of {{total}}.", {
600
+ count: formatCount(rows.length),
601
+ total: formatCount(windows.total)
602
+ }),
603
+ /* @__PURE__ */ jsx(Button$1, {
604
+ variant: "link",
605
+ size: "sm",
606
+ className: "h-auto p-0 text-xs",
607
+ onClick: windows.loadMore,
608
+ disabled: windows.loadingMore,
609
+ "data-testid": "fluidgrids-history-load-more",
610
+ children: tr("fluidgrids.moreTools.versions.loadMore", "Search {{count}} more", { count: formatCount(Math.min(500, windows.total - rows.length)) })
611
+ }),
612
+ windows.loadMoreError && /* @__PURE__ */ jsx("span", {
613
+ className: "text-status-error-text",
614
+ role: "alert",
615
+ children: tr("fluidgrids.moreTools.versions.loadMoreFailed", "Couldn't load more workflows. Try again.")
616
+ })
617
+ ]
618
+ });
619
+ }
620
+ function NoMatches({ query, onClear }) {
621
+ const tr = useTr();
622
+ return /* @__PURE__ */ jsx(NoResultsPanel, {
623
+ kind: query ? "no-results" : "filtered",
624
+ title: query ? tr("fluidgrids.moreTools.versions.noResultsFor", "No workflows match “{{query}}”", { query }) : tr("fluidgrids.moreTools.versions.noResults", "No workflows match these filters"),
625
+ text: tr("fluidgrids.moreTools.versions.noResultsText", "Try another name, or clear the filters."),
626
+ children: /* @__PURE__ */ jsxs(Button$1, {
627
+ variant: "outline",
628
+ onClick: onClear,
629
+ "data-testid": "fluidgrids-history-clear-filters",
630
+ children: [/* @__PURE__ */ jsx(X, {
631
+ className: "size-4",
632
+ "aria-hidden": "true"
633
+ }), tr("fluidgrids.moreTools.versions.clearFilters", "Clear filters")]
634
+ })
635
+ });
636
+ }
637
+ function NoVersionsYet({ onGoToWorkflows }) {
638
+ const tr = useTr();
639
+ return /* @__PURE__ */ jsx(EmptyPanel, {
640
+ illustration: "history",
641
+ icon: /* @__PURE__ */ jsx(History, {
642
+ className: "size-5 text-text-secondary",
643
+ "aria-hidden": "true"
644
+ }),
645
+ title: tr("fluidgrids.moreTools.versions.emptyTitle", "No versions yet"),
646
+ text: tr("fluidgrids.moreTools.versions.emptyText", "A version is saved each time a workflow is saved or turned on. Create a workflow and its versions show up here."),
647
+ children: /* @__PURE__ */ jsx(Button$1, {
648
+ onClick: onGoToWorkflows,
649
+ "data-testid": "fluidgrids-history-go-workflows",
650
+ children: tr("fluidgrids.moreTools.versions.goToWorkflows", "Go to Workflows")
651
+ })
652
+ });
653
+ }
654
+ function WorkflowList({ rows, lookup, params, authorName, canRestore, openTimeline, openInBuilder }) {
655
+ const tr = useTr();
656
+ return /* @__PURE__ */ jsx(CompactList, {
657
+ label: tr("fluidgrids.moreTools.versions.listHeading", "Workflows, recently changed first"),
658
+ columns: COLUMNS,
659
+ headings: [
660
+ "",
661
+ tr("fluidgrids.moreTools.versions.colWorkflow", "Workflow"),
662
+ tr("fluidgrids.moreTools.versions.colOnNow", "On now"),
663
+ tr("fluidgrids.moreTools.versions.colNewest", "Newest"),
664
+ tr("fluidgrids.moreTools.versions.colChanged", "Changed"),
665
+ ""
666
+ ],
667
+ testId: "fluidgrids-history-list",
668
+ children: rows.map((row) => /* @__PURE__ */ jsx(WorkflowRow, {
669
+ row,
670
+ onNow: onNowOf(row, lookup),
671
+ authorName,
672
+ timelineHref: timelineSearch(params, row.workflowKey),
673
+ compareHref: timelineSearch(params, row.workflowKey, "compare"),
674
+ canRestore,
675
+ openTimeline,
676
+ openInBuilder
677
+ }, row.id))
678
+ });
679
+ }
680
+ function VersionsResults(props) {
681
+ const tr = useTr();
682
+ const { windows, resultTotal, shownPage, pageLoading } = props;
683
+ if (props.error) return /* @__PURE__ */ jsx(LoadErrorPanel, {
684
+ title: tr("fluidgrids.moreTools.versions.loadErrorTitle", "Couldn't load version history"),
685
+ text: tr("fluidgrids.moreTools.versions.loadErrorText", "The workflow service did not answer. Your workflows and their versions are safe."),
686
+ error: props.error,
687
+ onRetry: props.onRetry
688
+ });
689
+ if (props.firstLoad) return /* @__PURE__ */ jsx(ListSkeleton, { rows: 8 });
690
+ if (props.noWorkflows) return /* @__PURE__ */ jsx(NoVersionsYet, { onGoToWorkflows: props.onGoToWorkflows });
691
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
692
+ /* @__PURE__ */ jsx(ResultsHeading, {
693
+ title: tr("fluidgrids.moreTools.versions.listHeading", "Workflows, recently changed first"),
694
+ page: shownPage,
695
+ total: resultTotal,
696
+ showRange: props.showRange || pageLoading,
697
+ headingRef: props.headingRef
698
+ }),
699
+ props.local && windows.rows && windows.hasMore && /* @__PURE__ */ jsx(PartialNote, {
700
+ rows: windows.rows,
701
+ windows
702
+ }),
703
+ resultTotal === 0 ? /* @__PURE__ */ jsx(NoMatches, {
704
+ query: props.query,
705
+ onClear: props.onClearFilters
706
+ }) : /* @__PURE__ */ jsx(PagedBody, {
707
+ pageLoading,
708
+ page: shownPage,
709
+ children: /* @__PURE__ */ jsx(WorkflowList, { ...props })
710
+ }),
711
+ /* @__PURE__ */ jsx(ResultsPager, {
712
+ page: shownPage,
713
+ total: resultTotal,
714
+ onPage: props.onPage,
715
+ className: "mt-4"
716
+ })
717
+ ] });
718
+ }
719
+
720
+ // src/modules/history/components/useVersionsByWorkflow.ts
721
+ /**
722
+ * State behind the "By workflow" version history list: the reads, the rows
723
+ * for the page, the filters' controls and the assistant's page controls.
724
+ */
725
+ /**
726
+ * The On lookup for the page the service pages: the newest On version of the
727
+ * page's workflows only (`workflowKeys`, BOFF-16690), one read instead of
728
+ * every window of the On list. The last answer stays while the next page's
729
+ * loads; it says nothing about workflows it was not read for.
730
+ */
731
+ function usePageOnLookup(pageRows) {
732
+ const pageKeys = useMemo(() => pageRows ? pageRows.map((row) => row.workflowKey) : null, [pageRows]);
733
+ const input = useMemo(() => onVersionsInput(pageKeys), [pageKeys]);
734
+ const pageOn = useDefinitionsQuery(input);
735
+ const { current: answersInput, data: answer } = pageOn;
736
+ const fresh = useMemo(() => answersInput && answer && input?.workflowKeys ? onLookupFrom(answer.items, true, input.workflowKeys) : null, [
737
+ answersInput,
738
+ answer,
739
+ input
740
+ ]);
741
+ const [kept, setKept] = useState(null);
742
+ if (fresh && fresh !== kept) setKept(fresh);
743
+ return {
744
+ pageOn,
745
+ lookup: fresh ?? kept
746
+ };
747
+ }
748
+ /** The reads the list is built from. */
749
+ function useHistoryReads(local, wantEveryone, page) {
750
+ const windows = useNewestWindows(local || wantEveryone);
751
+ const serverPage = useDefinitionsQuery(local ? null : {
752
+ latestOnly: true,
753
+ ...serverWindow(page)
754
+ });
755
+ const onQuery = useOnVersionsQuery(local);
756
+ const { pageOn, lookup: pageLookup } = usePageOnLookup(local ? void 0 : serverPage.data?.items);
757
+ const onCount = useDefinitionsQuery(local ? null : ON_COUNT_INPUT);
758
+ const versionTotal = useDefinitionsQuery({ limit: 1 });
759
+ const everyLookup = useMemo(() => onQuery.data ? onLookupFrom(onQuery.data.items, !onQuery.data.hasMore) : null, [onQuery.data]);
760
+ return {
761
+ windows,
762
+ serverPage,
763
+ onQuery,
764
+ pageOn,
765
+ onCount,
766
+ versionTotal,
767
+ lookup: local ? everyLookup : pageLookup,
768
+ onTotal: onTotalOf(local, onQuery, onCount),
769
+ workflowTotal: serverPage.data?.total ?? (windows.rows ? windows.total : null)
770
+ };
771
+ }
772
+ /** How many workflows have an On version, from whichever read the list sends. */
773
+ function onTotalOf(local, onQuery, onCount) {
774
+ return (local ? onQuery : onCount).data?.total ?? null;
775
+ }
776
+ /** The rows of the page: the local slice when filtering, else the server's. */
777
+ function pickRows(local, localReady, localItems, serverRows) {
778
+ if (!local) return serverRows ?? [];
779
+ return localReady && localItems ? localItems : [];
780
+ }
781
+ /** The rows, total and page to show, whichever path pages them. */
782
+ function useHistoryRows({ local, page, filters, reads, setPage }) {
783
+ const { windows, serverPage, lookup } = reads;
784
+ const filtered = useMemo(() => local && windows.rows ? filterNewestRows(windows.rows, filters, lookup) : null, [
785
+ local,
786
+ windows.rows,
787
+ filters,
788
+ lookup
789
+ ]);
790
+ const localReady = windows.rows !== null && (filters.chip !== "off" || lookup !== null);
791
+ const localSlice = useMemo(() => filtered ? pageSlice(filtered, page) : null, [filtered, page]);
792
+ const serverRows = serverPage.data?.items;
793
+ const localItems = localSlice?.items;
794
+ const rows = useMemo(() => pickRows(local, localReady, localItems, serverRows), [
795
+ local,
796
+ localReady,
797
+ localItems,
798
+ serverRows
799
+ ]);
800
+ const resultTotal = local ? filtered?.length ?? 0 : serverPage.data?.total ?? 0;
801
+ const shownPage = local ? localSlice?.page ?? page : page;
802
+ const settled = local ? localReady && !windows.loading : serverPage.current && !serverPage.loading;
803
+ useClampedPage(page, resultTotal, MORE_TOOLS_PAGE_SIZE, settled, setPage);
804
+ return {
805
+ rows,
806
+ resultTotal,
807
+ shownPage,
808
+ settled,
809
+ localReady
810
+ };
811
+ }
812
+ /** Who saved the newest versions shown (and the person filter's pick). */
813
+ function useHistoryAuthors(reads, rows, by) {
814
+ const loaded = reads.windows.rows;
815
+ const authorIds = useMemo(() => authorIdsOf([...loaded ?? [], ...rows]), [loaded, rows]);
816
+ return {
817
+ authorIds,
818
+ authorName: useAuthorNames(by ? [...authorIds, by] : authorIds)
819
+ };
820
+ }
821
+ /** The filter chips with their counts. */
822
+ function useHistoryChips(reads) {
823
+ const tr = useTr();
824
+ const { windows, onTotal, workflowTotal } = reads;
825
+ const allLoaded = windows.rows !== null && !windows.hasMore;
826
+ const counts = useMemo(() => chipCounts({
827
+ total: workflowTotal,
828
+ onTotal,
829
+ loadedRows: windows.rows,
830
+ allLoaded
831
+ }), [
832
+ workflowTotal,
833
+ onTotal,
834
+ windows.rows,
835
+ allLoaded
836
+ ]);
837
+ return useMemo(() => [
838
+ {
839
+ value: "all",
840
+ label: tr("fluidgrids.moreTools.versions.chipAll", "All workflows"),
841
+ count: counts.all
842
+ },
843
+ {
844
+ value: "draft",
845
+ label: tr("fluidgrids.moreTools.versions.chipDraft", "Newest is a draft"),
846
+ count: counts.draft
847
+ },
848
+ {
849
+ value: "off",
850
+ label: tr("fluidgrids.moreTools.versions.chipOff", "Nothing on"),
851
+ count: counts.off
852
+ }
853
+ ], [tr, counts]);
854
+ }
855
+ /** The "Changed by" choices, Anyone first. */
856
+ function usePeopleChoices(authorIds, by, authorName) {
857
+ const anyoneLabel = useTr()("fluidgrids.moreTools.versions.byAnyone", "Anyone");
858
+ return useMemo(() => [{
859
+ value: "",
860
+ label: anyoneLabel
861
+ }, ...peopleChoices(authorIds, by, authorName)], [
862
+ anyoneLabel,
863
+ authorIds,
864
+ by,
865
+ authorName
866
+ ]);
867
+ }
868
+ /** The list's controls: search draft, chip, person, clear, paging, opening. */
869
+ function useHistoryActions(list) {
870
+ const navigate = useNavigate();
871
+ const { params, set, setPage } = list;
872
+ const headingRef = useRef(null);
873
+ const [searchDraft, changeSearch] = useSearchDraft(params.get("q") ?? "", useCallback((value) => set({ q: value }), [set]));
874
+ return {
875
+ headingRef,
876
+ searchDraft,
877
+ changeSearch,
878
+ setChip: useCallback((chip) => set({ chip: chip === "all" ? null : chip }), [set]),
879
+ setPerson: useCallback((by) => set({ by: by || null }), [set]),
880
+ clearFilters: useCallback(() => set({
881
+ q: null,
882
+ chip: null,
883
+ by: null
884
+ }), [set]),
885
+ goToPage: useCallback((next) => {
886
+ setPage(next);
887
+ headingRef.current?.focus();
888
+ }, [setPage]),
889
+ openTimeline: useCallback((workflowKey, open) => navigate({ search: timelineSearch(params, workflowKey, open) }), [navigate, params])
890
+ };
891
+ }
892
+ /**
893
+ * What this page tells the assistant it lists and filters by. The page
894
+ * registers it itself (`useFluidGridsPageControls`), before its first return.
895
+ */
896
+ function useHistoryAssistantControls(input) {
897
+ const tr = useTr();
898
+ const { title, rows, filters, chips, people } = input;
899
+ const { set, setChip, setPerson, openTimeline } = input;
900
+ return useMemo(() => {
901
+ const spec = historyControls({
902
+ page: title,
903
+ search: (query) => set({ q: query }),
904
+ workflow: {
905
+ label: tr("fluidgrids.executions.executionTable.colWorkflow", "Workflow"),
906
+ allLabel: tr("fluidgrids.moreTools.versions.chipAll", "All workflows"),
907
+ neutral: "all",
908
+ options: rows.map((row) => ({
909
+ value: row.workflowKey,
910
+ label: row.name
911
+ })),
912
+ value: "all",
913
+ set: (workflowKey) => {
914
+ if (workflowKey !== "all") openTimeline(workflowKey);
915
+ }
916
+ }
917
+ });
918
+ return {
919
+ ...spec,
920
+ filters: [
921
+ ...spec.filters ?? [],
922
+ {
923
+ id: "chip",
924
+ label: tr("fluidgrids.moreTools.versions.chipsLabel", "Filter workflows"),
925
+ neutral: "all",
926
+ value: filters.chip,
927
+ options: chips.map(({ value, label }) => ({
928
+ value,
929
+ label
930
+ })),
931
+ set: (value) => setChip(chips.find((chip) => chip.value === value)?.value ?? "all")
932
+ },
933
+ {
934
+ id: "by",
935
+ label: tr("fluidgrids.moreTools.versions.byLabel", "Changed by"),
936
+ neutral: "",
937
+ value: filters.by,
938
+ options: people,
939
+ set: setPerson
940
+ }
941
+ ]
942
+ };
943
+ }, [
944
+ title,
945
+ tr,
946
+ rows,
947
+ filters.chip,
948
+ filters.by,
949
+ chips,
950
+ people,
951
+ set,
952
+ setChip,
953
+ setPerson,
954
+ openTimeline
955
+ ]);
956
+ }
957
+ /**
958
+ * The failed read the list is waiting on, if any. "Nothing on" also needs
959
+ * the On lookup: without it the list would wait for good, so its failure is
960
+ * said too, with Try again (which reads everything again).
961
+ */
962
+ function listError(local, chip, reads) {
963
+ if (!local) return reads.serverPage.error;
964
+ if (reads.windows.error) return reads.windows.error;
965
+ return chip === "off" && !reads.lookup ? reads.onQuery.error : null;
966
+ }
967
+ /** Everything the "By workflow" list needs to render. */
968
+ function useVersionsByWorkflow() {
969
+ const tr = useTr();
970
+ const list = useUrlListState();
971
+ const { params, page, set, setPage } = list;
972
+ const filters = useMemo(() => readHistoryFilters(params), [params]);
973
+ const local = needsLocalFilter(filters);
974
+ const [wantEveryone, setWantEveryone] = useState(false);
975
+ const reads = useHistoryReads(local, wantEveryone, page);
976
+ const shown = useHistoryRows({
977
+ local,
978
+ page,
979
+ filters,
980
+ reads,
981
+ setPage
982
+ });
983
+ const { authorIds, authorName } = useHistoryAuthors(reads, shown.rows, filters.by);
984
+ const actions = useHistoryActions(list);
985
+ const refetchPage = reads.serverPage.refetch;
986
+ const refetchOn = reads.onQuery.refetch;
987
+ const refetchPageOn = reads.pageOn.refetch;
988
+ const refetchOnCount = reads.onCount.refetch;
989
+ const refetchTotal = reads.versionTotal.refetch;
990
+ const refetchWindows = reads.windows.refetch;
991
+ const refresh = useCallback(() => {
992
+ refetchPage();
993
+ refetchOn();
994
+ refetchPageOn();
995
+ refetchOnCount();
996
+ refetchTotal();
997
+ refetchWindows();
998
+ }, [
999
+ refetchPage,
1000
+ refetchOn,
1001
+ refetchPageOn,
1002
+ refetchOnCount,
1003
+ refetchTotal,
1004
+ refetchWindows
1005
+ ]);
1006
+ const chips = useHistoryChips(reads);
1007
+ const people = usePeopleChoices(authorIds, filters.by, authorName);
1008
+ const title = tr("fluidgrids.moreTools.versions.title", "Version history");
1009
+ return {
1010
+ assistantControls: useHistoryAssistantControls({
1011
+ title,
1012
+ rows: shown.rows,
1013
+ filters,
1014
+ chips,
1015
+ people,
1016
+ set,
1017
+ setChip: actions.setChip,
1018
+ setPerson: actions.setPerson,
1019
+ openTimeline: actions.openTimeline
1020
+ }),
1021
+ title,
1022
+ params,
1023
+ filters,
1024
+ local,
1025
+ reads,
1026
+ ...shown,
1027
+ authorName,
1028
+ chips,
1029
+ people,
1030
+ refresh,
1031
+ requestEveryone: () => setWantEveryone(true),
1032
+ error: listError(local, filters.chip, reads),
1033
+ firstLoad: local ? !shown.localReady : !reads.serverPage.data,
1034
+ pageLoading: !local && reads.serverPage.loading && !reads.serverPage.current,
1035
+ noWorkflows: reads.workflowTotal === 0,
1036
+ ...actions
1037
+ };
1038
+ }
1039
+
1040
+ // src/modules/history/components/VersionsByWorkflow.tsx
1041
+ /**
1042
+ * Version history, by workflow (BOFF-15502; the prototype's Recommended
1043
+ * "By workflow" list): one row per workflow with the version that is On,
1044
+ * its newest version, how many versions it has, who saved the newest and
1045
+ * when. A row opens that workflow's timeline (`?workflow=<key>`), where
1046
+ * Compare and Restore sit together.
1047
+ *
1048
+ * The list is the Templates pager on every path: 20 per page, `?page=` in
1049
+ * the address and clamped, the search (`?q=`), the chip (`?chip=`) and the
1050
+ * person (`?by=`) in the address too. Without a filter the service pages it;
1051
+ * with one the page filters the newest version of every workflow itself (see
1052
+ * useVersionHistoryData).
1053
+ */
1054
+ function VersionsByWorkflow({ access, openInBuilder }) {
1055
+ const navigate = useNavigate();
1056
+ const state = useVersionsByWorkflow();
1057
+ const { reads, filters, assistantControls } = state;
1058
+ useFluidGridsPageControls(assistantControls);
1059
+ const showFilters = !(state.noWorkflows && !state.local);
1060
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1061
+ /* @__PURE__ */ jsx(VersionsHeader, {
1062
+ title: state.title,
1063
+ workflowTotal: reads.workflowTotal,
1064
+ versionTotal: reads.versionTotal.data?.total ?? null,
1065
+ viewOnly: access.viewOnly,
1066
+ onRefresh: state.refresh
1067
+ }),
1068
+ showFilters && /* @__PURE__ */ jsx(VersionsFilters, {
1069
+ chips: state.chips,
1070
+ chip: filters.chip,
1071
+ by: filters.by,
1072
+ people: state.people,
1073
+ searchDraft: state.searchDraft,
1074
+ onChip: state.setChip,
1075
+ onPerson: state.setPerson,
1076
+ onSearch: state.changeSearch,
1077
+ onWantEveryone: state.requestEveryone
1078
+ }),
1079
+ /* @__PURE__ */ jsx(VersionsResults, {
1080
+ error: state.error,
1081
+ firstLoad: state.firstLoad,
1082
+ noWorkflows: state.noWorkflows,
1083
+ local: state.local,
1084
+ windows: reads.windows,
1085
+ query: filters.q.trim(),
1086
+ rows: state.rows,
1087
+ lookup: reads.lookup,
1088
+ params: state.params,
1089
+ authorName: state.authorName,
1090
+ canRestore: access.canRestore,
1091
+ openTimeline: state.openTimeline,
1092
+ openInBuilder,
1093
+ resultTotal: state.resultTotal,
1094
+ shownPage: state.shownPage,
1095
+ showRange: state.settled,
1096
+ pageLoading: state.pageLoading,
1097
+ headingRef: state.headingRef,
1098
+ onRetry: state.refresh,
1099
+ onClearFilters: state.clearFilters,
1100
+ onPage: state.goToPage,
1101
+ onGoToWorkflows: () => navigate("../list")
1102
+ })
1103
+ ] });
1104
+ }
1105
+
1106
+ // src/modules/history/components/RestoreVersionDialog.tsx
1107
+ /**
1108
+ * "Restore 1.0.0 as a new draft?" (BOFF-15502): the one confirmation every
1109
+ * restore on the redesigned Version history goes through, from a timeline
1110
+ * row, the list's "Restore an older version…" or the compare dialog.
1111
+ *
1112
+ * It names the version and says what happens: a new draft is made from it,
1113
+ * and the version that is On and every other version stay as they are. On
1114
+ * success it keeps today's flow (a toast, then the new draft opens in the
1115
+ * builder); on failure it stays open and says so, with the service's words
1116
+ * under "Show technical details".
1117
+ */
1118
+ function RestoreVersionDialog({ workflowKey, version, onVersion, onClose, onRestored }) {
1119
+ const tr = useTr();
1120
+ const { restoreVersion, error: restoreError } = useRestoreWorkflowVersion();
1121
+ const [busy, setBusy] = useState(false);
1122
+ const [refusal, setRefusal] = useState(null);
1123
+ const failure = refusal && refusal.version === version ? refusal : null;
1124
+ const confirm = async () => {
1125
+ if (!version) return;
1126
+ setBusy(true);
1127
+ setRefusal(null);
1128
+ try {
1129
+ const result = await restoreVersion(workflowKey, version);
1130
+ if (result?.success && result.workflow) {
1131
+ toast.success(tr("fluidgrids.history.historyPage.restoreSuccess", "Version restored"), {
1132
+ description: tr("fluidgrids.history.historyPage.restoreSuccessDescription", "Created {{created}} from {{version}}", {
1133
+ created: result.workflow.version,
1134
+ version
1135
+ }),
1136
+ dismissible: true
1137
+ });
1138
+ onRestored({
1139
+ workflowKey: result.workflow.workflowKey,
1140
+ version: result.workflow.version
1141
+ });
1142
+ return;
1143
+ }
1144
+ setRefusal({
1145
+ version,
1146
+ message: result?.message ?? null
1147
+ });
1148
+ } finally {
1149
+ setBusy(false);
1150
+ }
1151
+ };
1152
+ const detail = failure ? failure.message ?? restoreError?.message ?? "" : "";
1153
+ const target = version ?? "";
1154
+ return /* @__PURE__ */ jsx(ConfirmActionDialog, {
1155
+ open: version !== null,
1156
+ onOpenChange: (open) => {
1157
+ if (!open && !busy) onClose();
1158
+ },
1159
+ title: tr("fluidgrids.moreTools.versions.restore.title", "Restore {{version}} as a new draft?", { version: target }),
1160
+ description: /* @__PURE__ */ jsxs("div", {
1161
+ className: "space-y-3",
1162
+ children: [/* @__PURE__ */ jsx("p", { children: onVersion ? tr("fluidgrids.moreTools.versions.restore.bodyWithOn", "This makes a new draft from {{version}}. The version that is On ({{on}}) and every other version stay as they are.", {
1163
+ version: target,
1164
+ on: onVersion
1165
+ }) : tr("fluidgrids.moreTools.versions.restore.body", "This makes a new draft from {{version}}. Every other version stays as it is.", { version: target }) }), failure && /* @__PURE__ */ jsxs(ToneAlert, {
1166
+ tone: "danger",
1167
+ role: "alert",
1168
+ className: "mb-0",
1169
+ title: tr("fluidgrids.moreTools.versions.restore.failedTitle", "Couldn't restore {{version}}", { version: target }),
1170
+ testId: "fluidgrids-version-restore-failed",
1171
+ children: [/* @__PURE__ */ jsx("p", { children: tr("fluidgrids.moreTools.versions.restore.failedText", "Nothing was changed. Try again in a moment.") }), detail && /* @__PURE__ */ jsx(ShowTechnicalDetails, {
1172
+ copyable: true,
1173
+ className: "mt-1",
1174
+ children: detail
1175
+ })]
1176
+ })]
1177
+ }),
1178
+ confirmLabel: tr("fluidgrids.moreTools.versions.restore.confirm", "Restore as draft"),
1179
+ cancelLabel: tr("fluidgrids.moreTools.versions.restore.cancel", "Don't restore"),
1180
+ busy,
1181
+ onConfirm: () => void confirm(),
1182
+ "data-testid": "fluidgrids-version-restore"
1183
+ });
1184
+ }
1185
+
1186
+ // src/modules/history/components/VersionCompareDialog.tsx
1187
+ /**
1188
+ * Compare versions (BOFF-15502), the redesigned Version history's compare
1189
+ * dialog: any two versions of one workflow, picked with the app's own menus
1190
+ * and swapped with one button, then a one-line summary ("2 steps added · 2
1191
+ * changed · 1 removed · 3 only moved") over three views:
1192
+ *
1193
+ * - Canvas: both versions on one read-only canvas, coloured by change;
1194
+ * - Changes: what was added, changed or removed, step by step, with the
1195
+ * value before and after, read from the same graph diff as the canvas;
1196
+ * - JSON: the service's list of changed paths and the line diff of the two
1197
+ * definitions, collapsed to the changed lines.
1198
+ *
1199
+ * The footer opens the "to" version in the builder or restores the "from"
1200
+ * version as a new draft (after a confirmation the page owns). Status words
1201
+ * are the list's: On, Draft, Retired, Archived.
1202
+ *
1203
+ * The builder's Versions panel keeps opening VersionDiffDialog.
1204
+ *
1205
+ * Under the stable tabbed-dialog opt-in (BOFF-15607, `useStableTabbedDialogs`)
1206
+ * the dialog is fe-libs' shared layout: a fixed-height viewer box (a bottom
1207
+ * sheet below md), the pickers fixed under the header, the three views as
1208
+ * cross-faded panels (each its own scroller, its scroll position kept) and the
1209
+ * footer pinned. The summary, the same-pair hint, loading and a failed
1210
+ * comparison show in the panel, so the tabs stay put. Without it the dialog is
1211
+ * today's.
1212
+ */
1213
+ const COMPARE_TABS = [
1214
+ "canvas",
1215
+ "changes",
1216
+ "json"
1217
+ ];
1218
+ function VersionCompareDialog({ onClose, workflowKey, workflowName, versions, initialFrom, initialTo, authorName, onRestore, onOpenVersion }) {
1219
+ const tr = useTr();
1220
+ const wordOf = useStageWords();
1221
+ const [from, setFrom] = useState(initialFrom);
1222
+ const [to, setTo] = useState(initialTo);
1223
+ const [tab, setTab] = useState("canvas");
1224
+ const samePair = from === to;
1225
+ const { comparison, loading, error, reload } = useVersionComparison(workflowKey, from, to);
1226
+ const options = useMemo(() => versions.map((v) => ({
1227
+ value: v.version,
1228
+ label: tr("fluidgrids.moreTools.versions.compare.option", "{{version}} · {{status}}", {
1229
+ version: v.version,
1230
+ status: wordOf(lifecycleStageOf(v.status))
1231
+ })
1232
+ })), [
1233
+ versions,
1234
+ tr,
1235
+ wordOf
1236
+ ]);
1237
+ const byVersion = useMemo(() => new Map(versions.map((v) => [v.version, v])), [versions]);
1238
+ const detailOf = (version) => {
1239
+ const option = byVersion.get(version);
1240
+ if (!option) return null;
1241
+ return tr("fluidgrids.moreTools.versions.whoWhen", "{{who}} · {{when}}", {
1242
+ who: authorName(option.createdById),
1243
+ when: formatShortDateTime(option.updatedAt ?? option.createdAt)
1244
+ });
1245
+ };
1246
+ const stable = useStableTabbedDialogs();
1247
+ const title = tr("fluidgrids.moreTools.versions.compare.title", "Compare versions");
1248
+ const pickers = /* @__PURE__ */ jsxs(Fragment$1, { children: [
1249
+ /* @__PURE__ */ jsx(VersionPicker, {
1250
+ id: "fluidgrids-version-compare-from",
1251
+ label: tr("fluidgrids.moreTools.versions.compare.from", "From"),
1252
+ value: from,
1253
+ options,
1254
+ onChange: setFrom,
1255
+ detail: detailOf(from)
1256
+ }),
1257
+ /* @__PURE__ */ jsx(Button$1, {
1258
+ variant: "outline",
1259
+ size: "icon",
1260
+ className: "mt-5",
1261
+ "aria-label": tr("fluidgrids.history.versionDiff.swap", "Swap versions"),
1262
+ onClick: () => {
1263
+ setFrom(to);
1264
+ setTo(from);
1265
+ },
1266
+ "data-testid": "fluidgrids-version-compare-swap",
1267
+ children: /* @__PURE__ */ jsx(ArrowLeftRight, {
1268
+ className: "size-4",
1269
+ "aria-hidden": "true"
1270
+ })
1271
+ }),
1272
+ /* @__PURE__ */ jsx(VersionPicker, {
1273
+ id: "fluidgrids-version-compare-to",
1274
+ label: tr("fluidgrids.moreTools.versions.compare.to", "To"),
1275
+ value: to,
1276
+ options,
1277
+ onChange: setTo,
1278
+ detail: detailOf(to)
1279
+ })
1280
+ ] });
1281
+ const actions = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Button$1, {
1282
+ variant: "outline",
1283
+ onClick: () => onOpenVersion(to),
1284
+ "data-testid": "fluidgrids-version-compare-open",
1285
+ children: [/* @__PURE__ */ jsx(ExternalLink, {
1286
+ className: "size-4",
1287
+ "aria-hidden": "true"
1288
+ }), tr("fluidgrids.moreTools.versions.compare.openTo", "Open {{version}} in builder", { version: to })]
1289
+ }), /* @__PURE__ */ jsxs("div", {
1290
+ className: "flex flex-wrap gap-2",
1291
+ children: [onRestore && /* @__PURE__ */ jsxs(Button$1, {
1292
+ variant: "outline",
1293
+ onClick: () => onRestore(from),
1294
+ "data-testid": "fluidgrids-version-compare-restore",
1295
+ children: [/* @__PURE__ */ jsx(RotateCcw, {
1296
+ className: "size-4",
1297
+ "aria-hidden": "true"
1298
+ }), tr("fluidgrids.moreTools.versions.compare.restoreFrom", "Restore {{version}} as a draft", { version: from })]
1299
+ }), /* @__PURE__ */ jsx(Button$1, {
1300
+ onClick: onClose,
1301
+ "data-testid": "fluidgrids-version-compare-done",
1302
+ children: tr("fluidgrids.moreTools.common.done", "Done")
1303
+ })]
1304
+ })] });
1305
+ if (stable) {
1306
+ const tabs = [
1307
+ {
1308
+ value: "canvas",
1309
+ label: tr("fluidgrids.moreTools.versions.compare.canvasTab", "Canvas"),
1310
+ icon: Workflow,
1311
+ testId: "fluidgrids-version-compare-tab-canvas"
1312
+ },
1313
+ {
1314
+ value: "changes",
1315
+ label: tr("fluidgrids.moreTools.versions.compare.changesTab", "Changes"),
1316
+ icon: List,
1317
+ testId: "fluidgrids-version-compare-tab-changes"
1318
+ },
1319
+ {
1320
+ value: "json",
1321
+ label: tr("fluidgrids.history.versionDiff.jsonTab", "JSON"),
1322
+ icon: Braces,
1323
+ testId: "fluidgrids-version-compare-tab-json"
1324
+ }
1325
+ ];
1326
+ return /* @__PURE__ */ jsx(TabbedDialog, {
1327
+ open: true,
1328
+ onOpenChange: (open) => {
1329
+ if (!open) onClose();
1330
+ },
1331
+ children: /* @__PURE__ */ jsxs(TabbedDialogContent, {
1332
+ size: "viewer",
1333
+ width: "wide",
1334
+ presentation: "sheet",
1335
+ onOpenAutoFocus: focusDialogOnOpen,
1336
+ "data-testid": "fluidgrids-version-compare-dialog",
1337
+ children: [
1338
+ /* @__PURE__ */ jsx(TabbedDialogHeader, {
1339
+ title,
1340
+ description: workflowName,
1341
+ closeLabel: tr("fluidgrids.ui.dialog.closeLabel", "Close")
1342
+ }),
1343
+ /* @__PURE__ */ jsx("div", {
1344
+ className: "grid shrink-0 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-start gap-2 border-b border-border-subtle px-5 py-3",
1345
+ children: pickers
1346
+ }),
1347
+ /* @__PURE__ */ jsx(TabbedDialogTabs, {
1348
+ tabs,
1349
+ value: tab,
1350
+ onValueChange: setTab,
1351
+ "aria-label": tr("fluidgrids.moreTools.versions.compare.views", "Compare views"),
1352
+ renderPanel: (view) => /* @__PURE__ */ jsx(StableComparisonPanel, {
1353
+ view,
1354
+ samePair,
1355
+ comparison,
1356
+ loading,
1357
+ error,
1358
+ onRetry: reload
1359
+ })
1360
+ }),
1361
+ /* @__PURE__ */ jsx(TabbedDialogFooter, {
1362
+ className: "sm:justify-between",
1363
+ children: actions
1364
+ })
1365
+ ]
1366
+ })
1367
+ });
1368
+ }
1369
+ return /* @__PURE__ */ jsx(ResponsiveDialog, {
1370
+ open: true,
1371
+ onOpenChange: (open) => {
1372
+ if (!open) onClose();
1373
+ },
1374
+ children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
1375
+ className: "max-h-[92vh] overflow-y-auto sm:max-w-5xl",
1376
+ "data-testid": "fluidgrids-version-compare-dialog",
1377
+ children: [
1378
+ /* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: title }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: workflowName })] }),
1379
+ /* @__PURE__ */ jsx("div", {
1380
+ className: "grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-start gap-2",
1381
+ children: pickers
1382
+ }),
1383
+ samePair ? /* @__PURE__ */ jsx(SamePairHint, {}) : /* @__PURE__ */ jsx(ComparisonArea, {
1384
+ comparison,
1385
+ loading,
1386
+ error,
1387
+ onRetry: reload,
1388
+ tab,
1389
+ onTabChange: setTab
1390
+ }),
1391
+ /* @__PURE__ */ jsx(ResponsiveDialogFooter, {
1392
+ className: "flex-wrap gap-2 sm:justify-between",
1393
+ children: actions
1394
+ })
1395
+ ]
1396
+ })
1397
+ });
1398
+ }
1399
+ function VersionPicker({ id, label, value, options, onChange, detail }) {
1400
+ return /* @__PURE__ */ jsxs("div", {
1401
+ className: "min-w-0",
1402
+ children: [
1403
+ /* @__PURE__ */ jsx("label", {
1404
+ htmlFor: id,
1405
+ className: "mb-1 block text-xs font-medium text-text-secondary",
1406
+ children: label
1407
+ }),
1408
+ /* @__PURE__ */ jsx(ChoiceSelect, {
1409
+ id,
1410
+ value,
1411
+ onValueChange: onChange,
1412
+ options,
1413
+ className: "w-full",
1414
+ "data-testid": id
1415
+ }),
1416
+ detail && /* @__PURE__ */ jsx("p", {
1417
+ className: cn("text-xs text-text-muted", "mt-1 truncate"),
1418
+ children: detail
1419
+ })
1420
+ ]
1421
+ });
1422
+ }
1423
+ /** "Pick two different versions": the same version on both sides. */
1424
+ function SamePairHint() {
1425
+ const tr = useTr();
1426
+ return /* @__PURE__ */ jsx(ToneAlert, {
1427
+ tone: "neutral",
1428
+ className: "mb-0",
1429
+ title: tr("fluidgrids.moreTools.versions.compare.samePair", "Pick two different versions"),
1430
+ testId: "fluidgrids-version-compare-same"
1431
+ });
1432
+ }
1433
+ /** A comparison that failed to load, with Try again. */
1434
+ function ComparisonError({ error, onRetry }) {
1435
+ const tr = useTr();
1436
+ return /* @__PURE__ */ jsxs(ToneAlert, {
1437
+ tone: "danger",
1438
+ role: "alert",
1439
+ className: "mb-0",
1440
+ title: tr("fluidgrids.moreTools.versions.compare.errorTitle", "Couldn't compare these versions"),
1441
+ actions: /* @__PURE__ */ jsx(Button$1, {
1442
+ variant: "outline",
1443
+ size: "sm",
1444
+ onClick: onRetry,
1445
+ "data-testid": "fluidgrids-version-compare-retry",
1446
+ children: tr("fluidgrids.moreTools.common.tryAgain", "Try again")
1447
+ }),
1448
+ testId: "fluidgrids-version-compare-error",
1449
+ children: [/* @__PURE__ */ jsx("p", { children: tr("fluidgrids.moreTools.versions.compare.errorText", "Something went wrong while loading them. Your versions are safe.") }), /* @__PURE__ */ jsx(ShowTechnicalDetails, {
1450
+ copyable: true,
1451
+ className: "mt-1",
1452
+ children: error
1453
+ })]
1454
+ });
1455
+ }
1456
+ function ComparisonLoading() {
1457
+ const tr = useTr();
1458
+ return /* @__PURE__ */ jsxs("div", {
1459
+ className: "flex items-center justify-center gap-2 py-10 text-sm text-text-secondary",
1460
+ children: [/* @__PURE__ */ jsx(SpinnerIcon, {
1461
+ className: "size-4 animate-spin motion-reduce:animate-none",
1462
+ "aria-hidden": "true"
1463
+ }), tr("fluidgrids.history.versionDiff.loading", "Comparing versions…")]
1464
+ });
1465
+ }
1466
+ /** One view of a loaded comparison: the canvas, the changes, or the JSON. */
1467
+ function ComparisonView({ view, comparison }) {
1468
+ const tr = useTr();
1469
+ if (view === "canvas") return /* @__PURE__ */ jsx(VersionDiffGraph, {
1470
+ graph: comparison.graph,
1471
+ plain: true
1472
+ });
1473
+ if (view === "changes") return /* @__PURE__ */ jsx(PlainChangesList, { comparison });
1474
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("section", { children: [/* @__PURE__ */ jsx("h3", {
1475
+ className: "mb-2 text-sm font-semibold text-text-primary",
1476
+ children: tr("fluidgrids.moreTools.versions.compare.changedPaths", "Every changed path")
1477
+ }), /* @__PURE__ */ jsx(VersionChangeList, {
1478
+ diff: comparison.serverDiff,
1479
+ error: comparison.serverDiffError,
1480
+ plain: true
1481
+ })] }), /* @__PURE__ */ jsxs("section", { children: [/* @__PURE__ */ jsx("h3", {
1482
+ className: "mb-2 text-sm font-semibold text-text-primary",
1483
+ children: tr("fluidgrids.history.versionDiff.rawHeading", "Definition JSON")
1484
+ }), /* @__PURE__ */ jsx(JsonLineDiffView, {
1485
+ before: comparison.from.definitionJson,
1486
+ after: comparison.to.definitionJson,
1487
+ fromVersion: comparison.fromVersion,
1488
+ toVersion: comparison.toVersion
1489
+ })] })] });
1490
+ }
1491
+ /**
1492
+ * A panel of the stable layout: the comparison's state (same pair, failed,
1493
+ * loading) or the summary over the view, so the tabs never come and go.
1494
+ */
1495
+ function StableComparisonPanel({ view, samePair, comparison, loading, error, onRetry }) {
1496
+ if (samePair) return /* @__PURE__ */ jsx(SamePairHint, {});
1497
+ if (error) return /* @__PURE__ */ jsx(ComparisonError, {
1498
+ error,
1499
+ onRetry
1500
+ });
1501
+ if (!comparison) return loading ? /* @__PURE__ */ jsx(ComparisonLoading, {}) : null;
1502
+ return /* @__PURE__ */ jsxs("div", {
1503
+ className: "min-w-0 space-y-3",
1504
+ children: [/* @__PURE__ */ jsx(CompareSummary, { graph: comparison.graph }), /* @__PURE__ */ jsx("div", {
1505
+ className: view === "json" ? "space-y-4" : void 0,
1506
+ children: /* @__PURE__ */ jsx(ComparisonView, {
1507
+ view,
1508
+ comparison
1509
+ })
1510
+ })]
1511
+ });
1512
+ }
1513
+ function ComparisonArea({ comparison, loading, error, onRetry, tab, onTabChange }) {
1514
+ const tr = useTr();
1515
+ if (error) return /* @__PURE__ */ jsx(ComparisonError, {
1516
+ error,
1517
+ onRetry
1518
+ });
1519
+ if (!comparison) return loading ? /* @__PURE__ */ jsx(ComparisonLoading, {}) : null;
1520
+ return /* @__PURE__ */ jsxs("div", {
1521
+ className: "min-w-0 space-y-3",
1522
+ children: [/* @__PURE__ */ jsx(CompareSummary, { graph: comparison.graph }), /* @__PURE__ */ jsxs(Tabs, {
1523
+ value: tab,
1524
+ onValueChange: (value) => onTabChange(COMPARE_TABS.find((t) => t === value) ?? "canvas"),
1525
+ children: [
1526
+ /* @__PURE__ */ jsxs(TabsList, {
1527
+ "aria-label": tr("fluidgrids.moreTools.versions.compare.views", "Compare views"),
1528
+ children: [
1529
+ /* @__PURE__ */ jsx(TabsTrigger, {
1530
+ value: "canvas",
1531
+ "data-testid": "fluidgrids-version-compare-tab-canvas",
1532
+ children: tr("fluidgrids.moreTools.versions.compare.canvasTab", "Canvas")
1533
+ }),
1534
+ /* @__PURE__ */ jsx(TabsTrigger, {
1535
+ value: "changes",
1536
+ "data-testid": "fluidgrids-version-compare-tab-changes",
1537
+ children: tr("fluidgrids.moreTools.versions.compare.changesTab", "Changes")
1538
+ }),
1539
+ /* @__PURE__ */ jsx(TabsTrigger, {
1540
+ value: "json",
1541
+ "data-testid": "fluidgrids-version-compare-tab-json",
1542
+ children: tr("fluidgrids.history.versionDiff.jsonTab", "JSON")
1543
+ })
1544
+ ]
1545
+ }),
1546
+ /* @__PURE__ */ jsx(TabsContent, {
1547
+ value: "canvas",
1548
+ className: "mt-3",
1549
+ children: /* @__PURE__ */ jsx(ComparisonView, {
1550
+ view: "canvas",
1551
+ comparison
1552
+ })
1553
+ }),
1554
+ /* @__PURE__ */ jsx(TabsContent, {
1555
+ value: "changes",
1556
+ className: "mt-3",
1557
+ children: /* @__PURE__ */ jsx(ComparisonView, {
1558
+ view: "changes",
1559
+ comparison
1560
+ })
1561
+ }),
1562
+ /* @__PURE__ */ jsx(TabsContent, {
1563
+ value: "json",
1564
+ className: "mt-3 space-y-4",
1565
+ children: /* @__PURE__ */ jsx(ComparisonView, {
1566
+ view: "json",
1567
+ comparison
1568
+ })
1569
+ })
1570
+ ]
1571
+ })]
1572
+ });
1573
+ }
1574
+ /** "2 steps added · 2 changed · 1 removed · 3 only moved". */
1575
+ function CompareSummary({ graph }) {
1576
+ const tr = useTr();
1577
+ const summary = summarizeGraphDiff(graph);
1578
+ const extras = [];
1579
+ if (summary.connections > 0) extras.push(summary.connections === 1 ? tr("fluidgrids.moreTools.versions.compare.connectionsOne", "1 connection changed") : tr("fluidgrids.moreTools.versions.compare.connectionsOther", "{{count}} connections changed", { count: formatCount(summary.connections) }));
1580
+ if (summary.moved > 0) extras.push(tr("fluidgrids.moreTools.versions.compare.onlyMoved", "{{count}} only moved", { count: formatCount(summary.moved) }));
1581
+ return /* @__PURE__ */ jsxs("p", {
1582
+ className: "text-[13.5px] text-text-primary",
1583
+ "data-testid": "fluidgrids-version-compare-summary",
1584
+ children: [summary.identical ? /* @__PURE__ */ jsx("b", {
1585
+ className: "font-semibold",
1586
+ children: tr("fluidgrids.moreTools.versions.compare.nothingChanged", "No step or connection changed")
1587
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
1588
+ /* @__PURE__ */ jsx("b", {
1589
+ className: "font-semibold",
1590
+ children: summary.added === 1 ? tr("fluidgrids.moreTools.versions.compare.stepsAddedOne", "1 step added") : tr("fluidgrids.moreTools.versions.compare.stepsAddedOther", "{{count}} steps added", { count: formatCount(summary.added) })
1591
+ }),
1592
+ " · ",
1593
+ /* @__PURE__ */ jsx("b", {
1594
+ className: "font-semibold",
1595
+ children: tr("fluidgrids.moreTools.versions.compare.stepsChanged", "{{count}} changed", { count: formatCount(summary.changed) })
1596
+ }),
1597
+ " · ",
1598
+ /* @__PURE__ */ jsx("b", {
1599
+ className: "font-semibold",
1600
+ children: tr("fluidgrids.moreTools.versions.compare.stepsRemoved", "{{count}} removed", { count: formatCount(summary.removed) })
1601
+ })
1602
+ ] }), extras.map((extra) => /* @__PURE__ */ jsxs("span", {
1603
+ className: "text-text-muted",
1604
+ children: [" · ", extra]
1605
+ }, extra))]
1606
+ });
1607
+ }
1608
+ const CHANGE_KIND_CLASS = {
1609
+ added: "border-status-success-border bg-status-success-bg-subtle text-status-success-text",
1610
+ changed: "border-status-warning-border bg-status-warning-bg-subtle text-status-warning-text",
1611
+ removed: "border-status-error-border bg-status-error-bg-subtle text-status-error-text"
1612
+ };
1613
+ const CHANGE_KIND_STATUS = {
1614
+ added: "added",
1615
+ changed: "modified",
1616
+ removed: "removed"
1617
+ };
1618
+ /** The Changes view: one row per change, in plain words. */
1619
+ function PlainChangesList({ comparison }) {
1620
+ const tr = useTr();
1621
+ const { changes, cappedSteps } = useMemo(() => plainChanges(comparison.graph, comparison.fromCanvas, comparison.toCanvas), [comparison]);
1622
+ if (!comparison.fromCanvas && !comparison.toCanvas) return /* @__PURE__ */ jsx(EmptyState, {
1623
+ kind: "first-use",
1624
+ illustration: "workflows",
1625
+ size: "panel",
1626
+ icon: null,
1627
+ title: tr("fluidgrids.moreTools.versions.compare.noCanvas", "Neither version has steps on a canvas. The JSON view lists every difference.")
1628
+ });
1629
+ if (changes.length === 0) return /* @__PURE__ */ jsx(EmptyState, {
1630
+ kind: "no-results",
1631
+ size: "panel",
1632
+ icon: null,
1633
+ title: tr("fluidgrids.moreTools.versions.compare.noChanges", "No step or connection changed between these versions.")
1634
+ });
1635
+ const subjectText = (change) => {
1636
+ if (change.field) return change.field;
1637
+ if (change.subject === "connection") return tr("fluidgrids.moreTools.versions.compare.connection", "Connection");
1638
+ return change.kind === "added" ? tr("fluidgrids.moreTools.versions.compare.newStep", "New step") : tr("fluidgrids.moreTools.versions.compare.removedStep", "Removed step");
1639
+ };
1640
+ return /* @__PURE__ */ jsxs("div", {
1641
+ className: "space-y-2",
1642
+ children: [/* @__PURE__ */ jsx("ul", {
1643
+ className: "max-h-[420px] divide-y divide-border-subtle overflow-y-auto overscroll-contain rounded-xl border border-border-default bg-surface",
1644
+ "data-testid": "fluidgrids-version-compare-changes",
1645
+ children: changes.map((change) => /* @__PURE__ */ jsxs("li", {
1646
+ className: "grid grid-cols-[4.75rem_minmax(0,1fr)] gap-2.5 px-3 py-2.5 text-[13px]",
1647
+ "data-change-kind": change.kind,
1648
+ children: [/* @__PURE__ */ jsx("span", {
1649
+ className: cn("h-fit justify-self-start rounded border px-1.5 text-[11.5px] font-bold", CHANGE_KIND_CLASS[change.kind]),
1650
+ children: plainDiffStatusLabel(tr, CHANGE_KIND_STATUS[change.kind])
1651
+ }), /* @__PURE__ */ jsxs("div", {
1652
+ className: "min-w-0",
1653
+ children: [
1654
+ /* @__PURE__ */ jsxs("p", {
1655
+ className: "break-words",
1656
+ children: [
1657
+ /* @__PURE__ */ jsx("b", {
1658
+ className: "font-semibold text-text-primary",
1659
+ children: change.title
1660
+ }),
1661
+ " ",
1662
+ /* @__PURE__ */ jsx("span", {
1663
+ className: "text-text-muted",
1664
+ children: subjectText(change)
1665
+ })
1666
+ ]
1667
+ }),
1668
+ change.before !== null && /* @__PURE__ */ jsxs("p", {
1669
+ className: "mt-0.5 break-words font-mono text-xs text-status-error-text",
1670
+ children: [
1671
+ /* @__PURE__ */ jsx("span", {
1672
+ "aria-hidden": "true",
1673
+ children: "− "
1674
+ }),
1675
+ /* @__PURE__ */ jsxs("span", {
1676
+ className: "sr-only",
1677
+ children: [tr("fluidgrids.moreTools.versions.compare.before", "Before:"), " "]
1678
+ }),
1679
+ change.before
1680
+ ]
1681
+ }),
1682
+ change.after !== null && /* @__PURE__ */ jsxs("p", {
1683
+ className: "mt-0.5 break-words font-mono text-xs text-status-success-text",
1684
+ children: [
1685
+ /* @__PURE__ */ jsx("span", {
1686
+ "aria-hidden": "true",
1687
+ children: "+ "
1688
+ }),
1689
+ /* @__PURE__ */ jsxs("span", {
1690
+ className: "sr-only",
1691
+ children: [tr("fluidgrids.moreTools.versions.compare.after", "After:"), " "]
1692
+ }),
1693
+ change.after
1694
+ ]
1695
+ })
1696
+ ]
1697
+ })]
1698
+ }, change.key))
1699
+ }), cappedSteps.length > 0 && /* @__PURE__ */ jsx("p", {
1700
+ className: "text-xs text-text-muted",
1701
+ children: tr("fluidgrids.moreTools.versions.compare.capped", "Some steps changed more settings than this list shows. The JSON view lists every difference.")
1702
+ })]
1703
+ });
1704
+ }
1705
+
1706
+ // src/modules/history/components/WorkflowTimelineParts.tsx
1707
+ /** Pieces of one workflow's version timeline (BOFF-15502). */
1708
+ function OnFact({ facts }) {
1709
+ const tr = useTr();
1710
+ if (facts.on === null) return /* @__PURE__ */ jsx(Fragment$1, { children: tr("fluidgrids.moreTools.versions.nothingOn", "Nothing on") });
1711
+ if (facts.newest === null) return /* @__PURE__ */ jsx(Fragment$1, { children: tr("fluidgrids.moreTools.versions.onIsNewest", "On: {{version}} (the newest)", { version: facts.on }) });
1712
+ return /* @__PURE__ */ jsx(Fragment$1, { children: tr("fluidgrids.moreTools.versions.onVersion", "On: {{version}}", { version: facts.on }) });
1713
+ }
1714
+ function TimelineFactsLine({ facts, viewOnly }) {
1715
+ const tr = useTr();
1716
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1717
+ /* @__PURE__ */ jsx("span", {
1718
+ className: "tabular-nums",
1719
+ "data-testid": "fluidgrids-history-timeline-count",
1720
+ children: facts.count === 1 ? tr("fluidgrids.moreTools.versions.versionsOne", "1 version") : tr("fluidgrids.moreTools.versions.versionsOther", "{{count}} versions", { count: facts.count })
1721
+ }),
1722
+ /* @__PURE__ */ jsx(Dot, {}),
1723
+ /* @__PURE__ */ jsx("span", {
1724
+ "data-testid": "fluidgrids-history-timeline-on",
1725
+ children: /* @__PURE__ */ jsx(OnFact, { facts })
1726
+ }),
1727
+ facts.newest && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Dot, {}), /* @__PURE__ */ jsx("span", {
1728
+ "data-testid": "fluidgrids-history-timeline-newest",
1729
+ children: /* @__PURE__ */ jsx(NewestFact, {
1730
+ version: facts.newest.version,
1731
+ stage: facts.newest.stage
1732
+ })
1733
+ })] }),
1734
+ viewOnly && /* @__PURE__ */ jsx(ViewOnlyPill, {})
1735
+ ] });
1736
+ }
1737
+ function TimelineHeader({ back, name, facts, viewOnly, compareFrom, onOpenInBuilder, onCompare }) {
1738
+ const tr = useTr();
1739
+ return /* @__PURE__ */ jsx("div", {
1740
+ "data-tour": "fluidgrids-history-header",
1741
+ children: /* @__PURE__ */ jsx(MoreToolsHeader, {
1742
+ back,
1743
+ title: name,
1744
+ titleTestId: "fluidgrids-history-title",
1745
+ facts: /* @__PURE__ */ jsx(TimelineFactsLine, {
1746
+ facts,
1747
+ viewOnly
1748
+ }),
1749
+ actions: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Button$1, {
1750
+ variant: "outline",
1751
+ onClick: onOpenInBuilder,
1752
+ "data-testid": "fluidgrids-history-timeline-open",
1753
+ children: [/* @__PURE__ */ jsx(ExternalLink, {
1754
+ className: "size-4",
1755
+ "aria-hidden": "true"
1756
+ }), tr("fluidgrids.history.historyPage.openInBuilderTooltip", "Open in builder")]
1757
+ }), compareFrom !== null && /* @__PURE__ */ jsxs(Button$1, {
1758
+ onClick: onCompare,
1759
+ "data-testid": "fluidgrids-history-timeline-compare",
1760
+ children: [/* @__PURE__ */ jsx(GitCompareArrows, {
1761
+ className: "size-4",
1762
+ "aria-hidden": "true"
1763
+ }), tr("fluidgrids.moreTools.versions.menuCompare", "Compare versions")]
1764
+ })] })
1765
+ })
1766
+ });
1767
+ }
1768
+ function WorkflowNotFound({ back, onBack }) {
1769
+ const tr = useTr();
1770
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
1771
+ "data-tour": "fluidgrids-history-header",
1772
+ children: /* @__PURE__ */ jsx(MoreToolsHeader, {
1773
+ back,
1774
+ title: tr("fluidgrids.moreTools.versions.notFoundTitle", "Workflow not found"),
1775
+ titleTestId: "fluidgrids-history-title"
1776
+ })
1777
+ }), /* @__PURE__ */ jsx(EmptyPanel, {
1778
+ kind: "not-found",
1779
+ icon: /* @__PURE__ */ jsx(Workflow, {
1780
+ className: "size-5 text-text-secondary",
1781
+ "aria-hidden": "true"
1782
+ }),
1783
+ title: tr("fluidgrids.moreTools.versions.notFoundHeading", "This workflow no longer exists"),
1784
+ text: tr("fluidgrids.moreTools.versions.notFoundText", "It may have been deleted. Its versions went with it."),
1785
+ children: /* @__PURE__ */ jsx(BackToList, {
1786
+ label: back.label,
1787
+ onBack
1788
+ })
1789
+ })] });
1790
+ }
1791
+ function BackToList({ label, onBack }) {
1792
+ return /* @__PURE__ */ jsxs(Button$1, {
1793
+ variant: "outline",
1794
+ onClick: onBack,
1795
+ "data-testid": "fluidgrids-history-not-found-back",
1796
+ children: [/* @__PURE__ */ jsx(ArrowLeft, {
1797
+ className: "size-4 rtl:rotate-180",
1798
+ "aria-hidden": "true"
1799
+ }), label]
1800
+ });
1801
+ }
1802
+ function timelineMenu(tr, props) {
1803
+ return [
1804
+ {
1805
+ id: "open",
1806
+ label: tr("fluidgrids.history.historyPage.openInBuilderTooltip", "Open in builder"),
1807
+ icon: /* @__PURE__ */ jsx(ExternalLink, {
1808
+ className: "size-4",
1809
+ "aria-hidden": "true"
1810
+ }),
1811
+ onSelect: props.onOpenInBuilder
1812
+ },
1813
+ ...props.canRestore ? [{
1814
+ id: "restore",
1815
+ label: tr("fluidgrids.moreTools.versions.menuRestore", "Restore as a new draft…"),
1816
+ icon: /* @__PURE__ */ jsx(RotateCcw, {
1817
+ className: "size-4",
1818
+ "aria-hidden": "true"
1819
+ }),
1820
+ onSelect: props.onRestore
1821
+ }] : [],
1822
+ {
1823
+ id: "copy-link",
1824
+ label: tr("fluidgrids.moreTools.versions.menuCopyLink", "Copy link to this version"),
1825
+ icon: /* @__PURE__ */ jsx(Copy, {
1826
+ className: "size-4",
1827
+ "aria-hidden": "true"
1828
+ }),
1829
+ onSelect: props.onCopyLink
1830
+ }
1831
+ ];
1832
+ }
1833
+ function VersionCard(props) {
1834
+ const tr = useTr();
1835
+ const { version, absolute, authorName } = props;
1836
+ const when = version.updatedAt || version.createdAt;
1837
+ return /* @__PURE__ */ jsxs("div", {
1838
+ className: "min-w-0 rounded-xl border border-border-subtle bg-surface px-3 py-2.5",
1839
+ children: [/* @__PURE__ */ jsxs("div", {
1840
+ className: "flex flex-wrap items-center gap-2",
1841
+ children: [
1842
+ /* @__PURE__ */ jsx(VersionCode, {
1843
+ version: version.version,
1844
+ className: "text-[13px] font-semibold"
1845
+ }),
1846
+ /* @__PURE__ */ jsx(VersionStatus, { status: version.status }),
1847
+ absolute === 0 && /* @__PURE__ */ jsx("span", {
1848
+ className: "rounded-full border border-border-subtle bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary",
1849
+ children: tr("fluidgrids.moreTools.versions.newestMarker", "Newest")
1850
+ })
1851
+ ]
1852
+ }), /* @__PURE__ */ jsxs("div", {
1853
+ className: "mt-1 flex min-w-0 flex-wrap items-center gap-x-1.5 text-[12.5px] text-text-secondary",
1854
+ children: [
1855
+ /* @__PURE__ */ jsx(PersonChip, { name: authorName(version.createdById) }),
1856
+ /* @__PURE__ */ jsx("span", {
1857
+ "aria-hidden": "true",
1858
+ children: "·"
1859
+ }),
1860
+ /* @__PURE__ */ jsx("time", {
1861
+ dateTime: when ?? void 0,
1862
+ title: formatExactTime(when),
1863
+ className: "tabular-nums",
1864
+ children: formatShortDateTime(when)
1865
+ })
1866
+ ]
1867
+ })]
1868
+ });
1869
+ }
1870
+ function TimelineItem(props) {
1871
+ const tr = useTr();
1872
+ const { version, previous, onComparePrevious } = props;
1873
+ const isOn = lifecycleStageOf(version.status) === "ACTIVE";
1874
+ return /* @__PURE__ */ jsxs("li", {
1875
+ className: "relative grid grid-cols-[1rem_minmax(0,1fr)] items-center gap-x-3.5 gap-y-2 py-1.5 sm:grid-cols-[1rem_minmax(0,1fr)_auto]",
1876
+ "data-testid": "fluidgrids-history-version",
1877
+ "data-version": version.version,
1878
+ children: [
1879
+ /* @__PURE__ */ jsx("span", {
1880
+ "aria-hidden": "true",
1881
+ className: cn("relative size-4 rounded-full border-2 bg-surface-canvas", isOn ? "border-status-success-text bg-status-success-bg-subtle" : "border-border-default")
1882
+ }),
1883
+ /* @__PURE__ */ jsx(VersionCard, { ...props }),
1884
+ /* @__PURE__ */ jsxs("div", {
1885
+ className: "col-start-2 flex items-center gap-1.5 sm:col-start-auto",
1886
+ children: [previous && /* @__PURE__ */ jsxs(Button$1, {
1887
+ variant: "outline",
1888
+ size: "sm",
1889
+ onClick: () => onComparePrevious(previous),
1890
+ "data-testid": "fluidgrids-history-compare-previous",
1891
+ children: [/* @__PURE__ */ jsx(GitCompareArrows, {
1892
+ className: "size-4",
1893
+ "aria-hidden": "true"
1894
+ }), /* @__PURE__ */ jsx("span", {
1895
+ className: "max-sm:sr-only",
1896
+ children: tr("fluidgrids.moreTools.versions.compareWith", "Compare with {{version}}", { version: previous })
1897
+ })]
1898
+ }), /* @__PURE__ */ jsx(RowMenu, {
1899
+ label: tr("fluidgrids.moreTools.versions.versionMenu", "More for {{version}}", { version: version.version }),
1900
+ items: timelineMenu(tr, props),
1901
+ testId: "fluidgrids-history-version-menu"
1902
+ })]
1903
+ })
1904
+ ]
1905
+ });
1906
+ }
1907
+ /** "Newest: 3.0.0 (draft)", with the status word the language writes in the sentence. */
1908
+ function NewestFact({ version, stage }) {
1909
+ const tr = useTr();
1910
+ switch (stage) {
1911
+ case "DEPRECATED": return /* @__PURE__ */ jsx(Fragment$1, { children: tr("fluidgrids.moreTools.versions.newestRetired", "Newest: {{version}} (retired)", { version }) });
1912
+ case "ARCHIVED": return /* @__PURE__ */ jsx(Fragment$1, { children: tr("fluidgrids.moreTools.versions.newestArchived", "Newest: {{version}} (archived)", { version }) });
1913
+ default: return /* @__PURE__ */ jsx(Fragment$1, { children: tr("fluidgrids.moreTools.versions.newestDraft", "Newest: {{version}} (draft)", { version }) });
1914
+ }
1915
+ }
1916
+
1917
+ // src/modules/history/components/WorkflowTimeline.tsx
1918
+ /**
1919
+ * One workflow's versions (BOFF-15502), opened from the list as
1920
+ * `?workflow=<key>`: every version newest first, with its status, who saved
1921
+ * it and when, and side by side the two things people come here for:
1922
+ * "Compare with <previous>" and "Restore as a new draft…".
1923
+ *
1924
+ * Long histories page like every More tools list (20 per page, `?page=`,
1925
+ * clamped). A link from the list can ask for the compare dialog or the
1926
+ * restore confirmation with `?open=`; it opens once the versions load and
1927
+ * leaves the address.
1928
+ */
1929
+ function WorkflowTimeline({ workflowKey, access, openInBuilder, openRestored }) {
1930
+ const tr = useTr();
1931
+ const navigate = useNavigate();
1932
+ const { pathname } = useLocation();
1933
+ const { params, page, setPage } = useUrlListState();
1934
+ const [, setSearchParams] = useSearchParams();
1935
+ const builderBase = useHref("../workflow");
1936
+ const { versions: loaded, loading, error, refetch } = useWorkflowVersions(workflowKey);
1937
+ const versions = useMemo(() => versionsOfWorkflow(loaded, workflowKey), [loaded, workflowKey]);
1938
+ const authorName = useAuthorNames(versions.map((v) => v.createdById ?? "").filter(Boolean));
1939
+ const facts = timelineFacts(versions);
1940
+ const slice = pageSlice(versions, page);
1941
+ const settled = !loading && !error;
1942
+ useClampedPage(page, versions.length, MORE_TOOLS_PAGE_SIZE, settled, setPage);
1943
+ const [compare, setCompare] = useState(null);
1944
+ const [restoreTarget, setRestoreTarget] = useState(null);
1945
+ const backTo = `${pathname}${listSearch(params)}`;
1946
+ const name = versions[0]?.name ?? "";
1947
+ const intent = TIMELINE_INTENTS.find((value) => value === params.get("open"));
1948
+ useEffect(() => {
1949
+ if (!intent || loading || intent === "restore" && !access.known) return;
1950
+ setSearchParams((previous) => {
1951
+ const next = new URLSearchParams(previous);
1952
+ next.delete("open");
1953
+ return next;
1954
+ }, { replace: true });
1955
+ if (error || versions.length < 2) return;
1956
+ if (intent === "compare") setCompare({
1957
+ from: versions[1].version,
1958
+ to: versions[0].version
1959
+ });
1960
+ else if (access.canRestore) setRestoreTarget(versions[1].version);
1961
+ }, [
1962
+ intent,
1963
+ loading,
1964
+ error,
1965
+ versions,
1966
+ access.known,
1967
+ access.canRestore,
1968
+ setSearchParams
1969
+ ]);
1970
+ const copyLink = useCallback(async (version) => {
1971
+ if (await copyText(absoluteUrl(`${builderBase}/${workflowKey}/${version}`))) toast.success(tr("fluidgrids.moreTools.common.copied", "Copied"));
1972
+ else toast.error(tr("fluidgrids.moreTools.versions.copyLinkFailed", "Couldn't copy the link. Your browser blocked it."));
1973
+ }, [
1974
+ builderBase,
1975
+ workflowKey,
1976
+ tr
1977
+ ]);
1978
+ const title = tr("fluidgrids.moreTools.versions.title", "Version history");
1979
+ const assistantControls = useMemo(() => historyControls({
1980
+ page: title,
1981
+ search: (query) => {
1982
+ const next = new URLSearchParams(listSearch(params));
1983
+ if (query) next.set("q", query);
1984
+ else next.delete("q");
1985
+ const search = next.toString();
1986
+ navigate({ search: search ? `?${search}` : "" });
1987
+ },
1988
+ workflow: {
1989
+ label: tr("fluidgrids.executions.executionTable.colWorkflow", "Workflow"),
1990
+ allLabel: tr("fluidgrids.moreTools.versions.chipAll", "All workflows"),
1991
+ neutral: "all",
1992
+ options: name ? [{
1993
+ value: workflowKey,
1994
+ label: name
1995
+ }] : [],
1996
+ value: workflowKey,
1997
+ set: (key) => {
1998
+ if (key === "all") navigate({ search: listSearch(params) });
1999
+ else if (key !== workflowKey) navigate({ search: timelineSearch(params, key) });
2000
+ }
2001
+ }
2002
+ }), [
2003
+ title,
2004
+ tr,
2005
+ params,
2006
+ navigate,
2007
+ name,
2008
+ workflowKey
2009
+ ]);
2010
+ useFluidGridsPageControls(assistantControls);
2011
+ const back = {
2012
+ to: backTo,
2013
+ label: tr("fluidgrids.moreTools.versions.title", "Version history")
2014
+ };
2015
+ if (loading && versions.length === 0) return /* @__PURE__ */ jsxs("div", {
2016
+ "aria-busy": "true",
2017
+ "data-tour": "fluidgrids-history-header",
2018
+ children: [
2019
+ /* @__PURE__ */ jsx(BackLink, {
2020
+ to: back.to,
2021
+ label: back.label
2022
+ }),
2023
+ /* @__PURE__ */ jsx(Skeleton, { className: "mb-2 h-8 w-64 max-w-full rounded" }),
2024
+ /* @__PURE__ */ jsx(Skeleton, { className: "mb-6 h-4 w-48 max-w-full rounded" }),
2025
+ /* @__PURE__ */ jsx(ListSkeleton, { rows: 5 })
2026
+ ]
2027
+ });
2028
+ if (error) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
2029
+ "data-tour": "fluidgrids-history-header",
2030
+ children: /* @__PURE__ */ jsx(MoreToolsHeader, {
2031
+ back,
2032
+ title
2033
+ })
2034
+ }), /* @__PURE__ */ jsx(LoadErrorPanel, {
2035
+ title: tr("fluidgrids.moreTools.versions.timelineErrorTitle", "Couldn't load this workflow's versions"),
2036
+ text: tr("fluidgrids.moreTools.versions.loadErrorText", "The workflow service did not answer. Your workflows and their versions are safe."),
2037
+ error,
2038
+ onRetry: () => void refetch()
2039
+ })] });
2040
+ if (versions.length === 0) return /* @__PURE__ */ jsx(WorkflowNotFound, {
2041
+ back,
2042
+ onBack: () => navigate(back.to)
2043
+ });
2044
+ const newest = versions[0];
2045
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2046
+ /* @__PURE__ */ jsx(TimelineHeader, {
2047
+ back,
2048
+ name,
2049
+ facts,
2050
+ viewOnly: access.viewOnly,
2051
+ newestVersion: newest.version,
2052
+ compareFrom: versions.length > 1 ? versions[1].version : null,
2053
+ onOpenInBuilder: () => openInBuilder(workflowKey, newest.version),
2054
+ onCompare: () => setCompare({
2055
+ from: versions[1].version,
2056
+ to: newest.version
2057
+ })
2058
+ }),
2059
+ /* @__PURE__ */ jsx("ol", {
2060
+ "aria-label": tr("fluidgrids.moreTools.versions.timelineLabel", "Versions, newest first"),
2061
+ className: "relative before:absolute before:inset-y-5 before:start-[7px] before:w-0.5 before:bg-border-subtle",
2062
+ "data-testid": "fluidgrids-history-timeline",
2063
+ children: slice.items.map((version, index) => {
2064
+ const absolute = (slice.page - 1) * MORE_TOOLS_PAGE_SIZE + index;
2065
+ return /* @__PURE__ */ jsx(TimelineItem, {
2066
+ version,
2067
+ absolute,
2068
+ previous: previousVersionAt(versions, absolute),
2069
+ canRestore: access.canRestore,
2070
+ authorName,
2071
+ onOpenInBuilder: () => openInBuilder(workflowKey, version.version),
2072
+ onRestore: () => setRestoreTarget(version.version),
2073
+ onCopyLink: () => void copyLink(version.version),
2074
+ onComparePrevious: (previous) => setCompare({
2075
+ from: previous,
2076
+ to: version.version
2077
+ })
2078
+ }, version.id);
2079
+ })
2080
+ }),
2081
+ /* @__PURE__ */ jsx(ResultsPager, {
2082
+ page: slice.page,
2083
+ total: versions.length,
2084
+ onPage: setPage,
2085
+ className: "mt-4"
2086
+ }),
2087
+ /* @__PURE__ */ jsxs("p", {
2088
+ className: "mt-4 flex items-start gap-1.5 text-[12.5px] text-text-muted",
2089
+ children: [/* @__PURE__ */ jsx(Info, {
2090
+ className: "mt-0.5 size-3.5 shrink-0",
2091
+ "aria-hidden": "true"
2092
+ }), tr("fluidgrids.moreTools.versions.timelineHint", "On is the version that runs. Restoring an older version makes a new draft from it; nothing that exists is changed.")]
2093
+ }),
2094
+ /* @__PURE__ */ jsx(ShowTechnicalDetails, {
2095
+ copyable: true,
2096
+ className: "mt-2",
2097
+ children: workflowKey
2098
+ }),
2099
+ compare && /* @__PURE__ */ jsx(VersionCompareDialog, {
2100
+ onClose: () => setCompare(null),
2101
+ workflowKey,
2102
+ workflowName: name,
2103
+ versions,
2104
+ initialFrom: compare.from,
2105
+ initialTo: compare.to,
2106
+ authorName,
2107
+ onRestore: access.canRestore ? setRestoreTarget : void 0,
2108
+ onOpenVersion: (version) => openInBuilder(workflowKey, version)
2109
+ }, `${compare.from}..${compare.to}`),
2110
+ /* @__PURE__ */ jsx(RestoreVersionDialog, {
2111
+ workflowKey,
2112
+ version: restoreTarget,
2113
+ onVersion: facts.on,
2114
+ onClose: () => setRestoreTarget(null),
2115
+ onRestored: (created) => {
2116
+ setRestoreTarget(null);
2117
+ setCompare(null);
2118
+ refetch();
2119
+ openRestored(created);
2120
+ }
2121
+ })
2122
+ ] });
2123
+ }
2124
+ /** The full address of an in-app path, or the path itself when the page has no usable base. */
2125
+ function absoluteUrl(path) {
2126
+ try {
2127
+ return new URL(path, window.location.href).toString();
2128
+ } catch {
2129
+ return path;
2130
+ }
2131
+ }
2132
+
2133
+ // src/modules/history/pages/VersionHistoryPage.tsx
2134
+ /**
2135
+ * Version history under Navigation v2 (BOFF-15502, FluidGrids only): the
2136
+ * redesigned More tools page, built from the approved prototype's
2137
+ * Recommended "By workflow" variant.
2138
+ *
2139
+ * - `/workflows/history`: every workflow once, with the version that is On
2140
+ * and its newest version (VersionsByWorkflow);
2141
+ * - `/workflows/history?workflow=<key>`: that workflow's versions, newest
2142
+ * first, with Compare and Restore side by side (WorkflowTimeline).
2143
+ *
2144
+ * The detail view is a search parameter on the same route, so Back, forward
2145
+ * and shared links work. Every other app keeps the classic page.
2146
+ */
2147
+ function VersionHistoryPage() {
2148
+ const navigate = useNavigate();
2149
+ const [params] = useSearchParams();
2150
+ const workflowKey = params.get("workflow");
2151
+ const restore = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_UPDATE);
2152
+ const access = useMemo(() => ({
2153
+ canRestore: restore.allowed,
2154
+ viewOnly: !restore.allowed && !restore.isLoading,
2155
+ known: !restore.isLoading
2156
+ }), [restore.allowed, restore.isLoading]);
2157
+ const openInBuilder = useCallback((key, version) => {
2158
+ markBuilderNavigation();
2159
+ navigate(`../workflow/${key}/${version}`);
2160
+ }, [navigate]);
2161
+ const openRestored = useCallback((created) => navigate(`../workflow/${created.workflowKey}/${created.version}`), [navigate]);
2162
+ return /* @__PURE__ */ jsx(MoreToolsPage, {
2163
+ testId: "fluidgrids-history-page",
2164
+ children: workflowKey ? /* @__PURE__ */ jsx(WorkflowTimeline, {
2165
+ workflowKey,
2166
+ access,
2167
+ openInBuilder,
2168
+ openRestored
2169
+ }, workflowKey) : /* @__PURE__ */ jsx(VersionsByWorkflow, {
2170
+ access,
2171
+ openInBuilder
2172
+ })
2173
+ });
2174
+ }
2175
+
2176
+ // src/modules/history/pages/HistoryPage.tsx
2177
+ /**
2178
+ * HistoryPage — cross-workflow version history.
2179
+ *
2180
+ * Under Navigation v2 (FluidGrids) this renders the redesigned More tools
2181
+ * page (VersionHistoryPage, BOFF-15502). Every other app keeps the classic
2182
+ * page below: it fetches every version row in one paginated
2183
+ * `workflowDefinitions` query (latestOnly defaults to false, so the list API
2184
+ * already returns one row per version) and resolves "Changed By" ids to
2185
+ * human names via the shared actor-profile lookup.
2186
+ */
2187
+ var HistoryPage_exports = /* @__PURE__ */ __exportAll({ HistoryPage: () => HistoryPage });
2188
+ const PAGE_SIZE = 20;
2189
+ /**
2190
+ * Version rows per window (newest first): the most one request to the
2191
+ * workflow list may ask for (BOFF-16425). "Show older versions" reads the
2192
+ * next window.
2193
+ */
2194
+ const FETCH_LIMIT = 100;
2195
+ function useStatusStyles(v2) {
2196
+ const tr = useTr();
2197
+ return useMemo(() => v2 ? {
2198
+ ACTIVE: {
2199
+ label: tr("fluidgrids.history.historyPage.statusOn", "On"),
2200
+ variant: "default"
2201
+ },
2202
+ DRAFT: {
2203
+ label: tr("fluidgrids.history.historyPage.statusOffDraft", "Off (draft)"),
2204
+ variant: "secondary"
2205
+ },
2206
+ ARCHIVED: {
2207
+ label: tr("fluidgrids.history.historyPage.statusArchived", "Archived"),
2208
+ variant: "outline"
2209
+ },
2210
+ DEPRECATED: {
2211
+ label: tr("fluidgrids.history.historyPage.statusRetired", "Retired"),
2212
+ variant: "destructive"
2213
+ }
2214
+ } : {
2215
+ ACTIVE: {
2216
+ label: tr("fluidgrids.history.historyPage.statusActive", "Active"),
2217
+ variant: "default"
2218
+ },
2219
+ DRAFT: {
2220
+ label: tr("fluidgrids.history.historyPage.statusDraft", "Draft"),
2221
+ variant: "secondary"
2222
+ },
2223
+ ARCHIVED: {
2224
+ label: tr("fluidgrids.history.historyPage.statusArchived", "Archived"),
2225
+ variant: "outline"
2226
+ },
2227
+ DEPRECATED: {
2228
+ label: tr("fluidgrids.history.historyPage.statusDeprecated", "Deprecated"),
2229
+ variant: "destructive"
2230
+ }
2231
+ }, [tr, v2]);
2232
+ }
2233
+ /** The page's language (the app's, when it sets one), else the browser's. */
2234
+ function pageLocale() {
2235
+ if (typeof document === "undefined") return void 0;
2236
+ return document.documentElement.lang || void 0;
2237
+ }
2238
+ function HistoryTableSkeleton() {
2239
+ return /* @__PURE__ */ jsx("div", {
2240
+ className: "space-y-3",
2241
+ children: Array.from({ length: 6 }).map((_, i) => /* @__PURE__ */ jsx(Skeleton, { className: "h-14 w-full rounded-lg bg-card-foreground/10" }, i))
2242
+ });
2243
+ }
2244
+ function HistoryEmptyState({ kind }) {
2245
+ const tr = useTr();
2246
+ return /* @__PURE__ */ jsx(EmptyState, {
2247
+ kind,
2248
+ illustration: "history",
2249
+ size: "page",
2250
+ icon: /* @__PURE__ */ jsx(Icon, {
2251
+ icon: "mdi:history",
2252
+ width: 40,
2253
+ className: "text-text-secondary"
2254
+ }),
2255
+ title: tr("fluidgrids.history.historyPage.emptyTitle", "No version history"),
2256
+ description: tr("fluidgrids.history.historyPage.emptyHint", "Version history will appear here once you create and update workflows.")
2257
+ });
2258
+ }
2259
+ function ErrorState({ message, onRetry, v2 }) {
2260
+ const tr = useTr();
2261
+ if (v2) return /* @__PURE__ */ jsxs("div", {
2262
+ role: "alert",
2263
+ className: "p-4 bg-[var(--color-status-error-bg-subtle)] border border-[var(--color-status-error-border)] rounded-lg",
2264
+ children: [
2265
+ /* @__PURE__ */ jsxs("div", {
2266
+ className: "flex items-center gap-2 text-[var(--color-status-error-text)]",
2267
+ children: [/* @__PURE__ */ jsx(Icon, {
2268
+ icon: "mdi:alert-circle",
2269
+ width: 20
2270
+ }), /* @__PURE__ */ jsx("span", {
2271
+ className: "font-medium",
2272
+ children: tr("fluidgrids.history.historyPage.errorHeadingPlain", "We couldn't load your versions")
2273
+ })]
2274
+ }),
2275
+ /* @__PURE__ */ jsx("p", {
2276
+ className: "mt-1 text-sm text-[var(--color-status-error-text)]",
2277
+ children: tr("fluidgrids.history.historyPage.errorPlain", "Something went wrong while loading. Try again in a moment.")
2278
+ }),
2279
+ /* @__PURE__ */ jsx(TechnicalDetails, {
2280
+ className: "mt-2 text-[var(--color-status-error-text)]",
2281
+ label: tr("fluidgrids.history.historyPage.showTechnicalDetails", "Show technical details"),
2282
+ hideLabel: tr("fluidgrids.history.historyPage.hideTechnicalDetails", "Hide technical details"),
2283
+ children: message
2284
+ }),
2285
+ /* @__PURE__ */ jsx(Button$1, {
2286
+ variant: "outline",
2287
+ size: "sm",
2288
+ onClick: onRetry,
2289
+ className: "mt-3 border-[var(--color-status-error-border)] text-[var(--color-status-error-text)] hover:bg-[var(--color-status-error-bg-subtle)]",
2290
+ children: tr("fluidgrids.history.historyPage.errorRetry", "Retry")
2291
+ })
2292
+ ]
2293
+ });
2294
+ return /* @__PURE__ */ jsxs("div", {
2295
+ className: "p-4 bg-[var(--color-status-error-bg-subtle)] border border-[var(--color-status-error-border)] rounded-lg",
2296
+ children: [
2297
+ /* @__PURE__ */ jsxs("div", {
2298
+ className: "flex items-center gap-2 text-[var(--color-status-error-text)]",
2299
+ children: [/* @__PURE__ */ jsx(Icon, {
2300
+ icon: "mdi:alert-circle",
2301
+ width: 20
2302
+ }), /* @__PURE__ */ jsx("span", {
2303
+ className: "font-medium",
2304
+ children: tr("fluidgrids.history.historyPage.errorHeading", "Error loading history")
2305
+ })]
2306
+ }),
2307
+ /* @__PURE__ */ jsx("p", {
2308
+ className: "mt-1 text-sm text-[var(--color-status-error-text)]",
2309
+ children: message
2310
+ }),
2311
+ /* @__PURE__ */ jsx(Button$1, {
2312
+ variant: "outline",
2313
+ size: "sm",
2314
+ onClick: onRetry,
2315
+ className: "mt-3 border-[var(--color-status-error-border)] text-[var(--color-status-error-text)] hover:bg-[var(--color-status-error-bg-subtle)]",
2316
+ children: tr("fluidgrids.history.historyPage.errorRetry", "Retry")
2317
+ })
2318
+ ]
2319
+ });
2320
+ }
2321
+ function StatCard({ label, value, valueClassName }) {
2322
+ return /* @__PURE__ */ jsxs("div", {
2323
+ className: "p-3 rounded-lg bg-surface border border-border-default",
2324
+ children: [/* @__PURE__ */ jsx("p", {
2325
+ className: "text-xs text-text-secondary",
2326
+ children: label
2327
+ }), /* @__PURE__ */ jsx("p", {
2328
+ className: `text-xl font-bold ${valueClassName ?? "text-text-primary"}`,
2329
+ children: value
2330
+ })]
2331
+ });
2332
+ }
2333
+ /** Navigation v2 gets the redesigned page; every other app the classic one. */
2334
+ function HistoryPage() {
2335
+ return useNavigationV2() ? /* @__PURE__ */ jsx(VersionHistoryPage, {}) : /* @__PURE__ */ jsx(ClassicHistoryPage, {});
2336
+ }
2337
+ /**
2338
+ * The classic page. It renders only with Navigation v2 off, so its `v2`
2339
+ * branches below no longer run; they stay until the classic page goes.
2340
+ */
2341
+ function ClassicHistoryPage() {
2342
+ const tr = useTr();
2343
+ const navigate = useNavigate();
2344
+ const v2 = useNavigationV2();
2345
+ const STATUS_STYLES = useStatusStyles(v2);
2346
+ const [search, setSearch] = useState("");
2347
+ const [workflowFilter, setWorkflowFilter] = useState("all");
2348
+ const [page, setPage] = useState(0);
2349
+ const [windowOffset, setWindowOffset] = useState(0);
2350
+ const [windows, setWindows] = useState({});
2351
+ const { workflows: versionRows, total, hasMore, loading, error, refetch } = useWorkflowDefinitions(windowOffset > 0 ? {
2352
+ limit: FETCH_LIMIT,
2353
+ offset: windowOffset
2354
+ } : { limit: FETCH_LIMIT });
2355
+ useEffect(() => {
2356
+ if (loading || error) return;
2357
+ setWindows((prev) => ({
2358
+ ...prev,
2359
+ [windowOffset]: versionRows
2360
+ }));
2361
+ }, [
2362
+ loading,
2363
+ error,
2364
+ versionRows,
2365
+ windowOffset
2366
+ ]);
2367
+ const loadedRows = useMemo(() => {
2368
+ if (Object.keys(windows).length === 0) return versionRows;
2369
+ const seen = /* @__PURE__ */ new Set();
2370
+ const merged = [];
2371
+ for (const offset of Object.keys(windows).map(Number).sort((a, b) => a - b)) for (const row of windows[offset]) {
2372
+ if (seen.has(row.id)) continue;
2373
+ seen.add(row.id);
2374
+ merged.push(row);
2375
+ }
2376
+ return merged;
2377
+ }, [versionRows, windows]);
2378
+ const handleRefresh = useCallback(() => {
2379
+ if (windowOffset > 0) {
2380
+ setWindows({});
2381
+ setWindowOffset(0);
2382
+ return;
2383
+ }
2384
+ setWindows({});
2385
+ refetch();
2386
+ }, [windowOffset, refetch]);
2387
+ const allRows = useMemo(() => [...loadedRows].sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()), [loadedRows]);
2388
+ const distinctWorkflows = useMemo(() => {
2389
+ const byKey = /* @__PURE__ */ new Map();
2390
+ for (const row of allRows) if (!byKey.has(row.workflowKey)) byKey.set(row.workflowKey, {
2391
+ workflowKey: row.workflowKey,
2392
+ name: row.name
2393
+ });
2394
+ return [...byKey.values()];
2395
+ }, [allRows]);
2396
+ const config = getFluidGridsConfig();
2397
+ const actorInputs = useMemo(() => {
2398
+ const ids = /* @__PURE__ */ new Set();
2399
+ for (const row of allRows) if (row.createdById) ids.add(row.createdById);
2400
+ return [...ids].map((actorId) => ({
2401
+ actorId,
2402
+ actorType: "user"
2403
+ }));
2404
+ }, [allRows]);
2405
+ const actorProfiles = useActorProfiles(actorInputs, {
2406
+ workspaceId: config.workspaceId || void 0,
2407
+ orgId: config.organizationId,
2408
+ authToken: config.authToken
2409
+ });
2410
+ const changedByLabel = useCallback((createdById) => {
2411
+ if (!createdById) return "—";
2412
+ return actorProfiles[createdById]?.displayName ?? buildActorFallback({
2413
+ actorId: createdById,
2414
+ actorType: "user"
2415
+ }).displayName;
2416
+ }, [actorProfiles]);
2417
+ const handleSearchChange = useCallback((value) => {
2418
+ setSearch(value);
2419
+ setPage(0);
2420
+ }, []);
2421
+ const handleWorkflowFilterChange = useCallback((value) => {
2422
+ setWorkflowFilter(value);
2423
+ setPage(0);
2424
+ }, []);
2425
+ const assistantControls = useMemo(() => historyControls({
2426
+ page: tr("fluidgrids.history.historyPage.title", v2 ? "Version history" : "Version History"),
2427
+ search: handleSearchChange,
2428
+ workflow: {
2429
+ label: tr("fluidgrids.executions.executionTable.colWorkflow", "Workflow"),
2430
+ allLabel: tr("fluidgrids.history.historyPage.workflowFilterAllOption", "All Workflows"),
2431
+ neutral: "all",
2432
+ options: distinctWorkflows.map((w) => ({
2433
+ value: w.workflowKey,
2434
+ label: w.name
2435
+ })),
2436
+ value: workflowFilter,
2437
+ set: handleWorkflowFilterChange
2438
+ }
2439
+ }), [
2440
+ tr,
2441
+ v2,
2442
+ distinctWorkflows,
2443
+ workflowFilter,
2444
+ handleSearchChange,
2445
+ handleWorkflowFilterChange
2446
+ ]);
2447
+ useFluidGridsPageControls(assistantControls);
2448
+ const filteredRows = useMemo(() => {
2449
+ let rows = allRows;
2450
+ if (workflowFilter !== "all") rows = rows.filter((r) => r.workflowKey === workflowFilter);
2451
+ if (search.trim()) {
2452
+ const q = search.toLowerCase();
2453
+ rows = rows.filter((r) => r.name.toLowerCase().includes(q) || r.version.toLowerCase().includes(q) || r.workflowKey.toLowerCase().includes(q) || changedByLabel(r.createdById).toLowerCase().includes(q));
2454
+ }
2455
+ return rows;
2456
+ }, [
2457
+ allRows,
2458
+ workflowFilter,
2459
+ search,
2460
+ changedByLabel
2461
+ ]);
2462
+ const totalPages = Math.max(1, Math.ceil(filteredRows.length / PAGE_SIZE));
2463
+ const paginatedRows = filteredRows.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE);
2464
+ const handleNavigateToVersion = (workflowKey, version) => {
2465
+ markBuilderNavigation();
2466
+ navigate(`../workflow/${workflowKey}/${version}`);
2467
+ };
2468
+ const { restoreVersion } = useRestoreWorkflowVersion();
2469
+ const [diffTarget, setDiffTarget] = useState(null);
2470
+ const versionsByKey = useMemo(() => {
2471
+ const byKey = /* @__PURE__ */ new Map();
2472
+ for (const w of distinctWorkflows) byKey.set(w.workflowKey, versionsOfWorkflow(allRows, w.workflowKey));
2473
+ return byKey;
2474
+ }, [allRows, distinctWorkflows]);
2475
+ const diffVersions = useMemo(() => diffTarget ? versionsByKey.get(diffTarget.workflowKey) ?? [] : [], [versionsByKey, diffTarget]);
2476
+ const previousVersionOf = useCallback((workflowKey, version) => {
2477
+ const list = versionsByKey.get(workflowKey) ?? [];
2478
+ const index = list.findIndex((v) => v.version === version);
2479
+ return index >= 0 && index + 1 < list.length ? list[index + 1].version : null;
2480
+ }, [versionsByKey]);
2481
+ const handleRestoreFromDiff = async (workflowKey, version) => {
2482
+ const result = await restoreVersion(workflowKey, version);
2483
+ if (result?.success && result.workflow) {
2484
+ toast.success(tr("fluidgrids.history.historyPage.restoreSuccess", "Version restored"), {
2485
+ description: tr("fluidgrids.history.historyPage.restoreSuccessDescription", "Created {{created}} from {{version}}", {
2486
+ created: result.workflow.version,
2487
+ version
2488
+ }),
2489
+ dismissible: true
2490
+ });
2491
+ setDiffTarget(null);
2492
+ refetch();
2493
+ navigate(`../workflow/${result.workflow.workflowKey}/${result.workflow.version}`);
2494
+ return;
2495
+ }
2496
+ toast.error(tr("fluidgrids.history.historyPage.restoreError", "Failed to restore version"), { description: result?.message ?? void 0 });
2497
+ };
2498
+ const formatDate = (dateStr) => {
2499
+ try {
2500
+ return new Intl.DateTimeFormat(pageLocale(), {
2501
+ month: "short",
2502
+ day: "numeric",
2503
+ year: "numeric",
2504
+ hour: "2-digit",
2505
+ minute: "2-digit"
2506
+ }).format(new Date(dateStr));
2507
+ } catch {
2508
+ return dateStr;
2509
+ }
2510
+ };
2511
+ const countByStatus = (status) => allRows.filter((r) => r.status === status).length;
2512
+ const showOlder = () => setWindowOffset(windowOffset + FETCH_LIMIT);
2513
+ return /* @__PURE__ */ jsxs("div", {
2514
+ className: "p-4 sm:p-6 bg-surface-canvas min-h-screen",
2515
+ children: [
2516
+ /* @__PURE__ */ jsxs("div", {
2517
+ className: "flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",
2518
+ "data-tour": "fluidgrids-history-header",
2519
+ children: [/* @__PURE__ */ jsxs("div", { children: [
2520
+ /* @__PURE__ */ jsx("h1", {
2521
+ className: "text-2xl sm:text-3xl font-bold text-text-primary",
2522
+ children: tr("fluidgrids.history.historyPage.title", v2 ? "Version history" : "Version History")
2523
+ }),
2524
+ /* @__PURE__ */ jsx("p", {
2525
+ className: "text-text-secondary mt-1",
2526
+ children: tr("fluidgrids.history.historyPage.subtitle", "Track changes and versions across all workflows")
2527
+ }),
2528
+ /* @__PURE__ */ jsx(FluidGridsDocsLink, {
2529
+ topic: "history",
2530
+ className: "mt-1"
2531
+ })
2532
+ ] }), /* @__PURE__ */ jsxs("div", {
2533
+ className: "flex flex-wrap items-center gap-3",
2534
+ children: [/* @__PURE__ */ jsxs(Button$1, {
2535
+ variant: "outline",
2536
+ onClick: handleRefresh,
2537
+ children: [/* @__PURE__ */ jsx(Icon, {
2538
+ icon: "mdi:refresh",
2539
+ className: "mr-2",
2540
+ width: 16
2541
+ }), tr("fluidgrids.history.historyPage.refreshButton", "Refresh")]
2542
+ }), !v2 && /* @__PURE__ */ jsxs(Button$1, {
2543
+ variant: "outline",
2544
+ onClick: () => navigate("../list"),
2545
+ children: [/* @__PURE__ */ jsx(Icon, {
2546
+ icon: "mdi:arrow-left",
2547
+ className: "mr-2",
2548
+ width: 16
2549
+ }), tr("fluidgrids.history.historyPage.backToWorkflowsButton", "Back to Workflows")]
2550
+ })]
2551
+ })]
2552
+ }),
2553
+ /* @__PURE__ */ jsxs("div", {
2554
+ className: "flex flex-col sm:flex-row gap-3 mb-6",
2555
+ children: [/* @__PURE__ */ jsxs("div", {
2556
+ className: "relative flex-1 max-w-sm",
2557
+ "data-tour": "fluidgrids-history-search",
2558
+ children: [/* @__PURE__ */ jsx(Icon, {
2559
+ icon: "mdi:magnify",
2560
+ width: 18,
2561
+ className: "absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary"
2562
+ }), /* @__PURE__ */ jsx(Input, {
2563
+ placeholder: tr("fluidgrids.history.historyPage.searchPlaceholder", v2 ? "Search by workflow or person" : "Search by name, version, key, or author..."),
2564
+ "aria-label": tr("fluidgrids.history.historyPage.searchLabel", "Search versions"),
2565
+ value: search,
2566
+ onChange: (e) => handleSearchChange(e.target.value),
2567
+ className: "pl-10 bg-surface border-border-default"
2568
+ })]
2569
+ }), /* @__PURE__ */ jsxs(Select, {
2570
+ value: workflowFilter,
2571
+ onValueChange: handleWorkflowFilterChange,
2572
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
2573
+ className: "w-[220px] bg-surface border-border-default",
2574
+ "data-tour": "fluidgrids-history-workflow-filter",
2575
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: tr("fluidgrids.history.historyPage.workflowFilterPlaceholder", "All Workflows") })
2576
+ }), /* @__PURE__ */ jsxs(SelectContent, { children: [/* @__PURE__ */ jsx(SelectItem, {
2577
+ value: "all",
2578
+ children: tr("fluidgrids.history.historyPage.workflowFilterAllOption", "All Workflows")
2579
+ }), distinctWorkflows.map((w) => /* @__PURE__ */ jsx(SelectItem, {
2580
+ value: w.workflowKey,
2581
+ children: w.name
2582
+ }, w.workflowKey))] })]
2583
+ })]
2584
+ }),
2585
+ /* @__PURE__ */ jsxs("div", {
2586
+ className: `grid grid-cols-2 ${v2 ? "sm:grid-cols-3 lg:grid-cols-6" : "sm:grid-cols-5"} gap-3 mb-6`,
2587
+ children: [
2588
+ /* @__PURE__ */ jsx(StatCard, {
2589
+ label: tr("fluidgrids.history.historyPage.statTotalVersions", "Total Versions"),
2590
+ value: v2 ? allRows.length : total || allRows.length
2591
+ }),
2592
+ /* @__PURE__ */ jsx(StatCard, {
2593
+ label: tr("fluidgrids.history.historyPage.statWorkflows", "Workflows"),
2594
+ value: distinctWorkflows.length
2595
+ }),
2596
+ /* @__PURE__ */ jsx(StatCard, {
2597
+ label: v2 ? tr("fluidgrids.history.historyPage.statOn", "On") : tr("fluidgrids.history.historyPage.statActive", "Active"),
2598
+ value: countByStatus("ACTIVE"),
2599
+ valueClassName: "text-[var(--color-status-success-text)]"
2600
+ }),
2601
+ /* @__PURE__ */ jsx(StatCard, {
2602
+ label: v2 ? tr("fluidgrids.history.historyPage.statOffDraft", "Off (draft)") : tr("fluidgrids.history.historyPage.statDraft", "Draft"),
2603
+ value: countByStatus("DRAFT"),
2604
+ valueClassName: "text-[var(--color-status-warning-text)]"
2605
+ }),
2606
+ /* @__PURE__ */ jsx(StatCard, {
2607
+ label: tr("fluidgrids.history.historyPage.statArchived", "Archived"),
2608
+ value: countByStatus("ARCHIVED")
2609
+ }),
2610
+ v2 && /* @__PURE__ */ jsx(StatCard, {
2611
+ label: tr("fluidgrids.history.historyPage.statRetired", "Retired"),
2612
+ value: countByStatus("DEPRECATED")
2613
+ })
2614
+ ]
2615
+ }),
2616
+ hasMore && /* @__PURE__ */ jsx("p", {
2617
+ className: "text-xs text-text-secondary mb-4",
2618
+ children: tr("fluidgrids.history.historyPage.partialResultsHint", "Showing the {{shown}} most recent versions of {{total}}.", {
2619
+ shown: allRows.length,
2620
+ total: total ?? allRows.length
2621
+ })
2622
+ }),
2623
+ error && /* @__PURE__ */ jsx("div", {
2624
+ className: "mb-6",
2625
+ children: /* @__PURE__ */ jsx(ErrorState, {
2626
+ message: error.message,
2627
+ onRetry: handleRefresh,
2628
+ v2
2629
+ })
2630
+ }),
2631
+ loading && !(windowOffset > 0 && allRows.length > 0) ? /* @__PURE__ */ jsx(HistoryTableSkeleton, {}) : filteredRows.length === 0 ? /* @__PURE__ */ jsx(HistoryEmptyState, { kind: search.trim() ? "no-results" : workflowFilter !== "all" ? "filtered" : "first-use" }) : /* @__PURE__ */ jsx("div", {
2632
+ className: "overflow-x-auto rounded-lg border border-border-default",
2633
+ children: /* @__PURE__ */ jsxs("table", {
2634
+ className: "w-full text-sm",
2635
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
2636
+ className: "border-b border-border-default bg-surface",
2637
+ children: [
2638
+ /* @__PURE__ */ jsx("th", {
2639
+ className: "text-left px-4 py-3 font-medium text-text-secondary",
2640
+ children: tr("fluidgrids.history.historyPage.columnWorkflowName", "Workflow Name")
2641
+ }),
2642
+ /* @__PURE__ */ jsx("th", {
2643
+ className: "text-left px-4 py-3 font-medium text-text-secondary",
2644
+ children: tr("fluidgrids.history.historyPage.columnVersion", "Version")
2645
+ }),
2646
+ /* @__PURE__ */ jsx("th", {
2647
+ className: "text-left px-4 py-3 font-medium text-text-secondary",
2648
+ children: tr("fluidgrids.history.historyPage.columnStatus", "Status")
2649
+ }),
2650
+ /* @__PURE__ */ jsx("th", {
2651
+ className: "text-left px-4 py-3 font-medium text-text-secondary",
2652
+ children: v2 ? tr("fluidgrids.history.historyPage.columnCreatedBy", "Created by") : tr("fluidgrids.history.historyPage.columnChangedBy", "Changed By")
2653
+ }),
2654
+ /* @__PURE__ */ jsx("th", {
2655
+ className: "text-left px-4 py-3 font-medium text-text-secondary",
2656
+ children: v2 ? tr("fluidgrids.history.historyPage.columnLastChanged", "Last changed") : tr("fluidgrids.history.historyPage.columnChangedAt", "Changed At")
2657
+ }),
2658
+ /* @__PURE__ */ jsx("th", {
2659
+ className: "text-right px-4 py-3 font-medium text-text-secondary",
2660
+ children: tr("fluidgrids.history.historyPage.columnActions", "Actions")
2661
+ })
2662
+ ]
2663
+ }) }), /* @__PURE__ */ jsx("tbody", { children: paginatedRows.map((row) => {
2664
+ const statusStyle = STATUS_STYLES[row.status] ?? STATUS_STYLES.DRAFT;
2665
+ return /* @__PURE__ */ jsxs("tr", {
2666
+ className: "border-b border-border-default last:border-0 hover:bg-surface-sunken/50 cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
2667
+ tabIndex: 0,
2668
+ "aria-label": tr("fluidgrids.history.historyPage.openVersionLabel", "Open {{name}} {{version}} in the builder", {
2669
+ name: row.name,
2670
+ version: row.version
2671
+ }),
2672
+ onClick: () => handleNavigateToVersion(row.workflowKey, row.version),
2673
+ onKeyDown: (e) => {
2674
+ if (e.target !== e.currentTarget) return;
2675
+ if (e.key === "Enter" || e.key === " ") {
2676
+ e.preventDefault();
2677
+ handleNavigateToVersion(row.workflowKey, row.version);
2678
+ }
2679
+ },
2680
+ children: [
2681
+ /* @__PURE__ */ jsx("td", {
2682
+ className: "px-4 py-3",
2683
+ children: /* @__PURE__ */ jsxs("div", {
2684
+ className: "flex items-center gap-2",
2685
+ children: [/* @__PURE__ */ jsx(Icon, {
2686
+ icon: "mdi:workflow",
2687
+ width: 18,
2688
+ className: "text-text-secondary"
2689
+ }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
2690
+ className: "font-medium text-text-primary",
2691
+ children: row.name
2692
+ }), /* @__PURE__ */ jsx("p", {
2693
+ className: "text-xs text-text-secondary",
2694
+ children: row.workflowKey
2695
+ })] })]
2696
+ })
2697
+ }),
2698
+ /* @__PURE__ */ jsx("td", {
2699
+ className: "px-4 py-3",
2700
+ children: /* @__PURE__ */ jsx("code", {
2701
+ className: "text-xs bg-surface px-2 py-0.5 rounded text-text-primary",
2702
+ children: row.version
2703
+ })
2704
+ }),
2705
+ /* @__PURE__ */ jsx("td", {
2706
+ className: "px-4 py-3",
2707
+ children: /* @__PURE__ */ jsx(Badge, {
2708
+ variant: statusStyle.variant,
2709
+ children: statusStyle.label
2710
+ })
2711
+ }),
2712
+ /* @__PURE__ */ jsx("td", {
2713
+ className: "px-4 py-3 text-text-secondary",
2714
+ children: /* @__PURE__ */ jsxs("div", {
2715
+ className: "flex items-center gap-1.5",
2716
+ title: row.createdById ?? void 0,
2717
+ children: [/* @__PURE__ */ jsx(Icon, {
2718
+ icon: "mdi:account",
2719
+ width: 16
2720
+ }), /* @__PURE__ */ jsx("span", {
2721
+ className: "truncate max-w-[160px]",
2722
+ children: changedByLabel(row.createdById)
2723
+ })]
2724
+ })
2725
+ }),
2726
+ /* @__PURE__ */ jsx("td", {
2727
+ className: "px-4 py-3 text-text-secondary",
2728
+ children: formatDate(row.updatedAt)
2729
+ }),
2730
+ /* @__PURE__ */ jsx("td", {
2731
+ className: "px-4 py-3 text-right",
2732
+ children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [previousVersionOf(row.workflowKey, row.version) && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
2733
+ asChild: true,
2734
+ children: /* @__PURE__ */ jsx("button", {
2735
+ type: "button",
2736
+ "aria-label": tr("fluidgrids.history.historyPage.compareTooltip", "Compare with the previous version"),
2737
+ "data-testid": "fluidgrids-history-compare",
2738
+ onClick: (e) => {
2739
+ e.stopPropagation();
2740
+ const from = previousVersionOf(row.workflowKey, row.version);
2741
+ if (!from) return;
2742
+ setDiffTarget({
2743
+ workflowKey: row.workflowKey,
2744
+ name: row.name,
2745
+ from,
2746
+ to: row.version
2747
+ });
2748
+ },
2749
+ className: "p-1.5 rounded hover:bg-surface-sunken text-text-secondary hover:text-text-primary transition-colors",
2750
+ children: /* @__PURE__ */ jsx(Icon, {
2751
+ icon: "mdi:compare-horizontal",
2752
+ width: 16
2753
+ })
2754
+ })
2755
+ }), /* @__PURE__ */ jsx(TooltipContent, { children: tr("fluidgrids.history.historyPage.compareTooltip", "Compare with the previous version") })] }), /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
2756
+ asChild: true,
2757
+ children: /* @__PURE__ */ jsx("button", {
2758
+ type: "button",
2759
+ "aria-label": tr("fluidgrids.history.historyPage.openInBuilderTooltip", "Open in builder"),
2760
+ onClick: (e) => {
2761
+ e.stopPropagation();
2762
+ handleNavigateToVersion(row.workflowKey, row.version);
2763
+ },
2764
+ className: "p-1.5 rounded hover:bg-surface-sunken text-text-secondary hover:text-text-primary transition-colors",
2765
+ children: /* @__PURE__ */ jsx(Icon, {
2766
+ icon: "mdi:open-in-new",
2767
+ width: 16
2768
+ })
2769
+ })
2770
+ }), /* @__PURE__ */ jsx(TooltipContent, { children: tr("fluidgrids.history.historyPage.openInBuilderTooltip", "Open in builder") })] })] })
2771
+ })
2772
+ ]
2773
+ }, row.id);
2774
+ }) })]
2775
+ })
2776
+ }),
2777
+ diffTarget && /* @__PURE__ */ jsx(VersionDiffDialog, {
2778
+ open: true,
2779
+ onOpenChange: (open) => !open && setDiffTarget(null),
2780
+ workflowKey: diffTarget.workflowKey,
2781
+ workflowName: diffTarget.name,
2782
+ versions: diffVersions,
2783
+ initialFrom: diffTarget.from,
2784
+ initialTo: diffTarget.to,
2785
+ authorName: (id) => id ? changedByLabel(id) : null,
2786
+ onRestore: (version) => handleRestoreFromDiff(diffTarget.workflowKey, version),
2787
+ onOpenVersion: (version) => handleNavigateToVersion(diffTarget.workflowKey, version)
2788
+ }),
2789
+ hasMore && !error && /* @__PURE__ */ jsx("div", {
2790
+ className: "mt-4 flex justify-center",
2791
+ children: /* @__PURE__ */ jsx(Button$1, {
2792
+ variant: "outline",
2793
+ onClick: showOlder,
2794
+ disabled: loading,
2795
+ "data-testid": "fluidgrids-history-show-older",
2796
+ children: tr("fluidgrids.history.historyPage.showOlderVersions", "Show older versions")
2797
+ })
2798
+ }),
2799
+ filteredRows.length > PAGE_SIZE && /* @__PURE__ */ jsxs("div", {
2800
+ className: "flex items-center justify-between mt-4 px-1",
2801
+ children: [/* @__PURE__ */ jsx("p", {
2802
+ className: "text-sm text-text-secondary",
2803
+ children: tr("fluidgrids.history.historyPage.rangeSummary", "Showing {{from}}–{{to}} of {{total}}", {
2804
+ from: page * PAGE_SIZE + 1,
2805
+ to: Math.min((page + 1) * PAGE_SIZE, filteredRows.length),
2806
+ total: filteredRows.length
2807
+ })
2808
+ }), /* @__PURE__ */ jsxs("div", {
2809
+ className: "flex gap-2",
2810
+ children: [/* @__PURE__ */ jsxs(Button$1, {
2811
+ variant: "outline",
2812
+ size: "sm",
2813
+ disabled: page === 0,
2814
+ onClick: () => setPage((p) => p - 1),
2815
+ children: [/* @__PURE__ */ jsx(Icon, {
2816
+ icon: "mdi:chevron-left",
2817
+ width: 16
2818
+ }), tr("fluidgrids.history.historyPage.previousPageButton", "Previous")]
2819
+ }), /* @__PURE__ */ jsxs(Button$1, {
2820
+ variant: "outline",
2821
+ size: "sm",
2822
+ disabled: page >= totalPages - 1,
2823
+ onClick: () => setPage((p) => p + 1),
2824
+ children: [tr("fluidgrids.history.historyPage.nextPageButton", "Next"), /* @__PURE__ */ jsx(Icon, {
2825
+ icon: "mdi:chevron-right",
2826
+ width: 16
2827
+ })]
2828
+ })]
2829
+ })]
2830
+ })
2831
+ ]
2832
+ });
2833
+ }
2834
+
2835
+ export { HistoryPage_exports as n, HistoryPage as t };