@fluidgrids/fe-sdk 0.0.0-stage → 2026.1203.7

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,4593 @@
1
+ "use client";
2
+ import { t as __exportAll } from "./rolldown-runtime-hDbaFkMy.js";
3
+ import { d as usePreviewN8nImport, g as useWorkflowDefinitions, l as useImportWorkflow, r as useCreateWorkflow, s as useDeleteWorkflow } from "./useWorkflows-Cvg-Z_IE.js";
4
+ import { i as createThenOpen, n as builderPathOf, r as classifyCreateRefusal } from "./create-workflow-first-Azg3JUdX.js";
5
+ import { a as QuotaExhaustedDialog, i as CreateWorkflowRefusalDialog } from "./useWorkflowCodeExport-pqxyLHD1.js";
6
+ import { n as BILLING_PLANS_PATH, u as isQuotaExhaustedFailure } from "./quota-DeA_CJ2e.js";
7
+ import { t as Icon } from "./Icon-BtQ0HXLh.js";
8
+ import { t as EntityTagBadge } from "./EntityTagBadge-1OlP6p0c.js";
9
+ import { t as loadedFlowStore } from "./flow-store-holder-CUN7Terz.js";
10
+ import { a as visibleWorkflowDescription, i as saveWorkflowDescription, n as commitWorkflowDescription, o as workflowDescriptionCharactersLeft, s as useDuplicateWorkflowCopy, t as useWorkflowListExport } from "./useWorkflowListExport-hcZNvTaB.js";
11
+ import { r as markBuilderNavigation } from "./builderTimings-pvGnK1m-.js";
12
+ import { a as SdkPermissionGate, i as SdkPermissionButton, s as useFluidGridsPermission, t as FLUIDGRIDS_PERMISSIONS } from "./constants-DlRnHBfQ.js";
13
+ import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
14
+ import { a as isExecutionMode, i as isAutonomyLevel, n as EXECUTION_MODES, o as useAutonomyLevelCopy, r as EXECUTION_MODE_ICONS, s as useExecutionModeCopy } from "./run-mode-USmM0-Uo.js";
15
+ import { IH as WorkflowAccessFilter, RU as WorkflowStatus, YH as WorkflowExportFormat } from "./graphql-types-UTYtujY9.js";
16
+ import { a as assertImportByteSize, g as readProjectArchive, h as primaryImportModule, i as MAX_IMPORT_SOURCE_BYTES, l as importAcceptAttribute, n as ImportSourceError, r as MAX_IMPORT_ARCHIVE_BYTES, s as checkTypeScriptImport, t as CODE_EXPORT_FORMATS, u as importFileKind, v as typeScriptImportSource, x as workflowNameFromFile, y as typeScriptModuleFile } from "./workflow-code-transfer-Bsy0JKAZ.js";
17
+ import { i as canShareWorkflow, r as canEditWorkflow, t as WorkflowShareDialog } from "./WorkflowShareDialog-e8jJtLjU.js";
18
+ import { n as formatRelativeTime, t as formatExactTime } from "./relative-time-Dxt8ZIIu.js";
19
+ import { n as useNavigationV2 } from "./useNavigationV2-C2WeqN7d.js";
20
+ import { t as ConfirmActionDialog } from "./ConfirmActionDialog-DHWTDRbp.js";
21
+ import { i as useOpenRequest, n as ACTION_PARAM_VALUES, r as useActionParam } from "./useActionParam-B2tU2BlY.js";
22
+ import { i as isPermissionDenied, t as describeOperationError } from "./errors-ClKb5sEt.js";
23
+ import { m as useFluidGridsFlagsSettled, p as useFluidGridsFlag, t as FLUIDGRIDS_FLAGS } from "./feature-flags-B2qetXKd.js";
24
+ import { r as parseWorkflowImport } from "./workflow-transfer-CQnQC-ke.js";
25
+ import { a as useWorkflowProjects, i as useWorkflowProjectActions, n as useWorkflowFolderActions, r as useWorkflowFolders, t as useBulkWorkflowActions } from "./useWorkflowOrganization-CpBbOrs7.js";
26
+ import { n as getFluidGridsClient } from "./client-holder-C0M5Cfwl.js";
27
+ import { t as WorkflowSettingsDrawer } from "./WorkflowSettingsDrawer-gazs97WR.js";
28
+ import { i as useExecutions } from "./useExecutions-2u5nGJJk.js";
29
+ import { a as firstWorkflowProgress, i as builderPathFor, r as GUIDED_TOUR_STATE } from "./firstWorkflow-C_h0KMB2.js";
30
+ import { n as useFluidGridsPageControls } from "./pageControlsBridge-0pX9s-3k.js";
31
+ import { i as workflowsListControls } from "./pageControlSpecs-DZJ9K37m.js";
32
+ import { t as FluidGridsDocsLink } from "./FluidGridsDocsLink-bX0Hnhxr.js";
33
+ import { t as WORKFLOW_STATUS_CHIPS } from "./chips-CvNrYJZa.js";
34
+ import { d as WorkflowsIntro, f as WorkflowsTableSkeleton, n as FilterChip, p as useWorkflowStatusLabels } from "./parts-B7fBcw-B.js";
35
+ import { n as FluidGridsContext } from "./useFluidGridsAnalytics-VM8lAi2x.js";
36
+ import { t as WorkflowsListPageDocument } from "./WorkflowsListPageDocument-CnzcQm_o.js";
37
+ import { i as RUN_STATUS_CONFIG, t as ExecutionStatusBadge } from "./ExecutionStatusBadge-BsDVor9t.js";
38
+ import { n as PageOperationContext } from "./page-operation-DrWuhd6Y.js";
39
+ import { t as canUseBridgeHere } from "./use-extension-bridge-B9ZreOkQ.js";
40
+ import { t as useDebouncedValue } from "./useDebouncedValue-BFekcv6n.js";
41
+ import { Suspense, lazy, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
42
+ import { Link, useNavigate, useSearchParams } from "react-router";
43
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
44
+ import { CircleDot } from "lucide-react";
45
+ import { toast } from "sonner";
46
+ import { cn } from "@burdenoff/fe-libs/utils";
47
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Card, Checkbox, CompactMarkOr, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, IllustratedEmptyState, Input, Label, LoadError, LoadRegion, NextSteps, OptionalFields, ResponsiveDialog, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, ResponsiveTable, Select, SelectContent, SelectItem, SelectSeparator, SelectTrigger, SelectValue, ShowTechnicalDetails, Skeleton, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, useLoadingSystem, useRememberedOpen } from "@burdenoff/fe-libs/ui";
48
+ import { v4 } from "uuid";
49
+
50
+ // src/generated/documents/wspace/WorkflowsListRowsDocument.ts
51
+ const WorkflowsListRowsDocument = {
52
+ "kind": "Document",
53
+ "definitions": [
54
+ {
55
+ "kind": "OperationDefinition",
56
+ "operation": "query",
57
+ "name": {
58
+ "kind": "Name",
59
+ "value": "WorkflowsListRows"
60
+ },
61
+ "variableDefinitions": [{
62
+ "kind": "VariableDefinition",
63
+ "variable": {
64
+ "kind": "Variable",
65
+ "name": {
66
+ "kind": "Name",
67
+ "value": "input"
68
+ }
69
+ },
70
+ "type": {
71
+ "kind": "NonNullType",
72
+ "type": {
73
+ "kind": "NamedType",
74
+ "name": {
75
+ "kind": "Name",
76
+ "value": "ListWorkflowDefinitionsInput"
77
+ }
78
+ }
79
+ },
80
+ "directives": []
81
+ }],
82
+ "directives": [],
83
+ "selectionSet": {
84
+ "kind": "SelectionSet",
85
+ "selections": [{
86
+ "kind": "Field",
87
+ "name": {
88
+ "kind": "Name",
89
+ "value": "workflowDefinitions"
90
+ },
91
+ "arguments": [{
92
+ "kind": "Argument",
93
+ "name": {
94
+ "kind": "Name",
95
+ "value": "input"
96
+ },
97
+ "value": {
98
+ "kind": "Variable",
99
+ "name": {
100
+ "kind": "Name",
101
+ "value": "input"
102
+ }
103
+ }
104
+ }],
105
+ "directives": [],
106
+ "selectionSet": {
107
+ "kind": "SelectionSet",
108
+ "selections": [
109
+ {
110
+ "kind": "Field",
111
+ "name": {
112
+ "kind": "Name",
113
+ "value": "items"
114
+ },
115
+ "arguments": [],
116
+ "directives": [],
117
+ "selectionSet": {
118
+ "kind": "SelectionSet",
119
+ "selections": [{
120
+ "kind": "FragmentSpread",
121
+ "name": {
122
+ "kind": "Name",
123
+ "value": "WorkflowsListRow"
124
+ },
125
+ "directives": []
126
+ }]
127
+ }
128
+ },
129
+ {
130
+ "kind": "Field",
131
+ "name": {
132
+ "kind": "Name",
133
+ "value": "total"
134
+ },
135
+ "arguments": [],
136
+ "directives": []
137
+ },
138
+ {
139
+ "kind": "Field",
140
+ "name": {
141
+ "kind": "Name",
142
+ "value": "hasMore"
143
+ },
144
+ "arguments": [],
145
+ "directives": []
146
+ }
147
+ ]
148
+ }
149
+ }]
150
+ }
151
+ },
152
+ {
153
+ "kind": "FragmentDefinition",
154
+ "name": {
155
+ "kind": "Name",
156
+ "value": "WorkflowsListRow"
157
+ },
158
+ "variableDefinitions": [],
159
+ "typeCondition": {
160
+ "kind": "NamedType",
161
+ "name": {
162
+ "kind": "Name",
163
+ "value": "WorkflowDefinition"
164
+ }
165
+ },
166
+ "directives": [],
167
+ "selectionSet": {
168
+ "kind": "SelectionSet",
169
+ "selections": [
170
+ {
171
+ "kind": "Field",
172
+ "name": {
173
+ "kind": "Name",
174
+ "value": "id"
175
+ },
176
+ "arguments": [],
177
+ "directives": []
178
+ },
179
+ {
180
+ "kind": "Field",
181
+ "name": {
182
+ "kind": "Name",
183
+ "value": "workflowKey"
184
+ },
185
+ "arguments": [],
186
+ "directives": []
187
+ },
188
+ {
189
+ "kind": "Field",
190
+ "name": {
191
+ "kind": "Name",
192
+ "value": "version"
193
+ },
194
+ "arguments": [],
195
+ "directives": []
196
+ },
197
+ {
198
+ "kind": "Field",
199
+ "name": {
200
+ "kind": "Name",
201
+ "value": "name"
202
+ },
203
+ "arguments": [],
204
+ "directives": []
205
+ },
206
+ {
207
+ "kind": "Field",
208
+ "name": {
209
+ "kind": "Name",
210
+ "value": "description"
211
+ },
212
+ "arguments": [],
213
+ "directives": []
214
+ },
215
+ {
216
+ "kind": "Field",
217
+ "name": {
218
+ "kind": "Name",
219
+ "value": "status"
220
+ },
221
+ "arguments": [],
222
+ "directives": []
223
+ },
224
+ {
225
+ "kind": "Field",
226
+ "name": {
227
+ "kind": "Name",
228
+ "value": "alias"
229
+ },
230
+ "arguments": [],
231
+ "directives": []
232
+ },
233
+ {
234
+ "kind": "Field",
235
+ "name": {
236
+ "kind": "Name",
237
+ "value": "icon"
238
+ },
239
+ "arguments": [],
240
+ "directives": []
241
+ },
242
+ {
243
+ "kind": "Field",
244
+ "name": {
245
+ "kind": "Name",
246
+ "value": "category"
247
+ },
248
+ "arguments": [],
249
+ "directives": []
250
+ },
251
+ {
252
+ "kind": "Field",
253
+ "name": {
254
+ "kind": "Name",
255
+ "value": "folderId"
256
+ },
257
+ "arguments": [],
258
+ "directives": []
259
+ },
260
+ {
261
+ "kind": "Field",
262
+ "name": {
263
+ "kind": "Name",
264
+ "value": "projectId"
265
+ },
266
+ "arguments": [],
267
+ "directives": []
268
+ },
269
+ {
270
+ "kind": "Field",
271
+ "name": {
272
+ "kind": "Name",
273
+ "value": "createdById"
274
+ },
275
+ "arguments": [],
276
+ "directives": []
277
+ },
278
+ {
279
+ "kind": "Field",
280
+ "name": {
281
+ "kind": "Name",
282
+ "value": "ownerId"
283
+ },
284
+ "arguments": [],
285
+ "directives": []
286
+ },
287
+ {
288
+ "kind": "Field",
289
+ "name": {
290
+ "kind": "Name",
291
+ "value": "visibility"
292
+ },
293
+ "arguments": [],
294
+ "directives": []
295
+ },
296
+ {
297
+ "kind": "Field",
298
+ "name": {
299
+ "kind": "Name",
300
+ "value": "myAccess"
301
+ },
302
+ "arguments": [],
303
+ "directives": []
304
+ },
305
+ {
306
+ "kind": "Field",
307
+ "name": {
308
+ "kind": "Name",
309
+ "value": "executionMode"
310
+ },
311
+ "arguments": [],
312
+ "directives": []
313
+ },
314
+ {
315
+ "kind": "Field",
316
+ "name": {
317
+ "kind": "Name",
318
+ "value": "autonomyLevel"
319
+ },
320
+ "arguments": [],
321
+ "directives": []
322
+ },
323
+ {
324
+ "kind": "Field",
325
+ "name": {
326
+ "kind": "Name",
327
+ "value": "updatedAt"
328
+ },
329
+ "arguments": [],
330
+ "directives": []
331
+ },
332
+ {
333
+ "kind": "Field",
334
+ "name": {
335
+ "kind": "Name",
336
+ "value": "createdAt"
337
+ },
338
+ "arguments": [],
339
+ "directives": []
340
+ },
341
+ {
342
+ "kind": "Field",
343
+ "name": {
344
+ "kind": "Name",
345
+ "value": "totalVersions"
346
+ },
347
+ "arguments": [],
348
+ "directives": []
349
+ },
350
+ {
351
+ "kind": "Field",
352
+ "name": {
353
+ "kind": "Name",
354
+ "value": "tagAssignments"
355
+ },
356
+ "arguments": [],
357
+ "directives": [],
358
+ "selectionSet": {
359
+ "kind": "SelectionSet",
360
+ "selections": [
361
+ {
362
+ "kind": "Field",
363
+ "name": {
364
+ "kind": "Name",
365
+ "value": "id"
366
+ },
367
+ "arguments": [],
368
+ "directives": []
369
+ },
370
+ {
371
+ "kind": "Field",
372
+ "name": {
373
+ "kind": "Name",
374
+ "value": "tagId"
375
+ },
376
+ "arguments": [],
377
+ "directives": []
378
+ },
379
+ {
380
+ "kind": "Field",
381
+ "name": {
382
+ "kind": "Name",
383
+ "value": "entityType"
384
+ },
385
+ "arguments": [],
386
+ "directives": []
387
+ },
388
+ {
389
+ "kind": "Field",
390
+ "name": {
391
+ "kind": "Name",
392
+ "value": "entityId"
393
+ },
394
+ "arguments": [],
395
+ "directives": []
396
+ },
397
+ {
398
+ "kind": "Field",
399
+ "name": {
400
+ "kind": "Name",
401
+ "value": "source"
402
+ },
403
+ "arguments": [],
404
+ "directives": []
405
+ },
406
+ {
407
+ "kind": "Field",
408
+ "name": {
409
+ "kind": "Name",
410
+ "value": "assignedAt"
411
+ },
412
+ "arguments": [],
413
+ "directives": []
414
+ },
415
+ {
416
+ "kind": "Field",
417
+ "name": {
418
+ "kind": "Name",
419
+ "value": "tagInfo"
420
+ },
421
+ "arguments": [],
422
+ "directives": [],
423
+ "selectionSet": {
424
+ "kind": "SelectionSet",
425
+ "selections": [
426
+ {
427
+ "kind": "Field",
428
+ "name": {
429
+ "kind": "Name",
430
+ "value": "id"
431
+ },
432
+ "arguments": [],
433
+ "directives": []
434
+ },
435
+ {
436
+ "kind": "Field",
437
+ "name": {
438
+ "kind": "Name",
439
+ "value": "key"
440
+ },
441
+ "arguments": [],
442
+ "directives": []
443
+ },
444
+ {
445
+ "kind": "Field",
446
+ "name": {
447
+ "kind": "Name",
448
+ "value": "label"
449
+ },
450
+ "arguments": [],
451
+ "directives": []
452
+ },
453
+ {
454
+ "kind": "Field",
455
+ "name": {
456
+ "kind": "Name",
457
+ "value": "color"
458
+ },
459
+ "arguments": [],
460
+ "directives": []
461
+ }
462
+ ]
463
+ }
464
+ }
465
+ ]
466
+ }
467
+ },
468
+ {
469
+ "kind": "Field",
470
+ "name": {
471
+ "kind": "Name",
472
+ "value": "latestRun"
473
+ },
474
+ "arguments": [],
475
+ "directives": [],
476
+ "selectionSet": {
477
+ "kind": "SelectionSet",
478
+ "selections": [{
479
+ "kind": "FragmentSpread",
480
+ "name": {
481
+ "kind": "Name",
482
+ "value": "WorkflowsListLastRun"
483
+ },
484
+ "directives": []
485
+ }]
486
+ }
487
+ }
488
+ ]
489
+ }
490
+ },
491
+ {
492
+ "kind": "FragmentDefinition",
493
+ "name": {
494
+ "kind": "Name",
495
+ "value": "WorkflowsListLastRun"
496
+ },
497
+ "variableDefinitions": [],
498
+ "typeCondition": {
499
+ "kind": "NamedType",
500
+ "name": {
501
+ "kind": "Name",
502
+ "value": "WorkflowRun"
503
+ }
504
+ },
505
+ "directives": [],
506
+ "selectionSet": {
507
+ "kind": "SelectionSet",
508
+ "selections": [
509
+ {
510
+ "kind": "Field",
511
+ "name": {
512
+ "kind": "Name",
513
+ "value": "id"
514
+ },
515
+ "arguments": [],
516
+ "directives": []
517
+ },
518
+ {
519
+ "kind": "Field",
520
+ "name": {
521
+ "kind": "Name",
522
+ "value": "status"
523
+ },
524
+ "arguments": [],
525
+ "directives": []
526
+ },
527
+ {
528
+ "kind": "Field",
529
+ "name": {
530
+ "kind": "Name",
531
+ "value": "createdAt"
532
+ },
533
+ "arguments": [],
534
+ "directives": []
535
+ },
536
+ {
537
+ "kind": "Field",
538
+ "name": {
539
+ "kind": "Name",
540
+ "value": "startedAt"
541
+ },
542
+ "arguments": [],
543
+ "directives": []
544
+ },
545
+ {
546
+ "kind": "Field",
547
+ "name": {
548
+ "kind": "Name",
549
+ "value": "completedAt"
550
+ },
551
+ "arguments": [],
552
+ "directives": []
553
+ }
554
+ ]
555
+ }
556
+ }
557
+ ]
558
+ };
559
+
560
+ // src/hooks/useCreateWorkflowFirst.ts
561
+ /**
562
+ * "Create Workflow" for a button: creates the blank workflow, and opens the
563
+ * builder only once the server has returned it (see `create-workflow-first`).
564
+ *
565
+ * A refused create leaves the person where they are; `refusal` says why, for
566
+ * `CreateWorkflowRefusalDialog`. A second press while one create is in flight
567
+ * is ignored, so a double click cannot create two workflows.
568
+ */
569
+ function useCreateWorkflowFirst(options = {}) {
570
+ const navigate = useNavigate();
571
+ const { createWorkflow } = useCreateWorkflow();
572
+ const [creating, setCreating] = useState(false);
573
+ const [refusal, setRefusal] = useState(null);
574
+ const inFlightRef = useRef(false);
575
+ const { basePath, state } = options;
576
+ return {
577
+ start: useCallback(async (name, buildInput) => {
578
+ if (inFlightRef.current) return null;
579
+ inFlightRef.current = true;
580
+ setCreating(true);
581
+ setRefusal(null);
582
+ try {
583
+ const result = await createThenOpen({
584
+ create: createWorkflow,
585
+ navigate: (path, navOptions) => navigate(path, navOptions),
586
+ mintKey: v4
587
+ }, {
588
+ basePath,
589
+ state,
590
+ name,
591
+ buildInput
592
+ });
593
+ if (result.status === "refused") setRefusal(result.refusal);
594
+ return result;
595
+ } finally {
596
+ inFlightRef.current = false;
597
+ setCreating(false);
598
+ }
599
+ }, [
600
+ basePath,
601
+ createWorkflow,
602
+ navigate,
603
+ state
604
+ ]),
605
+ creating,
606
+ refusal,
607
+ clearRefusal: useCallback(() => setRefusal(null), [])
608
+ };
609
+ }
610
+
611
+ // src/builder/components/ui/workflow-status-pill.tsx
612
+ /** Status pill: colored dot + a label resolved from the current host locale. */
613
+ function WorkflowStatusPill({ status }) {
614
+ const tr = useTr();
615
+ const styles = {
616
+ DRAFT: {
617
+ label: tr("fluidgrids.workflowsList.statusDraft", "Draft"),
618
+ dotClass: "bg-muted-foreground/60"
619
+ },
620
+ ACTIVE: {
621
+ label: tr("fluidgrids.workflowsList.statusActive", "Active"),
622
+ dotClass: "bg-[var(--color-status-success-text)]"
623
+ },
624
+ ARCHIVED: {
625
+ label: tr("fluidgrids.workflowsList.statusArchived", "Archived"),
626
+ dotClass: "bg-muted-foreground/30"
627
+ },
628
+ DEPRECATED: {
629
+ label: tr("fluidgrids.workflowsList.statusDeprecated", "Deprecated"),
630
+ dotClass: "bg-[var(--color-status-error-text)]"
631
+ }
632
+ };
633
+ const info = styles[status ?? "DRAFT"] ?? styles.DRAFT;
634
+ return /* @__PURE__ */ jsxs("span", {
635
+ className: "mt-0.5 inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border border-border px-2 py-0.5 text-[11px] font-medium text-muted-foreground",
636
+ children: [/* @__PURE__ */ jsx("span", { className: `size-1.5 rounded-full ${info.dotClass}` }), info.label]
637
+ });
638
+ }
639
+
640
+ // src/components/run-mode/WorkflowRunModeBadges.tsx
641
+ const BADGE_CLASS = "inline-flex shrink-0 items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[11px] font-medium text-muted-foreground";
642
+ /**
643
+ * A workflow's run mode and, when the author chose one, its autonomy level (BOFF-9955), as two
644
+ * small badges with their explanation in a tooltip. Renders nothing for values it does not know
645
+ * (an older service that does not send them yet). Needs a TooltipProvider above it.
646
+ */
647
+ function WorkflowRunModeBadges({ executionMode, autonomyLevel, className }) {
648
+ const tr = useTr();
649
+ const modes = useExecutionModeCopy();
650
+ const levels = useAutonomyLevelCopy();
651
+ const mode = isExecutionMode(executionMode) ? executionMode : null;
652
+ const level = isAutonomyLevel(autonomyLevel) ? autonomyLevel : null;
653
+ if (!mode && !level) return null;
654
+ return /* @__PURE__ */ jsxs("div", {
655
+ className: cn("flex flex-wrap items-center gap-1", className),
656
+ children: [mode && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
657
+ asChild: true,
658
+ children: /* @__PURE__ */ jsxs("span", {
659
+ className: BADGE_CLASS,
660
+ "data-testid": "workflow-run-mode-badge",
661
+ "data-mode": mode,
662
+ "aria-label": tr("fluidgrids.runMode.badgeAriaLabel", "Run mode: {{mode}}", { mode: modes[mode].label }),
663
+ children: [/* @__PURE__ */ jsx(Icon, {
664
+ icon: EXECUTION_MODE_ICONS[mode],
665
+ className: "size-3",
666
+ "aria-hidden": "true"
667
+ }), modes[mode].label]
668
+ })
669
+ }), /* @__PURE__ */ jsx(TooltipContent, {
670
+ side: "top",
671
+ children: /* @__PURE__ */ jsx("p", { children: modes[mode].hint })
672
+ })] }), level && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
673
+ asChild: true,
674
+ children: /* @__PURE__ */ jsxs("span", {
675
+ className: BADGE_CLASS,
676
+ "data-testid": "workflow-autonomy-badge",
677
+ "data-level": level,
678
+ "aria-label": tr("fluidgrids.autonomy.badgeAriaLabel", "Autonomy level: {{level}}", { level: levels[level].label }),
679
+ children: [/* @__PURE__ */ jsx(Icon, {
680
+ icon: "mdi:shield-account-outline",
681
+ className: "size-3",
682
+ "aria-hidden": "true"
683
+ }), level]
684
+ })
685
+ }), /* @__PURE__ */ jsxs(TooltipContent, {
686
+ side: "top",
687
+ className: "max-w-xs",
688
+ children: [
689
+ /* @__PURE__ */ jsx("p", {
690
+ className: "font-medium",
691
+ children: levels[level].label
692
+ }),
693
+ /* @__PURE__ */ jsx("p", { children: levels[level].hint }),
694
+ /* @__PURE__ */ jsx("p", {
695
+ className: "mt-1 text-[11px] opacity-80",
696
+ children: tr("fluidgrids.autonomy.notEnforcedYet", "Recorded only for now: agent approvals do not follow this level yet.")
697
+ })
698
+ ]
699
+ })] })]
700
+ });
701
+ }
702
+
703
+ // src/builder/components/ui/workflow-export-menu.tsx
704
+ /**
705
+ * The workflow card's Export menu with code-first on (BOFF-9904, spec 07 §8):
706
+ * Export as TypeScript, Python or JSON, each produced by the service's
707
+ * `exportWorkflow(format)`. With the flag off the card keeps its single
708
+ * "Export workflow JSON" button.
709
+ */
710
+ function exportFormatLabel(tr, format) {
711
+ switch (format) {
712
+ case "TYPESCRIPT": return tr("fluidgrids.builder.cardWorkflow.exportAsTypeScript", "Export as TypeScript");
713
+ case "PYTHON": return tr("fluidgrids.builder.cardWorkflow.exportAsPython", "Export as Python");
714
+ default: return tr("fluidgrids.builder.cardWorkflow.exportAsJson", "Export as JSON");
715
+ }
716
+ }
717
+ const FORMAT_ICON = {
718
+ ["TYPESCRIPT"]: "mynaui:code",
719
+ ["PYTHON"]: "mynaui:code-square",
720
+ ["JSON"]: "mynaui:file-text"
721
+ };
722
+ function WorkflowExportMenu({ onExportAs, exporting }) {
723
+ const tr = useTr();
724
+ const label = tr("fluidgrids.builder.cardWorkflow.exportMenu", "Export");
725
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
726
+ asChild: true,
727
+ children: /* @__PURE__ */ jsx(DropdownMenuTrigger, {
728
+ asChild: true,
729
+ children: /* @__PURE__ */ jsx(Button, {
730
+ variant: "ghost",
731
+ size: "icon",
732
+ className: "size-8",
733
+ "aria-label": label,
734
+ "data-testid": "fluidgrids-card-export-menu",
735
+ disabled: exporting !== null,
736
+ children: exporting ? /* @__PURE__ */ jsx(CompactMarkOr, {
737
+ today: /* @__PURE__ */ jsx(Icon, {
738
+ icon: "mynaui:spinner",
739
+ className: "size-4 animate-spin"
740
+ }),
741
+ className: "size-4"
742
+ }) : /* @__PURE__ */ jsx(Icon, {
743
+ icon: "mynaui:download",
744
+ className: "size-4"
745
+ })
746
+ })
747
+ })
748
+ }), /* @__PURE__ */ jsx(TooltipContent, {
749
+ side: "top",
750
+ children: /* @__PURE__ */ jsx("p", { children: label })
751
+ })] }), /* @__PURE__ */ jsx(DropdownMenuContent, {
752
+ align: "end",
753
+ "data-card-action": "",
754
+ children: CODE_EXPORT_FORMATS.map((format) => /* @__PURE__ */ jsxs(DropdownMenuItem, {
755
+ onClick: () => onExportAs(format),
756
+ "data-testid": `fluidgrids-card-export-${format.toLowerCase()}`,
757
+ children: [/* @__PURE__ */ jsx(Icon, {
758
+ icon: FORMAT_ICON[format],
759
+ className: "mr-2 size-4"
760
+ }), exportFormatLabel(tr, format)]
761
+ }, format))
762
+ })] });
763
+ }
764
+
765
+ // src/builder/components/ui/card-workflow.tsx
766
+ const CardWorkflow = ({ workflow, onUpdateSuccess, onExport, onExportAs, exportingFormat = null, onShare, onMoveToProject, onEditDescription }) => {
767
+ const tr = useTr();
768
+ const navigate = useNavigate();
769
+ const { duplicate: duplicateAsCopy } = useDuplicateWorkflowCopy();
770
+ const { deleteWorkflow: deleteWorkflowMutation } = useDeleteWorkflow();
771
+ const [showDeleteDialog, setShowDeleteDialog] = useState(false);
772
+ const [isDeleting, setIsDeleting] = useState(false);
773
+ const [showQuotaExhausted, setShowQuotaExhausted] = useState(false);
774
+ async function handleDuplicateWorkflow() {
775
+ try {
776
+ loadedFlowStore()?.getState().actions.resetWorkflow();
777
+ const copy = await duplicateAsCopy({
778
+ workflowKey: workflow.workflow_key,
779
+ version: workflow.version,
780
+ name: workflow.name
781
+ });
782
+ if (copy.renameRefused) toast.warning(tr("fluidgrids.builder.cardWorkflow.copyRenameFailed", "The copy was made but kept the original name. Rename it in the editor."));
783
+ navigate(`../workflow/${copy.workflow.workflowKey}/${copy.workflow.version}`);
784
+ } catch (error) {
785
+ const cause = error instanceof Error ? error.cause : void 0;
786
+ if (isQuotaExhaustedFailure(cause) || isQuotaExhaustedFailure(error)) {
787
+ setShowQuotaExhausted(true);
788
+ return;
789
+ }
790
+ console.error("Error duplicating workflow:", error);
791
+ toast.error(`${tr("fluidgrids.builder.cardWorkflow.duplicateErrorToast", "Error duplicating workflow:")} ${error instanceof Error ? error.message : String(error)}`);
792
+ }
793
+ }
794
+ const handleDeleteWorkflow = async () => {
795
+ if (!workflow.workflow_key) {
796
+ console.error("Workflow ID is required to delete.");
797
+ return;
798
+ }
799
+ setIsDeleting(true);
800
+ try {
801
+ if (await deleteWorkflowMutation(workflow.workflow_key)) setShowDeleteDialog(false);
802
+ } catch (error) {
803
+ console.error("Error deleting workflow:", error);
804
+ toast.error(`${tr("fluidgrids.builder.cardWorkflow.deleteErrorToast", "Error deleting workflow:")} ${error instanceof Error ? error.message : String(error)}`);
805
+ } finally {
806
+ setIsDeleting(false);
807
+ setShowDeleteDialog(false);
808
+ onUpdateSuccess();
809
+ }
810
+ };
811
+ const handleOnEdit = () => {
812
+ markBuilderNavigation();
813
+ navigate("../workflow/" + workflow.workflow_key + "/" + workflow.version);
814
+ };
815
+ const handleOnSettings = () => {
816
+ navigate("../settings/" + workflow.workflow_key);
817
+ };
818
+ /**
819
+ * The whole card opens the builder (n8n-style). Inner controls — action
820
+ * buttons, the share overlay (a non-portaled `fixed` div whose clicks bubble
821
+ * through the card), and the dialog — must not trigger navigation.
822
+ */
823
+ const handleCardClick = (e) => {
824
+ if (e.target.closest("button, a, input, [role='dialog'], .fixed, [data-card-action]")) return;
825
+ handleOnEdit();
826
+ };
827
+ const restricted = workflow.visibility === "RESTRICTED";
828
+ const editable = canEditWorkflow(workflow.my_access);
829
+ const shareable = canShareWorkflow(workflow.my_access);
830
+ const description = visibleWorkflowDescription(workflow.description, workflow.name);
831
+ const updatedExact = formatExactTime(workflow.updated_at);
832
+ return /* @__PURE__ */ jsxs(TooltipProvider, { children: [
833
+ /* @__PURE__ */ jsxs(Card, {
834
+ role: "button",
835
+ tabIndex: 0,
836
+ "aria-label": `${tr("fluidgrids.builder.cardWorkflow.openWorkflowAriaLabel", "Open workflow")} ${workflow.name}`,
837
+ onClick: handleCardClick,
838
+ onKeyDown: (e) => {
839
+ if (e.target === e.currentTarget && (e.key === "Enter" || e.key === " ")) {
840
+ e.preventDefault();
841
+ handleOnEdit();
842
+ }
843
+ },
844
+ className: cn("group relative flex min-h-44 cursor-pointer flex-col gap-0 rounded-xl border-border bg-card p-0", "transition-all duration-150 hover:-translate-y-0.5 hover:border-primary/40 hover:shadow-lg", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50"),
845
+ children: [/* @__PURE__ */ jsxs("div", {
846
+ className: "flex flex-1 items-start gap-3 p-4",
847
+ children: [/* @__PURE__ */ jsx("div", {
848
+ className: "flex size-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary",
849
+ children: /* @__PURE__ */ jsx(Icon, {
850
+ icon: "mdi:transit-connection-variant",
851
+ className: "size-5"
852
+ })
853
+ }), /* @__PURE__ */ jsxs("div", {
854
+ className: "min-w-0 flex-1",
855
+ children: [
856
+ /* @__PURE__ */ jsxs("div", {
857
+ className: "flex items-start justify-between gap-2",
858
+ children: [/* @__PURE__ */ jsxs("div", {
859
+ className: "flex min-w-0 items-center gap-1.5",
860
+ children: [/* @__PURE__ */ jsx("h3", {
861
+ className: "truncate font-semibold leading-6 text-card-foreground",
862
+ children: workflow?.name
863
+ }), restricted && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
864
+ asChild: true,
865
+ children: /* @__PURE__ */ jsx("span", {
866
+ className: "shrink-0 text-muted-foreground",
867
+ "data-testid": "workflow-restricted-badge",
868
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.restricted", "Shared only with chosen people"),
869
+ children: /* @__PURE__ */ jsx(Icon, {
870
+ icon: "mdi:lock-outline",
871
+ className: "size-3.5"
872
+ })
873
+ })
874
+ }), /* @__PURE__ */ jsx(TooltipContent, {
875
+ side: "top",
876
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.restricted", "Shared only with chosen people") })
877
+ })] })]
878
+ }), /* @__PURE__ */ jsx(WorkflowStatusPill, { status: workflow.status })]
879
+ }),
880
+ /* @__PURE__ */ jsx("p", {
881
+ className: "mt-1 truncate text-xs leading-snug text-muted-foreground",
882
+ "data-testid": "workflow-card-description",
883
+ title: description || void 0,
884
+ children: description || tr("fluidgrids.builder.cardWorkflow.noDescription", "No description")
885
+ }),
886
+ /* @__PURE__ */ jsx(WorkflowRunModeBadges, {
887
+ executionMode: workflow.execution_mode,
888
+ autonomyLevel: workflow.autonomy_level,
889
+ className: "mt-2"
890
+ }),
891
+ workflow.tags && workflow.tags.length > 0 && /* @__PURE__ */ jsxs("div", {
892
+ className: "mt-2 flex flex-wrap items-center gap-1",
893
+ children: [workflow.tags.slice(0, 3).map((tag) => /* @__PURE__ */ jsx(EntityTagBadge, {
894
+ id: tag.id,
895
+ label: tag.label,
896
+ color: tag.color,
897
+ size: "sm"
898
+ }, tag.id)), workflow.tags.length > 3 && /* @__PURE__ */ jsxs("span", {
899
+ className: "text-[11px] text-muted-foreground",
900
+ children: ["+", workflow.tags.length - 3]
901
+ })]
902
+ })
903
+ ]
904
+ })]
905
+ }), /* @__PURE__ */ jsxs("div", {
906
+ className: "flex items-center justify-between gap-2 border-t border-border px-4 py-1.5",
907
+ children: [/* @__PURE__ */ jsxs("div", {
908
+ className: "flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",
909
+ title: updatedExact,
910
+ children: [
911
+ /* @__PURE__ */ jsx(Icon, {
912
+ icon: "mdi:clock-outline",
913
+ className: "size-3.5 shrink-0"
914
+ }),
915
+ /* @__PURE__ */ jsxs("span", {
916
+ className: "truncate",
917
+ children: [
918
+ tr("fluidgrids.builder.cardWorkflow.updatedPrefix", "Updated"),
919
+ " ",
920
+ formatRelativeTime(tr, workflow.updated_at)
921
+ ]
922
+ }),
923
+ /* @__PURE__ */ jsx("span", {
924
+ "aria-hidden": "true",
925
+ children: "·"
926
+ }),
927
+ /* @__PURE__ */ jsxs("span", {
928
+ className: "shrink-0 font-mono",
929
+ children: [workflow.version, workflow.alias ? ` (${workflow.alias})` : ""]
930
+ }),
931
+ workflow.total_versions && workflow.total_versions > 1 ? /* @__PURE__ */ jsxs("span", {
932
+ className: "shrink-0",
933
+ children: [
934
+ "· ",
935
+ workflow.total_versions,
936
+ " ",
937
+ tr("fluidgrids.builder.cardWorkflow.versionsSuffix", "versions")
938
+ ]
939
+ }) : null
940
+ ]
941
+ }), /* @__PURE__ */ jsxs("div", {
942
+ className: "flex shrink-0 items-center gap-0.5 opacity-60 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",
943
+ children: [
944
+ /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
945
+ asChild: true,
946
+ children: /* @__PURE__ */ jsx(Button, {
947
+ variant: "ghost",
948
+ size: "icon",
949
+ className: "size-8",
950
+ onClick: handleOnEdit,
951
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.editWorkflow", "Edit workflow"),
952
+ children: /* @__PURE__ */ jsx(Icon, {
953
+ icon: "mynaui:edit",
954
+ className: "size-4"
955
+ })
956
+ })
957
+ }), /* @__PURE__ */ jsx(TooltipContent, {
958
+ side: "top",
959
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.editWorkflow", "Edit workflow") })
960
+ })] }),
961
+ /* @__PURE__ */ jsx(SdkPermissionGate, {
962
+ permission: FLUIDGRIDS_PERMISSIONS.SYSTEM_CONFIG_READ,
963
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
964
+ asChild: true,
965
+ children: /* @__PURE__ */ jsx(Button, {
966
+ variant: "ghost",
967
+ size: "icon",
968
+ className: "size-8",
969
+ onClick: handleOnSettings,
970
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.workflowSettings", "Workflow settings"),
971
+ children: /* @__PURE__ */ jsx(Icon, {
972
+ icon: "mdi:cog-outline",
973
+ className: "size-4"
974
+ })
975
+ })
976
+ }), /* @__PURE__ */ jsx(TooltipContent, {
977
+ side: "top",
978
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.workflowSettings", "Workflow settings") })
979
+ })] })
980
+ }),
981
+ onShare && shareable && /* @__PURE__ */ jsx(SdkPermissionGate, {
982
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_SHARE,
983
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
984
+ asChild: true,
985
+ children: /* @__PURE__ */ jsx(Button, {
986
+ variant: "ghost",
987
+ size: "icon",
988
+ className: "size-8",
989
+ onClick: onShare,
990
+ "data-testid": "workflow-card-share",
991
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.shareWorkflow", "Share workflow"),
992
+ children: /* @__PURE__ */ jsx(Icon, {
993
+ icon: "mynaui:share",
994
+ className: "size-4"
995
+ })
996
+ })
997
+ }), /* @__PURE__ */ jsx(TooltipContent, {
998
+ side: "top",
999
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.shareWorkflow", "Share workflow") })
1000
+ })] })
1001
+ }),
1002
+ onEditDescription && editable && /* @__PURE__ */ jsx(SdkPermissionGate, {
1003
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_UPDATE,
1004
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
1005
+ asChild: true,
1006
+ children: /* @__PURE__ */ jsx(Button, {
1007
+ variant: "ghost",
1008
+ size: "icon",
1009
+ className: "size-8",
1010
+ onClick: onEditDescription,
1011
+ "data-testid": "workflow-card-edit-description",
1012
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.editDescription", "Edit description"),
1013
+ children: /* @__PURE__ */ jsx(Icon, {
1014
+ icon: "mdi:text-box-edit-outline",
1015
+ className: "size-4"
1016
+ })
1017
+ })
1018
+ }), /* @__PURE__ */ jsx(TooltipContent, {
1019
+ side: "top",
1020
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.editDescription", "Edit description") })
1021
+ })] })
1022
+ }),
1023
+ onMoveToProject && editable && /* @__PURE__ */ jsx(SdkPermissionGate, {
1024
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_UPDATE,
1025
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
1026
+ asChild: true,
1027
+ children: /* @__PURE__ */ jsx(Button, {
1028
+ variant: "ghost",
1029
+ size: "icon",
1030
+ className: "size-8",
1031
+ onClick: onMoveToProject,
1032
+ "data-testid": "workflow-card-move-project",
1033
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.moveToProject", "Move to project"),
1034
+ children: /* @__PURE__ */ jsx(Icon, {
1035
+ icon: "mdi:folder-move-outline",
1036
+ className: "size-4"
1037
+ })
1038
+ })
1039
+ }), /* @__PURE__ */ jsx(TooltipContent, {
1040
+ side: "top",
1041
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.moveToProject", "Move to project") })
1042
+ })] })
1043
+ }),
1044
+ onExportAs ? /* @__PURE__ */ jsx("span", {
1045
+ "data-card-action": "",
1046
+ children: /* @__PURE__ */ jsx(WorkflowExportMenu, {
1047
+ onExportAs,
1048
+ exporting: exportingFormat
1049
+ })
1050
+ }) : onExport ? /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
1051
+ asChild: true,
1052
+ children: /* @__PURE__ */ jsx(Button, {
1053
+ variant: "ghost",
1054
+ size: "icon",
1055
+ className: "size-8",
1056
+ onClick: onExport,
1057
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.exportWorkflow", "Export workflow JSON"),
1058
+ children: /* @__PURE__ */ jsx(Icon, {
1059
+ icon: "mynaui:download",
1060
+ className: "size-4"
1061
+ })
1062
+ })
1063
+ }), /* @__PURE__ */ jsx(TooltipContent, {
1064
+ side: "top",
1065
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.exportWorkflow", "Export workflow JSON") })
1066
+ })] }) : null,
1067
+ /* @__PURE__ */ jsx(SdkPermissionGate, {
1068
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE,
1069
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
1070
+ asChild: true,
1071
+ children: /* @__PURE__ */ jsx(Button, {
1072
+ variant: "ghost",
1073
+ size: "icon",
1074
+ className: "size-8",
1075
+ onClick: () => handleDuplicateWorkflow(),
1076
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.duplicateWorkflow", "Duplicate workflow"),
1077
+ children: /* @__PURE__ */ jsx(Icon, {
1078
+ icon: "mynaui:copy",
1079
+ className: "size-4"
1080
+ })
1081
+ })
1082
+ }), /* @__PURE__ */ jsx(TooltipContent, {
1083
+ side: "top",
1084
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.duplicateWorkflow", "Duplicate workflow") })
1085
+ })] })
1086
+ }),
1087
+ editable && /* @__PURE__ */ jsx(SdkPermissionGate, {
1088
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_DELETE,
1089
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
1090
+ asChild: true,
1091
+ children: /* @__PURE__ */ jsx(Button, {
1092
+ variant: "ghost",
1093
+ size: "icon",
1094
+ className: "size-8 text-[var(--color-status-error-text)] hover:text-[var(--color-status-error-text)]",
1095
+ onClick: () => setShowDeleteDialog(true),
1096
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.deleteWorkflow", "Delete workflow"),
1097
+ children: /* @__PURE__ */ jsx(Icon, {
1098
+ icon: "mynaui:trash",
1099
+ className: "size-4"
1100
+ })
1101
+ })
1102
+ }), /* @__PURE__ */ jsx(TooltipContent, {
1103
+ side: "top",
1104
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.deleteWorkflow", "Delete workflow") })
1105
+ })] })
1106
+ })
1107
+ ]
1108
+ })]
1109
+ })]
1110
+ }),
1111
+ /* @__PURE__ */ jsx(AlertDialog, {
1112
+ open: showDeleteDialog,
1113
+ onOpenChange: setShowDeleteDialog,
1114
+ children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: tr("fluidgrids.builder.cardWorkflow.deleteDialogTitle", "Delete Workflow") }), /* @__PURE__ */ jsxs(AlertDialogDescription, { children: [
1115
+ tr("fluidgrids.builder.cardWorkflow.deleteDialogDescriptionPrefix", "Are you sure you want to delete workflow"),
1116
+ " ",
1117
+ "\"",
1118
+ workflow.name,
1119
+ "\"",
1120
+ " ",
1121
+ tr("fluidgrids.builder.cardWorkflow.deleteDialogDescriptionSuffix", "and all its versions? This action cannot be undone.")
1122
+ ] })] }), /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, {
1123
+ disabled: isDeleting,
1124
+ children: tr("fluidgrids.builder.cardWorkflow.cancelButton", "Cancel")
1125
+ }), /* @__PURE__ */ jsx(AlertDialogAction, {
1126
+ onClick: handleDeleteWorkflow,
1127
+ disabled: isDeleting,
1128
+ className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
1129
+ children: isDeleting ? tr("fluidgrids.builder.cardWorkflow.deletingButton", "Deleting...") : tr("fluidgrids.builder.cardWorkflow.deleteButton", "Delete")
1130
+ })] })] })
1131
+ }),
1132
+ /* @__PURE__ */ jsx(QuotaExhaustedDialog, {
1133
+ surface: "workflow-duplicate",
1134
+ open: showQuotaExhausted,
1135
+ onOpenChange: setShowQuotaExhausted,
1136
+ onUpgrade: () => {
1137
+ setShowQuotaExhausted(false);
1138
+ navigate(BILLING_PLANS_PATH);
1139
+ }
1140
+ })
1141
+ ] });
1142
+ };
1143
+
1144
+ // src/components/N8nImportReport.tsx
1145
+ /**
1146
+ * What importing an n8n workflow export carries over (BOFF-9730), shown in
1147
+ * the import dialog before the import: the nodes that convert, the ones that
1148
+ * become placeholders, the connections to create and the expressions to
1149
+ * review.
1150
+ */
1151
+ function Section({ title, icon, testId, children }) {
1152
+ return /* @__PURE__ */ jsxs("div", {
1153
+ className: "space-y-1",
1154
+ "data-testid": testId,
1155
+ children: [/* @__PURE__ */ jsxs("p", {
1156
+ className: "flex items-center gap-1.5 text-xs font-medium text-foreground",
1157
+ children: [/* @__PURE__ */ jsx(Icon, {
1158
+ icon,
1159
+ className: "size-3.5 text-muted-foreground"
1160
+ }), title]
1161
+ }), /* @__PURE__ */ jsx("ul", {
1162
+ className: "space-y-1 pl-5 text-xs text-muted-foreground",
1163
+ children
1164
+ })]
1165
+ });
1166
+ }
1167
+ /** Entries with a stable key each; an exact repeat says nothing new and is shown once. */
1168
+ function keyed(entries, keyOf) {
1169
+ const seen = /* @__PURE__ */ new Map();
1170
+ for (const entry of entries) {
1171
+ const key = keyOf(entry);
1172
+ if (!seen.has(key)) seen.set(key, entry);
1173
+ }
1174
+ return [...seen.entries()];
1175
+ }
1176
+ function N8nImportReport({ report }) {
1177
+ const tr = useTr();
1178
+ return /* @__PURE__ */ jsxs("div", {
1179
+ className: "space-y-3 rounded-lg border border-border bg-background p-3",
1180
+ "data-testid": "fluidgrids-import-n8n-report",
1181
+ children: [
1182
+ /* @__PURE__ */ jsxs("div", {
1183
+ className: "flex items-start gap-2",
1184
+ children: [/* @__PURE__ */ jsx(Icon, {
1185
+ icon: "mynaui:download",
1186
+ className: "mt-0.5 size-4 shrink-0 text-muted-foreground"
1187
+ }), /* @__PURE__ */ jsxs("div", {
1188
+ className: "space-y-0.5",
1189
+ children: [/* @__PURE__ */ jsx("p", {
1190
+ className: "text-sm font-medium text-foreground",
1191
+ children: tr("fluidgrids.workflowsList.importN8nDetected", "n8n workflow detected")
1192
+ }), /* @__PURE__ */ jsx("p", {
1193
+ className: "text-xs text-muted-foreground",
1194
+ "data-testid": "fluidgrids-import-n8n-summary",
1195
+ children: tr("fluidgrids.workflowsList.importN8nSummary", "{{mapped}} of {{total}} nodes convert directly · {{placeholders}} placeholders · {{connections}} connections to set up", {
1196
+ mapped: String(report.mappedNodes.length),
1197
+ total: String(report.nodeCount),
1198
+ placeholders: String(report.placeholders.length),
1199
+ connections: String(report.connectionsNeeded.length)
1200
+ })
1201
+ })]
1202
+ })]
1203
+ }),
1204
+ report.placeholders.length > 0 && /* @__PURE__ */ jsx(Section, {
1205
+ title: tr("fluidgrids.workflowsList.importN8nPlaceholders", "Placeholders: these nodes are kept as disabled No-op nodes, with their n8n settings in the node notes"),
1206
+ icon: "mynaui:square-dashed",
1207
+ testId: "fluidgrids-import-n8n-placeholders",
1208
+ children: report.placeholders.map((placeholder) => /* @__PURE__ */ jsxs("li", { children: [
1209
+ /* @__PURE__ */ jsx("span", {
1210
+ className: "font-medium text-foreground",
1211
+ children: placeholder.name
1212
+ }),
1213
+ " ",
1214
+ /* @__PURE__ */ jsxs("span", {
1215
+ className: "font-mono",
1216
+ children: [
1217
+ "(",
1218
+ placeholder.n8nType,
1219
+ ")"
1220
+ ]
1221
+ }),
1222
+ ":",
1223
+ " ",
1224
+ placeholder.reason
1225
+ ] }, placeholder.nodeId))
1226
+ }),
1227
+ report.connectionsNeeded.length > 0 && /* @__PURE__ */ jsx(Section, {
1228
+ title: tr("fluidgrids.workflowsList.importN8nConnections", "Connections to create: n8n credentials are never imported"),
1229
+ icon: "mynaui:key",
1230
+ testId: "fluidgrids-import-n8n-connections",
1231
+ children: keyed(report.connectionsNeeded, (connection) => `${connection.nodeId}|${connection.provider ?? ""}|${connection.n8nCredentialType ?? ""}`).map(([key, connection]) => /* @__PURE__ */ jsxs("li", { children: [
1232
+ /* @__PURE__ */ jsx("span", {
1233
+ className: "font-medium text-foreground",
1234
+ children: connection.nodeName
1235
+ }),
1236
+ connection.provider && connection.provider !== "*" ? ` · ${connection.provider}` : "",
1237
+ connection.n8nCredentialName ? ` · ${tr("fluidgrids.workflowsList.importN8nCredentialWas", "was {{credential}} in n8n", { credential: connection.n8nCredentialName })}` : ""
1238
+ ] }, key))
1239
+ }),
1240
+ report.expressionIssues.length > 0 && /* @__PURE__ */ jsx(Section, {
1241
+ title: tr("fluidgrids.workflowsList.importN8nExpressions", "Expressions and conditions to review"),
1242
+ icon: "mynaui:code",
1243
+ testId: "fluidgrids-import-n8n-expressions",
1244
+ children: keyed(report.expressionIssues, (issue) => `${issue.nodeName}|${issue.expression}|${issue.reason}`).map(([key, issue]) => /* @__PURE__ */ jsxs("li", { children: [
1245
+ /* @__PURE__ */ jsx("span", {
1246
+ className: "font-medium text-foreground",
1247
+ children: issue.nodeName
1248
+ }),
1249
+ ": ",
1250
+ /* @__PURE__ */ jsx("span", {
1251
+ className: "break-all font-mono",
1252
+ children: issue.expression
1253
+ }),
1254
+ " ",
1255
+ "— ",
1256
+ issue.reason
1257
+ ] }, key))
1258
+ }),
1259
+ report.warnings.length > 0 && /* @__PURE__ */ jsx(Section, {
1260
+ title: tr("fluidgrids.workflowsList.importN8nNotes", "Notes"),
1261
+ icon: "mynaui:info-circle",
1262
+ testId: "fluidgrids-import-n8n-warnings",
1263
+ children: keyed(report.warnings, (warning) => `${warning.nodeName ?? ""}|${warning.message}`).map(([key, warning]) => /* @__PURE__ */ jsxs("li", { children: [warning.nodeName ? /* @__PURE__ */ jsxs("span", {
1264
+ className: "font-medium text-foreground",
1265
+ children: [
1266
+ warning.nodeName,
1267
+ ":",
1268
+ " "
1269
+ ]
1270
+ }) : null, warning.message] }, key))
1271
+ })
1272
+ ]
1273
+ });
1274
+ }
1275
+
1276
+ // src/components/WorkflowImportIssues.tsx
1277
+ /**
1278
+ * Why an import was refused, shown inside the import dialog (BOFF-9904): the
1279
+ * service's validation errors and warnings for the definition or the
1280
+ * TypeScript build, or the operation error when the request itself failed.
1281
+ */
1282
+ function formatMiB(bytes) {
1283
+ const mib = bytes / 1048576;
1284
+ return Number.isInteger(mib) ? String(mib) : mib.toFixed(1);
1285
+ }
1286
+ /** The sentence the dialog shows for a source refused before it is sent. */
1287
+ function describeImportSourceProblem(tr, problem) {
1288
+ switch (problem.code) {
1289
+ case "too-large": return tr("fluidgrids.workflowsList.importSourceTooLarge", "The workflow sources are larger than {{size}} MiB, the import limit.", { size: formatMiB(problem.limitBytes) });
1290
+ case "too-many-files": return tr("fluidgrids.workflowsList.importSourceTooManyFiles", "An import holds at most {{limit}} files.", { limit: String(problem.limit) });
1291
+ case "invalid-archive": return tr("fluidgrids.workflowsList.importSourceInvalidArchive", "The file is not a readable .zip archive.");
1292
+ case "no-module": return tr("fluidgrids.workflowsList.importSourceNoModule", "No TypeScript workflow module (workflows/*.ts) was found.");
1293
+ case "python-needs-cli": return tr("fluidgrids.workflowsList.importSourcePythonNeedsCli", "Python workflows are imported with the FluidGrids CLI (fluidgrids push).");
1294
+ case "needs-node-clients": return tr("fluidgrids.workflowsList.importSourceNeedsNodeClients", "{{path}} imports the generated node clients (.fluidgrids/nodes.ts). Import the .zip that Export as TypeScript downloads, which includes them.", { path: problem.path });
1295
+ }
1296
+ }
1297
+ function WorkflowImportIssues({ issues }) {
1298
+ const tr = useTr();
1299
+ const errors = issues.errors.length > 0 ? issues.errors : issues.message ? [issues.message] : [];
1300
+ if (errors.length === 0 && issues.warnings.length === 0) return null;
1301
+ return /* @__PURE__ */ jsxs("div", {
1302
+ role: "alert",
1303
+ "data-testid": "fluidgrids-import-issues",
1304
+ className: "space-y-2 rounded-lg border border-[var(--color-status-error-border)] bg-[var(--color-status-error-bg)] p-3 text-xs",
1305
+ children: [errors.length > 0 && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
1306
+ className: "font-semibold text-[var(--color-status-error-text)]",
1307
+ children: tr("fluidgrids.workflowsList.importErrorsTitle", "The workflow could not be imported")
1308
+ }), /* @__PURE__ */ jsx("ul", {
1309
+ className: "mt-1 list-disc space-y-0.5 pl-4 text-[var(--color-status-error-text)]",
1310
+ children: errors.map((error, index) => /* @__PURE__ */ jsx("li", {
1311
+ className: "break-words",
1312
+ children: error
1313
+ }, `e-${index}`))
1314
+ })] }), issues.warnings.length > 0 && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
1315
+ className: "font-semibold text-[var(--color-status-warning-text)]",
1316
+ children: tr("fluidgrids.workflowsList.importWarningsTitle", "Warnings")
1317
+ }), /* @__PURE__ */ jsx("ul", {
1318
+ className: "mt-1 list-disc space-y-0.5 pl-4 text-[var(--color-status-warning-text)]",
1319
+ children: issues.warnings.map((warning, index) => /* @__PURE__ */ jsx("li", {
1320
+ className: "break-words",
1321
+ children: warning
1322
+ }, `w-${index}`))
1323
+ })] })]
1324
+ });
1325
+ }
1326
+
1327
+ // src/components/WorkflowImportDialog.tsx
1328
+ /** Content-Length of a response, when the server sent a valid one. */
1329
+ function declaredLength(response) {
1330
+ const value = Number(response.headers.get("content-length"));
1331
+ return Number.isFinite(value) && value > 0 ? value : null;
1332
+ }
1333
+ /**
1334
+ * A problem reading the picked source, as a toast: the title in the page's
1335
+ * language, the raw detail (a JSON parser's message, an HTTP status) under it
1336
+ * (BOFF-11843: these were English-only before).
1337
+ */
1338
+ function toastImportProblem(title, error) {
1339
+ const detail = error instanceof Error ? error.message : "";
1340
+ toast.error(title, detail && detail !== title ? { description: detail } : {});
1341
+ }
1342
+ /** The node references a FluidGrids file names, one per line, for "Show technical details". */
1343
+ function nodeReferencesDetail(tr, references) {
1344
+ const lines = references.map((ref) => ref.nodeVersion ? `${ref.nodeId}: ${ref.nodeType}@${ref.nodeVersion}` : `${ref.nodeId}: ${ref.nodeType}`);
1345
+ return [tr("fluidgrids.workflowsList.importNodeReferencesCount", "{{count}} node references found", { count: String(references.length) }), ...lines].join("\n");
1346
+ }
1347
+ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled }) {
1348
+ const tr = useTr();
1349
+ const navigate = useNavigate();
1350
+ const v2 = useNavigationV2();
1351
+ const fieldId = useId();
1352
+ const codeFirst = useFluidGridsFlag(FLUIDGRIDS_FLAGS.codeFirst);
1353
+ const { importWorkflow, loading } = useImportWorkflow();
1354
+ const [open, setOpen] = useState(false);
1355
+ const openFromRequest = useCallback(() => setOpen(true), []);
1356
+ useOpenRequest(openRequested, openFromRequest, onOpenRequestHandled);
1357
+ const [typeScript, setTypeScript] = useState(null);
1358
+ const [issues, setIssues] = useState(null);
1359
+ const [rawJson, setRawJson] = useState("");
1360
+ const [url, setUrl] = useState("");
1361
+ const [parsed, setParsed] = useState(null);
1362
+ const [name, setName] = useState("");
1363
+ const nameEdited = useRef(false);
1364
+ const [nameMissing, setNameMissing] = useState(false);
1365
+ const [pickedFile, setPickedFile] = useState(null);
1366
+ const [refusal, setRefusal] = useState(null);
1367
+ const [requestError, setRequestError] = useState(null);
1368
+ const [workflowKey, setWorkflowKey] = useState("");
1369
+ const [version, setVersion] = useState("");
1370
+ const [loadingUrl, setLoadingUrl] = useState(false);
1371
+ const { previewN8nImport } = usePreviewN8nImport();
1372
+ const [n8nPreview, setN8nPreview] = useState(null);
1373
+ const [previewingN8n, setPreviewingN8n] = useState(false);
1374
+ const previewRequest = useRef(0);
1375
+ /** Forget any n8n preview, including one still in flight. */
1376
+ const dropN8nPreview = () => {
1377
+ previewRequest.current += 1;
1378
+ setN8nPreview(null);
1379
+ setPreviewingN8n(false);
1380
+ };
1381
+ const reset = () => {
1382
+ dropN8nPreview();
1383
+ setRawJson("");
1384
+ setUrl("");
1385
+ setParsed(null);
1386
+ setName("");
1387
+ nameEdited.current = false;
1388
+ setNameMissing(false);
1389
+ setPickedFile(null);
1390
+ setRequestError(null);
1391
+ setWorkflowKey("");
1392
+ setVersion("");
1393
+ setTypeScript(null);
1394
+ setIssues(null);
1395
+ };
1396
+ /** A name read from the source, unless the person already typed one. */
1397
+ const suggestName = (next) => {
1398
+ if (v2 && nameEdited.current) return;
1399
+ setName(next);
1400
+ };
1401
+ const selectTypeScript = (label, files) => {
1402
+ dropN8nPreview();
1403
+ setParsed(null);
1404
+ setIssues(null);
1405
+ setTypeScript({
1406
+ label,
1407
+ files
1408
+ });
1409
+ suggestName(workflowNameFromFile(primaryImportModule(files)?.path ?? label));
1410
+ setWorkflowKey("");
1411
+ setVersion("");
1412
+ };
1413
+ /** A source refused before sending: explained inline, like a refused import. */
1414
+ const refuseSource = (error) => {
1415
+ dropN8nPreview();
1416
+ setTypeScript(null);
1417
+ setParsed(null);
1418
+ setIssues({
1419
+ errors: [describeImportSourceProblem(tr, error.problem)],
1420
+ warnings: []
1421
+ });
1422
+ };
1423
+ /**
1424
+ * Reads a code-first pick (a TypeScript module, a project `.zip` or a
1425
+ * Python file) and selects it. Returns false for a JSON pick, which the
1426
+ * caller parses as before. `size` is checked before `read` runs, so an
1427
+ * oversized file is never loaded.
1428
+ */
1429
+ const readCodeSource = async (kind, label, size, read) => {
1430
+ if (!codeFirst || kind === null || kind === "json") return false;
1431
+ try {
1432
+ if (kind === "python") throw new ImportSourceError({ code: "python-needs-cli" });
1433
+ if (kind === "archive") {
1434
+ if (size !== null) assertImportByteSize(size, MAX_IMPORT_ARCHIVE_BYTES);
1435
+ const files = await readProjectArchive(await read.bytes());
1436
+ selectTypeScript(label, checkTypeScriptImport(files));
1437
+ return true;
1438
+ }
1439
+ if (size !== null) assertImportByteSize(size, MAX_IMPORT_SOURCE_BYTES);
1440
+ const files = [typeScriptModuleFile(label, await read.text())];
1441
+ selectTypeScript(label, checkTypeScriptImport(files));
1442
+ } catch (error) {
1443
+ if (!(error instanceof ImportSourceError)) throw error;
1444
+ refuseSource(error);
1445
+ }
1446
+ return true;
1447
+ };
1448
+ /** Ask the service what the n8n export converts to, and show its report. */
1449
+ const showN8nPreview = async (next) => {
1450
+ const request = previewRequest.current;
1451
+ setPreviewingN8n(true);
1452
+ try {
1453
+ const preview = await previewN8nImport(next.definitionJson);
1454
+ if (request !== previewRequest.current) return;
1455
+ setN8nPreview(preview);
1456
+ suggestName(preview.name);
1457
+ } catch (error) {
1458
+ if (request !== previewRequest.current) return;
1459
+ setParsed(null);
1460
+ toastImportProblem(tr("fluidgrids.workflowsList.importN8nPreviewFailed", "The n8n workflow could not be read"), error);
1461
+ } finally {
1462
+ if (request === previewRequest.current) setPreviewingN8n(false);
1463
+ }
1464
+ };
1465
+ const parse = (value) => {
1466
+ setTypeScript(null);
1467
+ setIssues(null);
1468
+ dropN8nPreview();
1469
+ try {
1470
+ const next = parseWorkflowImport(value);
1471
+ setParsed(next);
1472
+ suggestName(next.name);
1473
+ setWorkflowKey("");
1474
+ setVersion(next.version ?? "");
1475
+ if (next.source === "n8n") showN8nPreview(next);
1476
+ } catch (error) {
1477
+ setParsed(null);
1478
+ toastImportProblem(tr("fluidgrids.workflowsList.importInvalidJson", "Invalid workflow JSON"), error);
1479
+ }
1480
+ };
1481
+ const handleFile = async (file) => {
1482
+ if (!file) return;
1483
+ setPickedFile(file.name);
1484
+ try {
1485
+ if (!await readCodeSource(importFileKind(file.name), file.name, file.size, {
1486
+ text: () => file.text(),
1487
+ bytes: () => file.arrayBuffer()
1488
+ })) parse(await file.text());
1489
+ } catch (error) {
1490
+ toastImportProblem(tr("fluidgrids.workflowsList.importReadFileFailed", "Unable to read import file"), error);
1491
+ }
1492
+ };
1493
+ const handleUrl = async () => {
1494
+ if (!url.trim()) return;
1495
+ let parsedUrl;
1496
+ try {
1497
+ parsedUrl = new URL(url.trim());
1498
+ if (parsedUrl.protocol !== "https:") throw new Error(tr("fluidgrids.workflowsList.importUrlNotHttps", "Import URLs must use HTTPS"));
1499
+ } catch (error) {
1500
+ toastImportProblem(tr("fluidgrids.workflowsList.importUrlInvalid", "Invalid import URL"), error);
1501
+ return;
1502
+ }
1503
+ setLoadingUrl(true);
1504
+ try {
1505
+ const response = await fetch(parsedUrl, { credentials: "omit" });
1506
+ if (!response.ok) throw new Error(tr("fluidgrids.workflowsList.importUrlHttpError", "Import URL returned HTTP {{status}}", { status: String(response.status) }));
1507
+ const segments = parsedUrl.pathname.split("/").filter(Boolean);
1508
+ if (!await readCodeSource(importFileKind(parsedUrl.pathname), decodeURIComponent(segments[segments.length - 1] ?? "workflow.ts"), declaredLength(response), {
1509
+ text: () => response.text(),
1510
+ bytes: () => response.arrayBuffer()
1511
+ })) parse(await response.text());
1512
+ } catch (error) {
1513
+ toastImportProblem(tr("fluidgrids.workflowsList.importUrlFetchFailed", "Unable to fetch import URL"), error);
1514
+ } finally {
1515
+ setLoadingUrl(false);
1516
+ }
1517
+ };
1518
+ /**
1519
+ * Sends the import. A failed request is no longer silent (BOFF-11843): a
1520
+ * plan-limit refusal opens the Workflow Limit Reached dialog, anything else
1521
+ * is said inside this dialog. Returns null when nothing was imported.
1522
+ */
1523
+ const sendImport = async (input) => {
1524
+ setRequestError(null);
1525
+ try {
1526
+ return await importWorkflow(input);
1527
+ } catch (error) {
1528
+ const refused = classifyCreateRefusal(error);
1529
+ if (refused.kind === "failed") setRequestError(describeOperationError(error));
1530
+ else setRefusal(refused);
1531
+ return null;
1532
+ }
1533
+ };
1534
+ const handleTypeScriptImport = async (source) => {
1535
+ setIssues(null);
1536
+ const input = {
1537
+ workflowKey: workflowKey.trim() || void 0,
1538
+ version: version.trim() || void 0,
1539
+ name: name.trim(),
1540
+ source: typeScriptImportSource(source.files),
1541
+ allowMissingNodes: false
1542
+ };
1543
+ const imported = await sendImport(input);
1544
+ if (!imported) return;
1545
+ if (!imported.success || !imported.workflow) {
1546
+ setIssues({
1547
+ errors: imported.validation.errors,
1548
+ warnings: imported.validation.warnings,
1549
+ message: imported.message || tr("fluidgrids.workflowsList.importValidationFailed", "Workflow import validation failed")
1550
+ });
1551
+ return;
1552
+ }
1553
+ toast.success(tr("fluidgrids.workflowsList.importSuccess", "Workflow imported"));
1554
+ setOpen(false);
1555
+ reset();
1556
+ onImported();
1557
+ };
1558
+ const handleImport = async () => {
1559
+ if (v2 && (parsed || typeScript) && !name.trim()) {
1560
+ setNameMissing(true);
1561
+ return;
1562
+ }
1563
+ if (typeScript && name.trim()) {
1564
+ await handleTypeScriptImport(typeScript);
1565
+ return;
1566
+ }
1567
+ if (!parsed || !name.trim()) return;
1568
+ if (codeFirst) setIssues(null);
1569
+ const input = {
1570
+ workflowKey: workflowKey.trim() || `${name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-")}-${Date.now()}`,
1571
+ version: version.trim() || "v1",
1572
+ name: name.trim(),
1573
+ description: parsed.description,
1574
+ definitionJson: parsed.definitionJson,
1575
+ context: parsed.context,
1576
+ tags: parsed.tags,
1577
+ tagsV2: parsed.tagsV2,
1578
+ icon: parsed.icon,
1579
+ category: parsed.category,
1580
+ allowMissingNodes: false
1581
+ };
1582
+ const imported = await sendImport(input);
1583
+ if (!imported) return;
1584
+ if (!imported.success || !imported.workflow) {
1585
+ if (codeFirst) {
1586
+ setIssues({
1587
+ errors: imported.validation.errors,
1588
+ warnings: imported.validation.warnings,
1589
+ message: imported.message || tr("fluidgrids.workflowsList.importValidationFailed", "Workflow import validation failed")
1590
+ });
1591
+ return;
1592
+ }
1593
+ const validationMessage = [...imported.validation.errors, ...imported.validation.warnings].join(" ");
1594
+ toast.error(validationMessage || imported.message || tr("fluidgrids.workflowsList.importValidationFailed", "Workflow import validation failed"));
1595
+ return;
1596
+ }
1597
+ toast.success(tr("fluidgrids.workflowsList.importSuccess", "Workflow imported"));
1598
+ setOpen(false);
1599
+ reset();
1600
+ onImported();
1601
+ };
1602
+ const closeDialog = () => {
1603
+ setOpen(false);
1604
+ reset();
1605
+ };
1606
+ const importDisabled = loading || !parsed && !typeScript || !v2 && !name.trim() || parsed?.source === "n8n" && !n8nPreview;
1607
+ const fileInputId = "fluidgrids-workflow-import-file";
1608
+ const nameId = "fluidgrids-import-name";
1609
+ const nameErrorId = `${fieldId}-name-error`;
1610
+ const chooseFileLabel = codeFirst ? tr("fluidgrids.workflowsList.importChooseFileCode", "Choose JSON, TypeScript or .zip file") : tr("fluidgrids.workflowsList.importChooseFile", "Choose JSON file");
1611
+ const dialogTitle = codeFirst ? tr("fluidgrids.workflowsList.importTitleCode", "Import workflow") : tr("fluidgrids.workflowsList.importTitle", "Import workflow JSON");
1612
+ const dialogDescription = codeFirst ? tr("fluidgrids.workflowsList.importDescriptionCode", "Import a workflow JSON file, a TypeScript workflow module, or the .zip that Export as TypeScript downloads, from a file, an HTTPS URL, or pasted JSON. Credentials remain references and must be configured in this workspace.") : tr("fluidgrids.workflowsList.importDescription", "Import from a file, an HTTPS URL, or pasted JSON. Credentials remain references and must be configured in this workspace.");
1613
+ const filePicker = /* @__PURE__ */ jsxs("div", {
1614
+ className: "flex flex-wrap items-center gap-2",
1615
+ children: [
1616
+ /* @__PURE__ */ jsxs(Label, {
1617
+ htmlFor: fileInputId,
1618
+ className: "inline-flex min-h-11 cursor-pointer items-center gap-2 rounded-md border border-border px-3 py-2 text-sm hover:bg-accent focus-within:ring-2 focus-within:ring-ring",
1619
+ children: [/* @__PURE__ */ jsx(Icon, {
1620
+ icon: "mynaui:upload",
1621
+ className: "size-4",
1622
+ "aria-hidden": "true"
1623
+ }), chooseFileLabel]
1624
+ }),
1625
+ /* @__PURE__ */ jsx("input", {
1626
+ id: fileInputId,
1627
+ type: "file",
1628
+ accept: importAcceptAttribute(codeFirst),
1629
+ className: "sr-only",
1630
+ "data-testid": "fluidgrids-import-file",
1631
+ onChange: (event) => void handleFile(event.currentTarget.files?.[0])
1632
+ }),
1633
+ v2 && pickedFile && /* @__PURE__ */ jsx("span", {
1634
+ className: "min-w-0 truncate text-sm text-muted-foreground",
1635
+ "data-testid": "fluidgrids-import-picked-file",
1636
+ children: pickedFile
1637
+ })
1638
+ ]
1639
+ });
1640
+ const urlRow = /* @__PURE__ */ jsxs("div", {
1641
+ className: "flex gap-2",
1642
+ children: [/* @__PURE__ */ jsx(Input, {
1643
+ value: url,
1644
+ onChange: (event) => setUrl(event.target.value),
1645
+ placeholder: "https://example.com/workflow.json",
1646
+ "aria-label": codeFirst ? tr("fluidgrids.workflowsList.importUrlLabelCode", "Workflow JSON, TypeScript or .zip URL") : tr("fluidgrids.workflowsList.importUrlLabel", "Workflow JSON URL")
1647
+ }), /* @__PURE__ */ jsx(Button, {
1648
+ variant: "outline",
1649
+ onClick: () => void handleUrl(),
1650
+ disabled: loadingUrl || !url.trim(),
1651
+ children: loadingUrl ? tr("fluidgrids.workflowsList.importFetchingUrl", "Loading…") : tr("fluidgrids.workflowsList.importFetchUrl", "Fetch")
1652
+ })]
1653
+ });
1654
+ const pasteArea = /* @__PURE__ */ jsx(Textarea, {
1655
+ value: rawJson,
1656
+ onChange: (event) => {
1657
+ setRawJson(event.target.value);
1658
+ setParsed(null);
1659
+ dropN8nPreview();
1660
+ },
1661
+ onBlur: () => rawJson.trim() && parse(rawJson),
1662
+ placeholder: tr("fluidgrids.workflowsList.importPastePlaceholder", "Paste workflow JSON here"),
1663
+ className: "min-h-44 font-mono text-xs",
1664
+ "aria-label": tr("fluidgrids.workflowsList.importPasteLabel", "Workflow JSON")
1665
+ });
1666
+ /** What the picked source is: the n8n report or the TypeScript summary. */
1667
+ const sourceSummary = parsed?.source === "n8n" ? n8nPreview ? /* @__PURE__ */ jsx(N8nImportReport, { report: n8nPreview.report }) : /* @__PURE__ */ jsx("p", {
1668
+ className: "text-xs text-muted-foreground",
1669
+ "data-testid": "fluidgrids-import-n8n-previewing",
1670
+ children: previewingN8n ? tr("fluidgrids.workflowsList.importN8nPreviewing", "Reading the n8n workflow…") : tr("fluidgrids.workflowsList.importN8nDetected", "n8n workflow detected")
1671
+ }) : typeScript ? /* @__PURE__ */ jsx("p", {
1672
+ className: "text-xs text-muted-foreground",
1673
+ "data-testid": "fluidgrids-import-typescript",
1674
+ children: typeScript.files.length > 1 ? tr("fluidgrids.workflowsList.importTypeScriptProject", "{{file}}: {{count}} project files. The service builds the TypeScript and checks the workflow it defines before creating a draft.", {
1675
+ file: typeScript.label,
1676
+ count: String(typeScript.files.length)
1677
+ }) : tr("fluidgrids.workflowsList.importTypeScriptFile", "TypeScript module {{file}}: the service builds it and checks the workflow it defines before creating a draft.", { file: typeScript.label })
1678
+ }) : null;
1679
+ const nameInput = /* @__PURE__ */ jsx(Input, {
1680
+ id: nameId,
1681
+ value: name,
1682
+ required: v2,
1683
+ "aria-invalid": v2 && nameMissing ? true : void 0,
1684
+ "aria-describedby": v2 && nameMissing ? nameErrorId : void 0,
1685
+ onChange: (event) => {
1686
+ nameEdited.current = true;
1687
+ setName(event.target.value);
1688
+ if (event.target.value.trim()) setNameMissing(false);
1689
+ }
1690
+ });
1691
+ const keyField = /* @__PURE__ */ jsxs("div", {
1692
+ className: "space-y-1",
1693
+ children: [/* @__PURE__ */ jsx(Label, {
1694
+ htmlFor: "fluidgrids-import-key",
1695
+ children: tr("fluidgrids.workflowsList.importKey", "Workflow key (optional)")
1696
+ }), /* @__PURE__ */ jsx(Input, {
1697
+ id: "fluidgrids-import-key",
1698
+ value: workflowKey,
1699
+ onChange: (event) => setWorkflowKey(event.target.value)
1700
+ })]
1701
+ });
1702
+ const versionField = /* @__PURE__ */ jsxs("div", {
1703
+ className: "space-y-1",
1704
+ children: [/* @__PURE__ */ jsx(Label, {
1705
+ htmlFor: "fluidgrids-import-version",
1706
+ children: tr("fluidgrids.workflowsList.importVersion", "Version")
1707
+ }), /* @__PURE__ */ jsx(Input, {
1708
+ id: "fluidgrids-import-version",
1709
+ value: version,
1710
+ onChange: (event) => setVersion(event.target.value),
1711
+ placeholder: "v1"
1712
+ })]
1713
+ });
1714
+ const issuesShown = !loading && (issues || requestError) && /* @__PURE__ */ jsx(WorkflowImportIssues, { issues: issues ?? {
1715
+ errors: [],
1716
+ warnings: [],
1717
+ message: requestError
1718
+ } });
1719
+ const importButton = /* @__PURE__ */ jsx(Button, {
1720
+ onClick: () => void handleImport(),
1721
+ disabled: importDisabled,
1722
+ "data-testid": "fluidgrids-import-confirm",
1723
+ children: loading ? tr("fluidgrids.workflowsList.importing", "Importing…") : tr("fluidgrids.workflowsList.importConfirm", "Import workflow")
1724
+ });
1725
+ const refusalDialog = /* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
1726
+ surface: "workflow-import",
1727
+ refusal,
1728
+ onClose: () => setRefusal(null),
1729
+ onUpgrade: () => navigate(BILLING_PLANS_PATH)
1730
+ });
1731
+ if (v2) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ResponsiveDialog, {
1732
+ open,
1733
+ onOpenChange: (nextOpen) => {
1734
+ setOpen(nextOpen);
1735
+ if (!nextOpen) reset();
1736
+ },
1737
+ children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
1738
+ className: "max-h-[90vh] overflow-y-auto sm:max-w-xl",
1739
+ "data-testid": "fluidgrids-import-dialog",
1740
+ children: [
1741
+ /* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: dialogTitle }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: dialogDescription })] }),
1742
+ /* @__PURE__ */ jsxs("div", {
1743
+ className: "space-y-4",
1744
+ children: [
1745
+ filePicker,
1746
+ /* @__PURE__ */ jsxs("div", {
1747
+ className: "space-y-1",
1748
+ children: [
1749
+ /* @__PURE__ */ jsx(Label, {
1750
+ htmlFor: nameId,
1751
+ children: tr("fluidgrids.workflowsList.importName", "Name")
1752
+ }),
1753
+ nameInput,
1754
+ nameMissing && /* @__PURE__ */ jsx("p", {
1755
+ id: nameErrorId,
1756
+ className: "text-xs text-destructive",
1757
+ role: "alert",
1758
+ children: tr("fluidgrids.workflowsList.importNameRequired", "Give the workflow a name.")
1759
+ })
1760
+ ]
1761
+ }),
1762
+ sourceSummary,
1763
+ parsed?.source === "fluidgrids" && /* @__PURE__ */ jsx(ShowTechnicalDetails, { children: nodeReferencesDetail(tr, parsed.nodeReferences) }),
1764
+ issuesShown,
1765
+ /* @__PURE__ */ jsx(OptionalFields, {
1766
+ storageKey: "workflows.import",
1767
+ children: /* @__PURE__ */ jsxs("div", {
1768
+ className: "space-y-3",
1769
+ children: [
1770
+ urlRow,
1771
+ pasteArea,
1772
+ /* @__PURE__ */ jsxs("div", {
1773
+ className: "grid gap-3 sm:grid-cols-3",
1774
+ children: [/* @__PURE__ */ jsx("div", {
1775
+ className: "sm:col-span-2",
1776
+ children: keyField
1777
+ }), versionField]
1778
+ })
1779
+ ]
1780
+ })
1781
+ })
1782
+ ]
1783
+ }),
1784
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
1785
+ variant: "outline",
1786
+ onClick: closeDialog,
1787
+ children: tr("fluidgrids.workflowsList.importCancel", "Cancel")
1788
+ }), importButton] })
1789
+ ]
1790
+ })
1791
+ }), refusalDialog] });
1792
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Dialog, {
1793
+ open,
1794
+ onOpenChange: (nextOpen) => {
1795
+ setOpen(nextOpen);
1796
+ if (!nextOpen) reset();
1797
+ },
1798
+ children: [/* @__PURE__ */ jsx(SdkPermissionButton, {
1799
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE,
1800
+ deniedTooltip: tr("fluidgrids.workflowsList.importDeniedTooltip", "You don't have permission to import workflows"),
1801
+ children: /* @__PURE__ */ jsxs(Button, {
1802
+ variant: "outline",
1803
+ size: "default",
1804
+ onClick: () => setOpen(true),
1805
+ "data-tour": "fluidgrids-list-import",
1806
+ children: [/* @__PURE__ */ jsx(Icon, {
1807
+ icon: "mynaui:download",
1808
+ className: "size-4"
1809
+ }), tr("fluidgrids.workflowsList.importButton", "Import")]
1810
+ })
1811
+ }), /* @__PURE__ */ jsxs(DialogContent, {
1812
+ className: "max-h-[90vh] overflow-y-auto sm:max-w-2xl",
1813
+ children: [
1814
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: dialogTitle }), /* @__PURE__ */ jsx(DialogDescription, { children: dialogDescription })] }),
1815
+ /* @__PURE__ */ jsxs("div", {
1816
+ className: "space-y-4",
1817
+ children: [
1818
+ filePicker,
1819
+ urlRow,
1820
+ pasteArea,
1821
+ (parsed || typeScript) && /* @__PURE__ */ jsxs("div", {
1822
+ className: "space-y-3 rounded-lg border border-border bg-muted/30 p-3",
1823
+ children: [parsed?.source === "fluidgrids" ? /* @__PURE__ */ jsxs("p", {
1824
+ className: "text-xs text-muted-foreground",
1825
+ children: [
1826
+ parsed.nodeReferences.length,
1827
+ " ",
1828
+ tr("fluidgrids.workflowsList.importNodeReferences", "node references found")
1829
+ ]
1830
+ }) : sourceSummary, /* @__PURE__ */ jsxs("div", {
1831
+ className: "grid gap-3 sm:grid-cols-3",
1832
+ children: [
1833
+ /* @__PURE__ */ jsxs("div", {
1834
+ className: "space-y-1 sm:col-span-3",
1835
+ children: [/* @__PURE__ */ jsx(Label, {
1836
+ htmlFor: nameId,
1837
+ children: tr("fluidgrids.workflowsList.importName", "Name")
1838
+ }), nameInput]
1839
+ }),
1840
+ /* @__PURE__ */ jsx("div", {
1841
+ className: "sm:col-span-2",
1842
+ children: keyField
1843
+ }),
1844
+ versionField
1845
+ ]
1846
+ })]
1847
+ }),
1848
+ issuesShown
1849
+ ]
1850
+ }),
1851
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
1852
+ variant: "outline",
1853
+ onClick: () => setOpen(false),
1854
+ children: tr("fluidgrids.workflowsList.importCancel", "Cancel")
1855
+ }), importButton] })
1856
+ ]
1857
+ })]
1858
+ }), refusalDialog] });
1859
+ }
1860
+
1861
+ // src/components/workflowFolderTree.ts
1862
+ /** The folder `id` anywhere in the tree, or null. */
1863
+ function findFolder(folders, id) {
1864
+ for (const folder of folders) {
1865
+ if (folder.id === id) return folder;
1866
+ const found = findFolder(folder.children ?? [], id);
1867
+ if (found) return found;
1868
+ }
1869
+ return null;
1870
+ }
1871
+
1872
+ // src/components/WorkflowFolderSidebar.tsx
1873
+ function FolderRow({ folder, depth, selectedFolderId, onSelect, onCreateChild, onRename, onDelete }) {
1874
+ const tr = useTr();
1875
+ const [expanded, setExpanded] = useState(true);
1876
+ const hasChildren = (folder.children ?? []).length > 0;
1877
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
1878
+ className: cn("group flex items-center gap-1 rounded-md px-2 py-1.5 text-sm", selectedFolderId === folder.id ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-card hover:text-foreground"),
1879
+ style: { paddingLeft: `${8 + depth * 14}px` },
1880
+ children: [
1881
+ /* @__PURE__ */ jsx("button", {
1882
+ type: "button",
1883
+ onClick: () => setExpanded((v) => !v),
1884
+ className: cn("flex size-4 shrink-0 items-center justify-center", !hasChildren && "invisible"),
1885
+ "aria-label": tr("fluidgrids.workflowsList.folders.toggleAriaLabel", "Toggle folder"),
1886
+ children: /* @__PURE__ */ jsx(Icon, {
1887
+ icon: expanded ? "mynaui:chevron-down" : "mynaui:chevron-right",
1888
+ className: "size-3.5"
1889
+ })
1890
+ }),
1891
+ /* @__PURE__ */ jsxs("button", {
1892
+ type: "button",
1893
+ onClick: () => onSelect(folder.id),
1894
+ className: "flex min-w-0 flex-1 items-center gap-1.5 truncate text-left",
1895
+ children: [
1896
+ /* @__PURE__ */ jsx(Icon, {
1897
+ icon: "mynaui:folder",
1898
+ className: "size-4 shrink-0"
1899
+ }),
1900
+ /* @__PURE__ */ jsx("span", {
1901
+ className: "truncate",
1902
+ children: folder.name
1903
+ }),
1904
+ /* @__PURE__ */ jsx(Badge, {
1905
+ variant: "secondary",
1906
+ className: "ml-1 font-mono text-[10px]",
1907
+ children: folder.workflowCount
1908
+ })
1909
+ ]
1910
+ }),
1911
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
1912
+ asChild: true,
1913
+ children: /* @__PURE__ */ jsx("button", {
1914
+ type: "button",
1915
+ className: "invisible flex size-5 shrink-0 items-center justify-center rounded group-hover:visible hover:bg-muted",
1916
+ "aria-label": tr("fluidgrids.workflowsList.folders.menuAriaLabel", "Folder actions"),
1917
+ children: /* @__PURE__ */ jsx(Icon, {
1918
+ icon: "mynaui:dots",
1919
+ className: "size-3.5"
1920
+ })
1921
+ })
1922
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
1923
+ align: "start",
1924
+ children: [
1925
+ /* @__PURE__ */ jsx(DropdownMenuItem, {
1926
+ onClick: () => onCreateChild(folder.id),
1927
+ children: tr("fluidgrids.workflowsList.folders.newSubfolder", "New subfolder")
1928
+ }),
1929
+ /* @__PURE__ */ jsx(DropdownMenuItem, {
1930
+ onClick: () => onRename(folder),
1931
+ children: tr("fluidgrids.workflowsList.folders.rename", "Rename")
1932
+ }),
1933
+ /* @__PURE__ */ jsx(DropdownMenuItem, {
1934
+ onClick: () => onDelete(folder),
1935
+ className: "text-destructive",
1936
+ children: tr("fluidgrids.workflowsList.folders.delete", "Delete")
1937
+ })
1938
+ ]
1939
+ })] })
1940
+ ]
1941
+ }), expanded && (folder.children ?? []).map((child) => /* @__PURE__ */ jsx(FolderRow, {
1942
+ folder: child,
1943
+ depth: depth + 1,
1944
+ selectedFolderId,
1945
+ onSelect,
1946
+ onCreateChild,
1947
+ onRename,
1948
+ onDelete
1949
+ }, child.id))] });
1950
+ }
1951
+ /**
1952
+ * Nested folder tree sidebar for the workflows list (BOFF-7518). Selecting a
1953
+ * folder narrows the list to workflows whose `folderId` matches; the list
1954
+ * itself owns that filtering (see WorkflowsList's `folderFilter` state) so
1955
+ * this component stays a pure navigation/management surface.
1956
+ */
1957
+ function WorkflowFolderSidebar({ selectedFolderId, onSelectFolder, createRequested, onCreateRequestHandled, dialogsOnly = false, folderActionRequest = null, onFolderActionRequestHandled }) {
1958
+ const tr = useTr();
1959
+ const { folders, loading, refetch } = useWorkflowFolders();
1960
+ const { createFolder, renameFolder, deleteFolder } = useWorkflowFolderActions();
1961
+ const [dialog, setDialog] = useState(null);
1962
+ const [name, setName] = useState("");
1963
+ const [deleteTarget, setDeleteTarget] = useState(null);
1964
+ const openCreate = useCallback((parentId) => {
1965
+ setName("");
1966
+ setDialog({
1967
+ mode: "create",
1968
+ parentId
1969
+ });
1970
+ }, []);
1971
+ const openCreateTopLevel = useCallback(() => openCreate(null), [openCreate]);
1972
+ useOpenRequest(createRequested, openCreateTopLevel, onCreateRequestHandled);
1973
+ const openRename = useCallback((folder) => {
1974
+ setName(folder.name);
1975
+ setDialog({
1976
+ mode: "rename",
1977
+ parentId: folder.parentId ?? null,
1978
+ folder
1979
+ });
1980
+ }, []);
1981
+ useEffect(() => {
1982
+ if (!folderActionRequest || loading) return;
1983
+ const { action, folderId } = folderActionRequest;
1984
+ if (action === "create-child") openCreate(folderId);
1985
+ else {
1986
+ const folder = findFolder(folders, folderId);
1987
+ if (!folder) toast.error(action === "rename" ? tr("fluidgrids.workflowsList.folders.renameError", "Couldn't rename the folder") : tr("fluidgrids.workflowsList.folders.deleteError", "Couldn't delete the folder"));
1988
+ else if (action === "rename") openRename(folder);
1989
+ else setDeleteTarget(folder);
1990
+ }
1991
+ onFolderActionRequestHandled?.();
1992
+ }, [
1993
+ folderActionRequest,
1994
+ loading,
1995
+ folders,
1996
+ openCreate,
1997
+ openRename,
1998
+ onFolderActionRequestHandled,
1999
+ tr
2000
+ ]);
2001
+ const submitDialog = async () => {
2002
+ if (!dialog || !name.trim()) return;
2003
+ if (dialog.mode === "create") {
2004
+ if (!await createFolder({
2005
+ name: name.trim(),
2006
+ parentId: dialog.parentId
2007
+ })) {
2008
+ toast.error(tr("fluidgrids.workflowsList.folders.createError", "Couldn't create the folder"));
2009
+ return;
2010
+ }
2011
+ } else if (dialog.folder) {
2012
+ if (!await renameFolder(dialog.folder.id, name.trim())) {
2013
+ toast.error(tr("fluidgrids.workflowsList.folders.renameError", "Couldn't rename the folder"));
2014
+ return;
2015
+ }
2016
+ }
2017
+ setDialog(null);
2018
+ refetch();
2019
+ };
2020
+ const confirmDelete = async () => {
2021
+ if (!deleteTarget) return;
2022
+ if (!await deleteFolder(deleteTarget.id)) toast.error(tr("fluidgrids.workflowsList.folders.deleteError", "Couldn't delete the folder"));
2023
+ else {
2024
+ if (selectedFolderId === deleteTarget.id) onSelectFolder(null);
2025
+ refetch();
2026
+ }
2027
+ setDeleteTarget(null);
2028
+ };
2029
+ const dialogs = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Dialog, {
2030
+ open: dialog !== null,
2031
+ onOpenChange: (open) => !open && setDialog(null),
2032
+ children: /* @__PURE__ */ jsxs(DialogContent, { children: [
2033
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: dialog?.mode === "rename" ? tr("fluidgrids.workflowsList.folders.renameTitle", "Rename folder") : tr("fluidgrids.workflowsList.folders.createTitle", "New folder") }), /* @__PURE__ */ jsx(DialogDescription, { children: tr("fluidgrids.workflowsList.folders.nameDescription", "Folder name") })] }),
2034
+ /* @__PURE__ */ jsx(Input, {
2035
+ autoFocus: true,
2036
+ value: name,
2037
+ onChange: (e) => setName(e.target.value),
2038
+ onKeyDown: (e) => {
2039
+ if (e.key === "Enter") submitDialog();
2040
+ },
2041
+ placeholder: tr("fluidgrids.workflowsList.folders.namePlaceholder", "e.g. Marketing")
2042
+ }),
2043
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
2044
+ variant: "outline",
2045
+ onClick: () => setDialog(null),
2046
+ children: tr("fluidgrids.workflowsList.folders.cancel", "Cancel")
2047
+ }), /* @__PURE__ */ jsx(Button, {
2048
+ onClick: () => void submitDialog(),
2049
+ disabled: !name.trim(),
2050
+ children: tr("fluidgrids.workflowsList.folders.save", "Save")
2051
+ })] })
2052
+ ] })
2053
+ }), /* @__PURE__ */ jsx(Dialog, {
2054
+ open: deleteTarget !== null,
2055
+ onOpenChange: (open) => !open && setDeleteTarget(null),
2056
+ children: /* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: tr("fluidgrids.workflowsList.folders.deleteTitle", "Delete folder?") }), /* @__PURE__ */ jsx(DialogDescription, { children: tr("fluidgrids.workflowsList.folders.deleteDescription", "Its workflows move to the top level; child folders move up a level. This can't be undone.") })] }), /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
2057
+ variant: "outline",
2058
+ onClick: () => setDeleteTarget(null),
2059
+ children: tr("fluidgrids.workflowsList.folders.cancel", "Cancel")
2060
+ }), /* @__PURE__ */ jsx(Button, {
2061
+ variant: "destructive",
2062
+ onClick: () => void confirmDelete(),
2063
+ children: tr("fluidgrids.workflowsList.folders.delete", "Delete")
2064
+ })] })] })
2065
+ })] });
2066
+ if (dialogsOnly) return dialogs;
2067
+ return /* @__PURE__ */ jsxs("aside", {
2068
+ className: "flex w-56 shrink-0 flex-col gap-1 border-r border-border p-2",
2069
+ "data-tour": "fluidgrids-list-folders",
2070
+ children: [
2071
+ /* @__PURE__ */ jsxs("div", {
2072
+ className: "flex items-center justify-between px-2 py-1",
2073
+ children: [/* @__PURE__ */ jsx("span", {
2074
+ className: "text-xs font-semibold uppercase text-muted-foreground",
2075
+ children: tr("fluidgrids.workflowsList.folders.title", "Folders")
2076
+ }), /* @__PURE__ */ jsx("button", {
2077
+ type: "button",
2078
+ onClick: () => openCreate(null),
2079
+ className: "flex size-5 items-center justify-center rounded hover:bg-muted",
2080
+ "aria-label": tr("fluidgrids.workflowsList.folders.newFolderAriaLabel", "New folder"),
2081
+ children: /* @__PURE__ */ jsx(Icon, {
2082
+ icon: "mynaui:plus",
2083
+ className: "size-3.5"
2084
+ })
2085
+ })]
2086
+ }),
2087
+ /* @__PURE__ */ jsxs("button", {
2088
+ type: "button",
2089
+ onClick: () => onSelectFolder(null),
2090
+ className: cn("flex items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-sm", selectedFolderId === null ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-card hover:text-foreground"),
2091
+ children: [/* @__PURE__ */ jsx(Icon, {
2092
+ icon: "mynaui:grid",
2093
+ className: "size-4"
2094
+ }), tr("fluidgrids.workflowsList.folders.allWorkflows", "All workflows")]
2095
+ }),
2096
+ loading ? /* @__PURE__ */ jsx("div", {
2097
+ className: "px-2 py-1 text-xs text-muted-foreground",
2098
+ children: tr("fluidgrids.workflowsList.folders.loading", "Loading…")
2099
+ }) : folders.map((folder) => /* @__PURE__ */ jsx(FolderRow, {
2100
+ folder,
2101
+ depth: 0,
2102
+ selectedFolderId,
2103
+ onSelect: onSelectFolder,
2104
+ onCreateChild: openCreate,
2105
+ onRename: openRename,
2106
+ onDelete: setDeleteTarget
2107
+ }, folder.id)),
2108
+ dialogs
2109
+ ]
2110
+ });
2111
+ }
2112
+
2113
+ // src/components/WorkflowProjectSelect.tsx
2114
+ const ALL_PROJECTS_VALUE = "__all__";
2115
+ const NEW_PROJECT_VALUE = "__new__";
2116
+ /**
2117
+ * Project filter/switcher for the workflows list (BOFF-7518). Supersedes the
2118
+ * legacy free-form `context.projectId` key — see WorkflowProject's own schema
2119
+ * doc comment.
2120
+ */
2121
+ function WorkflowProjectSelect({ selectedProjectId, onSelectProject }) {
2122
+ const tr = useTr();
2123
+ const { projects, refetch } = useWorkflowProjects();
2124
+ const { createProject } = useWorkflowProjectActions();
2125
+ const [creating, setCreating] = useState(false);
2126
+ const [name, setName] = useState("");
2127
+ const handleChange = (value) => {
2128
+ if (value === NEW_PROJECT_VALUE) {
2129
+ setName("");
2130
+ setCreating(true);
2131
+ return;
2132
+ }
2133
+ onSelectProject(value === ALL_PROJECTS_VALUE ? null : value);
2134
+ };
2135
+ const submitCreate = async () => {
2136
+ if (!name.trim()) return;
2137
+ const created = await createProject({ name: name.trim() });
2138
+ if (!created) {
2139
+ toast.error(tr("fluidgrids.workflowsList.projects.createError", "Couldn't create the project"));
2140
+ return;
2141
+ }
2142
+ setCreating(false);
2143
+ refetch();
2144
+ onSelectProject(created.id);
2145
+ };
2146
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Select, {
2147
+ value: selectedProjectId ?? ALL_PROJECTS_VALUE,
2148
+ onValueChange: handleChange,
2149
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
2150
+ className: "w-44",
2151
+ "aria-label": tr("fluidgrids.workflowsList.projects.selectAriaLabel", "Project"),
2152
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: tr("fluidgrids.workflowsList.projects.allProjects", "All projects") })
2153
+ }), /* @__PURE__ */ jsxs(SelectContent, { children: [
2154
+ /* @__PURE__ */ jsx(SelectItem, {
2155
+ value: ALL_PROJECTS_VALUE,
2156
+ children: tr("fluidgrids.workflowsList.projects.allProjects", "All projects")
2157
+ }),
2158
+ projects.map((project) => /* @__PURE__ */ jsxs(SelectItem, {
2159
+ value: project.id,
2160
+ children: [
2161
+ project.name,
2162
+ " (",
2163
+ project.workflowCount,
2164
+ ")"
2165
+ ]
2166
+ }, project.id)),
2167
+ /* @__PURE__ */ jsx(SelectSeparator, {}),
2168
+ /* @__PURE__ */ jsx(SelectItem, {
2169
+ value: NEW_PROJECT_VALUE,
2170
+ children: tr("fluidgrids.workflowsList.projects.newProject", "+ New project")
2171
+ })
2172
+ ] })]
2173
+ }), /* @__PURE__ */ jsx(Dialog, {
2174
+ open: creating,
2175
+ onOpenChange: setCreating,
2176
+ children: /* @__PURE__ */ jsxs(DialogContent, { children: [
2177
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: tr("fluidgrids.workflowsList.projects.createTitle", "New project") }), /* @__PURE__ */ jsx(DialogDescription, { children: tr("fluidgrids.workflowsList.projects.nameDescription", "Project name") })] }),
2178
+ /* @__PURE__ */ jsx(Input, {
2179
+ autoFocus: true,
2180
+ value: name,
2181
+ onChange: (e) => setName(e.target.value),
2182
+ onKeyDown: (e) => {
2183
+ if (e.key === "Enter") submitCreate();
2184
+ },
2185
+ placeholder: tr("fluidgrids.workflowsList.projects.namePlaceholder", "e.g. Q4 launch")
2186
+ }),
2187
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
2188
+ variant: "outline",
2189
+ onClick: () => setCreating(false),
2190
+ children: tr("fluidgrids.workflowsList.projects.cancel", "Cancel")
2191
+ }), /* @__PURE__ */ jsx(Button, {
2192
+ onClick: () => void submitCreate(),
2193
+ disabled: !name.trim(),
2194
+ children: tr("fluidgrids.workflowsList.projects.save", "Save")
2195
+ })] })
2196
+ ] })
2197
+ })] });
2198
+ }
2199
+
2200
+ // src/components/WorkflowBulkActionsBar.tsx
2201
+ const UNFILED_VALUE = "__unfiled__";
2202
+ /**
2203
+ * Multi-select bulk action toolbar for the workflows list (BOFF-7518): move
2204
+ * to folder, assign to project, delete. Shown only while `selectedIds` is
2205
+ * non-empty; the caller (WorkflowsList) owns selection state and clears it on
2206
+ * `onDone`.
2207
+ */
2208
+ function WorkflowBulkActionsBar({ selectedIds, onDone }) {
2209
+ const tr = useTr();
2210
+ const { folders } = useWorkflowFolders();
2211
+ const { projects } = useWorkflowProjects();
2212
+ const { bulkMoveToFolder, bulkAssignToProject, bulkDelete, loading } = useBulkWorkflowActions();
2213
+ const [confirmingDelete, setConfirmingDelete] = useState(false);
2214
+ const flatFolders = flattenFolders(folders);
2215
+ const reportFailures = (result) => {
2216
+ if (result && result.failedIds.length > 0) toast.error(tr("fluidgrids.workflowsList.bulk.partialFailure", "{{count}} workflow(s) couldn't be updated", { count: result.failedIds.length }));
2217
+ };
2218
+ const handleMove = async (folderId) => {
2219
+ const result = await bulkMoveToFolder(selectedIds, folderId === UNFILED_VALUE ? null : folderId);
2220
+ reportFailures(result);
2221
+ onDone();
2222
+ };
2223
+ const handleAssign = async (projectId) => {
2224
+ const result = await bulkAssignToProject(selectedIds, projectId === UNFILED_VALUE ? null : projectId);
2225
+ reportFailures(result);
2226
+ onDone();
2227
+ };
2228
+ const handleDelete = async () => {
2229
+ setConfirmingDelete(false);
2230
+ const result = await bulkDelete(selectedIds);
2231
+ reportFailures(result);
2232
+ onDone();
2233
+ };
2234
+ return /* @__PURE__ */ jsxs("div", {
2235
+ className: "flex flex-wrap items-center gap-2 rounded-lg border border-border bg-card px-3 py-2",
2236
+ "data-tour": "fluidgrids-list-bulk-bar",
2237
+ children: [
2238
+ /* @__PURE__ */ jsx("span", {
2239
+ className: "text-sm font-medium",
2240
+ children: tr("fluidgrids.workflowsList.bulk.selectedCount", "{{count}} selected", { count: selectedIds.length })
2241
+ }),
2242
+ /* @__PURE__ */ jsxs(Select, {
2243
+ onValueChange: (v) => void handleMove(v),
2244
+ disabled: loading,
2245
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
2246
+ className: "h-8 w-40 text-xs",
2247
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: tr("fluidgrids.workflowsList.bulk.moveToFolder", "Move to folder") })
2248
+ }), /* @__PURE__ */ jsxs(SelectContent, { children: [/* @__PURE__ */ jsx(SelectItem, {
2249
+ value: UNFILED_VALUE,
2250
+ children: tr("fluidgrids.workflowsList.bulk.unfiled", "Unfiled")
2251
+ }), flatFolders.map((folder) => /* @__PURE__ */ jsx(SelectItem, {
2252
+ value: folder.id,
2253
+ children: folder.label
2254
+ }, folder.id))] })]
2255
+ }),
2256
+ /* @__PURE__ */ jsxs(Select, {
2257
+ onValueChange: (v) => void handleAssign(v),
2258
+ disabled: loading,
2259
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
2260
+ className: "h-8 w-40 text-xs",
2261
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: tr("fluidgrids.workflowsList.bulk.assignToProject", "Assign to project") })
2262
+ }), /* @__PURE__ */ jsxs(SelectContent, { children: [/* @__PURE__ */ jsx(SelectItem, {
2263
+ value: UNFILED_VALUE,
2264
+ children: tr("fluidgrids.workflowsList.bulk.noProject", "No project")
2265
+ }), projects.map((project) => /* @__PURE__ */ jsx(SelectItem, {
2266
+ value: project.id,
2267
+ children: project.name
2268
+ }, project.id))] })]
2269
+ }),
2270
+ /* @__PURE__ */ jsxs(Button, {
2271
+ variant: "outline",
2272
+ size: "sm",
2273
+ className: "h-8 text-destructive",
2274
+ disabled: loading,
2275
+ onClick: () => setConfirmingDelete(true),
2276
+ children: [/* @__PURE__ */ jsx(Icon, {
2277
+ icon: "mynaui:trash",
2278
+ className: "size-3.5"
2279
+ }), tr("fluidgrids.workflowsList.bulk.delete", "Delete")]
2280
+ }),
2281
+ /* @__PURE__ */ jsx(Button, {
2282
+ variant: "ghost",
2283
+ size: "sm",
2284
+ className: "h-8 ml-auto",
2285
+ onClick: onDone,
2286
+ children: tr("fluidgrids.workflowsList.bulk.cancel", "Cancel")
2287
+ }),
2288
+ /* @__PURE__ */ jsx(AlertDialog, {
2289
+ open: confirmingDelete,
2290
+ onOpenChange: setConfirmingDelete,
2291
+ children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: tr("fluidgrids.workflowsList.bulk.deleteConfirmTitle", "Delete {{count}} workflow(s)?", { count: selectedIds.length }) }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: tr("fluidgrids.workflowsList.bulk.deleteConfirmDescription", "This can't be undone.") })] }), /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, { children: tr("fluidgrids.workflowsList.bulk.cancel", "Cancel") }), /* @__PURE__ */ jsx(AlertDialogAction, {
2292
+ onClick: () => void handleDelete(),
2293
+ children: tr("fluidgrids.workflowsList.bulk.delete", "Delete")
2294
+ })] })] })
2295
+ })
2296
+ ]
2297
+ });
2298
+ }
2299
+ function flattenFolders(folders, depth = 0) {
2300
+ return folders.flatMap((folder) => [{
2301
+ id: folder.id,
2302
+ label: `${"— ".repeat(depth)}${folder.name}`
2303
+ }, ...flattenFolders(folder.children ?? [], depth + 1)]);
2304
+ }
2305
+
2306
+ // src/components/WorkflowMoveToProjectDialog.tsx
2307
+ /**
2308
+ * Move one workflow to another project (BOFF-9726), from its card.
2309
+ *
2310
+ * The service moves every version of the workflow, and a version saved later
2311
+ * keeps the project, so the move is not lost on the next save. "No project"
2312
+ * takes it out of any project.
2313
+ */
2314
+ const NO_PROJECT = "__none__";
2315
+ function WorkflowMoveToProjectDialog({ workflow, onClose, onMoved }) {
2316
+ const tr = useTr();
2317
+ const { projects } = useWorkflowProjects();
2318
+ const { bulkAssignToProject, loading } = useBulkWorkflowActions();
2319
+ const [choice, setChoice] = useState(null);
2320
+ const current = workflow?.projectId ?? NO_PROJECT;
2321
+ const selected = choice ?? current;
2322
+ const close = () => {
2323
+ setChoice(null);
2324
+ onClose();
2325
+ };
2326
+ const move = async () => {
2327
+ if (!workflow) return;
2328
+ const result = await bulkAssignToProject([workflow.id], selected === NO_PROJECT ? null : selected);
2329
+ if (!result || result.failedIds.length > 0) {
2330
+ toast.error(tr("fluidgrids.workflowsList.moveToProject.failed", "The workflow couldn't be moved"));
2331
+ return;
2332
+ }
2333
+ toast.success(tr("fluidgrids.workflowsList.moveToProject.moved", "Workflow moved"));
2334
+ setChoice(null);
2335
+ onMoved?.();
2336
+ onClose();
2337
+ };
2338
+ return /* @__PURE__ */ jsx(Dialog, {
2339
+ open: workflow !== null,
2340
+ onOpenChange: (open) => !open && close(),
2341
+ children: /* @__PURE__ */ jsxs(DialogContent, {
2342
+ "data-testid": "move-to-project-dialog",
2343
+ children: [
2344
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: tr("fluidgrids.workflowsList.moveToProject.title", "Move {{name}} to a project", { name: workflow?.name ?? "" }) }), /* @__PURE__ */ jsx(DialogDescription, { children: tr("fluidgrids.workflowsList.moveToProject.description", "Every version moves, and new versions stay in the project.") })] }),
2345
+ /* @__PURE__ */ jsxs("div", {
2346
+ className: "flex flex-col gap-2",
2347
+ children: [/* @__PURE__ */ jsx(Label, {
2348
+ htmlFor: "move-to-project-select",
2349
+ children: tr("fluidgrids.workflowsList.moveToProject.label", "Project")
2350
+ }), /* @__PURE__ */ jsxs(Select, {
2351
+ value: selected,
2352
+ onValueChange: setChoice,
2353
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
2354
+ id: "move-to-project-select",
2355
+ "data-testid": "move-to-project-select",
2356
+ children: /* @__PURE__ */ jsx(SelectValue, {})
2357
+ }), /* @__PURE__ */ jsxs(SelectContent, { children: [/* @__PURE__ */ jsx(SelectItem, {
2358
+ value: NO_PROJECT,
2359
+ children: tr("fluidgrids.workflowsList.bulk.noProject", "No project")
2360
+ }), projects.map((project) => /* @__PURE__ */ jsx(SelectItem, {
2361
+ value: project.id,
2362
+ children: project.name
2363
+ }, project.id))] })]
2364
+ })]
2365
+ }),
2366
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
2367
+ variant: "outline",
2368
+ onClick: close,
2369
+ disabled: loading,
2370
+ children: tr("fluidgrids.workflowsList.moveToProject.cancel", "Cancel")
2371
+ }), /* @__PURE__ */ jsx(Button, {
2372
+ onClick: () => void move(),
2373
+ disabled: loading || selected === current,
2374
+ "data-testid": "move-to-project-confirm",
2375
+ children: tr("fluidgrids.workflowsList.moveToProject.confirm", "Move")
2376
+ })] })
2377
+ ]
2378
+ })
2379
+ });
2380
+ }
2381
+
2382
+ // src/components/WorkflowDescriptionDialog.tsx
2383
+ /**
2384
+ * Edit a workflow's description from its card in the workflow list
2385
+ * (BOFF-9743). The description of the listed version changes in place: no new
2386
+ * version is created. An empty description clears it.
2387
+ */
2388
+ function WorkflowDescriptionDialog({ workflow, onClose, onSaved }) {
2389
+ return /* @__PURE__ */ jsx(ResponsiveDialog, {
2390
+ open: workflow !== null,
2391
+ onOpenChange: (open) => !open && onClose(),
2392
+ children: workflow && /* @__PURE__ */ jsx(DescriptionForm, {
2393
+ workflow,
2394
+ onClose,
2395
+ onSaved
2396
+ }, workflow.id)
2397
+ });
2398
+ }
2399
+ function DescriptionForm({ workflow, onClose, onSaved }) {
2400
+ const tr = useTr();
2401
+ const shown = visibleWorkflowDescription(workflow.description, workflow.name);
2402
+ const [draft, setDraft] = useState(shown);
2403
+ const [saving, setSaving] = useState(false);
2404
+ const decision = commitWorkflowDescription(shown, draft);
2405
+ const left = workflowDescriptionCharactersLeft(draft);
2406
+ const save = async () => {
2407
+ if (decision.kind !== "save") return;
2408
+ setSaving(true);
2409
+ try {
2410
+ const saved = await saveWorkflowDescription(getFluidGridsClient(), workflow.id, decision.description);
2411
+ toast.success(tr("fluidgrids.workflowsList.editDescription.saved", "Description saved"));
2412
+ onSaved?.(saved.description);
2413
+ onClose();
2414
+ } catch (error) {
2415
+ toast.error(tr("fluidgrids.builder.workflowDescription.saveFailed", "The description couldn't be saved"), { description: describeOperationError(error) });
2416
+ } finally {
2417
+ setSaving(false);
2418
+ }
2419
+ };
2420
+ return /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
2421
+ "data-testid": "workflow-description-dialog",
2422
+ children: [
2423
+ /* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: tr("fluidgrids.workflowsList.editDescription.title", "Describe {{name}}", { name: workflow.name }) }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: tr("fluidgrids.workflowsList.editDescription.help", "Shown under the workflow's name. Saving changes this version in place.") })] }),
2424
+ /* @__PURE__ */ jsxs("div", {
2425
+ className: "flex flex-col gap-2",
2426
+ children: [
2427
+ /* @__PURE__ */ jsx(Label, {
2428
+ htmlFor: "workflow-description-input",
2429
+ children: tr("fluidgrids.builder.workflowDescription.label", "Workflow description")
2430
+ }),
2431
+ /* @__PURE__ */ jsx(Textarea, {
2432
+ id: "workflow-description-input",
2433
+ "data-testid": "workflow-description-input",
2434
+ autoFocus: true,
2435
+ rows: 4,
2436
+ maxLength: 500,
2437
+ placeholder: tr("fluidgrids.builder.workflowDescription.placeholder", "What does this workflow do?"),
2438
+ value: draft,
2439
+ onChange: (event) => setDraft(event.target.value),
2440
+ onKeyDown: (event) => {
2441
+ if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
2442
+ event.preventDefault();
2443
+ save();
2444
+ }
2445
+ },
2446
+ className: "resize-none"
2447
+ }),
2448
+ /* @__PURE__ */ jsxs("span", {
2449
+ "data-testid": "workflow-description-counter",
2450
+ className: cn("self-end text-xs tabular-nums text-muted-foreground", left < 0 && "text-destructive"),
2451
+ children: [
2452
+ 500 - left,
2453
+ "/",
2454
+ 500
2455
+ ]
2456
+ })
2457
+ ]
2458
+ }),
2459
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
2460
+ variant: "outline",
2461
+ onClick: onClose,
2462
+ disabled: saving,
2463
+ children: tr("fluidgrids.workflowsList.moveToProject.cancel", "Cancel")
2464
+ }), /* @__PURE__ */ jsx(Button, {
2465
+ onClick: () => void save(),
2466
+ disabled: saving || decision.kind !== "save",
2467
+ "aria-busy": saving,
2468
+ "data-testid": "workflow-description-save",
2469
+ children: tr("fluidgrids.workflowsList.editDescription.save", "Save")
2470
+ })] })
2471
+ ]
2472
+ });
2473
+ }
2474
+
2475
+ // src/components/createWorkflowName.ts
2476
+ /**
2477
+ * Name handling for the "New workflow" dialog (Navigation v2, BOFF-11843),
2478
+ * kept out of the component file so Fast Refresh can preserve its state.
2479
+ */
2480
+ /** The name to create with, or null when the form cannot be submitted. */
2481
+ function workflowNameFromInput(value) {
2482
+ const name = value.trim();
2483
+ return name ? name : null;
2484
+ }
2485
+
2486
+ // src/components/CreateWorkflowNameDialog.tsx
2487
+ /**
2488
+ * "New workflow" asks for a name (Navigation v2, BOFF-11843).
2489
+ *
2490
+ * The name is the only required step. Starting from a template is one click
2491
+ * away ("Browse templates"), never a question asked first. Creating still runs
2492
+ * `useCreateWorkflowFirst`: the workflow is created, then the builder opens; a
2493
+ * refusal (a plan limit, a permission) keeps the person on the list, where the
2494
+ * caller's refusal dialog explains it.
2495
+ */
2496
+ function CreateWorkflowNameDialog({ open, onOpenChange, onCreate, creating, templatesHref }) {
2497
+ return /* @__PURE__ */ jsx(ResponsiveDialog, {
2498
+ open,
2499
+ onOpenChange,
2500
+ children: /* @__PURE__ */ jsx(ResponsiveDialogContent, {
2501
+ className: "sm:max-w-md",
2502
+ "data-testid": "create-workflow-name-dialog",
2503
+ children: /* @__PURE__ */ jsx(CreateWorkflowNameForm, {
2504
+ onOpenChange,
2505
+ onCreate,
2506
+ creating,
2507
+ templatesHref
2508
+ })
2509
+ })
2510
+ });
2511
+ }
2512
+ function CreateWorkflowNameForm({ onOpenChange, onCreate, creating, templatesHref }) {
2513
+ const tr = useTr();
2514
+ const id = useId();
2515
+ const inputId = `${id}-name`;
2516
+ const errorId = `${id}-error`;
2517
+ const [value, setValue] = useState("");
2518
+ const [showError, setShowError] = useState(false);
2519
+ const submit = (event) => {
2520
+ event.preventDefault();
2521
+ const name = workflowNameFromInput(value);
2522
+ if (!name) {
2523
+ setShowError(true);
2524
+ return;
2525
+ }
2526
+ onCreate(name);
2527
+ };
2528
+ return /* @__PURE__ */ jsxs("form", {
2529
+ onSubmit: submit,
2530
+ noValidate: true,
2531
+ className: "space-y-4",
2532
+ children: [
2533
+ /* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: tr("fluidgrids.workflowsList.createDialog.title", "New workflow") }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: tr("fluidgrids.workflowsList.createDialog.description", "Give it a name. You can change it later.") })] }),
2534
+ /* @__PURE__ */ jsxs("div", {
2535
+ className: "space-y-1.5",
2536
+ children: [
2537
+ /* @__PURE__ */ jsx(Label, {
2538
+ htmlFor: inputId,
2539
+ children: tr("fluidgrids.workflowsList.createDialog.nameLabel", "Name")
2540
+ }),
2541
+ /* @__PURE__ */ jsx(Input, {
2542
+ id: inputId,
2543
+ autoFocus: true,
2544
+ required: true,
2545
+ value,
2546
+ placeholder: tr("fluidgrids.workflowsList.createDialog.namePlaceholder", "e.g. Daily sales report"),
2547
+ "aria-invalid": showError ? true : void 0,
2548
+ "aria-describedby": showError ? errorId : void 0,
2549
+ onChange: (event) => {
2550
+ setValue(event.target.value);
2551
+ if (event.target.value.trim()) setShowError(false);
2552
+ },
2553
+ "data-testid": "create-workflow-name-input"
2554
+ }),
2555
+ showError && /* @__PURE__ */ jsx("p", {
2556
+ id: errorId,
2557
+ className: "text-xs text-destructive",
2558
+ role: "alert",
2559
+ children: tr("fluidgrids.workflowsList.createDialog.nameRequired", "Give the workflow a name.")
2560
+ })
2561
+ ]
2562
+ }),
2563
+ /* @__PURE__ */ jsxs("p", {
2564
+ className: "text-sm text-muted-foreground",
2565
+ children: [
2566
+ tr("fluidgrids.workflowsList.createDialog.templatesHint", "Want a head start?"),
2567
+ " ",
2568
+ /* @__PURE__ */ jsxs(Link, {
2569
+ to: templatesHref,
2570
+ className: "inline-flex min-h-11 items-center gap-1 font-medium text-primary underline-offset-4 hover:underline",
2571
+ "data-testid": "create-workflow-browse-templates",
2572
+ onClick: () => onOpenChange(false),
2573
+ children: [/* @__PURE__ */ jsx(Icon, {
2574
+ icon: "mynaui:grid",
2575
+ className: "size-4",
2576
+ "aria-hidden": "true"
2577
+ }), tr("fluidgrids.workflowsList.browseTemplates", "Browse templates")]
2578
+ })
2579
+ ]
2580
+ }),
2581
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
2582
+ type: "button",
2583
+ variant: "outline",
2584
+ className: "min-h-11",
2585
+ onClick: () => onOpenChange(false),
2586
+ children: tr("fluidgrids.workflowsList.createDialog.cancel", "Cancel")
2587
+ }), /* @__PURE__ */ jsx(Button, {
2588
+ type: "submit",
2589
+ className: "min-h-11",
2590
+ disabled: creating,
2591
+ "aria-busy": creating,
2592
+ "data-testid": "create-workflow-name-submit",
2593
+ children: creating ? tr("fluidgrids.workflowsList.createDialog.creating", "Creating…") : tr("fluidgrids.workflowsList.createDialog.create", "Create")
2594
+ })] })
2595
+ ]
2596
+ });
2597
+ }
2598
+
2599
+ // src/onboarding/firstWorkflowSteps.tsx
2600
+ /** The first-workflow checklist steps, from progress and the handlers. */
2601
+ function firstWorkflowSteps({ progress, canCreate, onCreate, onOpen, onTemplates, tr }) {
2602
+ const { runTarget, activateTarget } = progress;
2603
+ return [
2604
+ {
2605
+ id: "create",
2606
+ label: tr("fluidgrids.onboarding.createLabel", "Build your first workflow, with a guided tour"),
2607
+ description: tr("fluidgrids.onboarding.createDescription", "Opens a new draft in the builder and walks you through adding a trigger, connecting nodes and saving."),
2608
+ icon: /* @__PURE__ */ jsx(Icon, {
2609
+ icon: "mynaui:plus",
2610
+ className: "size-4",
2611
+ "aria-hidden": "true"
2612
+ }),
2613
+ done: progress.created,
2614
+ onClick: !progress.created && canCreate ? onCreate : void 0
2615
+ },
2616
+ {
2617
+ id: "run",
2618
+ label: tr("fluidgrids.onboarding.runLabel", "Run it once to test"),
2619
+ description: tr("fluidgrids.onboarding.runDescription", "Press Run in the builder. Every execution shows up in Runs with a step-by-step timeline and logs."),
2620
+ icon: /* @__PURE__ */ jsx(Icon, {
2621
+ icon: "mdi:play-circle-outline",
2622
+ className: "size-4",
2623
+ "aria-hidden": "true"
2624
+ }),
2625
+ done: progress.ran,
2626
+ onClick: !progress.ran && runTarget ? () => onOpen(runTarget) : void 0
2627
+ },
2628
+ {
2629
+ id: "activate",
2630
+ label: tr("fluidgrids.onboarding.activateLabel", "Activate it to go live"),
2631
+ description: tr("fluidgrids.onboarding.activateDescription", "An active workflow answers its webhooks, schedules and other automatic triggers."),
2632
+ icon: /* @__PURE__ */ jsx(Icon, {
2633
+ icon: "mdi:lightning-bolt-outline",
2634
+ className: "size-4",
2635
+ "aria-hidden": "true"
2636
+ }),
2637
+ done: progress.activated,
2638
+ onClick: !progress.activated && activateTarget ? () => onOpen(activateTarget) : void 0
2639
+ },
2640
+ {
2641
+ id: "templates",
2642
+ label: tr("fluidgrids.onboarding.templatesLabel", "Or start from a template"),
2643
+ description: tr("fluidgrids.onboarding.templatesDescription", "Pick a pre-built workflow and adapt it instead of starting from a blank canvas."),
2644
+ icon: /* @__PURE__ */ jsx(Icon, {
2645
+ icon: "mynaui:layers-three",
2646
+ className: "size-4",
2647
+ "aria-hidden": "true"
2648
+ }),
2649
+ done: progress.created,
2650
+ onClick: progress.created ? void 0 : onTemplates
2651
+ }
2652
+ ];
2653
+ }
2654
+
2655
+ // src/onboarding/FirstWorkflowChecklist.tsx
2656
+ /** The checklist itself; hidden once every step is done. */
2657
+ function FirstWorkflowChecklistView(props) {
2658
+ const { progress, tr } = props;
2659
+ if (progress.complete) return null;
2660
+ return /* @__PURE__ */ jsx("div", {
2661
+ "data-tour": "fluidgrids-list-onboarding",
2662
+ children: /* @__PURE__ */ jsx(NextSteps, {
2663
+ storageKey: "fluidgrids-first-workflow",
2664
+ title: tr("fluidgrids.onboarding.title", "Get started with your first workflow"),
2665
+ steps: firstWorkflowSteps(props)
2666
+ })
2667
+ });
2668
+ }
2669
+ function useChecklistHandlers() {
2670
+ const navigate = useNavigate();
2671
+ const createFirst = useCreateWorkflowFirst({ state: GUIDED_TOUR_STATE });
2672
+ const { start } = createFirst;
2673
+ return {
2674
+ handlers: useMemo(() => ({
2675
+ onCreate: () => void start(),
2676
+ onOpen: (workflow) => navigate(builderPathFor(workflow)),
2677
+ onTemplates: () => navigate("../templates")
2678
+ }), [navigate, start]),
2679
+ refusalDialog: /* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
2680
+ surface: "builder-create",
2681
+ refusal: createFirst.refusal,
2682
+ onClose: createFirst.clearRefusal,
2683
+ onUpgrade: () => navigate(BILLING_PLANS_PATH)
2684
+ })
2685
+ };
2686
+ }
2687
+ /** With workflows: reads the run count (one row) to know whether one ran. */
2688
+ function ChecklistReadingRuns({ workflows, canCreate }) {
2689
+ const { total, loading, error } = useExecutions({ limit: 1 });
2690
+ return /* @__PURE__ */ jsx(ChecklistWithRuns, {
2691
+ workflows,
2692
+ canCreate,
2693
+ runsTotal: loading || error ? null : total,
2694
+ loading
2695
+ });
2696
+ }
2697
+ /** With workflows and a run count (or none yet, while it loads). */
2698
+ function ChecklistWithRuns({ workflows, canCreate, runsTotal, loading }) {
2699
+ const tr = useTr();
2700
+ const { handlers, refusalDialog } = useChecklistHandlers();
2701
+ const progress = useMemo(() => firstWorkflowProgress(workflows, runsTotal), [workflows, runsTotal]);
2702
+ const undecided = useLoadingSystem() && loading && progress.activated;
2703
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [undecided ? null : /* @__PURE__ */ jsx(FirstWorkflowChecklistView, {
2704
+ progress,
2705
+ canCreate,
2706
+ tr,
2707
+ ...handlers
2708
+ }), refusalDialog] });
2709
+ }
2710
+ /** No workflows yet: nothing can have run, so no runs request is made. */
2711
+ function ChecklistWithoutWorkflows({ canCreate }) {
2712
+ const tr = useTr();
2713
+ const { handlers, refusalDialog } = useChecklistHandlers();
2714
+ const progress = useMemo(() => firstWorkflowProgress([], 0), []);
2715
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FirstWorkflowChecklistView, {
2716
+ progress,
2717
+ canCreate,
2718
+ tr,
2719
+ ...handlers
2720
+ }), refusalDialog] });
2721
+ }
2722
+ /**
2723
+ * First-workflow onboarding checklist for the Workflows list (parity G21).
2724
+ * Render it only once the list has loaded without error.
2725
+ */
2726
+ function FirstWorkflowChecklist({ workflows, canCreate, runsTotal }) {
2727
+ if (workflows.length === 0) return /* @__PURE__ */ jsx(ChecklistWithoutWorkflows, { canCreate });
2728
+ if (typeof runsTotal === "number") return /* @__PURE__ */ jsx(ChecklistWithRuns, {
2729
+ workflows,
2730
+ canCreate,
2731
+ runsTotal,
2732
+ loading: false
2733
+ });
2734
+ return /* @__PURE__ */ jsx(ChecklistReadingRuns, {
2735
+ workflows,
2736
+ canCreate
2737
+ });
2738
+ }
2739
+
2740
+ // src/pages/workflowsListUrlState.ts
2741
+ /**
2742
+ * URL-driven filter state for the workflows list (BOFF-10854).
2743
+ *
2744
+ * The access, status and folder filters live in the query string so the
2745
+ * shell's navigation ("Shared with me", "Archived", a folder) can link
2746
+ * straight to a filtered list, and a filtered list survives reload and
2747
+ * back/forward. Supported values:
2748
+ *
2749
+ * ?access=mine | shared (absent or "all" = every visible workflow)
2750
+ * ?status=active | draft | archived | deprecated (absent = any status)
2751
+ * ?folder=<folder id> (absent = all folders)
2752
+ * ?mode=deterministic | agentic | hybrid (absent = any run mode, BOFF-9955)
2753
+ *
2754
+ * Unknown values fall back to the default rather than erroring. Writes use
2755
+ * history replace, so toggling chips does not flood the back stack, and a
2756
+ * default value removes its parameter so plain `/workflows/list` stays clean.
2757
+ */
2758
+ const WORKFLOWS_LIST_PARAMS = {
2759
+ access: "access",
2760
+ status: "status",
2761
+ folder: "folder",
2762
+ mode: "mode"
2763
+ };
2764
+ /** The workflow statuses the list's status chips offer. */
2765
+ const WORKFLOW_LIST_STATUSES = [
2766
+ "ACTIVE",
2767
+ "DRAFT",
2768
+ "ARCHIVED",
2769
+ "DEPRECATED"
2770
+ ];
2771
+ const ACCESS_BY_PARAM = {
2772
+ all: "ALL",
2773
+ mine: "OWNED_BY_ME",
2774
+ shared: "SHARED_WITH_ME"
2775
+ };
2776
+ const PARAM_BY_ACCESS = {
2777
+ ["ALL"]: null,
2778
+ ["OWNED_BY_ME"]: "mine",
2779
+ ["SHARED_WITH_ME"]: "shared"
2780
+ };
2781
+ function accessFromParam(value) {
2782
+ if (!value) return "ALL";
2783
+ return ACCESS_BY_PARAM[value.trim().toLowerCase()] ?? "ALL";
2784
+ }
2785
+ function accessToParam(access) {
2786
+ return PARAM_BY_ACCESS[access];
2787
+ }
2788
+ function isWorkflowListStatus(value) {
2789
+ return WORKFLOW_LIST_STATUSES.includes(value);
2790
+ }
2791
+ /** `archived` / `ARCHIVED` → `ARCHIVED`; anything unknown → no filter. */
2792
+ function statusFromParam(value) {
2793
+ if (!value) return null;
2794
+ const upper = value.trim().toUpperCase();
2795
+ return isWorkflowListStatus(upper) ? upper : null;
2796
+ }
2797
+ function statusToParam(status) {
2798
+ if (!status) return null;
2799
+ const upper = status.toUpperCase();
2800
+ return isWorkflowListStatus(upper) ? upper.toLowerCase() : null;
2801
+ }
2802
+ function folderFromParam(value) {
2803
+ const trimmed = value?.trim();
2804
+ return trimmed ? trimmed : null;
2805
+ }
2806
+ /** `agentic` / `AGENTIC` → AGENTIC (BOFF-9955); anything unknown → no filter. */
2807
+ function modeFromParam(value) {
2808
+ if (!value) return null;
2809
+ const upper = value.trim().toUpperCase();
2810
+ return isExecutionMode(upper) ? upper : null;
2811
+ }
2812
+ function modeToParam(mode) {
2813
+ return mode ? mode.toLowerCase() : null;
2814
+ }
2815
+ /**
2816
+ * Applies a filter patch to a copy of `params`. Keys missing from the patch
2817
+ * are left untouched; default values delete their parameter. Unrelated
2818
+ * parameters (e.g. `?action=`) are preserved.
2819
+ */
2820
+ function applyFilterPatch(params, patch) {
2821
+ const next = new URLSearchParams(params);
2822
+ const write = (key, value) => {
2823
+ if (value === null) next.delete(key);
2824
+ else next.set(key, value);
2825
+ };
2826
+ if (patch.access !== void 0) write(WORKFLOWS_LIST_PARAMS.access, accessToParam(patch.access));
2827
+ if (patch.status !== void 0) write(WORKFLOWS_LIST_PARAMS.status, statusToParam(patch.status));
2828
+ if (patch.folder !== void 0) write(WORKFLOWS_LIST_PARAMS.folder, folderFromParam(patch.folder));
2829
+ if (patch.mode !== void 0) write(WORKFLOWS_LIST_PARAMS.mode, modeToParam(patch.mode));
2830
+ return next;
2831
+ }
2832
+ function useWorkflowsListUrlState() {
2833
+ const [searchParams, setSearchParams] = useSearchParams();
2834
+ const access = accessFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.access));
2835
+ const status = statusFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.status));
2836
+ const folder = folderFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.folder));
2837
+ const mode = modeFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.mode));
2838
+ const update = useCallback((patch) => {
2839
+ setSearchParams((prev) => applyFilterPatch(prev, patch), { replace: true });
2840
+ }, [setSearchParams]);
2841
+ return useMemo(() => ({
2842
+ access,
2843
+ status,
2844
+ folder,
2845
+ mode,
2846
+ update,
2847
+ setAccess: (next) => update({ access: next }),
2848
+ setStatus: (next) => update({ status: next }),
2849
+ setFolder: (next) => update({ folder: next }),
2850
+ setMode: (next) => update({ mode: next })
2851
+ }), [
2852
+ access,
2853
+ status,
2854
+ folder,
2855
+ mode,
2856
+ update
2857
+ ]);
2858
+ }
2859
+
2860
+ // src/pages/workflows-list/pageOperation.ts
2861
+ /**
2862
+ * The Workflows list page operation (BOFF-16424, GQL-05).
2863
+ *
2864
+ * WorkflowsListPage (src/operations/workflows/queries/workflowsListPage.graphql)
2865
+ * reads in one request what the page draws on first paint: the rows, the
2866
+ * folder tree, the projects and the run count. It is composed from the
2867
+ * fragments the components own (WorkflowsListRow, WorkflowFolderTreeFields,
2868
+ * WorkflowProjectFields), so the folder and project readers find the answer in
2869
+ * the cache and do not send their own request (`PageOperationContext`). Later
2870
+ * pages, filter changes and refetches read the rows alone (WorkflowsListRows).
2871
+ */
2872
+ function runsTotalOf(data) {
2873
+ const total = data?.workflowRunsCount?.total;
2874
+ return typeof total === "number" ? total : null;
2875
+ }
2876
+ function useWorkflowsListPageOperation() {
2877
+ const [answer, setAnswer] = useState({
2878
+ settled: false,
2879
+ runsTotal: null
2880
+ });
2881
+ const onPageSettled = useCallback((data) => {
2882
+ setAnswer({
2883
+ settled: true,
2884
+ runsTotal: runsTotalOf(data)
2885
+ });
2886
+ }, []);
2887
+ return {
2888
+ documents: useMemo(() => ({
2889
+ page: WorkflowsListPageDocument,
2890
+ rows: WorkflowsListRowsDocument,
2891
+ onPageSettled
2892
+ }), [onPageSettled]),
2893
+ state: useMemo(() => ({ settled: answer.settled }), [answer.settled]),
2894
+ runsTotal: answer.runsTotal
2895
+ };
2896
+ }
2897
+
2898
+ // src/pages/workflows-list/WorkflowLastRunCell.tsx
2899
+ /**
2900
+ * The Workflows list's "Last run" cell (BOFF-16424): the status and the time
2901
+ * of the workflow's newest run, from the `latestRun` the list reads with its
2902
+ * rows (WorkflowsListLastRun fragment), or a dash when it has never run.
2903
+ */
2904
+ function isRunStatus(status) {
2905
+ return Object.hasOwn(RUN_STATUS_CONFIG, status);
2906
+ }
2907
+ /** When the run last moved: finished, else started, else queued. */
2908
+ function lastRunTime(run) {
2909
+ return run.completedAt ?? run.startedAt ?? run.createdAt;
2910
+ }
2911
+ function WorkflowLastRunCell({ run }) {
2912
+ const tr = useTr();
2913
+ if (!run) {
2914
+ const none = tr("fluidgrids.workflowsList.table.lastRunNone", "No runs yet");
2915
+ return /* @__PURE__ */ jsxs("span", {
2916
+ className: "text-sm text-muted-foreground",
2917
+ title: none,
2918
+ "data-testid": "workflow-last-run-none",
2919
+ children: [/* @__PURE__ */ jsx("span", {
2920
+ "aria-hidden": "true",
2921
+ children: "—"
2922
+ }), /* @__PURE__ */ jsx("span", {
2923
+ className: "sr-only",
2924
+ children: none
2925
+ })]
2926
+ });
2927
+ }
2928
+ const at = lastRunTime(run);
2929
+ return /* @__PURE__ */ jsxs("span", {
2930
+ className: "inline-flex items-center gap-2 text-sm text-muted-foreground",
2931
+ "data-testid": "workflow-last-run",
2932
+ children: [/* @__PURE__ */ jsx(ExecutionStatusBadge, {
2933
+ status: isRunStatus(run.status) ? run.status : "PENDING",
2934
+ size: "sm",
2935
+ animated: false
2936
+ }), /* @__PURE__ */ jsx("span", {
2937
+ className: "whitespace-nowrap",
2938
+ title: formatExactTime(at),
2939
+ children: formatRelativeTime(tr, at)
2940
+ })]
2941
+ });
2942
+ }
2943
+
2944
+ // src/pages/useLoadAllWhileFiltering.ts
2945
+ /**
2946
+ * My Workflows (v2): folder, tag, project and the search box filter the LOADED
2947
+ * rows, because the service pages the list (100 a page) and cannot apply them
2948
+ * (BOFF-11843 review). While one is set, the rest of the pages are loaded, so a
2949
+ * folder opened from the sidebar shows its workflows even when they are not on
2950
+ * the first page, and "No workflows match your filters" waits until every page
2951
+ * is in.
2952
+ */
2953
+ function useLoadAllWhileFiltering({ filtered, hasMore, loading, loadingMore, loadMoreError, loadMore }) {
2954
+ useEffect(() => {
2955
+ if (filtered && hasMore && !loading && !loadingMore && !loadMoreError) loadMore();
2956
+ }, [
2957
+ filtered,
2958
+ hasMore,
2959
+ loading,
2960
+ loadingMore,
2961
+ loadMoreError,
2962
+ loadMore
2963
+ ]);
2964
+ return {
2965
+ clientFiltered: filtered,
2966
+ /** Filtered rows may still be on pages not loaded yet. */
2967
+ filteringMore: filtered && (hasMore && !loadMoreError || loadingMore)
2968
+ };
2969
+ }
2970
+
2971
+ // src/builder/components/rpa/recording-review/index.tsx
2972
+ /**
2973
+ * New › Record a task, loaded on first use (RPA plan P1-12): the dialog
2974
+ * brings `@burdenoff/ui-engine` and the builder's node registry, which My
2975
+ * Workflows never needs otherwise. This file must not import either
2976
+ * statically; `check-builder-chunks` fails the build if the workflows-list
2977
+ * entry reaches the engine or the canvas without a dynamic import.
2978
+ */
2979
+ const RecordTaskDialog = lazy(() => import("./RecordTaskDialog-BkpCDvhR.js").then((n) => n.n));
2980
+ /** The Record a task dialog; nothing loads until it first opens. */
2981
+ function LazyRecordTaskDialog(props) {
2982
+ if (!props.open) return null;
2983
+ return /* @__PURE__ */ jsx(Suspense, {
2984
+ fallback: null,
2985
+ children: /* @__PURE__ */ jsx(RecordTaskDialog, { ...props })
2986
+ });
2987
+ }
2988
+
2989
+ // src/pages/workflows-list/serverFilters.ts
2990
+ /** The service's status for each status chip. */
2991
+ const SERVER_WORKFLOW_STATUS = {
2992
+ ACTIVE: "ACTIVE",
2993
+ DRAFT: "DRAFT",
2994
+ ARCHIVED: "ARCHIVED",
2995
+ DEPRECATED: "DEPRECATED"
2996
+ };
2997
+ /** The filter part of the list input; a filter left at its default is not sent. */
2998
+ function workflowsListServerInput(filters) {
2999
+ const search = filters.search.trim();
3000
+ return {
3001
+ ...filters.access === "ALL" ? {} : { access: filters.access },
3002
+ ...filters.mode ? { executionMode: filters.mode } : {},
3003
+ ...filters.status ? { status: SERVER_WORKFLOW_STATUS[filters.status] } : {},
3004
+ ...filters.folder ? { folderId: filters.folder } : {},
3005
+ ...filters.project ? { projectId: filters.project } : {},
3006
+ ...search ? { search } : {},
3007
+ ...filters.tag ? { tagIds: [filters.tag] } : {}
3008
+ };
3009
+ }
3010
+ /** True when any filter narrows the list, so an empty answer is "no match", not "no workflows". */
3011
+ function hasWorkflowsListFilter(filters) {
3012
+ return Object.keys(workflowsListServerInput(filters)).length > 0;
3013
+ }
3014
+ /**
3015
+ * The search that decides whether the list counts as filtered. The live box
3016
+ * value wins once it holds text; while it is blank (or only spaces) the
3017
+ * debounced value still filtering the shown rows counts, so clearing the box
3018
+ * does not flash the "no workflows" state before the list refetches.
3019
+ */
3020
+ function pendingSearch(live, settled) {
3021
+ return live.trim() ? live : settled;
3022
+ }
3023
+
3024
+ // src/pages/workflows-list/WorkflowsLoadMore.tsx
3025
+ /**
3026
+ * "Load more" under the workflows list (BOFF-11843): the list used to stop at
3027
+ * its first 100 workflows. Shown only while the server says more exist, with
3028
+ * how many are shown out of how many, and why a page did not load.
3029
+ */
3030
+ function WorkflowsLoadMore({ hasMore, loadingMore, error, shown, total, onLoadMore }) {
3031
+ const tr = useTr();
3032
+ if (!hasMore) return null;
3033
+ return /* @__PURE__ */ jsxs("div", {
3034
+ className: "flex flex-col items-center gap-2 py-2",
3035
+ "data-testid": "workflows-load-more",
3036
+ children: [
3037
+ /* @__PURE__ */ jsx("p", {
3038
+ className: "text-xs text-muted-foreground",
3039
+ "aria-live": "polite",
3040
+ children: tr("fluidgrids.workflowsList.shownOfTotal", "Showing {{shown}} of {{total}} workflows", {
3041
+ shown: String(shown),
3042
+ total: String(Math.max(total, shown))
3043
+ })
3044
+ }),
3045
+ error && /* @__PURE__ */ jsx("p", {
3046
+ className: "text-xs text-destructive",
3047
+ role: "alert",
3048
+ children: tr("fluidgrids.workflowsList.loadMoreFailed", "Couldn't load more workflows. Try again.")
3049
+ }),
3050
+ /* @__PURE__ */ jsx(Button, {
3051
+ variant: "outline",
3052
+ className: "min-h-11",
3053
+ onClick: onLoadMore,
3054
+ disabled: loadingMore,
3055
+ "aria-busy": loadingMore,
3056
+ children: loadingMore ? tr("fluidgrids.workflowsList.loadingMore", "Loading…") : tr("fluidgrids.workflowsList.loadMore", "Load more")
3057
+ })
3058
+ ]
3059
+ });
3060
+ }
3061
+
3062
+ // src/pages/workflows-list/WorkflowRowMenu.tsx
3063
+ /**
3064
+ * A workflow row's actions on My Workflows (Navigation v2, BOFF-11843).
3065
+ *
3066
+ * Visible: Edit. Under "⋯": Duplicate and Delete, then a "More options"
3067
+ * submenu with Settings, Download a copy, Move to project, Edit description
3068
+ * and Share, and last the version, alias and version count as read-only
3069
+ * information. Every item is shown only to people who may do it (the same
3070
+ * checks the card used); Share keeps exactly today's dialog and its check.
3071
+ * Both buttons are at least 44px, so they are easy to hit on a phone.
3072
+ */
3073
+ function WorkflowRowMenu({ workflow, actions, downloading = false }) {
3074
+ const tr = useTr();
3075
+ const canCreate = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE).allowed;
3076
+ const canUpdate = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_UPDATE).allowed;
3077
+ const canDelete = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_DELETE).allowed;
3078
+ const canShare = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_SHARE).allowed;
3079
+ const editable = canEditWorkflow(workflow.myAccess);
3080
+ const shareable = canShareWorkflow(workflow.myAccess);
3081
+ const editLabel = tr("fluidgrids.workflowsList.row.edit", "Edit");
3082
+ const menuLabel = tr("fluidgrids.workflowsList.row.moreActions", "More actions for {{name}}", { name: workflow.name });
3083
+ const versionInfo = [tr("fluidgrids.workflowsList.row.version", "Version {{version}}", { version: workflow.version }), workflow.alias ? `(${workflow.alias})` : null].filter(Boolean).join(" ");
3084
+ const versionCount = workflow.totalVersions && workflow.totalVersions > 1 ? tr("fluidgrids.workflowsList.row.versionCount", "{{count}} versions", { count: String(workflow.totalVersions) }) : null;
3085
+ const downloadLabel = tr("fluidgrids.builder.cardWorkflow.exportWorkflow", "Export workflow JSON");
3086
+ return /* @__PURE__ */ jsxs("div", {
3087
+ className: "flex items-center gap-1",
3088
+ children: [/* @__PURE__ */ jsx(Button, {
3089
+ variant: "outline",
3090
+ size: "sm",
3091
+ className: "min-h-11 min-w-11",
3092
+ onClick: actions.onEdit,
3093
+ "aria-label": tr("fluidgrids.workflowsList.row.editAriaLabel", "Edit {{name}}", { name: workflow.name }),
3094
+ "data-testid": "workflow-row-edit",
3095
+ children: editLabel
3096
+ }), /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
3097
+ asChild: true,
3098
+ children: /* @__PURE__ */ jsx(Button, {
3099
+ variant: "ghost",
3100
+ size: "icon",
3101
+ className: "size-11",
3102
+ "aria-label": menuLabel,
3103
+ title: menuLabel,
3104
+ "data-testid": "workflow-row-menu",
3105
+ children: /* @__PURE__ */ jsx(Icon, {
3106
+ icon: "mdi:dots-horizontal",
3107
+ className: "size-5"
3108
+ })
3109
+ })
3110
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
3111
+ align: "end",
3112
+ className: "min-w-56",
3113
+ children: [
3114
+ /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [canCreate && /* @__PURE__ */ jsxs(DropdownMenuItem, {
3115
+ className: "min-h-11",
3116
+ onSelect: actions.onDuplicate,
3117
+ "data-testid": "workflow-row-menu-duplicate",
3118
+ children: [/* @__PURE__ */ jsx(Icon, {
3119
+ icon: "mynaui:copy",
3120
+ className: "mr-2 size-4"
3121
+ }), tr("fluidgrids.builder.cardWorkflow.duplicateWorkflow", "Duplicate workflow")]
3122
+ }), editable && canDelete && /* @__PURE__ */ jsxs(DropdownMenuItem, {
3123
+ className: "min-h-11 text-destructive focus:text-destructive",
3124
+ onSelect: actions.onDelete,
3125
+ "data-testid": "workflow-row-menu-delete",
3126
+ children: [/* @__PURE__ */ jsx(Icon, {
3127
+ icon: "mynaui:trash",
3128
+ className: "mr-2 size-4"
3129
+ }), tr("fluidgrids.builder.cardWorkflow.deleteWorkflow", "Delete workflow")]
3130
+ })] }),
3131
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
3132
+ /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [/* @__PURE__ */ jsxs(DropdownMenuSubTrigger, {
3133
+ className: "min-h-11",
3134
+ "data-testid": "workflow-row-menu-more",
3135
+ children: [/* @__PURE__ */ jsx(Icon, {
3136
+ icon: "mdi:tune-variant",
3137
+ className: "mr-2 size-4"
3138
+ }), tr("fluidgrids.builder.cardWorkflow.workflowSettings", "Workflow settings")]
3139
+ }), /* @__PURE__ */ jsxs(DropdownMenuSubContent, {
3140
+ className: "min-w-56",
3141
+ children: [
3142
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
3143
+ className: "min-h-11",
3144
+ onSelect: actions.onSettings,
3145
+ "data-testid": "workflow-row-menu-settings",
3146
+ children: [/* @__PURE__ */ jsx(Icon, {
3147
+ icon: "mdi:cog-outline",
3148
+ className: "mr-2 size-4"
3149
+ }), tr("fluidgrids.workflowsList.row.settings", "Settings")]
3150
+ }),
3151
+ actions.onDownloadAs ? /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [/* @__PURE__ */ jsxs(DropdownMenuSubTrigger, {
3152
+ className: "min-h-11",
3153
+ disabled: downloading,
3154
+ "data-testid": "workflow-row-menu-download",
3155
+ children: [/* @__PURE__ */ jsx(Icon, {
3156
+ icon: "mynaui:download",
3157
+ className: "mr-2 size-4"
3158
+ }), downloadLabel]
3159
+ }), /* @__PURE__ */ jsx(DropdownMenuSubContent, { children: CODE_EXPORT_FORMATS.map((format) => /* @__PURE__ */ jsx(DropdownMenuItem, {
3160
+ className: "min-h-11",
3161
+ onSelect: () => actions.onDownloadAs?.(format),
3162
+ "data-testid": `workflow-row-menu-download-${format.toLowerCase()}`,
3163
+ children: exportFormatLabel(tr, format)
3164
+ }, format)) })] }) : /* @__PURE__ */ jsxs(DropdownMenuItem, {
3165
+ className: "min-h-11",
3166
+ onSelect: actions.onDownload,
3167
+ disabled: downloading,
3168
+ "data-testid": "workflow-row-menu-download",
3169
+ children: [/* @__PURE__ */ jsx(Icon, {
3170
+ icon: "mynaui:download",
3171
+ className: "mr-2 size-4"
3172
+ }), downloadLabel]
3173
+ }),
3174
+ editable && canUpdate && /* @__PURE__ */ jsxs(DropdownMenuItem, {
3175
+ className: "min-h-11",
3176
+ onSelect: actions.onMoveToProject,
3177
+ "data-testid": "workflow-row-menu-move",
3178
+ children: [/* @__PURE__ */ jsx(Icon, {
3179
+ icon: "mdi:folder-move-outline",
3180
+ className: "mr-2 size-4"
3181
+ }), tr("fluidgrids.builder.cardWorkflow.moveToProject", "Move to project")]
3182
+ }),
3183
+ editable && canUpdate && /* @__PURE__ */ jsxs(DropdownMenuItem, {
3184
+ className: "min-h-11",
3185
+ onSelect: actions.onEditDescription,
3186
+ "data-testid": "workflow-row-menu-description",
3187
+ children: [/* @__PURE__ */ jsx(Icon, {
3188
+ icon: "mdi:text-box-edit-outline",
3189
+ className: "mr-2 size-4"
3190
+ }), tr("fluidgrids.builder.cardWorkflow.editDescription", "Edit description")]
3191
+ }),
3192
+ shareable && canShare && /* @__PURE__ */ jsxs(DropdownMenuItem, {
3193
+ className: "min-h-11",
3194
+ onSelect: actions.onShare,
3195
+ "data-testid": "workflow-row-menu-share",
3196
+ children: [/* @__PURE__ */ jsx(Icon, {
3197
+ icon: "mynaui:share",
3198
+ className: "mr-2 size-4"
3199
+ }), tr("fluidgrids.builder.cardWorkflow.shareWorkflow", "Share workflow")]
3200
+ })
3201
+ ]
3202
+ })] }),
3203
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
3204
+ /* @__PURE__ */ jsxs(DropdownMenuLabel, {
3205
+ className: "text-xs font-normal text-muted-foreground",
3206
+ "data-testid": "workflow-row-menu-version",
3207
+ children: [/* @__PURE__ */ jsx("span", {
3208
+ className: "font-mono",
3209
+ children: versionInfo
3210
+ }), versionCount ? /* @__PURE__ */ jsxs("span", { children: [" · ", versionCount] }) : null]
3211
+ })
3212
+ ]
3213
+ })] })]
3214
+ });
3215
+ }
3216
+
3217
+ // src/pages/WorkflowsListV2.tsx
3218
+ /**
3219
+ * My Workflows under Navigation v2 (FluidGrids only, BOFF-11843; mockup 12).
3220
+ *
3221
+ * - One table (fe-libs `ResponsiveTable`, cards on a phone): Name with its
3222
+ * tags, Status, Updated and Last run, Edit and "⋯" on each row.
3223
+ * - Status chips All / On / Off (draft) / Archived / Retired filter on the
3224
+ * server, so `?status=archived` (the shell's "Archived") matches its count.
3225
+ * The tag chips sit beside them (level 1); access (All / Mine / Shared with
3226
+ * me), project and run mode sit under "More filters".
3227
+ * - The count is the server's total, and "Load more" pages past the first
3228
+ * 100 workflows.
3229
+ * - The shell's My Workflows drill-down lists All workflows, Shared with me,
3230
+ * Folders and Archived, so the in-page folder tree is not shown. Its
3231
+ * `?access=`, `?status=`, `?folder=` and `?action=` links still work
3232
+ * (`workflowsListUrlState.ts`, `useActionParam.ts`). With a folder open,
3233
+ * the header's "⋯" offers New subfolder, Rename folder and Delete folder,
3234
+ * which the tree's per-folder menu used to hold.
3235
+ * - "New workflow" asks for a name; "Browse templates" is one click away. The
3236
+ * header's "⋯" holds Import and the bulk selection.
3237
+ *
3238
+ * The "Last run" column shows each workflow's newest run (`latestRun`, which
3239
+ * the service reads for the whole page in one query, BOFF-16425), or a dash
3240
+ * when it has none. There is no Owner column: the list query has only the
3241
+ * owner's id, not a name to show.
3242
+ * - The first paint is one page operation, WorkflowsListPage (BOFF-16424):
3243
+ * see `workflows-list/pageOperation.ts`.
3244
+ */
3245
+ /** Where "Browse templates" goes, relative to the list. */
3246
+ const TEMPLATES_PATH = "../templates";
3247
+ /** The access choices under "More filters", in the classic list's order. */
3248
+ const ACCESS_CHOICES = [
3249
+ "ALL",
3250
+ "OWNED_BY_ME",
3251
+ "SHARED_WITH_ME"
3252
+ ];
3253
+ /** The access labels: the classic list's keys, so translations carry over. */
3254
+ function useAccessLabels() {
3255
+ const tr = useTr();
3256
+ return useMemo(() => ({
3257
+ ["ALL"]: tr("fluidgrids.workflowsList.access.all", "All"),
3258
+ ["OWNED_BY_ME"]: tr("fluidgrids.workflowsList.access.mine", "Mine"),
3259
+ ["SHARED_WITH_ME"]: tr("fluidgrids.workflowsList.access.sharedWithMe", "Shared with me")
3260
+ }), [tr]);
3261
+ }
3262
+ function WorkflowsListV2() {
3263
+ const tr = useTr();
3264
+ const navigate = useNavigate();
3265
+ const statusLabels = useWorkflowStatusLabels();
3266
+ const accessLabels = useAccessLabels();
3267
+ const modeCopy = useExecutionModeCopy();
3268
+ const workspaceId = useContext(FluidGridsContext)?.workspaceId ?? "";
3269
+ const urlFilters = useWorkflowsListUrlState();
3270
+ const { access: accessFilter, status: statusFilter, folder: folderFilter, mode: modeFilter, setAccess: setAccessFilter, setStatus: setStatusFilter, setMode: setModeFilter } = urlFilters;
3271
+ const pageOperation = useWorkflowsListPageOperation();
3272
+ const { workflows, total, hasMore, loading, loadingMore, loadMore, loadMoreError, error, tagsByKey, refetch } = useWorkflowDefinitions({
3273
+ limit: 100,
3274
+ latestOnly: true,
3275
+ ...accessFilter === "ALL" ? {} : { access: accessFilter },
3276
+ ...statusFilter ? { status: SERVER_WORKFLOW_STATUS[statusFilter] } : {},
3277
+ ...modeFilter ? { executionMode: modeFilter } : {}
3278
+ }, {
3279
+ paginate: true,
3280
+ documents: pageOperation.documents
3281
+ });
3282
+ const [loadedOnce, setLoadedOnce] = useState(false);
3283
+ if (!loading && !loadedOnce) setLoadedOnce(true);
3284
+ const [firstAnswer, setFirstAnswer] = useState(null);
3285
+ if (!loading && firstAnswer === null) setFirstAnswer({
3286
+ rows: workflows.length > 0,
3287
+ failed: Boolean(error)
3288
+ });
3289
+ const filteredOnServer = accessFilter !== "ALL" || modeFilter !== null || statusFilter !== null;
3290
+ const createPermission = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE);
3291
+ const canCreate = createPermission.allowed;
3292
+ const importRequest = useActionParam(ACTION_PARAM_VALUES.import, createPermission);
3293
+ const newFolderRequest = useActionParam(ACTION_PARAM_VALUES.newFolder);
3294
+ const rpaWeb = useFluidGridsFlag(FLUIDGRIDS_FLAGS.rpaWeb);
3295
+ const flagsSettled = useFluidGridsFlagsSettled();
3296
+ const canRecord = canCreate && rpaWeb && canUseBridgeHere();
3297
+ const recordRequest = useActionParam(ACTION_PARAM_VALUES.recordTask, {
3298
+ allowed: canRecord,
3299
+ isLoading: createPermission.isLoading || !flagsSettled
3300
+ });
3301
+ const [recordOpen, setRecordOpen] = useState(false);
3302
+ const openRecord = useCallback(() => setRecordOpen(true), []);
3303
+ useOpenRequest(recordRequest.requested, openRecord, recordRequest.handled);
3304
+ const [folderAction, setFolderAction] = useState(null);
3305
+ const clearFolderAction = useCallback(() => setFolderAction(null), []);
3306
+ const [importFromMenu, setImportFromMenu] = useState(false);
3307
+ const [search, setSearch] = useState("");
3308
+ const [tagFilter, setTagFilter] = useState(null);
3309
+ const [projectFilter, setProjectFilter] = useState(null);
3310
+ const [moreFiltersOpen, setMoreFiltersOpen] = useRememberedOpen("workflows.list.moreFilters", false);
3311
+ const [selectMode, setSelectMode] = useState(false);
3312
+ const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
3313
+ const [createOpen, setCreateOpen] = useState(false);
3314
+ const [sharing, setSharing] = useState(null);
3315
+ const [moving, setMoving] = useState(null);
3316
+ const [describing, setDescribing] = useState(null);
3317
+ const [settingsFor, setSettingsFor] = useState(null);
3318
+ const [deleteTarget, setDeleteTarget] = useState(null);
3319
+ const [deleting, setDeleting] = useState(false);
3320
+ const [quotaOpen, setQuotaOpen] = useState(false);
3321
+ const codeFirst = useFluidGridsFlag(FLUIDGRIDS_FLAGS.codeFirst);
3322
+ const { exportJson, exportInFormat, exportingFormatOf } = useWorkflowListExport();
3323
+ const { duplicate } = useDuplicateWorkflowCopy();
3324
+ const { deleteWorkflow } = useDeleteWorkflow();
3325
+ const createFirst = useCreateWorkflowFirst();
3326
+ const presentTags = useMemo(() => {
3327
+ const byId = /* @__PURE__ */ new Map();
3328
+ for (const w of workflows) for (const a of tagsByKey[w.workflowKey] ?? []) if (!byId.has(a.tagId)) byId.set(a.tagId, {
3329
+ id: a.tagId,
3330
+ label: a.tagInfo?.label ?? a.tagInfo?.key ?? tr("fluidgrids.workflowsList.tagFallbackLabel", "Tag")
3331
+ });
3332
+ return [...byId.values()].sort((a, b) => a.label.localeCompare(b.label));
3333
+ }, [
3334
+ workflows,
3335
+ tagsByKey,
3336
+ tr
3337
+ ]);
3338
+ const filtered = useMemo(() => {
3339
+ const q = search.trim().toLowerCase();
3340
+ return workflows.filter((w) => {
3341
+ if (tagFilter && !(tagsByKey[w.workflowKey] ?? []).some((a) => a.tagId === tagFilter)) return false;
3342
+ if (folderFilter && w.folderId !== folderFilter) return false;
3343
+ if (projectFilter && w.projectId !== projectFilter) return false;
3344
+ if (!q) return true;
3345
+ return [
3346
+ w.name,
3347
+ w.description,
3348
+ w.alias
3349
+ ].filter((v) => typeof v === "string").some((v) => v.toLowerCase().includes(q));
3350
+ });
3351
+ }, [
3352
+ workflows,
3353
+ search,
3354
+ tagFilter,
3355
+ tagsByKey,
3356
+ folderFilter,
3357
+ projectFilter
3358
+ ]);
3359
+ const { clientFiltered, filteringMore } = useLoadAllWhileFiltering({
3360
+ filtered: Boolean(folderFilter || tagFilter || projectFilter || search.trim()),
3361
+ hasMore,
3362
+ loading,
3363
+ loadingMore,
3364
+ loadMoreError: Boolean(loadMoreError),
3365
+ loadMore
3366
+ });
3367
+ const moreFiltersSet = (accessFilter !== "ALL" ? 1 : 0) + (projectFilter ? 1 : 0) + (modeFilter ? 1 : 0);
3368
+ const toolbarShown = loadedOnce && !error;
3369
+ const loadingSystem = useLoadingSystem();
3370
+ const toolbarReserved = loadingSystem && !loadedOnce && !error;
3371
+ const assistantControls = useMemo(() => workflowsListControls({
3372
+ page: tr("fluidgrids.workflowsList.title", "Workflows"),
3373
+ toolbarShown,
3374
+ search: setSearch,
3375
+ status: {
3376
+ label: tr("fluidgrids.executions.executionTable.colStatus", "Status"),
3377
+ allLabel: tr("fluidgrids.workflowsList.statusFilterAll", "All"),
3378
+ options: WORKFLOW_STATUS_CHIPS.map((value) => ({
3379
+ value,
3380
+ label: statusLabels[value]
3381
+ })),
3382
+ value: statusFilter,
3383
+ set: setStatusFilter
3384
+ },
3385
+ tag: {
3386
+ label: tr("fluidgrids.workflowsList.tagFallbackLabel", "Tag"),
3387
+ allLabel: tr("fluidgrids.workflowsList.statusFilterAll", "All"),
3388
+ options: presentTags.map((t) => ({
3389
+ value: t.id,
3390
+ label: t.label
3391
+ })),
3392
+ value: tagFilter,
3393
+ set: setTagFilter
3394
+ }
3395
+ }), [
3396
+ tr,
3397
+ toolbarShown,
3398
+ statusLabels,
3399
+ statusFilter,
3400
+ setStatusFilter,
3401
+ presentTags,
3402
+ tagFilter
3403
+ ]);
3404
+ useFluidGridsPageControls(assistantControls);
3405
+ const clearFilters = () => {
3406
+ setSearch("");
3407
+ setTagFilter(null);
3408
+ setProjectFilter(null);
3409
+ urlFilters.update({
3410
+ status: null,
3411
+ folder: null,
3412
+ mode: null,
3413
+ access: "ALL"
3414
+ });
3415
+ };
3416
+ const openBuilder = (w) => {
3417
+ markBuilderNavigation();
3418
+ navigate(builderPathOf({
3419
+ workflowKey: w.workflowKey,
3420
+ version: w.version
3421
+ }));
3422
+ };
3423
+ const handleDuplicate = async (w) => {
3424
+ try {
3425
+ const copy = await duplicate({
3426
+ workflowKey: w.workflowKey,
3427
+ version: w.version,
3428
+ name: w.name
3429
+ });
3430
+ if (copy.renameRefused) toast.warning(tr("fluidgrids.builder.cardWorkflow.copyRenameFailed", "The copy was made but kept the original name. Rename it in the editor."));
3431
+ navigate(builderPathOf(copy.workflow));
3432
+ } catch (err) {
3433
+ const cause = err instanceof Error ? err.cause : void 0;
3434
+ if (isQuotaExhaustedFailure(cause) || isQuotaExhaustedFailure(err)) {
3435
+ setQuotaOpen(true);
3436
+ return;
3437
+ }
3438
+ toast.error(tr("fluidgrids.workflowsList.duplicateFailed", "Couldn't duplicate the workflow"), { description: describeOperationError(err) });
3439
+ }
3440
+ };
3441
+ const confirmDelete = async () => {
3442
+ if (!deleteTarget) return;
3443
+ setDeleting(true);
3444
+ try {
3445
+ if (!await deleteWorkflow(deleteTarget.workflowKey)) {
3446
+ toast.error(tr("fluidgrids.workflowsList.deleteFailed", "Couldn't delete the workflow"));
3447
+ return;
3448
+ }
3449
+ setDeleteTarget(null);
3450
+ refetch();
3451
+ } finally {
3452
+ setDeleting(false);
3453
+ }
3454
+ };
3455
+ const toggleSelected = (id) => {
3456
+ setSelectedIds((prev) => {
3457
+ const next = new Set(prev);
3458
+ if (next.has(id)) next.delete(id);
3459
+ else next.add(id);
3460
+ return next;
3461
+ });
3462
+ };
3463
+ const createButton = /* @__PURE__ */ jsx(SdkPermissionButton, {
3464
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE,
3465
+ deniedTooltip: tr("fluidgrids.workflowsList.createDeniedTooltip", "You don't have permission to create workflows"),
3466
+ children: /* @__PURE__ */ jsxs(Button, {
3467
+ variant: "default",
3468
+ className: "min-h-11 font-bold text-primary-foreground",
3469
+ onClick: () => setCreateOpen(true),
3470
+ disabled: createFirst.creating,
3471
+ "aria-busy": createFirst.creating,
3472
+ "data-tour": "fluidgrids-list-create",
3473
+ children: [/* @__PURE__ */ jsx(Icon, {
3474
+ icon: "mynaui:plus",
3475
+ className: "size-5 text-primary-foreground"
3476
+ }), tr("fluidgrids.workflowsList.createButton", "Create Workflow")]
3477
+ })
3478
+ });
3479
+ const browseTemplatesButton = /* @__PURE__ */ jsx(Button, {
3480
+ asChild: true,
3481
+ variant: "outline",
3482
+ className: "min-h-11",
3483
+ children: /* @__PURE__ */ jsxs(Link, {
3484
+ to: TEMPLATES_PATH,
3485
+ "data-testid": "workflows-browse-templates",
3486
+ children: [/* @__PURE__ */ jsx(Icon, {
3487
+ icon: "mynaui:grid",
3488
+ className: "size-4",
3489
+ "aria-hidden": "true"
3490
+ }), tr("fluidgrids.workflowsList.browseTemplates", "Browse templates")]
3491
+ })
3492
+ });
3493
+ const headerMenuLabel = tr("fluidgrids.workflowsList.headerMenu", "More actions");
3494
+ const headerMenu = /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
3495
+ asChild: true,
3496
+ children: /* @__PURE__ */ jsx(Button, {
3497
+ variant: "outline",
3498
+ size: "icon",
3499
+ className: "size-11",
3500
+ "aria-label": headerMenuLabel,
3501
+ title: headerMenuLabel,
3502
+ "data-testid": "workflows-header-menu",
3503
+ "data-tour": "fluidgrids-list-import",
3504
+ children: /* @__PURE__ */ jsx(Icon, {
3505
+ icon: "mdi:dots-horizontal",
3506
+ className: "size-5"
3507
+ })
3508
+ })
3509
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
3510
+ align: "end",
3511
+ className: "min-w-52",
3512
+ children: [
3513
+ canCreate && /* @__PURE__ */ jsxs(DropdownMenuItem, {
3514
+ className: "min-h-11",
3515
+ onSelect: () => setImportFromMenu(true),
3516
+ "data-testid": "workflows-header-menu-import",
3517
+ children: [/* @__PURE__ */ jsx(Icon, {
3518
+ icon: "mynaui:upload",
3519
+ className: "mr-2 size-4"
3520
+ }), tr("fluidgrids.workflowsList.importButton", "Import")]
3521
+ }),
3522
+ canRecord && /* @__PURE__ */ jsxs(DropdownMenuItem, {
3523
+ className: "min-h-11",
3524
+ onSelect: () => setRecordOpen(true),
3525
+ "data-testid": "workflows-header-menu-record-task",
3526
+ children: [/* @__PURE__ */ jsx(CircleDot, {
3527
+ className: "mr-2 size-4",
3528
+ "aria-hidden": "true"
3529
+ }), tr("fluidgrids.workflowsList.recordTask", "Record a task")]
3530
+ }),
3531
+ /* @__PURE__ */ jsx(DropdownMenuCheckboxItem, {
3532
+ className: "min-h-11",
3533
+ checked: selectMode,
3534
+ onCheckedChange: (checked) => {
3535
+ setSelectMode(checked === true);
3536
+ setSelectedIds(/* @__PURE__ */ new Set());
3537
+ },
3538
+ "data-testid": "workflows-header-menu-select",
3539
+ children: tr("fluidgrids.workflowsList.bulk.selectToggle", "Select")
3540
+ }),
3541
+ folderFilter && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3542
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
3543
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
3544
+ className: "min-h-11",
3545
+ onSelect: () => setFolderAction({
3546
+ action: "create-child",
3547
+ folderId: folderFilter
3548
+ }),
3549
+ "data-testid": "workflows-header-menu-new-subfolder",
3550
+ children: [/* @__PURE__ */ jsx(Icon, {
3551
+ icon: "mynaui:folder-plus",
3552
+ className: "mr-2 size-4"
3553
+ }), tr("fluidgrids.workflowsList.folders.newSubfolder", "New subfolder")]
3554
+ }),
3555
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
3556
+ className: "min-h-11",
3557
+ onSelect: () => setFolderAction({
3558
+ action: "rename",
3559
+ folderId: folderFilter
3560
+ }),
3561
+ "data-testid": "workflows-header-menu-rename-folder",
3562
+ children: [/* @__PURE__ */ jsx(Icon, {
3563
+ icon: "mynaui:edit",
3564
+ className: "mr-2 size-4"
3565
+ }), tr("fluidgrids.workflowsList.folders.renameTitle", "Rename folder")]
3566
+ }),
3567
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
3568
+ className: "min-h-11 text-destructive",
3569
+ onSelect: () => setFolderAction({
3570
+ action: "delete",
3571
+ folderId: folderFilter
3572
+ }),
3573
+ "data-testid": "workflows-header-menu-delete-folder",
3574
+ children: [/* @__PURE__ */ jsx(Icon, {
3575
+ icon: "mynaui:trash",
3576
+ className: "mr-2 size-4"
3577
+ }), tr("fluidgrids.workflowsList.folders.deleteFolder", "Delete folder")]
3578
+ })
3579
+ ] })
3580
+ ]
3581
+ })] });
3582
+ const nameCell = (w) => {
3583
+ const tags = tagsByKey[w.workflowKey] ?? [];
3584
+ const description = visibleWorkflowDescription(w.description, w.name);
3585
+ return /* @__PURE__ */ jsxs("div", {
3586
+ className: "min-w-0",
3587
+ children: [
3588
+ /* @__PURE__ */ jsxs("div", {
3589
+ className: "flex min-w-0 items-center gap-1.5",
3590
+ children: [/* @__PURE__ */ jsx(Link, {
3591
+ to: builderPathOf({
3592
+ workflowKey: w.workflowKey,
3593
+ version: w.version
3594
+ }),
3595
+ onClick: (event) => {
3596
+ event.stopPropagation();
3597
+ markBuilderNavigation();
3598
+ },
3599
+ className: "truncate font-semibold text-foreground underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
3600
+ "data-testid": "workflow-row-name",
3601
+ children: w.name
3602
+ }), w.visibility === "RESTRICTED" && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
3603
+ asChild: true,
3604
+ children: /* @__PURE__ */ jsx("span", {
3605
+ role: "img",
3606
+ tabIndex: 0,
3607
+ className: "shrink-0 rounded-sm text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
3608
+ "data-testid": "workflow-restricted-badge",
3609
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.restricted", "Shared only with chosen people"),
3610
+ children: /* @__PURE__ */ jsx(Icon, {
3611
+ icon: "mdi:lock-outline",
3612
+ className: "size-3.5",
3613
+ "aria-hidden": "true"
3614
+ })
3615
+ })
3616
+ }), /* @__PURE__ */ jsx(TooltipContent, {
3617
+ side: "top",
3618
+ children: tr("fluidgrids.builder.cardWorkflow.restricted", "Shared only with chosen people")
3619
+ })] })]
3620
+ }),
3621
+ description && /* @__PURE__ */ jsx("p", {
3622
+ className: "mt-0.5 truncate text-xs text-muted-foreground",
3623
+ title: description,
3624
+ children: description
3625
+ }),
3626
+ /* @__PURE__ */ jsx(WorkflowRunModeBadges, {
3627
+ executionMode: w.executionMode,
3628
+ autonomyLevel: w.autonomyLevel,
3629
+ className: "mt-1"
3630
+ }),
3631
+ tags.length > 0 && /* @__PURE__ */ jsxs("div", {
3632
+ className: "mt-1 flex flex-wrap items-center gap-1",
3633
+ children: [tags.slice(0, 3).map((a) => /* @__PURE__ */ jsx(EntityTagBadge, {
3634
+ id: a.tagId,
3635
+ label: a.tagInfo?.label ?? a.tagInfo?.key ?? tr("fluidgrids.workflowsList.cardTagFallbackLabel", "Tag"),
3636
+ color: a.tagInfo?.color ?? void 0,
3637
+ size: "sm"
3638
+ }, a.tagId)), tags.length > 3 && /* @__PURE__ */ jsxs("span", {
3639
+ className: "text-xs text-muted-foreground",
3640
+ children: ["+", tags.length - 3]
3641
+ })]
3642
+ })
3643
+ ]
3644
+ });
3645
+ };
3646
+ const columns = [
3647
+ ...selectMode ? [{
3648
+ key: "select",
3649
+ header: /* @__PURE__ */ jsx("span", {
3650
+ className: "sr-only",
3651
+ children: tr("fluidgrids.workflowsList.bulk.selectToggle", "Select")
3652
+ }),
3653
+ mobileLabel: tr("fluidgrids.workflowsList.bulk.selectToggle", "Select"),
3654
+ cell: (w) => /* @__PURE__ */ jsx("span", {
3655
+ onClick: (event) => event.stopPropagation(),
3656
+ children: /* @__PURE__ */ jsx(Checkbox, {
3657
+ checked: selectedIds.has(w.id),
3658
+ onCheckedChange: () => toggleSelected(w.id),
3659
+ "aria-label": tr("fluidgrids.workflowsList.bulk.selectNamedAriaLabel", "Select {{name}}", { name: w.name })
3660
+ })
3661
+ }),
3662
+ headerClassName: "w-10"
3663
+ }] : [],
3664
+ {
3665
+ key: "name",
3666
+ header: tr("fluidgrids.workflowsList.table.name", "Name"),
3667
+ priority: "primary",
3668
+ cell: nameCell,
3669
+ cellClassName: "max-w-0 w-1/2"
3670
+ },
3671
+ {
3672
+ key: "status",
3673
+ header: tr("fluidgrids.executions.executionTable.colStatus", "Status"),
3674
+ cell: (w) => /* @__PURE__ */ jsx(WorkflowStatusPill, { status: w.status ?? void 0 })
3675
+ },
3676
+ {
3677
+ key: "updated",
3678
+ header: tr("fluidgrids.workflowsList.table.updated", "Updated"),
3679
+ cell: (w) => /* @__PURE__ */ jsx("span", {
3680
+ className: "whitespace-nowrap text-sm text-muted-foreground",
3681
+ title: formatExactTime(w.updatedAt),
3682
+ children: formatRelativeTime(tr, w.updatedAt)
3683
+ })
3684
+ },
3685
+ {
3686
+ key: "lastRun",
3687
+ header: tr("fluidgrids.workflowsList.table.lastRun", "Last run"),
3688
+ priority: "hidden-on-mobile",
3689
+ cell: (w) => /* @__PURE__ */ jsx(WorkflowLastRunCell, { run: w.latestRun })
3690
+ }
3691
+ ];
3692
+ const isEmpty = !loading && workflows.length === 0 && !filteredOnServer && !folderFilter;
3693
+ const loadedLabel = tr("fluidgrids.workflowsList.loadedRegion", "Workflows loaded");
3694
+ const listFills = Boolean(error) || isEmpty || filtered.length === 0 && !filteringMore;
3695
+ const renderList = () => error && isPermissionDenied(error) ? /* @__PURE__ */ jsx("div", {
3696
+ className: "grid flex-1 place-items-center",
3697
+ "data-testid": "workflows-load-denied",
3698
+ children: /* @__PURE__ */ jsx(LoadError, {
3699
+ kind: "denied",
3700
+ what: tr("fluidgrids.workflowsList.deniedWhat", "workflows"),
3701
+ error
3702
+ })
3703
+ }) : error ? /* @__PURE__ */ jsx("div", {
3704
+ className: "grid flex-1 place-items-center",
3705
+ role: "alert",
3706
+ "data-testid": "workflows-load-error",
3707
+ children: /* @__PURE__ */ jsx(EmptyState, {
3708
+ kind: "error",
3709
+ size: "page",
3710
+ icon: /* @__PURE__ */ jsx(Icon, {
3711
+ icon: "mynaui:danger-triangle",
3712
+ className: "size-8 text-destructive",
3713
+ "aria-hidden": "true"
3714
+ }),
3715
+ title: tr("fluidgrids.workflowsList.loadErrorTitle", "Couldn't load workflows"),
3716
+ description: error.message,
3717
+ action: /* @__PURE__ */ jsxs(Button, {
3718
+ variant: "outline",
3719
+ className: "min-h-11",
3720
+ onClick: () => void refetch(),
3721
+ children: [/* @__PURE__ */ jsx(Icon, {
3722
+ icon: "mynaui:refresh",
3723
+ className: "size-4"
3724
+ }), tr("fluidgrids.workflowsList.tryAgainButton", "Try again")]
3725
+ })
3726
+ })
3727
+ }) : isEmpty ? /* @__PURE__ */ jsx("div", {
3728
+ className: "grid flex-1 place-items-center",
3729
+ "data-testid": "workflows-empty",
3730
+ children: /* @__PURE__ */ jsx(IllustratedEmptyState, {
3731
+ illustration: "onboarding",
3732
+ kind: "first-use",
3733
+ glassIllustration: "workflows",
3734
+ size: "page",
3735
+ title: tr("fluidgrids.workflowsList.emptyStateTitle", "Create your first workflow"),
3736
+ description: tr("fluidgrids.workflowsList.emptyStateDescription", "Workflows automate multi-step processes — sync signups into your CRM, post alerts to Slack, or transform data between apps. Start from a blank canvas or a template."),
3737
+ action: /* @__PURE__ */ jsxs("div", {
3738
+ className: "flex flex-wrap items-center justify-center gap-2",
3739
+ children: [createButton, browseTemplatesButton]
3740
+ })
3741
+ })
3742
+ }) : filtered.length === 0 && !filteringMore ? /* @__PURE__ */ jsx("div", {
3743
+ className: "grid flex-1 place-items-center",
3744
+ "data-testid": "workflows-no-match",
3745
+ children: /* @__PURE__ */ jsx(EmptyState, {
3746
+ kind: search.trim() ? "no-results" : "filtered",
3747
+ size: "page",
3748
+ icon: /* @__PURE__ */ jsx(Icon, {
3749
+ icon: "mynaui:search",
3750
+ className: "size-8 text-muted-foreground",
3751
+ "aria-hidden": "true"
3752
+ }),
3753
+ title: tr("fluidgrids.workflowsList.noFilterMatchTitle", "No workflows match your filters"),
3754
+ action: /* @__PURE__ */ jsx(Button, {
3755
+ variant: "outline",
3756
+ className: "min-h-11",
3757
+ onClick: clearFilters,
3758
+ children: tr("fluidgrids.workflowsList.clearFiltersButton", "Clear filters")
3759
+ })
3760
+ })
3761
+ }) : /* @__PURE__ */ jsx("div", {
3762
+ "data-testid": "workflows-table",
3763
+ "data-tour": "fluidgrids-list-results",
3764
+ children: /* @__PURE__ */ jsx(ResponsiveTable, {
3765
+ columns,
3766
+ data: filtered,
3767
+ rowKey: (w) => w.id,
3768
+ onRowClick: openBuilder,
3769
+ rowActionsLabel: tr("fluidgrids.workflowsList.table.actions", "Actions"),
3770
+ rowActions: (w) => /* @__PURE__ */ jsx(WorkflowRowMenu, {
3771
+ workflow: {
3772
+ name: w.name,
3773
+ version: w.version,
3774
+ alias: w.alias,
3775
+ totalVersions: w.totalVersions,
3776
+ myAccess: w.myAccess
3777
+ },
3778
+ downloading: exportingFormatOf(w.workflowKey) !== null,
3779
+ actions: {
3780
+ onEdit: () => openBuilder(w),
3781
+ onDuplicate: () => void handleDuplicate(w),
3782
+ onDelete: () => setDeleteTarget({
3783
+ workflowKey: w.workflowKey,
3784
+ name: w.name
3785
+ }),
3786
+ onSettings: () => setSettingsFor({
3787
+ workflowKey: w.workflowKey,
3788
+ name: w.name
3789
+ }),
3790
+ onDownload: () => void exportJson(w.id),
3791
+ onDownloadAs: codeFirst ? (format) => void exportInFormat(w.workflowKey, w.version, format) : void 0,
3792
+ onMoveToProject: () => setMoving({
3793
+ id: w.id,
3794
+ name: w.name,
3795
+ projectId: w.projectId ?? null
3796
+ }),
3797
+ onEditDescription: () => setDescribing({
3798
+ id: w.id,
3799
+ name: w.name,
3800
+ description: w.description ?? null
3801
+ }),
3802
+ onShare: () => setSharing({
3803
+ workflowKey: w.workflowKey,
3804
+ name: w.name
3805
+ })
3806
+ }
3807
+ })
3808
+ })
3809
+ });
3810
+ return /* @__PURE__ */ jsx(PageOperationContext.Provider, {
3811
+ value: pageOperation.state,
3812
+ children: /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs("main", {
3813
+ className: "flex min-h-screen w-full flex-col gap-5 bg-surface-canvas p-4 sm:p-6",
3814
+ children: [
3815
+ /* @__PURE__ */ jsx(WorkflowsIntro, {
3816
+ "data-tour": "fluidgrids-list-header",
3817
+ docsLink: /* @__PURE__ */ jsx(FluidGridsDocsLink, {
3818
+ topic: "workflows",
3819
+ className: "mt-1"
3820
+ }),
3821
+ badge: toolbarShown && /* @__PURE__ */ jsx(Badge, {
3822
+ variant: "secondary",
3823
+ className: "font-mono",
3824
+ "data-testid": "workflows-total",
3825
+ children: clientFiltered ? `${filtered.length}${filteringMore ? "+" : ""}` : Math.max(total, workflows.length)
3826
+ }),
3827
+ actions: /* @__PURE__ */ jsxs(Fragment$1, { children: [headerMenu, createButton] })
3828
+ }),
3829
+ !loading && !error && !filteredOnServer && /* @__PURE__ */ jsx(FirstWorkflowChecklist, {
3830
+ workflows,
3831
+ canCreate,
3832
+ runsTotal: pageOperation.runsTotal
3833
+ }),
3834
+ (toolbarShown || toolbarReserved) && !isEmpty && /* @__PURE__ */ jsxs("div", {
3835
+ className: "flex flex-col gap-3",
3836
+ "data-tour": "fluidgrids-list-toolbar",
3837
+ children: [/* @__PURE__ */ jsxs("div", {
3838
+ className: "flex flex-wrap items-center gap-2",
3839
+ children: [
3840
+ /* @__PURE__ */ jsxs("div", {
3841
+ className: "relative w-full min-w-0 sm:max-w-md sm:flex-1",
3842
+ children: [/* @__PURE__ */ jsx(Icon, {
3843
+ icon: "mynaui:search",
3844
+ className: "pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground",
3845
+ "aria-hidden": "true"
3846
+ }), /* @__PURE__ */ jsx(Input, {
3847
+ type: "search",
3848
+ value: search,
3849
+ onChange: (e) => setSearch(e.target.value),
3850
+ placeholder: tr("fluidgrids.workflowsList.searchPlaceholder", "Search workflows…"),
3851
+ "aria-label": tr("fluidgrids.workflowsList.searchAriaLabel", "Search workflows"),
3852
+ className: "min-h-11 pl-9"
3853
+ })]
3854
+ }),
3855
+ /* @__PURE__ */ jsxs("div", {
3856
+ className: "flex flex-wrap items-center gap-1.5",
3857
+ role: "group",
3858
+ "aria-label": tr("fluidgrids.executions.executionTable.colStatus", "Status"),
3859
+ "data-testid": "workflow-status-filter",
3860
+ children: [/* @__PURE__ */ jsx(FilterChip, {
3861
+ pressed: statusFilter === null,
3862
+ onClick: () => setStatusFilter(null),
3863
+ children: tr("fluidgrids.workflowsList.statusFilterAll", "All")
3864
+ }), WORKFLOW_STATUS_CHIPS.map((status) => /* @__PURE__ */ jsx(FilterChip, {
3865
+ pressed: statusFilter === status,
3866
+ onClick: () => setStatusFilter(statusFilter === status ? null : status),
3867
+ testId: `workflow-status-chip-${status.toLowerCase()}`,
3868
+ children: statusLabels[status]
3869
+ }, status))]
3870
+ }),
3871
+ presentTags.length > 0 && /* @__PURE__ */ jsx("div", {
3872
+ className: "flex flex-wrap items-center gap-1.5",
3873
+ role: "group",
3874
+ "data-testid": "workflow-tag-filter",
3875
+ "aria-label": tr("fluidgrids.workflowsList.tagsLabel", "Tags"),
3876
+ children: presentTags.map((t) => /* @__PURE__ */ jsx(FilterChip, {
3877
+ pressed: tagFilter === t.id,
3878
+ onClick: () => setTagFilter((cur) => cur === t.id ? null : t.id),
3879
+ children: t.label
3880
+ }, t.id))
3881
+ }),
3882
+ /* @__PURE__ */ jsxs(Button, {
3883
+ variant: "ghost",
3884
+ className: "min-h-11",
3885
+ "aria-expanded": moreFiltersOpen,
3886
+ "aria-controls": "workflows-more-filters",
3887
+ onClick: () => setMoreFiltersOpen(!moreFiltersOpen),
3888
+ "data-testid": "workflows-more-filters",
3889
+ children: [
3890
+ /* @__PURE__ */ jsx(Icon, {
3891
+ icon: "mdi:tune-variant",
3892
+ className: "size-4",
3893
+ "aria-hidden": "true"
3894
+ }),
3895
+ tr("fluidgrids.workflowsList.moreFilters", "More filters"),
3896
+ moreFiltersSet > 0 && /* @__PURE__ */ jsx(Badge, {
3897
+ variant: "secondary",
3898
+ className: "ml-1",
3899
+ children: moreFiltersSet
3900
+ })
3901
+ ]
3902
+ })
3903
+ ]
3904
+ }), /* @__PURE__ */ jsxs("div", {
3905
+ id: "workflows-more-filters",
3906
+ hidden: !moreFiltersOpen,
3907
+ className: "flex flex-col gap-3 rounded-lg border border-border bg-card p-3",
3908
+ children: [
3909
+ /* @__PURE__ */ jsx("div", {
3910
+ className: "flex flex-wrap items-center gap-1.5",
3911
+ role: "group",
3912
+ "aria-label": tr("fluidgrids.workflowsList.access.label", "Access"),
3913
+ "data-testid": "workflow-access-filter",
3914
+ children: ACCESS_CHOICES.map((access) => /* @__PURE__ */ jsx(FilterChip, {
3915
+ pressed: accessFilter === access,
3916
+ onClick: () => setAccessFilter(access),
3917
+ testId: `workflow-access-chip-${access.toLowerCase()}`,
3918
+ children: accessLabels[access]
3919
+ }, access))
3920
+ }),
3921
+ /* @__PURE__ */ jsx(WorkflowProjectSelect, {
3922
+ selectedProjectId: projectFilter,
3923
+ onSelectProject: setProjectFilter
3924
+ }),
3925
+ /* @__PURE__ */ jsxs("div", {
3926
+ className: "flex flex-wrap items-center gap-1.5",
3927
+ role: "group",
3928
+ "aria-label": tr("fluidgrids.workflowsList.mode.label", "Run mode"),
3929
+ "data-testid": "workflow-mode-filter",
3930
+ children: [/* @__PURE__ */ jsx(FilterChip, {
3931
+ pressed: modeFilter === null,
3932
+ onClick: () => setModeFilter(null),
3933
+ children: tr("fluidgrids.workflowsList.mode.all", "Any mode")
3934
+ }), EXECUTION_MODES.map((mode) => /* @__PURE__ */ jsxs(FilterChip, {
3935
+ pressed: modeFilter === mode,
3936
+ title: modeCopy[mode].hint,
3937
+ onClick: () => setModeFilter(modeFilter === mode ? null : mode),
3938
+ children: [/* @__PURE__ */ jsx(Icon, {
3939
+ icon: EXECUTION_MODE_ICONS[mode],
3940
+ className: "size-3.5",
3941
+ "aria-hidden": "true"
3942
+ }), modeCopy[mode].label]
3943
+ }, mode))]
3944
+ })
3945
+ ]
3946
+ })]
3947
+ }),
3948
+ selectedIds.size > 0 && /* @__PURE__ */ jsx(WorkflowBulkActionsBar, {
3949
+ selectedIds: [...selectedIds],
3950
+ onDone: () => {
3951
+ setSelectedIds(/* @__PURE__ */ new Set());
3952
+ setSelectMode(false);
3953
+ refetch();
3954
+ }
3955
+ }),
3956
+ loadingSystem ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
3957
+ className: "sr-only",
3958
+ role: "status",
3959
+ "aria-live": "polite",
3960
+ "data-testid": "workflows-first-answer-status",
3961
+ children: firstAnswer?.rows === false && !firstAnswer.failed ? loadedLabel : ""
3962
+ }), /* @__PURE__ */ jsx(LoadRegion, {
3963
+ loading,
3964
+ skeleton: /* @__PURE__ */ jsx(WorkflowsTableSkeleton, {}),
3965
+ className: !loading && listFills ? "flex-1 [&>.boff-ld-layer]:flex [&>.boff-ld-layer]:flex-col" : void 0,
3966
+ label: tr("fluidgrids.workflowsList.loadingRegion", "Loading workflows"),
3967
+ doneLabel: loadedLabel,
3968
+ onRetry: () => void refetch(),
3969
+ children: renderList()
3970
+ }, firstAnswer?.rows === false ? "first-answer-without-rows" : "rows")] }) : loading ? /* @__PURE__ */ jsx(WorkflowsTableSkeleton, {}) : renderList(),
3971
+ !loading && !error && /* @__PURE__ */ jsx(WorkflowsLoadMore, {
3972
+ hasMore,
3973
+ loadingMore,
3974
+ error: loadMoreError,
3975
+ shown: workflows.length,
3976
+ total,
3977
+ onLoadMore: () => void loadMore()
3978
+ }),
3979
+ /* @__PURE__ */ jsx(LazyRecordTaskDialog, {
3980
+ open: recordOpen,
3981
+ onOpenChange: setRecordOpen,
3982
+ workspaceId,
3983
+ createWorkflow: (name, buildInput) => createFirst.start(name, buildInput)
3984
+ }),
3985
+ /* @__PURE__ */ jsx(WorkflowImportDialog, {
3986
+ onImported: () => void refetch(),
3987
+ openRequested: importRequest.requested || importFromMenu,
3988
+ onOpenRequestHandled: () => {
3989
+ if (importRequest.requested) importRequest.handled();
3990
+ setImportFromMenu(false);
3991
+ }
3992
+ }),
3993
+ /* @__PURE__ */ jsx(WorkflowFolderSidebar, {
3994
+ dialogsOnly: true,
3995
+ selectedFolderId: folderFilter,
3996
+ onSelectFolder: urlFilters.setFolder,
3997
+ createRequested: newFolderRequest.requested,
3998
+ onCreateRequestHandled: newFolderRequest.handled,
3999
+ folderActionRequest: folderAction,
4000
+ onFolderActionRequestHandled: clearFolderAction
4001
+ }),
4002
+ /* @__PURE__ */ jsx(CreateWorkflowNameDialog, {
4003
+ open: createOpen,
4004
+ onOpenChange: setCreateOpen,
4005
+ creating: createFirst.creating,
4006
+ templatesHref: TEMPLATES_PATH,
4007
+ onCreate: (name) => {
4008
+ createFirst.start(name).then((result) => {
4009
+ if (result) setCreateOpen(false);
4010
+ });
4011
+ }
4012
+ }),
4013
+ /* @__PURE__ */ jsx(WorkflowSettingsDrawer, {
4014
+ workflowKey: settingsFor?.workflowKey ?? null,
4015
+ workflowName: settingsFor?.name ?? "",
4016
+ onClose: () => setSettingsFor(null),
4017
+ allSettingsHref: settingsFor ? `../settings/${encodeURIComponent(settingsFor.workflowKey)}` : "../settings"
4018
+ }),
4019
+ /* @__PURE__ */ jsx(ConfirmActionDialog, {
4020
+ open: deleteTarget !== null,
4021
+ title: tr("fluidgrids.builder.cardWorkflow.deleteDialogTitle", "Delete Workflow"),
4022
+ description: tr("fluidgrids.workflowsList.deleteConfirmDescription", "“{{name}}” and all its versions will be deleted. This can't be undone.", { name: deleteTarget?.name ?? "" }),
4023
+ confirmLabel: deleting ? tr("fluidgrids.builder.cardWorkflow.deletingButton", "Deleting...") : tr("fluidgrids.builder.cardWorkflow.deleteButton", "Delete"),
4024
+ cancelLabel: tr("fluidgrids.workflowsList.deleteConfirmCancel", "Keep it"),
4025
+ destructive: true,
4026
+ busy: deleting,
4027
+ onConfirm: () => void confirmDelete(),
4028
+ onOpenChange: (open) => {
4029
+ if (!open && !deleting) setDeleteTarget(null);
4030
+ },
4031
+ "data-testid": "workflow-delete-confirm"
4032
+ }),
4033
+ /* @__PURE__ */ jsx(QuotaExhaustedDialog, {
4034
+ surface: "workflow-duplicate",
4035
+ open: quotaOpen,
4036
+ onOpenChange: setQuotaOpen,
4037
+ onUpgrade: () => {
4038
+ setQuotaOpen(false);
4039
+ navigate(BILLING_PLANS_PATH);
4040
+ }
4041
+ }),
4042
+ /* @__PURE__ */ jsx(WorkflowShareDialog, {
4043
+ open: sharing !== null,
4044
+ onClose: () => setSharing(null),
4045
+ workflowKey: sharing?.workflowKey ?? null,
4046
+ workflowName: sharing?.name ?? "",
4047
+ workspaceId,
4048
+ onShared: () => void refetch()
4049
+ }),
4050
+ /* @__PURE__ */ jsx(WorkflowMoveToProjectDialog, {
4051
+ workflow: moving,
4052
+ onClose: () => setMoving(null),
4053
+ onMoved: () => void refetch()
4054
+ }),
4055
+ /* @__PURE__ */ jsx(WorkflowDescriptionDialog, {
4056
+ workflow: describing,
4057
+ onClose: () => setDescribing(null),
4058
+ onSaved: () => void refetch()
4059
+ }),
4060
+ /* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
4061
+ surface: "builder-create",
4062
+ refusal: createFirst.refusal,
4063
+ onClose: createFirst.clearRefusal,
4064
+ onUpgrade: () => navigate(BILLING_PLANS_PATH)
4065
+ })
4066
+ ]
4067
+ }) })
4068
+ });
4069
+ }
4070
+
4071
+ // src/pages/workflows-list/knownTags.ts
4072
+ /**
4073
+ * The tag chips to offer after a list response.
4074
+ *
4075
+ * - With no tag filter, the chips are rebuilt from the loaded rows, so a tag
4076
+ * that is gone (its last workflow deleted or untagged) drops out and a
4077
+ * renamed tag shows its new label.
4078
+ * - With a tag filter, the rows hold only that tag's workflows, so the chips
4079
+ * seen before are kept (that is the point of remembering them) and the rows
4080
+ * only add tags or refresh labels. The active tag always stays offered.
4081
+ * - While loading, nothing changes.
4082
+ *
4083
+ * Returns `known` itself when the chips are unchanged, so a caller can store
4084
+ * the result in state during render without looping.
4085
+ */
4086
+ function mergeKnownTags(known, workflows, tagsByKey, fallbackLabel, { activeTagId, loading }) {
4087
+ if (loading) return known;
4088
+ const next = /* @__PURE__ */ new Map();
4089
+ if (activeTagId !== null) for (const tag of known) next.set(tag.id, tag);
4090
+ for (const workflow of workflows) for (const assignment of tagsByKey[workflow.workflowKey] ?? []) next.set(assignment.tagId, {
4091
+ id: assignment.tagId,
4092
+ label: assignment.tagInfo?.label ?? assignment.tagInfo?.key ?? fallbackLabel
4093
+ });
4094
+ const result = [...next.values()].sort((a, b) => a.label.localeCompare(b.label));
4095
+ return result.length === known.length && result.every((tag, index) => tag.id === known[index].id && tag.label === known[index].label) ? known : result;
4096
+ }
4097
+
4098
+ // src/pages/WorkflowsList.tsx
4099
+ var WorkflowsList_exports = /* @__PURE__ */ __exportAll({ WorkflowsList: () => WorkflowsList });
4100
+ function useStatusFilters() {
4101
+ const tr = useTr();
4102
+ return useMemo(() => [
4103
+ {
4104
+ value: "ACTIVE",
4105
+ label: tr("fluidgrids.workflowsList.statusActive", "Active")
4106
+ },
4107
+ {
4108
+ value: "DRAFT",
4109
+ label: tr("fluidgrids.workflowsList.statusDraft", "Draft")
4110
+ },
4111
+ {
4112
+ value: "ARCHIVED",
4113
+ label: tr("fluidgrids.workflowsList.statusArchived", "Archived")
4114
+ },
4115
+ {
4116
+ value: "DEPRECATED",
4117
+ label: tr("fluidgrids.workflowsList.statusDeprecated", "Deprecated")
4118
+ }
4119
+ ], [tr]);
4120
+ }
4121
+ function useAccessFilters() {
4122
+ const tr = useTr();
4123
+ return useMemo(() => [
4124
+ {
4125
+ value: "ALL",
4126
+ label: tr("fluidgrids.workflowsList.access.all", "All")
4127
+ },
4128
+ {
4129
+ value: "OWNED_BY_ME",
4130
+ label: tr("fluidgrids.workflowsList.access.mine", "Mine")
4131
+ },
4132
+ {
4133
+ value: "SHARED_WITH_ME",
4134
+ label: tr("fluidgrids.workflowsList.access.sharedWithMe", "Shared with me")
4135
+ }
4136
+ ], [tr]);
4137
+ }
4138
+ function SkeletonCard() {
4139
+ return /* @__PURE__ */ jsxs("div", {
4140
+ className: "flex min-h-40 flex-col justify-between rounded-xl border border-border bg-card p-6",
4141
+ children: [/* @__PURE__ */ jsxs("div", {
4142
+ className: "space-y-2.5",
4143
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-2/3 bg-card-foreground/15" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full bg-card-foreground/10" })]
4144
+ }), /* @__PURE__ */ jsxs("div", {
4145
+ className: "flex items-center gap-2",
4146
+ children: [
4147
+ /* @__PURE__ */ jsx(Skeleton, { className: "mr-4 h-6 w-full bg-card-foreground/10" }),
4148
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-8 bg-card-foreground/10" }),
4149
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-8 bg-card-foreground/10" })
4150
+ ]
4151
+ })]
4152
+ });
4153
+ }
4154
+ /**
4155
+ * My Workflows. FluidGrids turns on Navigation v2 (`NavigationV2Provider`),
4156
+ * which shows the table of `WorkflowsListV2` (BOFF-11843); every other app
4157
+ * keeps the card grid below.
4158
+ */
4159
+ function WorkflowsList() {
4160
+ return useNavigationV2() ? /* @__PURE__ */ jsx(WorkflowsListV2, {}) : /* @__PURE__ */ jsx(WorkflowsListClassic, {});
4161
+ }
4162
+ function WorkflowsListClassic() {
4163
+ const tr = useTr();
4164
+ const navigate = useNavigate();
4165
+ const STATUS_FILTERS = useStatusFilters();
4166
+ const ACCESS_FILTERS = useAccessFilters();
4167
+ const workspaceId = useContext(FluidGridsContext)?.workspaceId ?? "";
4168
+ const urlFilters = useWorkflowsListUrlState();
4169
+ const { access: accessFilter, status: statusFilter, folder: folderFilter, mode: modeFilter, setAccess: setAccessFilter, setStatus: setStatusFilter, setFolder: setFolderFilter, setMode: setModeFilter } = urlFilters;
4170
+ const modeCopy = useExecutionModeCopy();
4171
+ const [search, setSearch] = useState("");
4172
+ const [tagFilter, setTagFilter] = useState(null);
4173
+ const [projectFilter, setProjectFilter] = useState(null);
4174
+ const settledSearch = useDebouncedValue(search, 300);
4175
+ const listFilters = {
4176
+ access: accessFilter,
4177
+ mode: modeFilter,
4178
+ status: statusFilter,
4179
+ folder: folderFilter,
4180
+ project: projectFilter,
4181
+ search: settledSearch,
4182
+ tag: tagFilter
4183
+ };
4184
+ const { workflows, total, hasMore, loading, loadingMore, loadMore, loadMoreError, error, tagsByKey, refetch } = useWorkflowDefinitions({
4185
+ limit: 100,
4186
+ latestOnly: true,
4187
+ ...workflowsListServerInput(listFilters)
4188
+ }, { paginate: true });
4189
+ const [loadedOnce, setLoadedOnce] = useState(false);
4190
+ if (!loading && !loadedOnce) setLoadedOnce(true);
4191
+ const [sharing, setSharing] = useState(null);
4192
+ const [moving, setMoving] = useState(null);
4193
+ const [describing, setDescribing] = useState(null);
4194
+ const filteredOnServer = hasWorkflowsListFilter({
4195
+ ...listFilters,
4196
+ search: pendingSearch(search, settledSearch)
4197
+ });
4198
+ const createPermission = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE);
4199
+ const canCreate = createPermission.allowed;
4200
+ const importRequest = useActionParam(ACTION_PARAM_VALUES.import, createPermission);
4201
+ const newFolderRequest = useActionParam(ACTION_PARAM_VALUES.newFolder);
4202
+ const [selectMode, setSelectMode] = useState(false);
4203
+ const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
4204
+ const presentStatuses = STATUS_FILTERS;
4205
+ const [knownTags, setKnownTags] = useState([]);
4206
+ const mergedTags = mergeKnownTags(knownTags, workflows, tagsByKey, tr("fluidgrids.workflowsList.tagFallbackLabel", "Tag"), {
4207
+ activeTagId: tagFilter,
4208
+ loading
4209
+ });
4210
+ if (mergedTags !== knownTags) setKnownTags(mergedTags);
4211
+ const presentTags = mergedTags;
4212
+ const toggleSelected = (id) => {
4213
+ setSelectedIds((prev) => {
4214
+ const next = new Set(prev);
4215
+ if (next.has(id)) next.delete(id);
4216
+ else next.add(id);
4217
+ return next;
4218
+ });
4219
+ };
4220
+ const clearSelection = () => {
4221
+ setSelectedIds(/* @__PURE__ */ new Set());
4222
+ setSelectMode(false);
4223
+ refetch();
4224
+ };
4225
+ const assistantControls = useMemo(() => workflowsListControls({
4226
+ page: tr("fluidgrids.workflowsList.title", "Workflows"),
4227
+ toolbarShown: loadedOnce && !error && (workflows.length > 0 || filteredOnServer),
4228
+ search: setSearch,
4229
+ status: {
4230
+ label: tr("fluidgrids.executions.executionTable.colStatus", "Status"),
4231
+ allLabel: tr("fluidgrids.workflowsList.statusFilterAll", "All"),
4232
+ options: presentStatuses,
4233
+ value: statusFilter,
4234
+ set: setStatusFilter
4235
+ },
4236
+ tag: {
4237
+ label: tr("fluidgrids.workflowsList.tagFallbackLabel", "Tag"),
4238
+ allLabel: tr("fluidgrids.workflowsList.statusFilterAll", "All"),
4239
+ options: presentTags.map((t) => ({
4240
+ value: t.id,
4241
+ label: t.label
4242
+ })),
4243
+ value: tagFilter,
4244
+ set: setTagFilter
4245
+ }
4246
+ }), [
4247
+ tr,
4248
+ loadedOnce,
4249
+ error,
4250
+ workflows.length,
4251
+ filteredOnServer,
4252
+ presentStatuses,
4253
+ presentTags,
4254
+ statusFilter,
4255
+ setStatusFilter,
4256
+ tagFilter
4257
+ ]);
4258
+ useFluidGridsPageControls(assistantControls);
4259
+ const codeFirst = useFluidGridsFlag(FLUIDGRIDS_FLAGS.codeFirst);
4260
+ const { exportJson, exportInFormat, exportingFormatOf } = useWorkflowListExport();
4261
+ const createFirst = useCreateWorkflowFirst();
4262
+ const createButton = /* @__PURE__ */ jsx(SdkPermissionButton, {
4263
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE,
4264
+ deniedTooltip: tr("fluidgrids.workflowsList.createDeniedTooltip", "You don't have permission to create workflows"),
4265
+ children: /* @__PURE__ */ jsxs(Button, {
4266
+ variant: "default",
4267
+ size: "default",
4268
+ className: "font-bold text-primary-foreground",
4269
+ onClick: () => void createFirst.start(),
4270
+ disabled: createFirst.creating,
4271
+ "aria-busy": createFirst.creating,
4272
+ "data-tour": "fluidgrids-list-create",
4273
+ children: [/* @__PURE__ */ jsx(Icon, {
4274
+ icon: "mynaui:plus",
4275
+ className: "size-5 text-primary-foreground"
4276
+ }), tr("fluidgrids.workflowsList.createButton", "Create Workflow")]
4277
+ })
4278
+ });
4279
+ return /* @__PURE__ */ jsxs("main", {
4280
+ className: "flex min-h-screen w-full flex-row bg-surface-canvas",
4281
+ children: [
4282
+ /* @__PURE__ */ jsx(WorkflowFolderSidebar, {
4283
+ selectedFolderId: folderFilter,
4284
+ onSelectFolder: setFolderFilter,
4285
+ createRequested: newFolderRequest.requested,
4286
+ onCreateRequestHandled: newFolderRequest.handled
4287
+ }),
4288
+ /* @__PURE__ */ jsxs("div", {
4289
+ className: "flex flex-1 flex-col gap-5 p-4 sm:p-6",
4290
+ "data-tour": "fluidgrids-list-results",
4291
+ children: [
4292
+ /* @__PURE__ */ jsxs("div", {
4293
+ className: "flex flex-wrap items-start justify-between gap-3",
4294
+ "data-tour": "fluidgrids-list-header",
4295
+ children: [
4296
+ /* @__PURE__ */ jsxs("div", {
4297
+ className: "min-w-0",
4298
+ children: [
4299
+ /* @__PURE__ */ jsxs("div", {
4300
+ className: "flex items-center gap-2.5",
4301
+ children: [/* @__PURE__ */ jsx("h1", {
4302
+ className: "text-2xl font-bold tracking-tight",
4303
+ children: tr("fluidgrids.workflowsList.title", "Workflows")
4304
+ }), !loading && !error && /* @__PURE__ */ jsx(Badge, {
4305
+ variant: "secondary",
4306
+ className: "font-mono",
4307
+ children: Math.max(total, workflows.length)
4308
+ })]
4309
+ }),
4310
+ /* @__PURE__ */ jsx("p", {
4311
+ className: "mt-1 text-sm text-muted-foreground",
4312
+ children: tr("fluidgrids.workflowsList.subtitle", "Build, run, and manage your automations. Open a workflow to edit it in the visual builder.")
4313
+ }),
4314
+ /* @__PURE__ */ jsx(FluidGridsDocsLink, {
4315
+ topic: "workflows",
4316
+ className: "mt-1"
4317
+ })
4318
+ ]
4319
+ }),
4320
+ createButton,
4321
+ /* @__PURE__ */ jsx(WorkflowImportDialog, {
4322
+ onImported: () => void refetch(),
4323
+ openRequested: importRequest.requested,
4324
+ onOpenRequestHandled: importRequest.handled
4325
+ })
4326
+ ]
4327
+ }),
4328
+ !loading && !error && !filteredOnServer && /* @__PURE__ */ jsx(FirstWorkflowChecklist, {
4329
+ workflows,
4330
+ canCreate
4331
+ }),
4332
+ loadedOnce && !error && (workflows.length > 0 || filteredOnServer) && /* @__PURE__ */ jsxs("div", {
4333
+ className: "flex flex-wrap items-center gap-3",
4334
+ "data-tour": "fluidgrids-list-toolbar",
4335
+ children: [
4336
+ /* @__PURE__ */ jsxs("div", {
4337
+ className: "relative w-full max-w-xs",
4338
+ children: [/* @__PURE__ */ jsx(Icon, {
4339
+ icon: "mynaui:search",
4340
+ className: "pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"
4341
+ }), /* @__PURE__ */ jsx(Input, {
4342
+ value: search,
4343
+ onChange: (e) => setSearch(e.target.value),
4344
+ placeholder: tr("fluidgrids.workflowsList.searchPlaceholder", "Search workflows…"),
4345
+ "aria-label": tr("fluidgrids.workflowsList.searchAriaLabel", "Search workflows"),
4346
+ className: "pl-8"
4347
+ })]
4348
+ }),
4349
+ /* @__PURE__ */ jsx(WorkflowProjectSelect, {
4350
+ selectedProjectId: projectFilter,
4351
+ onSelectProject: setProjectFilter
4352
+ }),
4353
+ /* @__PURE__ */ jsx("div", {
4354
+ className: "flex flex-wrap items-center gap-1.5",
4355
+ role: "group",
4356
+ "aria-label": tr("fluidgrids.workflowsList.access.label", "Access"),
4357
+ "data-testid": "workflow-access-filter",
4358
+ children: ACCESS_FILTERS.map((option) => /* @__PURE__ */ jsx("button", {
4359
+ type: "button",
4360
+ "aria-pressed": accessFilter === option.value,
4361
+ onClick: () => setAccessFilter(option.value),
4362
+ className: cn("rounded-full border px-3 py-1 text-xs font-medium transition-colors", accessFilter === option.value ? "border-transparent bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground hover:text-foreground"),
4363
+ children: option.label
4364
+ }, option.value))
4365
+ }),
4366
+ /* @__PURE__ */ jsxs("div", {
4367
+ className: "flex flex-wrap items-center gap-1.5",
4368
+ role: "group",
4369
+ "aria-label": tr("fluidgrids.workflowsList.mode.label", "Run mode"),
4370
+ "data-testid": "workflow-mode-filter",
4371
+ children: [/* @__PURE__ */ jsx("button", {
4372
+ type: "button",
4373
+ "aria-pressed": modeFilter === null,
4374
+ onClick: () => setModeFilter(null),
4375
+ className: cn("rounded-full border px-3 py-1 text-xs font-medium transition-colors", modeFilter === null ? "border-transparent bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground hover:text-foreground"),
4376
+ children: tr("fluidgrids.workflowsList.mode.all", "Any mode")
4377
+ }), EXECUTION_MODES.map((mode) => /* @__PURE__ */ jsxs("button", {
4378
+ type: "button",
4379
+ "aria-pressed": modeFilter === mode,
4380
+ title: modeCopy[mode].hint,
4381
+ onClick: () => setModeFilter(modeFilter === mode ? null : mode),
4382
+ className: cn("inline-flex items-center gap-1 rounded-full border px-3 py-1 text-xs font-medium transition-colors", modeFilter === mode ? "border-transparent bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground hover:text-foreground"),
4383
+ children: [/* @__PURE__ */ jsx(Icon, {
4384
+ icon: EXECUTION_MODE_ICONS[mode],
4385
+ className: "size-3.5",
4386
+ "aria-hidden": "true"
4387
+ }), modeCopy[mode].label]
4388
+ }, mode))]
4389
+ }),
4390
+ /* @__PURE__ */ jsxs(Button, {
4391
+ variant: selectMode ? "secondary" : "outline",
4392
+ size: "sm",
4393
+ onClick: () => {
4394
+ setSelectMode((v) => !v);
4395
+ setSelectedIds(/* @__PURE__ */ new Set());
4396
+ },
4397
+ children: [/* @__PURE__ */ jsx(Icon, {
4398
+ icon: "mynaui:check-square",
4399
+ className: "size-4"
4400
+ }), tr("fluidgrids.workflowsList.bulk.selectToggle", "Select")]
4401
+ }),
4402
+ presentStatuses.length > 0 && /* @__PURE__ */ jsxs("div", {
4403
+ className: "flex flex-wrap items-center gap-1.5",
4404
+ children: [/* @__PURE__ */ jsx("button", {
4405
+ type: "button",
4406
+ onClick: () => setStatusFilter(null),
4407
+ className: cn("rounded-full border px-3 py-1 text-xs font-medium transition-colors", statusFilter === null ? "border-transparent bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground hover:text-foreground"),
4408
+ children: tr("fluidgrids.workflowsList.statusFilterAll", "All")
4409
+ }), presentStatuses.map((s) => /* @__PURE__ */ jsx("button", {
4410
+ type: "button",
4411
+ onClick: () => setStatusFilter(statusFilter === s.value ? null : s.value),
4412
+ className: cn("rounded-full border px-3 py-1 text-xs font-medium transition-colors", statusFilter === s.value ? "border-transparent bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground hover:text-foreground"),
4413
+ children: s.label
4414
+ }, s.value))]
4415
+ }),
4416
+ presentTags.length > 0 && /* @__PURE__ */ jsxs("div", {
4417
+ className: "flex flex-wrap items-center gap-1.5",
4418
+ children: [/* @__PURE__ */ jsx(Icon, {
4419
+ icon: "mdi:tag-outline",
4420
+ className: "size-4 text-muted-foreground",
4421
+ "aria-hidden": "true"
4422
+ }), presentTags.map((t) => /* @__PURE__ */ jsx("button", {
4423
+ type: "button",
4424
+ onClick: () => setTagFilter((cur) => cur === t.id ? null : t.id),
4425
+ className: cn("rounded-full border px-3 py-1 text-xs font-medium transition-colors", tagFilter === t.id ? "border-transparent bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground hover:text-foreground"),
4426
+ children: t.label
4427
+ }, t.id))]
4428
+ })
4429
+ ]
4430
+ }),
4431
+ selectedIds.size > 0 && /* @__PURE__ */ jsx(WorkflowBulkActionsBar, {
4432
+ selectedIds: [...selectedIds],
4433
+ onDone: clearSelection
4434
+ }),
4435
+ loading ? /* @__PURE__ */ jsx("div", {
4436
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4",
4437
+ children: Array.from({ length: 6 }, (_, i) => /* @__PURE__ */ jsx(SkeletonCard, {}, i))
4438
+ }) : error ? /* @__PURE__ */ jsx("div", {
4439
+ className: "grid flex-1 place-items-center",
4440
+ children: /* @__PURE__ */ jsxs("div", {
4441
+ className: "flex max-w-md flex-col items-center gap-3 rounded-xl border border-border bg-card p-8 text-center",
4442
+ children: [
4443
+ /* @__PURE__ */ jsx(Icon, {
4444
+ icon: "mynaui:danger-triangle",
4445
+ className: "size-8 text-destructive"
4446
+ }),
4447
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
4448
+ className: "font-semibold",
4449
+ children: tr("fluidgrids.workflowsList.loadErrorTitle", "Couldn't load workflows")
4450
+ }), /* @__PURE__ */ jsx("p", {
4451
+ className: "mt-1 text-sm text-muted-foreground",
4452
+ children: error.message
4453
+ })] }),
4454
+ /* @__PURE__ */ jsxs(Button, {
4455
+ variant: "outline",
4456
+ size: "sm",
4457
+ onClick: () => refetch(),
4458
+ children: [/* @__PURE__ */ jsx(Icon, {
4459
+ icon: "mynaui:refresh",
4460
+ className: "size-4"
4461
+ }), tr("fluidgrids.workflowsList.tryAgainButton", "Try again")]
4462
+ })
4463
+ ]
4464
+ })
4465
+ }) : workflows.length === 0 && !filteredOnServer ? /* @__PURE__ */ jsx("div", {
4466
+ className: "grid flex-1 place-items-center",
4467
+ children: /* @__PURE__ */ jsx(IllustratedEmptyState, {
4468
+ illustration: "onboarding",
4469
+ kind: "first-use",
4470
+ glassIllustration: "workflows",
4471
+ size: "page",
4472
+ title: tr("fluidgrids.workflowsList.emptyStateTitle", "Create your first workflow"),
4473
+ description: tr("fluidgrids.workflowsList.emptyStateDescription", "Workflows automate multi-step processes — sync signups into your CRM, post alerts to Slack, or transform data between apps. Start from a blank canvas or a template."),
4474
+ action: createButton
4475
+ })
4476
+ }) : workflows.length === 0 ? /* @__PURE__ */ jsx("div", {
4477
+ className: "grid flex-1 place-items-center",
4478
+ children: /* @__PURE__ */ jsx(EmptyState, {
4479
+ kind: search.trim() ? "no-results" : "filtered",
4480
+ size: "page",
4481
+ icon: /* @__PURE__ */ jsx(Icon, {
4482
+ icon: "mynaui:search",
4483
+ className: "size-8 text-muted-foreground"
4484
+ }),
4485
+ title: tr("fluidgrids.workflowsList.noFilterMatchTitle", "No workflows match your filters"),
4486
+ action: /* @__PURE__ */ jsx(Button, {
4487
+ variant: "outline",
4488
+ size: "sm",
4489
+ onClick: () => {
4490
+ setSearch("");
4491
+ setTagFilter(null);
4492
+ setProjectFilter(null);
4493
+ urlFilters.update({
4494
+ status: null,
4495
+ folder: null,
4496
+ mode: null,
4497
+ access: "ALL"
4498
+ });
4499
+ },
4500
+ children: tr("fluidgrids.workflowsList.clearFiltersButton", "Clear filters")
4501
+ })
4502
+ })
4503
+ }) : /* @__PURE__ */ jsx("div", {
4504
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4",
4505
+ children: workflows.map((workflow) => /* @__PURE__ */ jsxs("div", {
4506
+ className: "relative",
4507
+ children: [selectMode && /* @__PURE__ */ jsx(Checkbox, {
4508
+ className: "absolute right-3 top-3 z-10 bg-surface-canvas",
4509
+ checked: selectedIds.has(workflow.id),
4510
+ onCheckedChange: () => toggleSelected(workflow.id),
4511
+ "aria-label": tr("fluidgrids.workflowsList.bulk.selectWorkflowAriaLabel", "Select workflow")
4512
+ }), /* @__PURE__ */ jsx(CardWorkflow, {
4513
+ workflow: {
4514
+ id: workflow.id,
4515
+ workflow_key: workflow.workflowKey,
4516
+ version: workflow.version,
4517
+ name: workflow.name,
4518
+ description: workflow.description ?? void 0,
4519
+ status: workflow.status ?? void 0,
4520
+ alias: workflow.alias ?? void 0,
4521
+ updated_at: workflow.updatedAt ?? void 0,
4522
+ created_at: workflow.createdAt ?? void 0,
4523
+ total_versions: workflow.totalVersions ?? void 0,
4524
+ tags: (tagsByKey[workflow.workflowKey] ?? []).map((a) => ({
4525
+ id: a.tagId,
4526
+ label: a.tagInfo?.label ?? a.tagInfo?.key ?? tr("fluidgrids.workflowsList.cardTagFallbackLabel", "Tag"),
4527
+ color: a.tagInfo?.color ?? void 0
4528
+ })),
4529
+ visibility: workflow.visibility ?? void 0,
4530
+ my_access: workflow.myAccess ?? null,
4531
+ execution_mode: workflow.executionMode ?? null,
4532
+ autonomy_level: workflow.autonomyLevel ?? null
4533
+ },
4534
+ onUpdateSuccess: () => refetch(),
4535
+ onShare: () => setSharing({
4536
+ workflowKey: workflow.workflowKey,
4537
+ name: workflow.name
4538
+ }),
4539
+ onMoveToProject: () => setMoving({
4540
+ id: workflow.id,
4541
+ name: workflow.name,
4542
+ projectId: workflow.projectId ?? null
4543
+ }),
4544
+ onEditDescription: () => setDescribing({
4545
+ id: workflow.id,
4546
+ name: workflow.name,
4547
+ description: workflow.description ?? null
4548
+ }),
4549
+ onExport: () => void exportJson(workflow.id),
4550
+ onExportAs: codeFirst ? (format) => void exportInFormat(workflow.workflowKey, workflow.version, format) : void 0,
4551
+ exportingFormat: exportingFormatOf(workflow.workflowKey)
4552
+ })]
4553
+ }, workflow.id))
4554
+ }),
4555
+ !loading && !error && /* @__PURE__ */ jsx(WorkflowsLoadMore, {
4556
+ hasMore,
4557
+ loadingMore,
4558
+ error: loadMoreError,
4559
+ shown: workflows.length,
4560
+ total,
4561
+ onLoadMore: () => void loadMore()
4562
+ })
4563
+ ]
4564
+ }),
4565
+ /* @__PURE__ */ jsx(WorkflowShareDialog, {
4566
+ open: sharing !== null,
4567
+ onClose: () => setSharing(null),
4568
+ workflowKey: sharing?.workflowKey ?? null,
4569
+ workflowName: sharing?.name ?? "",
4570
+ workspaceId,
4571
+ onShared: () => void refetch()
4572
+ }),
4573
+ /* @__PURE__ */ jsx(WorkflowMoveToProjectDialog, {
4574
+ workflow: moving,
4575
+ onClose: () => setMoving(null),
4576
+ onMoved: () => void refetch()
4577
+ }),
4578
+ /* @__PURE__ */ jsx(WorkflowDescriptionDialog, {
4579
+ workflow: describing,
4580
+ onClose: () => setDescribing(null),
4581
+ onSaved: () => void refetch()
4582
+ }),
4583
+ /* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
4584
+ surface: "builder-create",
4585
+ refusal: createFirst.refusal,
4586
+ onClose: createFirst.clearRefusal,
4587
+ onUpgrade: () => navigate(BILLING_PLANS_PATH)
4588
+ })
4589
+ ]
4590
+ });
4591
+ }
4592
+
4593
+ export { useCreateWorkflowFirst as a, FirstWorkflowChecklistView as i, WorkflowsList_exports as n, WorkflowsListRowsDocument as o, FirstWorkflowChecklist as r, WorkflowsList as t };