@burdenoff/fluidgrids-fe-sdk 2026.1115.7 → 2026.1115.9

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 (73) hide show
  1. package/dist/{AiStudioPage-tzv59pH4.js → AiStudioPage-CZTaVeQE.js} +4 -4
  2. package/dist/{DataSinkDashboardPage-BtWSidiD.js → DataSinkDashboardPage-CPq6-jZM.js} +1 -1
  3. package/dist/{ExecutionDetailPage-CO3BWG_V.js → ExecutionDetailPage-d29WPJDN.js} +92 -27
  4. package/dist/ExecutionSettingsFields-DzKJDOjU.js +1003 -0
  5. package/dist/{ExecutionsListPage-CaO9A4Ph.js → ExecutionsListPage-xQthHGAJ.js} +8 -26
  6. package/dist/{FailureTriagePanel-CBGgU4Tl.js → FailureTriagePanel-Cka9Rc1_.js} +1 -1
  7. package/dist/{FluidGridsProvider-Bemnt09v.js → FluidGridsProvider-BRC0WlAa.js} +248 -3045
  8. package/dist/{HistoryPage-DPGYma-Z.js → HistoryPage-Drdk9j_Q.js} +1 -1
  9. package/dist/{InsightsPage-C6b9WuBc.js → InsightsPage-mYWZvyGR.js} +5 -5
  10. package/dist/{OpenTemplateAsCodeButton-BemhA1u4.js → OpenTemplateAsCodeButton-CQV-YHlJ.js} +2 -2
  11. package/dist/{PaidTemplateConfirm-bNEOQ_Se.js → PaidTemplateConfirm-Dog5moZa.js} +1 -1
  12. package/dist/{agent-form-D0uLvzx4.js → RunLogAppendedDocument-D1_BfMZa.js} +1 -82
  13. package/dist/{SettingsPage-CTd4LQPW.js → SettingsPage-DFnqjkpT.js} +239 -894
  14. package/dist/{TaskQueuesPage-ESjeGUg3.js → TaskQueuesPage-CZQUO33o.js} +1 -1
  15. package/dist/{TemplateCard-D7jG3RaU.js → TemplateCard-D2zt-kXW.js} +5 -5
  16. package/dist/{TemplateConfigurationModal-DMyuHZ3O.js → TemplateConfigurationModal-D8eQsJXJ.js} +1 -1
  17. package/dist/{TemplatePreview-CNbCxOsc.js → TemplatePreview-BgdkcCF-.js} +5 -5
  18. package/dist/{TemplatesPage-DLOVSXa9.js → TemplatesPage-t7rGU-BP.js} +10 -10
  19. package/dist/{WorkflowBuilder-YJlFY071.js → WorkflowBuilder-BS9kVcgU.js} +3 -3
  20. package/dist/{WorkflowBuilder-DhvPS34U.js → WorkflowBuilder-CtTM79lP.js} +6 -5
  21. package/dist/{WorkflowSearchRedirect-vyY1d6nn.js → WorkflowSearchRedirect-Bqdxr833.js} +1 -1
  22. package/dist/WorkflowSettingsDrawer-BiqTf_tV.js +191 -0
  23. package/dist/WorkflowSettingsDrawer-MVU1BKfY.d.ts +18 -0
  24. package/dist/{WorkflowShareDialog-qyGW0cSr.js → WorkflowShareDialog-D_G3TUGQ.js} +1 -1
  25. package/dist/{WorkflowsList-DQq_-Gaq.js → WorkflowsList-DjKePEwo.js} +2035 -517
  26. package/dist/agent-form-Bfvm32j1.js +83 -0
  27. package/dist/{agentTools-uC7Kw2uc.js → agentTools-DrVlHNeP.js} +1 -1
  28. package/dist/{ai-usage-yzPWZgAC.js → ai-usage-DhSKp0tV.js} +1 -1
  29. package/dist/{api-o5UUDbr8.js → api-D1cWC1yx.js} +190 -1
  30. package/dist/{assert-rules-FOiGC7-z.js → assert-rules-D9PNDTMK.js} +1 -1
  31. package/dist/{canvasNoteTools-DedWIXHZ.js → canvasNoteTools-Bo2QldkD.js} +1 -1
  32. package/dist/executions.js +2 -2
  33. package/dist/{flow-builder-BfkigZeg.js → flow-builder-CWfNAFd8.js} +73 -18
  34. package/dist/{graphql-types-C2heV7ot.js → graphql-types-CxkVzQqA.js} +25 -1
  35. package/dist/history.js +1 -1
  36. package/dist/{index-CIRkv8Dr.d.ts → index-C2ehY2Ld.d.ts} +180 -10
  37. package/dist/index.d.ts +3 -3
  38. package/dist/index.js +45 -42
  39. package/dist/{node-detail-view-B-nHEP6Z.js → node-detail-view-D_N3kLtA.js} +7 -7
  40. package/dist/{node-editor-tab-body-CZHYnHmY.js → node-editor-tab-body-BQ9JZa72.js} +2 -2
  41. package/dist/observability.d.ts +1 -1
  42. package/dist/observability.js +2 -2
  43. package/dist/{useAgentDefinitions-CVBnPMnJ.js → operations-qq_bbgXP.js} +3 -223
  44. package/dist/{popover-C2ohJ0Rd.js → popover-DZdTN21a.js} +3 -3
  45. package/dist/{quick-config-panel-ButILqM4.js → quick-config-panel-BCUY4tQy.js} +3 -3
  46. package/dist/relative-time-Dxt8ZIIu.js +55 -0
  47. package/dist/{run-list-links-sTAexiqj.js → run-list-links-BwsCiBPB.js} +1 -1
  48. package/dist/{run-mode-DjXIqsz3.js → run-mode-vpIlmfgY.js} +1 -1
  49. package/dist/{schedule-panel-BZuH1ltc.js → schedule-panel-B6FrpX9d.js} +9 -8
  50. package/dist/settings.d.ts +2 -2
  51. package/dist/settings.js +3 -2
  52. package/dist/{sidebar-node-editor-B0-72udR.js → sidebar-node-editor-CWrmlFlZ.js} +3 -3
  53. package/dist/{template-code-DrS_vlf_.js → template-code-9dL1SUji.js} +1 -1
  54. package/dist/templates.js +2 -2
  55. package/dist/{use-workflow-code-editor-DfWsRWC7.js → use-workflow-code-editor-DJMH7-Xx.js} +1 -1
  56. package/dist/{use-workflow-tests-CVVKinFU.js → use-workflow-tests-C4e6aJZS.js} +2 -2
  57. package/dist/useAgentDefinitions-DX5GvEIp.js +223 -0
  58. package/dist/{useDurableParity-gnKk3TyL.js → useDurableParity-BtWk4d-i.js} +1 -1
  59. package/dist/{useExecutions-Dwa7jo1o.js → useExecutions-C9pVKexC.js} +3 -2
  60. package/dist/{useGlobalStoreClient-4BH2Xbru.js → useGlobalStoreClient-C2P50Gj5.js} +1 -1
  61. package/dist/{useObservability-Bp4LtS1S.js → useObservability-DsHX86Xl.js} +1 -1
  62. package/dist/{useRunHistory-Zqh59sXN.js → useRunHistory-DUNLNOKA.js} +2 -2
  63. package/dist/{useWorkflowCodeExport-C93cPJQ5.js → useWorkflowCodeExport-DSbfcehl.js} +13 -3
  64. package/dist/{useWorkflows-BodVSonO.js → useWorkflows-B13Cp8tk.js} +90 -10
  65. package/dist/workflow-builder.js +4 -4
  66. package/dist/{workflow-description-DxiRgyxy.js → workflow-description-F3inwvof.js} +1 -1
  67. package/dist/workflow-pages.d.ts +2 -2
  68. package/dist/workflow-pages.js +14 -14
  69. package/dist/workflow-save-state-DUE9lNwQ.js +2813 -0
  70. package/dist/{workflow-transfer-BlDyxa9L.js → workflow-transfer-CsXh0mIi.js} +1 -1
  71. package/dist/workflows-list.js +1 -1
  72. package/package.json +3 -3
  73. package/dist/SettingsPage-DMHQFj5-.d.ts +0 -9
@@ -1,34 +1,39 @@
1
1
  "use client";
2
2
  import { t as __exportAll } from "./rolldown-runtime-hDbaFkMy.js";
3
- import { c as useImportWorkflow, h as useWorkflowDefinitions, l as useLazyWorkflowDefinition, n as useCreateWorkflow, o as useDeleteWorkflow, s as useDuplicateWorkflow, u as usePreviewN8nImport } from "./useWorkflows-BodVSonO.js";
4
- import { t as FluidGridsContext, wt as createThenOpen } from "./FluidGridsProvider-Bemnt09v.js";
5
- import { a as workflowDescriptionCharactersLeft, i as visibleWorkflowDescription, o as CreateWorkflowRefusalDialog, r as saveWorkflowDescription, t as commitWorkflowDescription } from "./workflow-description-DxiRgyxy.js";
3
+ import { c as useDuplicateWorkflow, d as usePreviewN8nImport, g as useWorkflowDefinitions, l as useImportWorkflow, r as useCreateWorkflow, s as useDeleteWorkflow, u as useLazyWorkflowDefinition } from "./useWorkflows-B13Cp8tk.js";
4
+ import { Ct as classifyCreateRefusal, St as builderPathOf, t as FluidGridsContext, wt as createThenOpen } from "./FluidGridsProvider-BRC0WlAa.js";
5
+ import { a as workflowDescriptionCharactersLeft, i as visibleWorkflowDescription, o as CreateWorkflowRefusalDialog, r as saveWorkflowDescription, t as commitWorkflowDescription } from "./workflow-description-F3inwvof.js";
6
6
  import { c as isQuotaExhaustedFailure, t as BILLING_PLANS_PATH } from "./quota-Cdt8yz7N.js";
7
7
  import { A as useFlowStore } from "./node-operation-selection-sT7nCmDk.js";
8
+ import { n as getFluidGridsClient } from "./client-Ctl4jmY3.js";
9
+ import { o as throwIfResultError, t as describeOperationError } from "./errors-xPZ-IbQd.js";
10
+ import { o as UpdateWorkflowDefinitionDocument } from "./WorkflowVersionsDocument-DRVOp8Uj.js";
8
11
  import { a as SdkPermissionGate, i as SdkPermissionButton, s as useFluidGridsPermission, t as FLUIDGRIDS_PERMISSIONS } from "./constants-65QV61nQ.js";
9
- import { i as QuotaExhaustedDialog, n as useExportWorkflowAs } from "./useWorkflowCodeExport-C93cPJQ5.js";
10
12
  import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
11
- 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-DjXIqsz3.js";
12
- import { II as WorkflowAccessFilter, qI as WorkflowExportFormat } from "./graphql-types-C2heV7ot.js";
13
- import { S as typeScriptModuleFile, a as ImportSourceError, c as assertImportByteSize, f as importAcceptAttribute, i as CODE_EXPORT_FORMATS, n as downloadWorkflowExport, o as MAX_IMPORT_ARCHIVE_BYTES, p as importFileKind, r as parseWorkflowImport, s as MAX_IMPORT_SOURCE_BYTES, u as checkTypeScriptImport, v as primaryImportModule, w as workflowNameFromFile, x as typeScriptImportSource, y as readProjectArchive } from "./workflow-transfer-BlDyxa9L.js";
14
- import { i as canShareWorkflow, r as canEditWorkflow, t as WorkflowShareDialog } from "./WorkflowShareDialog-qyGW0cSr.js";
13
+ import { i as QuotaExhaustedDialog, n as useExportWorkflowAs } from "./useWorkflowCodeExport-DSbfcehl.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-vpIlmfgY.js";
15
+ import { CL as WorkflowStatus, RI as WorkflowAccessFilter, YI as WorkflowExportFormat } from "./graphql-types-CxkVzQqA.js";
16
+ import { S as typeScriptModuleFile, a as ImportSourceError, c as assertImportByteSize, f as importAcceptAttribute, i as CODE_EXPORT_FORMATS, n as downloadWorkflowExport, o as MAX_IMPORT_ARCHIVE_BYTES, p as importFileKind, r as parseWorkflowImport, s as MAX_IMPORT_SOURCE_BYTES, u as checkTypeScriptImport, v as primaryImportModule, w as workflowNameFromFile, x as typeScriptImportSource, y as readProjectArchive } from "./workflow-transfer-CsXh0mIi.js";
17
+ import { i as canShareWorkflow, r as canEditWorkflow, t as WorkflowShareDialog } from "./WorkflowShareDialog-D_G3TUGQ.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-D9Pir3bc.js";
15
21
  import { i as useOpenRequest, n as ACTION_PARAM_VALUES, r as useActionParam } from "./useActionParam-B0ebTZmg.js";
16
22
  import { d as useFluidGridsFlag, t as FLUIDGRIDS_FLAGS } from "./feature-flags-B_b8PJ6Z.js";
17
23
  import { a as useWorkflowProjects, i as useWorkflowProjectActions, n as useWorkflowFolderActions, r as useWorkflowFolders, t as useBulkWorkflowActions } from "./useWorkflowOrganization-r5FWNBs6.js";
18
- import { t as describeOperationError } from "./errors-xPZ-IbQd.js";
19
- import { a as useExecutions } from "./useExecutions-Dwa7jo1o.js";
24
+ import { t as WorkflowSettingsDrawer } from "./WorkflowSettingsDrawer-BiqTf_tV.js";
25
+ import { a as useExecutions } from "./useExecutions-C9pVKexC.js";
20
26
  import { a as firstWorkflowProgress, i as builderPathFor, r as GUIDED_TOUR_STATE } from "./firstWorkflow-C_h0KMB2.js";
21
27
  import { n as useFluidGridsPageControls } from "./pageControlsBridge-0pX9s-3k.js";
22
28
  import { i as workflowsListControls } from "./pageControlSpecs-DZJ9K37m.js";
23
29
  import { t as FluidGridsDocsLink } from "./FluidGridsDocsLink-JxkBpOeb.js";
24
- import { n as getFluidGridsClient } from "./client-Ctl4jmY3.js";
25
- import { useCallback, useContext, useMemo, useRef, useState } from "react";
26
- import { useNavigate, useSearchParams } from "react-router";
30
+ import { useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
31
+ import { Link, useNavigate, useSearchParams } from "react-router";
27
32
  import { Icon } from "@iconify/react";
28
33
  import { cn } from "@burdenoff/fe-libs/utils";
29
34
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
30
35
  import { toast } from "sonner";
31
- import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Card, Checkbox, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, IllustratedEmptyState, Input, Label, NextSteps, ResponsiveDialog, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, Select, SelectContent, SelectItem, SelectSeparator, SelectTrigger, SelectValue, Skeleton, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@burdenoff/fe-libs/ui";
36
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Card, Checkbox, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, IllustratedEmptyState, Input, Label, NextSteps, OptionalFields, ResponsiveDialog, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, ResponsiveTable, Select, SelectContent, SelectItem, SelectSeparator, SelectTrigger, SelectValue, ShowTechnicalDetails, Skeleton, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, useRememberedOpen } from "@burdenoff/fe-libs/ui";
32
37
  import { v4 } from "uuid";
33
38
  import { TagBadge } from "@burdenoff/fe-libs/tag";
34
39
 
@@ -49,7 +54,7 @@ function useCreateWorkflowFirst(options = {}) {
49
54
  const inFlightRef = useRef(false);
50
55
  const { basePath, state } = options;
51
56
  return {
52
- start: useCallback(async () => {
57
+ start: useCallback(async (name) => {
53
58
  if (inFlightRef.current) return null;
54
59
  inFlightRef.current = true;
55
60
  setCreating(true);
@@ -61,7 +66,8 @@ function useCreateWorkflowFirst(options = {}) {
61
66
  mintKey: v4
62
67
  }, {
63
68
  basePath,
64
- state
69
+ state,
70
+ name
65
71
  });
66
72
  if (result.status === "refused") setRefusal(result.refusal);
67
73
  return result;
@@ -81,6 +87,93 @@ function useCreateWorkflowFirst(options = {}) {
81
87
  };
82
88
  }
83
89
 
90
+ // src/hooks/useDuplicateWorkflowCopy.ts
91
+ /**
92
+ * Duplicate a workflow as "<name> (copy)" (BOFF-11843).
93
+ *
94
+ * `duplicateWorkflow` only takes a new key, so the copy used to keep the
95
+ * original's name and the two could not be told apart in the list. Until the
96
+ * service takes the new name itself (`DuplicateWorkflowInput.newName`,
97
+ * BOFF-13715), the copy is renamed right after it is made with
98
+ * `updateWorkflowDefinition`. A failed rename never undoes the copy: the copy
99
+ * exists, so the person is told it kept the original name. The rename needs
100
+ * workflow:update, which duplicating does not, so a caller without it gets
101
+ * the copy under the original name and no rename is tried (or reported).
102
+ *
103
+ * `duplicateAsCopy` is pure (its calls are injected) so the order and the
104
+ * rename are unit tested without a DOM.
105
+ */
106
+ /** "Invoices (copy)" in the page's language. */
107
+ function copyNameOf(tr, name) {
108
+ return tr("fluidgrids.builder.cardWorkflow.copyName", "{{name}} (copy)", { name });
109
+ }
110
+ /** The key the copy is created under: unique, and readable as a copy. */
111
+ function copyKeyOf(workflowKey, now) {
112
+ return `${workflowKey}_copy_${now}`;
113
+ }
114
+ /**
115
+ * Duplicate `source`, then give the copy `copyName`. Throws what the
116
+ * duplicate threw (a quota refusal among them) or an Error with the service's
117
+ * message when it answered without a copy.
118
+ */
119
+ async function duplicateAsCopy(deps, source, copyName) {
120
+ const result = await deps.duplicate(source.workflowKey, source.version, { newWorkflowKey: copyKeyOf(source.workflowKey, deps.now()) });
121
+ if (!result?.success || !result.workflow) throw new Error(result?.message || "Failed to duplicate workflow");
122
+ const workflow = result.workflow;
123
+ if (!deps.canRename) return {
124
+ workflow,
125
+ name: source.name,
126
+ renamed: false,
127
+ renameRefused: false
128
+ };
129
+ try {
130
+ await deps.rename(workflow.id, copyName);
131
+ return {
132
+ workflow,
133
+ name: copyName,
134
+ renamed: true,
135
+ renameRefused: false
136
+ };
137
+ } catch {
138
+ return {
139
+ workflow,
140
+ name: source.name,
141
+ renamed: false,
142
+ renameRefused: true
143
+ };
144
+ }
145
+ }
146
+ /** Renames one workflow version in place (no new version). */
147
+ async function renameWorkflowVersion(id, name) {
148
+ if (!throwIfResultError(await getFluidGridsClient().mutate({
149
+ mutation: UpdateWorkflowDefinitionDocument,
150
+ variables: {
151
+ id,
152
+ input: { name }
153
+ },
154
+ refetchQueries: ["WorkflowDefinitions"]
155
+ })).data?.updateWorkflowDefinition) throw new Error("The copy was not renamed");
156
+ }
157
+ /** `duplicateAsCopy` wired to the SDK's client and the page's language. */
158
+ function useDuplicateWorkflowCopy() {
159
+ const tr = useTr();
160
+ const { duplicateWorkflow, loading } = useDuplicateWorkflow();
161
+ const { allowed: canRename } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_UPDATE);
162
+ return {
163
+ duplicate: useCallback((source) => duplicateAsCopy({
164
+ duplicate: duplicateWorkflow,
165
+ rename: renameWorkflowVersion,
166
+ canRename,
167
+ now: Date.now
168
+ }, source, copyNameOf(tr, source.name)), [
169
+ duplicateWorkflow,
170
+ canRename,
171
+ tr
172
+ ]),
173
+ duplicating: loading
174
+ };
175
+ }
176
+
84
177
  // src/builder/components/ui/workflow-status-pill.tsx
85
178
  /** Status pill: colored dot + a label resolved from the current host locale. */
86
179
  function WorkflowStatusPill({ status }) {
@@ -230,29 +323,11 @@ function WorkflowExportMenu({ onExportAs, exporting }) {
230
323
  }
231
324
 
232
325
  // src/builder/components/ui/card-workflow.tsx
233
- /** Compact relative timestamp ("2h ago"); absolute date beyond a week. */
234
- function relativeTime(iso) {
235
- if (!iso) return "—";
236
- const then = new Date(iso).getTime();
237
- if (Number.isNaN(then)) return "—";
238
- const mins = Math.floor((Date.now() - then) / 6e4);
239
- if (mins < 1) return "just now";
240
- if (mins < 60) return `${mins}m ago`;
241
- const hrs = Math.floor(mins / 60);
242
- if (hrs < 24) return `${hrs}h ago`;
243
- const days = Math.floor(hrs / 24);
244
- if (days < 7) return `${days}d ago`;
245
- return new Intl.DateTimeFormat("en-US", {
246
- month: "short",
247
- day: "numeric",
248
- year: "numeric"
249
- }).format(new Date(then));
250
- }
251
326
  const CardWorkflow = ({ workflow, onUpdateSuccess, onExport, onExportAs, exportingFormat = null, onShare, onMoveToProject, onEditDescription }) => {
252
327
  const tr = useTr();
253
328
  const navigate = useNavigate();
254
329
  const resetWorkflow = useFlowStore((s) => s.actions.resetWorkflow);
255
- const { duplicateWorkflow: duplicateWorkflowMutation } = useDuplicateWorkflow();
330
+ const { duplicate: duplicateAsCopy } = useDuplicateWorkflowCopy();
256
331
  const { deleteWorkflow: deleteWorkflowMutation } = useDeleteWorkflow();
257
332
  const [showDeleteDialog, setShowDeleteDialog] = useState(false);
258
333
  const [isDeleting, setIsDeleting] = useState(false);
@@ -260,9 +335,13 @@ const CardWorkflow = ({ workflow, onUpdateSuccess, onExport, onExportAs, exporti
260
335
  async function handleDuplicateWorkflow() {
261
336
  try {
262
337
  resetWorkflow();
263
- const result = await duplicateWorkflowMutation(workflow.workflow_key, workflow.version, { newWorkflowKey: `${workflow.workflow_key}_copy_${Date.now()}` });
264
- if (result?.success && result.workflow) navigate(`../workflow/${result.workflow.workflowKey}/${result.workflow.version}`);
265
- else throw new Error(result?.message || "Failed to duplicate workflow");
338
+ const copy = await duplicateAsCopy({
339
+ workflowKey: workflow.workflow_key,
340
+ version: workflow.version,
341
+ name: workflow.name
342
+ });
343
+ if (copy.renameRefused) toast.warning(tr("fluidgrids.builder.cardWorkflow.copyRenameFailed", "The copy was made but kept the original name. Rename it in the editor."));
344
+ navigate(`../workflow/${copy.workflow.workflowKey}/${copy.workflow.version}`);
266
345
  } catch (error) {
267
346
  const cause = error instanceof Error ? error.cause : void 0;
268
347
  if (isQuotaExhaustedFailure(cause) || isQuotaExhaustedFailure(error)) {
@@ -309,7 +388,7 @@ const CardWorkflow = ({ workflow, onUpdateSuccess, onExport, onExportAs, exporti
309
388
  const editable = canEditWorkflow(workflow.my_access);
310
389
  const shareable = canShareWorkflow(workflow.my_access);
311
390
  const description = visibleWorkflowDescription(workflow.description, workflow.name);
312
- const updatedExact = workflow.updated_at ? new Date(workflow.updated_at).toLocaleString() : void 0;
391
+ const updatedExact = formatExactTime(workflow.updated_at);
313
392
  return /* @__PURE__ */ jsxs(TooltipProvider, { children: [
314
393
  /* @__PURE__ */ jsxs(Card, {
315
394
  role: "button",
@@ -398,7 +477,7 @@ const CardWorkflow = ({ workflow, onUpdateSuccess, onExport, onExportAs, exporti
398
477
  children: [
399
478
  tr("fluidgrids.builder.cardWorkflow.updatedPrefix", "Updated"),
400
479
  " ",
401
- relativeTime(workflow.updated_at)
480
+ formatRelativeTime(tr, workflow.updated_at)
402
481
  ]
403
482
  }),
404
483
  /* @__PURE__ */ jsx("span", {
@@ -439,23 +518,26 @@ const CardWorkflow = ({ workflow, onUpdateSuccess, onExport, onExportAs, exporti
439
518
  side: "top",
440
519
  children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.editWorkflow", "Edit workflow") })
441
520
  })] }),
442
- /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
443
- asChild: true,
444
- children: /* @__PURE__ */ jsx(Button, {
445
- variant: "ghost",
446
- size: "icon",
447
- className: "size-8",
448
- onClick: handleOnSettings,
449
- "aria-label": tr("fluidgrids.builder.cardWorkflow.workflowSettings", "Workflow settings"),
450
- children: /* @__PURE__ */ jsx(Icon, {
451
- icon: "mdi:cog-outline",
452
- className: "size-4"
521
+ /* @__PURE__ */ jsx(SdkPermissionGate, {
522
+ permission: FLUIDGRIDS_PERMISSIONS.SYSTEM_CONFIG_READ,
523
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
524
+ asChild: true,
525
+ children: /* @__PURE__ */ jsx(Button, {
526
+ variant: "ghost",
527
+ size: "icon",
528
+ className: "size-8",
529
+ onClick: handleOnSettings,
530
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.workflowSettings", "Workflow settings"),
531
+ children: /* @__PURE__ */ jsx(Icon, {
532
+ icon: "mdi:cog-outline",
533
+ className: "size-4"
534
+ })
453
535
  })
454
- })
455
- }), /* @__PURE__ */ jsx(TooltipContent, {
456
- side: "top",
457
- children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.workflowSettings", "Workflow settings") })
458
- })] }),
536
+ }), /* @__PURE__ */ jsx(TooltipContent, {
537
+ side: "top",
538
+ children: /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.builder.cardWorkflow.workflowSettings", "Workflow settings") })
539
+ })] })
540
+ }),
459
541
  onShare && shareable && /* @__PURE__ */ jsx(SdkPermissionGate, {
460
542
  permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_SHARE,
461
543
  children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
@@ -808,20 +890,41 @@ function declaredLength(response) {
808
890
  const value = Number(response.headers.get("content-length"));
809
891
  return Number.isFinite(value) && value > 0 ? value : null;
810
892
  }
893
+ /**
894
+ * A problem reading the picked source, as a toast: the title in the page's
895
+ * language, the raw detail (a JSON parser's message, an HTTP status) under it
896
+ * (BOFF-11843: these were English-only before).
897
+ */
898
+ function toastImportProblem(title, error) {
899
+ const detail = error instanceof Error ? error.message : "";
900
+ toast.error(title, detail && detail !== title ? { description: detail } : {});
901
+ }
902
+ /** The node references a FluidGrids file names, one per line, for "Show technical details". */
903
+ function nodeReferencesDetail(tr, references) {
904
+ const lines = references.map((ref) => ref.nodeVersion ? `${ref.nodeId}: ${ref.nodeType}@${ref.nodeVersion}` : `${ref.nodeId}: ${ref.nodeType}`);
905
+ return [tr("fluidgrids.workflowsList.importNodeReferencesCount", "{{count}} node references found", { count: String(references.length) }), ...lines].join("\n");
906
+ }
811
907
  function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled }) {
812
908
  const tr = useTr();
909
+ const navigate = useNavigate();
910
+ const v2 = useNavigationV2();
911
+ const fieldId = useId();
813
912
  const codeFirst = useFluidGridsFlag(FLUIDGRIDS_FLAGS.codeFirst);
814
- const { importWorkflow, loading, error: importError } = useImportWorkflow();
913
+ const { importWorkflow, loading } = useImportWorkflow();
815
914
  const [open, setOpen] = useState(false);
816
915
  const openFromRequest = useCallback(() => setOpen(true), []);
817
916
  useOpenRequest(openRequested, openFromRequest, onOpenRequestHandled);
818
917
  const [typeScript, setTypeScript] = useState(null);
819
918
  const [issues, setIssues] = useState(null);
820
- const [submitted, setSubmitted] = useState(false);
821
919
  const [rawJson, setRawJson] = useState("");
822
920
  const [url, setUrl] = useState("");
823
921
  const [parsed, setParsed] = useState(null);
824
922
  const [name, setName] = useState("");
923
+ const nameEdited = useRef(false);
924
+ const [nameMissing, setNameMissing] = useState(false);
925
+ const [pickedFile, setPickedFile] = useState(null);
926
+ const [refusal, setRefusal] = useState(null);
927
+ const [requestError, setRequestError] = useState(null);
825
928
  const [workflowKey, setWorkflowKey] = useState("");
826
929
  const [version, setVersion] = useState("");
827
930
  const [loadingUrl, setLoadingUrl] = useState(false);
@@ -841,22 +944,29 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
841
944
  setUrl("");
842
945
  setParsed(null);
843
946
  setName("");
947
+ nameEdited.current = false;
948
+ setNameMissing(false);
949
+ setPickedFile(null);
950
+ setRequestError(null);
844
951
  setWorkflowKey("");
845
952
  setVersion("");
846
953
  setTypeScript(null);
847
954
  setIssues(null);
848
- setSubmitted(false);
955
+ };
956
+ /** A name read from the source, unless the person already typed one. */
957
+ const suggestName = (next) => {
958
+ if (v2 && nameEdited.current) return;
959
+ setName(next);
849
960
  };
850
961
  const selectTypeScript = (label, files) => {
851
962
  dropN8nPreview();
852
963
  setParsed(null);
853
964
  setIssues(null);
854
- setSubmitted(false);
855
965
  setTypeScript({
856
966
  label,
857
967
  files
858
968
  });
859
- setName(workflowNameFromFile(primaryImportModule(files)?.path ?? label));
969
+ suggestName(workflowNameFromFile(primaryImportModule(files)?.path ?? label));
860
970
  setWorkflowKey("");
861
971
  setVersion("");
862
972
  };
@@ -865,7 +975,6 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
865
975
  dropN8nPreview();
866
976
  setTypeScript(null);
867
977
  setParsed(null);
868
- setSubmitted(false);
869
978
  setIssues({
870
979
  errors: [describeImportSourceProblem(tr, error.problem)],
871
980
  warnings: []
@@ -904,11 +1013,11 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
904
1013
  const preview = await previewN8nImport(next.definitionJson);
905
1014
  if (request !== previewRequest.current) return;
906
1015
  setN8nPreview(preview);
907
- setName(preview.name);
1016
+ suggestName(preview.name);
908
1017
  } catch (error) {
909
1018
  if (request !== previewRequest.current) return;
910
1019
  setParsed(null);
911
- toast.error(error instanceof Error ? error.message : tr("fluidgrids.workflowsList.importN8nPreviewFailed", "The n8n workflow could not be read"));
1020
+ toastImportProblem(tr("fluidgrids.workflowsList.importN8nPreviewFailed", "The n8n workflow could not be read"), error);
912
1021
  } finally {
913
1022
  if (request === previewRequest.current) setPreviewingN8n(false);
914
1023
  }
@@ -916,29 +1025,29 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
916
1025
  const parse = (value) => {
917
1026
  setTypeScript(null);
918
1027
  setIssues(null);
919
- setSubmitted(false);
920
1028
  dropN8nPreview();
921
1029
  try {
922
1030
  const next = parseWorkflowImport(value);
923
1031
  setParsed(next);
924
- setName(next.name);
1032
+ suggestName(next.name);
925
1033
  setWorkflowKey("");
926
1034
  setVersion(next.version ?? "");
927
1035
  if (next.source === "n8n") showN8nPreview(next);
928
1036
  } catch (error) {
929
1037
  setParsed(null);
930
- toast.error(error instanceof Error ? error.message : tr("fluidgrids.workflowsList.importInvalidJson", "Invalid workflow JSON"));
1038
+ toastImportProblem(tr("fluidgrids.workflowsList.importInvalidJson", "Invalid workflow JSON"), error);
931
1039
  }
932
1040
  };
933
1041
  const handleFile = async (file) => {
934
1042
  if (!file) return;
1043
+ setPickedFile(file.name);
935
1044
  try {
936
1045
  if (!await readCodeSource(importFileKind(file.name), file.name, file.size, {
937
1046
  text: () => file.text(),
938
1047
  bytes: () => file.arrayBuffer()
939
1048
  })) parse(await file.text());
940
1049
  } catch (error) {
941
- toast.error(error instanceof Error ? error.message : tr("fluidgrids.workflowsList.importReadFileFailed", "Unable to read import file"));
1050
+ toastImportProblem(tr("fluidgrids.workflowsList.importReadFileFailed", "Unable to read import file"), error);
942
1051
  }
943
1052
  };
944
1053
  const handleUrl = async () => {
@@ -948,7 +1057,7 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
948
1057
  parsedUrl = new URL(url.trim());
949
1058
  if (parsedUrl.protocol !== "https:") throw new Error(tr("fluidgrids.workflowsList.importUrlNotHttps", "Import URLs must use HTTPS"));
950
1059
  } catch (error) {
951
- toast.error(error instanceof Error ? error.message : tr("fluidgrids.workflowsList.importUrlInvalid", "Invalid import URL"));
1060
+ toastImportProblem(tr("fluidgrids.workflowsList.importUrlInvalid", "Invalid import URL"), error);
952
1061
  return;
953
1062
  }
954
1063
  setLoadingUrl(true);
@@ -961,14 +1070,29 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
961
1070
  bytes: () => response.arrayBuffer()
962
1071
  })) parse(await response.text());
963
1072
  } catch (error) {
964
- toast.error(error instanceof Error ? error.message : tr("fluidgrids.workflowsList.importUrlFetchFailed", "Unable to fetch import URL"));
1073
+ toastImportProblem(tr("fluidgrids.workflowsList.importUrlFetchFailed", "Unable to fetch import URL"), error);
965
1074
  } finally {
966
1075
  setLoadingUrl(false);
967
1076
  }
968
1077
  };
1078
+ /**
1079
+ * Sends the import. A failed request is no longer silent (BOFF-11843): a
1080
+ * plan-limit refusal opens the Workflow Limit Reached dialog, anything else
1081
+ * is said inside this dialog. Returns null when nothing was imported.
1082
+ */
1083
+ const sendImport = async (input) => {
1084
+ setRequestError(null);
1085
+ try {
1086
+ return await importWorkflow(input);
1087
+ } catch (error) {
1088
+ const refused = classifyCreateRefusal(error);
1089
+ if (refused.kind === "failed") setRequestError(describeOperationError(error));
1090
+ else setRefusal(refused);
1091
+ return null;
1092
+ }
1093
+ };
969
1094
  const handleTypeScriptImport = async (source) => {
970
1095
  setIssues(null);
971
- setSubmitted(true);
972
1096
  const input = {
973
1097
  workflowKey: workflowKey.trim() || void 0,
974
1098
  version: version.trim() || void 0,
@@ -976,7 +1100,7 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
976
1100
  source: typeScriptImportSource(source.files),
977
1101
  allowMissingNodes: false
978
1102
  };
979
- const imported = await importWorkflow(input);
1103
+ const imported = await sendImport(input);
980
1104
  if (!imported) return;
981
1105
  if (!imported.success || !imported.workflow) {
982
1106
  setIssues({
@@ -992,15 +1116,16 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
992
1116
  onImported();
993
1117
  };
994
1118
  const handleImport = async () => {
1119
+ if (v2 && (parsed || typeScript) && !name.trim()) {
1120
+ setNameMissing(true);
1121
+ return;
1122
+ }
995
1123
  if (typeScript && name.trim()) {
996
1124
  await handleTypeScriptImport(typeScript);
997
1125
  return;
998
1126
  }
999
1127
  if (!parsed || !name.trim()) return;
1000
- if (codeFirst) {
1001
- setIssues(null);
1002
- setSubmitted(true);
1003
- }
1128
+ if (codeFirst) setIssues(null);
1004
1129
  const input = {
1005
1130
  workflowKey: workflowKey.trim() || `${name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-")}-${Date.now()}`,
1006
1131
  version: version.trim() || "v1",
@@ -1014,7 +1139,7 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
1014
1139
  category: parsed.category,
1015
1140
  allowMissingNodes: false
1016
1141
  };
1017
- const imported = await importWorkflow(input);
1142
+ const imported = await sendImport(input);
1018
1143
  if (!imported) return;
1019
1144
  if (!imported.success || !imported.workflow) {
1020
1145
  if (codeFirst) {
@@ -1034,7 +1159,197 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
1034
1159
  reset();
1035
1160
  onImported();
1036
1161
  };
1037
- return /* @__PURE__ */ jsxs(Dialog, {
1162
+ const closeDialog = () => {
1163
+ setOpen(false);
1164
+ reset();
1165
+ };
1166
+ const importDisabled = loading || !parsed && !typeScript || !v2 && !name.trim() || parsed?.source === "n8n" && !n8nPreview;
1167
+ const fileInputId = "fluidgrids-workflow-import-file";
1168
+ const nameId = "fluidgrids-import-name";
1169
+ const nameErrorId = `${fieldId}-name-error`;
1170
+ const chooseFileLabel = codeFirst ? tr("fluidgrids.workflowsList.importChooseFileCode", "Choose JSON, TypeScript or .zip file") : tr("fluidgrids.workflowsList.importChooseFile", "Choose JSON file");
1171
+ const dialogTitle = codeFirst ? tr("fluidgrids.workflowsList.importTitleCode", "Import workflow") : tr("fluidgrids.workflowsList.importTitle", "Import workflow JSON");
1172
+ 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.");
1173
+ const filePicker = /* @__PURE__ */ jsxs("div", {
1174
+ className: "flex flex-wrap items-center gap-2",
1175
+ children: [
1176
+ /* @__PURE__ */ jsxs(Label, {
1177
+ htmlFor: fileInputId,
1178
+ 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",
1179
+ children: [/* @__PURE__ */ jsx(Icon, {
1180
+ icon: "mynaui:upload",
1181
+ className: "size-4",
1182
+ "aria-hidden": "true"
1183
+ }), chooseFileLabel]
1184
+ }),
1185
+ /* @__PURE__ */ jsx("input", {
1186
+ id: fileInputId,
1187
+ type: "file",
1188
+ accept: importAcceptAttribute(codeFirst),
1189
+ className: "sr-only",
1190
+ "data-testid": "fluidgrids-import-file",
1191
+ onChange: (event) => void handleFile(event.currentTarget.files?.[0])
1192
+ }),
1193
+ v2 && pickedFile && /* @__PURE__ */ jsx("span", {
1194
+ className: "min-w-0 truncate text-sm text-muted-foreground",
1195
+ "data-testid": "fluidgrids-import-picked-file",
1196
+ children: pickedFile
1197
+ })
1198
+ ]
1199
+ });
1200
+ const urlRow = /* @__PURE__ */ jsxs("div", {
1201
+ className: "flex gap-2",
1202
+ children: [/* @__PURE__ */ jsx(Input, {
1203
+ value: url,
1204
+ onChange: (event) => setUrl(event.target.value),
1205
+ placeholder: "https://example.com/workflow.json",
1206
+ "aria-label": codeFirst ? tr("fluidgrids.workflowsList.importUrlLabelCode", "Workflow JSON, TypeScript or .zip URL") : tr("fluidgrids.workflowsList.importUrlLabel", "Workflow JSON URL")
1207
+ }), /* @__PURE__ */ jsx(Button, {
1208
+ variant: "outline",
1209
+ onClick: () => void handleUrl(),
1210
+ disabled: loadingUrl || !url.trim(),
1211
+ children: loadingUrl ? tr("fluidgrids.workflowsList.importFetchingUrl", "Loading…") : tr("fluidgrids.workflowsList.importFetchUrl", "Fetch")
1212
+ })]
1213
+ });
1214
+ const pasteArea = /* @__PURE__ */ jsx(Textarea, {
1215
+ value: rawJson,
1216
+ onChange: (event) => {
1217
+ setRawJson(event.target.value);
1218
+ setParsed(null);
1219
+ dropN8nPreview();
1220
+ },
1221
+ onBlur: () => rawJson.trim() && parse(rawJson),
1222
+ placeholder: tr("fluidgrids.workflowsList.importPastePlaceholder", "Paste workflow JSON here"),
1223
+ className: "min-h-44 font-mono text-xs",
1224
+ "aria-label": tr("fluidgrids.workflowsList.importPasteLabel", "Workflow JSON")
1225
+ });
1226
+ /** What the picked source is: the n8n report or the TypeScript summary. */
1227
+ const sourceSummary = parsed?.source === "n8n" ? n8nPreview ? /* @__PURE__ */ jsx(N8nImportReport, { report: n8nPreview.report }) : /* @__PURE__ */ jsx("p", {
1228
+ className: "text-xs text-muted-foreground",
1229
+ "data-testid": "fluidgrids-import-n8n-previewing",
1230
+ children: previewingN8n ? tr("fluidgrids.workflowsList.importN8nPreviewing", "Reading the n8n workflow…") : tr("fluidgrids.workflowsList.importN8nDetected", "n8n workflow detected")
1231
+ }) : typeScript ? /* @__PURE__ */ jsx("p", {
1232
+ className: "text-xs text-muted-foreground",
1233
+ "data-testid": "fluidgrids-import-typescript",
1234
+ 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.", {
1235
+ file: typeScript.label,
1236
+ count: String(typeScript.files.length)
1237
+ }) : tr("fluidgrids.workflowsList.importTypeScriptFile", "TypeScript module {{file}}: the service builds it and checks the workflow it defines before creating a draft.", { file: typeScript.label })
1238
+ }) : null;
1239
+ const nameInput = /* @__PURE__ */ jsx(Input, {
1240
+ id: nameId,
1241
+ value: name,
1242
+ required: v2,
1243
+ "aria-invalid": v2 && nameMissing ? true : void 0,
1244
+ "aria-describedby": v2 && nameMissing ? nameErrorId : void 0,
1245
+ onChange: (event) => {
1246
+ nameEdited.current = true;
1247
+ setName(event.target.value);
1248
+ if (event.target.value.trim()) setNameMissing(false);
1249
+ }
1250
+ });
1251
+ const keyField = /* @__PURE__ */ jsxs("div", {
1252
+ className: "space-y-1",
1253
+ children: [/* @__PURE__ */ jsx(Label, {
1254
+ htmlFor: "fluidgrids-import-key",
1255
+ children: tr("fluidgrids.workflowsList.importKey", "Workflow key (optional)")
1256
+ }), /* @__PURE__ */ jsx(Input, {
1257
+ id: "fluidgrids-import-key",
1258
+ value: workflowKey,
1259
+ onChange: (event) => setWorkflowKey(event.target.value)
1260
+ })]
1261
+ });
1262
+ const versionField = /* @__PURE__ */ jsxs("div", {
1263
+ className: "space-y-1",
1264
+ children: [/* @__PURE__ */ jsx(Label, {
1265
+ htmlFor: "fluidgrids-import-version",
1266
+ children: tr("fluidgrids.workflowsList.importVersion", "Version")
1267
+ }), /* @__PURE__ */ jsx(Input, {
1268
+ id: "fluidgrids-import-version",
1269
+ value: version,
1270
+ onChange: (event) => setVersion(event.target.value),
1271
+ placeholder: "v1"
1272
+ })]
1273
+ });
1274
+ const issuesShown = !loading && (issues || requestError) && /* @__PURE__ */ jsx(WorkflowImportIssues, { issues: issues ?? {
1275
+ errors: [],
1276
+ warnings: [],
1277
+ message: requestError
1278
+ } });
1279
+ const importButton = /* @__PURE__ */ jsx(Button, {
1280
+ onClick: () => void handleImport(),
1281
+ disabled: importDisabled,
1282
+ "data-testid": "fluidgrids-import-confirm",
1283
+ children: loading ? tr("fluidgrids.workflowsList.importing", "Importing…") : tr("fluidgrids.workflowsList.importConfirm", "Import workflow")
1284
+ });
1285
+ const refusalDialog = /* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
1286
+ surface: "workflow-import",
1287
+ refusal,
1288
+ onClose: () => setRefusal(null),
1289
+ onUpgrade: () => navigate(BILLING_PLANS_PATH)
1290
+ });
1291
+ if (v2) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ResponsiveDialog, {
1292
+ open,
1293
+ onOpenChange: (nextOpen) => {
1294
+ setOpen(nextOpen);
1295
+ if (!nextOpen) reset();
1296
+ },
1297
+ children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
1298
+ className: "max-h-[90vh] overflow-y-auto sm:max-w-xl",
1299
+ "data-testid": "fluidgrids-import-dialog",
1300
+ children: [
1301
+ /* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: dialogTitle }), /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: dialogDescription })] }),
1302
+ /* @__PURE__ */ jsxs("div", {
1303
+ className: "space-y-4",
1304
+ children: [
1305
+ filePicker,
1306
+ /* @__PURE__ */ jsxs("div", {
1307
+ className: "space-y-1",
1308
+ children: [
1309
+ /* @__PURE__ */ jsx(Label, {
1310
+ htmlFor: nameId,
1311
+ children: tr("fluidgrids.workflowsList.importName", "Name")
1312
+ }),
1313
+ nameInput,
1314
+ nameMissing && /* @__PURE__ */ jsx("p", {
1315
+ id: nameErrorId,
1316
+ className: "text-xs text-destructive",
1317
+ role: "alert",
1318
+ children: tr("fluidgrids.workflowsList.importNameRequired", "Give the workflow a name.")
1319
+ })
1320
+ ]
1321
+ }),
1322
+ sourceSummary,
1323
+ parsed?.source === "fluidgrids" && /* @__PURE__ */ jsx(ShowTechnicalDetails, { children: nodeReferencesDetail(tr, parsed.nodeReferences) }),
1324
+ issuesShown,
1325
+ /* @__PURE__ */ jsx(OptionalFields, {
1326
+ storageKey: "workflows.import",
1327
+ children: /* @__PURE__ */ jsxs("div", {
1328
+ className: "space-y-3",
1329
+ children: [
1330
+ urlRow,
1331
+ pasteArea,
1332
+ /* @__PURE__ */ jsxs("div", {
1333
+ className: "grid gap-3 sm:grid-cols-3",
1334
+ children: [/* @__PURE__ */ jsx("div", {
1335
+ className: "sm:col-span-2",
1336
+ children: keyField
1337
+ }), versionField]
1338
+ })
1339
+ ]
1340
+ })
1341
+ })
1342
+ ]
1343
+ }),
1344
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
1345
+ variant: "outline",
1346
+ onClick: closeDialog,
1347
+ children: tr("fluidgrids.workflowsList.importCancel", "Cancel")
1348
+ }), importButton] })
1349
+ ]
1350
+ })
1351
+ }), refusalDialog] });
1352
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Dialog, {
1038
1353
  open,
1039
1354
  onOpenChange: (nextOpen) => {
1040
1355
  setOpen(nextOpen);
@@ -1056,132 +1371,62 @@ function WorkflowImportDialog({ onImported, openRequested, onOpenRequestHandled
1056
1371
  }), /* @__PURE__ */ jsxs(DialogContent, {
1057
1372
  className: "max-h-[90vh] overflow-y-auto sm:max-w-2xl",
1058
1373
  children: [
1059
- /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: codeFirst ? tr("fluidgrids.workflowsList.importTitleCode", "Import workflow") : tr("fluidgrids.workflowsList.importTitle", "Import workflow JSON") }), /* @__PURE__ */ jsx(DialogDescription, { children: 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.") })] }),
1374
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: dialogTitle }), /* @__PURE__ */ jsx(DialogDescription, { children: dialogDescription })] }),
1060
1375
  /* @__PURE__ */ jsxs("div", {
1061
1376
  className: "space-y-4",
1062
1377
  children: [
1063
- /* @__PURE__ */ jsxs("div", {
1064
- className: "flex flex-wrap gap-2",
1065
- children: [/* @__PURE__ */ jsxs(Label, {
1066
- htmlFor: "fluidgrids-workflow-import-file",
1067
- className: "inline-flex cursor-pointer items-center gap-2 rounded-md border border-border px-3 py-2 text-sm hover:bg-accent",
1068
- children: [/* @__PURE__ */ jsx(Icon, {
1069
- icon: "mynaui:upload",
1070
- className: "size-4"
1071
- }), codeFirst ? tr("fluidgrids.workflowsList.importChooseFileCode", "Choose JSON, TypeScript or .zip file") : tr("fluidgrids.workflowsList.importChooseFile", "Choose JSON file")]
1072
- }), /* @__PURE__ */ jsx("input", {
1073
- id: "fluidgrids-workflow-import-file",
1074
- type: "file",
1075
- accept: importAcceptAttribute(codeFirst),
1076
- className: "sr-only",
1077
- onChange: (event) => void handleFile(event.currentTarget.files?.[0])
1078
- })]
1079
- }),
1080
- /* @__PURE__ */ jsxs("div", {
1081
- className: "flex gap-2",
1082
- children: [/* @__PURE__ */ jsx(Input, {
1083
- value: url,
1084
- onChange: (event) => setUrl(event.target.value),
1085
- placeholder: "https://example.com/workflow.json",
1086
- "aria-label": codeFirst ? tr("fluidgrids.workflowsList.importUrlLabelCode", "Workflow JSON, TypeScript or .zip URL") : tr("fluidgrids.workflowsList.importUrlLabel", "Workflow JSON URL")
1087
- }), /* @__PURE__ */ jsx(Button, {
1088
- variant: "outline",
1089
- onClick: () => void handleUrl(),
1090
- disabled: loadingUrl || !url.trim(),
1091
- children: loadingUrl ? tr("fluidgrids.workflowsList.importFetchingUrl", "Loading…") : tr("fluidgrids.workflowsList.importFetchUrl", "Fetch")
1092
- })]
1093
- }),
1094
- /* @__PURE__ */ jsx(Textarea, {
1095
- value: rawJson,
1096
- onChange: (event) => {
1097
- setRawJson(event.target.value);
1098
- setParsed(null);
1099
- dropN8nPreview();
1100
- },
1101
- onBlur: () => rawJson.trim() && parse(rawJson),
1102
- placeholder: tr("fluidgrids.workflowsList.importPastePlaceholder", "Paste workflow JSON here"),
1103
- className: "min-h-44 font-mono text-xs",
1104
- "aria-label": tr("fluidgrids.workflowsList.importPasteLabel", "Workflow JSON")
1105
- }),
1378
+ filePicker,
1379
+ urlRow,
1380
+ pasteArea,
1106
1381
  (parsed || typeScript) && /* @__PURE__ */ jsxs("div", {
1107
1382
  className: "space-y-3 rounded-lg border border-border bg-muted/30 p-3",
1108
- children: [parsed?.source === "n8n" ? n8nPreview ? /* @__PURE__ */ jsx(N8nImportReport, { report: n8nPreview.report }) : /* @__PURE__ */ jsx("p", {
1109
- className: "text-xs text-muted-foreground",
1110
- "data-testid": "fluidgrids-import-n8n-previewing",
1111
- children: previewingN8n ? tr("fluidgrids.workflowsList.importN8nPreviewing", "Reading the n8n workflow…") : tr("fluidgrids.workflowsList.importN8nDetected", "n8n workflow detected")
1112
- }) : parsed ? /* @__PURE__ */ jsxs("p", {
1383
+ children: [parsed?.source === "fluidgrids" ? /* @__PURE__ */ jsxs("p", {
1113
1384
  className: "text-xs text-muted-foreground",
1114
1385
  children: [
1115
1386
  parsed.nodeReferences.length,
1116
1387
  " ",
1117
1388
  tr("fluidgrids.workflowsList.importNodeReferences", "node references found")
1118
1389
  ]
1119
- }) : typeScript ? /* @__PURE__ */ jsx("p", {
1120
- className: "text-xs text-muted-foreground",
1121
- "data-testid": "fluidgrids-import-typescript",
1122
- 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.", {
1123
- file: typeScript.label,
1124
- count: String(typeScript.files.length)
1125
- }) : tr("fluidgrids.workflowsList.importTypeScriptFile", "TypeScript module {{file}}: the service builds it and checks the workflow it defines before creating a draft.", { file: typeScript.label })
1126
- }) : null, /* @__PURE__ */ jsxs("div", {
1390
+ }) : sourceSummary, /* @__PURE__ */ jsxs("div", {
1127
1391
  className: "grid gap-3 sm:grid-cols-3",
1128
1392
  children: [
1129
1393
  /* @__PURE__ */ jsxs("div", {
1130
1394
  className: "space-y-1 sm:col-span-3",
1131
1395
  children: [/* @__PURE__ */ jsx(Label, {
1132
- htmlFor: "fluidgrids-import-name",
1396
+ htmlFor: nameId,
1133
1397
  children: tr("fluidgrids.workflowsList.importName", "Name")
1134
- }), /* @__PURE__ */ jsx(Input, {
1135
- id: "fluidgrids-import-name",
1136
- value: name,
1137
- onChange: (event) => setName(event.target.value)
1138
- })]
1398
+ }), nameInput]
1139
1399
  }),
1140
- /* @__PURE__ */ jsxs("div", {
1141
- className: "space-y-1 sm:col-span-2",
1142
- children: [/* @__PURE__ */ jsx(Label, {
1143
- htmlFor: "fluidgrids-import-key",
1144
- children: tr("fluidgrids.workflowsList.importKey", "Workflow key (optional)")
1145
- }), /* @__PURE__ */ jsx(Input, {
1146
- id: "fluidgrids-import-key",
1147
- value: workflowKey,
1148
- onChange: (event) => setWorkflowKey(event.target.value)
1149
- })]
1400
+ /* @__PURE__ */ jsx("div", {
1401
+ className: "sm:col-span-2",
1402
+ children: keyField
1150
1403
  }),
1151
- /* @__PURE__ */ jsxs("div", {
1152
- className: "space-y-1",
1153
- children: [/* @__PURE__ */ jsx(Label, {
1154
- htmlFor: "fluidgrids-import-version",
1155
- children: tr("fluidgrids.workflowsList.importVersion", "Version")
1156
- }), /* @__PURE__ */ jsx(Input, {
1157
- id: "fluidgrids-import-version",
1158
- value: version,
1159
- onChange: (event) => setVersion(event.target.value),
1160
- placeholder: "v1"
1161
- })]
1162
- })
1404
+ versionField
1163
1405
  ]
1164
1406
  })]
1165
1407
  }),
1166
- codeFirst && !loading && (issues || submitted && importError) && /* @__PURE__ */ jsx(WorkflowImportIssues, { issues: issues ?? {
1167
- errors: [],
1168
- warnings: [],
1169
- message: importError?.message ?? null
1170
- } })
1408
+ issuesShown
1171
1409
  ]
1172
1410
  }),
1173
1411
  /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
1174
1412
  variant: "outline",
1175
1413
  onClick: () => setOpen(false),
1176
1414
  children: tr("fluidgrids.workflowsList.importCancel", "Cancel")
1177
- }), /* @__PURE__ */ jsx(Button, {
1178
- onClick: () => void handleImport(),
1179
- disabled: loading || !parsed && !typeScript || !name.trim() || parsed?.source === "n8n" && !n8nPreview,
1180
- children: loading ? tr("fluidgrids.workflowsList.importing", "Importing…") : tr("fluidgrids.workflowsList.importConfirm", "Import workflow")
1181
- })] })
1415
+ }), importButton] })
1182
1416
  ]
1183
1417
  })]
1184
- });
1418
+ }), refusalDialog] });
1419
+ }
1420
+
1421
+ // src/components/workflowFolderTree.ts
1422
+ /** The folder `id` anywhere in the tree, or null. */
1423
+ function findFolder(folders, id) {
1424
+ for (const folder of folders) {
1425
+ if (folder.id === id) return folder;
1426
+ const found = findFolder(folder.children ?? [], id);
1427
+ if (found) return found;
1428
+ }
1429
+ return null;
1185
1430
  }
1186
1431
 
1187
1432
  // src/components/WorkflowFolderSidebar.tsx
@@ -1269,7 +1514,7 @@ function FolderRow({ folder, depth, selectedFolderId, onSelect, onCreateChild, o
1269
1514
  * itself owns that filtering (see WorkflowsList's `folderFilter` state) so
1270
1515
  * this component stays a pure navigation/management surface.
1271
1516
  */
1272
- function WorkflowFolderSidebar({ selectedFolderId, onSelectFolder, createRequested, onCreateRequestHandled }) {
1517
+ function WorkflowFolderSidebar({ selectedFolderId, onSelectFolder, createRequested, onCreateRequestHandled, dialogsOnly = false, folderActionRequest = null, onFolderActionRequestHandled }) {
1273
1518
  const tr = useTr();
1274
1519
  const { folders, loading, refetch } = useWorkflowFolders();
1275
1520
  const { createFolder, renameFolder, deleteFolder } = useWorkflowFolderActions();
@@ -1285,14 +1530,34 @@ function WorkflowFolderSidebar({ selectedFolderId, onSelectFolder, createRequest
1285
1530
  }, []);
1286
1531
  const openCreateTopLevel = useCallback(() => openCreate(null), [openCreate]);
1287
1532
  useOpenRequest(createRequested, openCreateTopLevel, onCreateRequestHandled);
1288
- const openRename = (folder) => {
1533
+ const openRename = useCallback((folder) => {
1289
1534
  setName(folder.name);
1290
1535
  setDialog({
1291
1536
  mode: "rename",
1292
1537
  parentId: folder.parentId ?? null,
1293
1538
  folder
1294
1539
  });
1295
- };
1540
+ }, []);
1541
+ useEffect(() => {
1542
+ if (!folderActionRequest || loading) return;
1543
+ const { action, folderId } = folderActionRequest;
1544
+ if (action === "create-child") openCreate(folderId);
1545
+ else {
1546
+ const folder = findFolder(folders, folderId);
1547
+ 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"));
1548
+ else if (action === "rename") openRename(folder);
1549
+ else setDeleteTarget(folder);
1550
+ }
1551
+ onFolderActionRequestHandled?.();
1552
+ }, [
1553
+ folderActionRequest,
1554
+ loading,
1555
+ folders,
1556
+ openCreate,
1557
+ openRename,
1558
+ onFolderActionRequestHandled,
1559
+ tr
1560
+ ]);
1296
1561
  const submitDialog = async () => {
1297
1562
  if (!dialog || !name.trim()) return;
1298
1563
  if (dialog.mode === "create") {
@@ -1321,6 +1586,44 @@ function WorkflowFolderSidebar({ selectedFolderId, onSelectFolder, createRequest
1321
1586
  }
1322
1587
  setDeleteTarget(null);
1323
1588
  };
1589
+ const dialogs = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Dialog, {
1590
+ open: dialog !== null,
1591
+ onOpenChange: (open) => !open && setDialog(null),
1592
+ children: /* @__PURE__ */ jsxs(DialogContent, { children: [
1593
+ /* @__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") })] }),
1594
+ /* @__PURE__ */ jsx(Input, {
1595
+ autoFocus: true,
1596
+ value: name,
1597
+ onChange: (e) => setName(e.target.value),
1598
+ onKeyDown: (e) => {
1599
+ if (e.key === "Enter") submitDialog();
1600
+ },
1601
+ placeholder: tr("fluidgrids.workflowsList.folders.namePlaceholder", "e.g. Marketing")
1602
+ }),
1603
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
1604
+ variant: "outline",
1605
+ onClick: () => setDialog(null),
1606
+ children: tr("fluidgrids.workflowsList.folders.cancel", "Cancel")
1607
+ }), /* @__PURE__ */ jsx(Button, {
1608
+ onClick: () => void submitDialog(),
1609
+ disabled: !name.trim(),
1610
+ children: tr("fluidgrids.workflowsList.folders.save", "Save")
1611
+ })] })
1612
+ ] })
1613
+ }), /* @__PURE__ */ jsx(Dialog, {
1614
+ open: deleteTarget !== null,
1615
+ onOpenChange: (open) => !open && setDeleteTarget(null),
1616
+ 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, {
1617
+ variant: "outline",
1618
+ onClick: () => setDeleteTarget(null),
1619
+ children: tr("fluidgrids.workflowsList.folders.cancel", "Cancel")
1620
+ }), /* @__PURE__ */ jsx(Button, {
1621
+ variant: "destructive",
1622
+ onClick: () => void confirmDelete(),
1623
+ children: tr("fluidgrids.workflowsList.folders.delete", "Delete")
1624
+ })] })] })
1625
+ })] });
1626
+ if (dialogsOnly) return dialogs;
1324
1627
  return /* @__PURE__ */ jsxs("aside", {
1325
1628
  className: "flex w-56 shrink-0 flex-col gap-1 border-r border-border p-2",
1326
1629
  "data-tour": "fluidgrids-list-folders",
@@ -1362,44 +1665,7 @@ function WorkflowFolderSidebar({ selectedFolderId, onSelectFolder, createRequest
1362
1665
  onRename: openRename,
1363
1666
  onDelete: setDeleteTarget
1364
1667
  }, folder.id)),
1365
- /* @__PURE__ */ jsx(Dialog, {
1366
- open: dialog !== null,
1367
- onOpenChange: (open) => !open && setDialog(null),
1368
- children: /* @__PURE__ */ jsxs(DialogContent, { children: [
1369
- /* @__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") })] }),
1370
- /* @__PURE__ */ jsx(Input, {
1371
- autoFocus: true,
1372
- value: name,
1373
- onChange: (e) => setName(e.target.value),
1374
- onKeyDown: (e) => {
1375
- if (e.key === "Enter") submitDialog();
1376
- },
1377
- placeholder: tr("fluidgrids.workflowsList.folders.namePlaceholder", "e.g. Marketing")
1378
- }),
1379
- /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
1380
- variant: "outline",
1381
- onClick: () => setDialog(null),
1382
- children: tr("fluidgrids.workflowsList.folders.cancel", "Cancel")
1383
- }), /* @__PURE__ */ jsx(Button, {
1384
- onClick: () => void submitDialog(),
1385
- disabled: !name.trim(),
1386
- children: tr("fluidgrids.workflowsList.folders.save", "Save")
1387
- })] })
1388
- ] })
1389
- }),
1390
- /* @__PURE__ */ jsx(Dialog, {
1391
- open: deleteTarget !== null,
1392
- onOpenChange: (open) => !open && setDeleteTarget(null),
1393
- 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, {
1394
- variant: "outline",
1395
- onClick: () => setDeleteTarget(null),
1396
- children: tr("fluidgrids.workflowsList.folders.cancel", "Cancel")
1397
- }), /* @__PURE__ */ jsx(Button, {
1398
- variant: "destructive",
1399
- onClick: () => void confirmDelete(),
1400
- children: tr("fluidgrids.workflowsList.folders.delete", "Delete")
1401
- })] })] })
1402
- })
1668
+ dialogs
1403
1669
  ]
1404
1670
  });
1405
1671
  }
@@ -1597,132 +1863,6 @@ function flattenFolders(folders, depth = 0) {
1597
1863
  }, ...flattenFolders(folder.children ?? [], depth + 1)]);
1598
1864
  }
1599
1865
 
1600
- // src/onboarding/firstWorkflowSteps.tsx
1601
- /** The first-workflow checklist steps, from progress and the handlers. */
1602
- function firstWorkflowSteps({ progress, canCreate, onCreate, onOpen, onTemplates, tr }) {
1603
- const { runTarget, activateTarget } = progress;
1604
- return [
1605
- {
1606
- id: "create",
1607
- label: tr("fluidgrids.onboarding.createLabel", "Build your first workflow, with a guided tour"),
1608
- description: tr("fluidgrids.onboarding.createDescription", "Opens a new draft in the builder and walks you through adding a trigger, connecting nodes and saving."),
1609
- icon: /* @__PURE__ */ jsx(Icon, {
1610
- icon: "mynaui:plus",
1611
- className: "size-4",
1612
- "aria-hidden": "true"
1613
- }),
1614
- done: progress.created,
1615
- onClick: !progress.created && canCreate ? onCreate : void 0
1616
- },
1617
- {
1618
- id: "run",
1619
- label: tr("fluidgrids.onboarding.runLabel", "Run it once to test"),
1620
- description: tr("fluidgrids.onboarding.runDescription", "Press Run in the builder. Every execution shows up in Runs with a step-by-step timeline and logs."),
1621
- icon: /* @__PURE__ */ jsx(Icon, {
1622
- icon: "mdi:play-circle-outline",
1623
- className: "size-4",
1624
- "aria-hidden": "true"
1625
- }),
1626
- done: progress.ran,
1627
- onClick: !progress.ran && runTarget ? () => onOpen(runTarget) : void 0
1628
- },
1629
- {
1630
- id: "activate",
1631
- label: tr("fluidgrids.onboarding.activateLabel", "Activate it to go live"),
1632
- description: tr("fluidgrids.onboarding.activateDescription", "An active workflow answers its webhooks, schedules and other automatic triggers."),
1633
- icon: /* @__PURE__ */ jsx(Icon, {
1634
- icon: "mdi:lightning-bolt-outline",
1635
- className: "size-4",
1636
- "aria-hidden": "true"
1637
- }),
1638
- done: progress.activated,
1639
- onClick: !progress.activated && activateTarget ? () => onOpen(activateTarget) : void 0
1640
- },
1641
- {
1642
- id: "templates",
1643
- label: tr("fluidgrids.onboarding.templatesLabel", "Or start from a template"),
1644
- description: tr("fluidgrids.onboarding.templatesDescription", "Pick a pre-built workflow and adapt it instead of starting from a blank canvas."),
1645
- icon: /* @__PURE__ */ jsx(Icon, {
1646
- icon: "mynaui:layers-three",
1647
- className: "size-4",
1648
- "aria-hidden": "true"
1649
- }),
1650
- done: progress.created,
1651
- onClick: progress.created ? void 0 : onTemplates
1652
- }
1653
- ];
1654
- }
1655
-
1656
- // src/onboarding/FirstWorkflowChecklist.tsx
1657
- /** The checklist itself; hidden once every step is done. */
1658
- function FirstWorkflowChecklistView(props) {
1659
- const { progress, tr } = props;
1660
- if (progress.complete) return null;
1661
- return /* @__PURE__ */ jsx("div", {
1662
- "data-tour": "fluidgrids-list-onboarding",
1663
- children: /* @__PURE__ */ jsx(NextSteps, {
1664
- storageKey: "fluidgrids-first-workflow",
1665
- title: tr("fluidgrids.onboarding.title", "Get started with your first workflow"),
1666
- steps: firstWorkflowSteps(props)
1667
- })
1668
- });
1669
- }
1670
- function useChecklistHandlers() {
1671
- const navigate = useNavigate();
1672
- const createFirst = useCreateWorkflowFirst({ state: GUIDED_TOUR_STATE });
1673
- const { start } = createFirst;
1674
- return {
1675
- handlers: useMemo(() => ({
1676
- onCreate: () => void start(),
1677
- onOpen: (workflow) => navigate(builderPathFor(workflow)),
1678
- onTemplates: () => navigate("../templates")
1679
- }), [navigate, start]),
1680
- refusalDialog: /* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
1681
- surface: "builder-create",
1682
- refusal: createFirst.refusal,
1683
- onClose: createFirst.clearRefusal,
1684
- onUpgrade: () => navigate(BILLING_PLANS_PATH)
1685
- })
1686
- };
1687
- }
1688
- /** With workflows: reads the run count (one row) to know whether one ran. */
1689
- function ChecklistWithRuns({ workflows, canCreate }) {
1690
- const tr = useTr();
1691
- const { handlers, refusalDialog } = useChecklistHandlers();
1692
- const { total, loading, error } = useExecutions({ limit: 1 });
1693
- const runsTotal = loading || error ? null : total;
1694
- const progress = useMemo(() => firstWorkflowProgress(workflows, runsTotal), [workflows, runsTotal]);
1695
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FirstWorkflowChecklistView, {
1696
- progress,
1697
- canCreate,
1698
- tr,
1699
- ...handlers
1700
- }), refusalDialog] });
1701
- }
1702
- /** No workflows yet: nothing can have run, so no runs request is made. */
1703
- function ChecklistWithoutWorkflows({ canCreate }) {
1704
- const tr = useTr();
1705
- const { handlers, refusalDialog } = useChecklistHandlers();
1706
- const progress = useMemo(() => firstWorkflowProgress([], 0), []);
1707
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FirstWorkflowChecklistView, {
1708
- progress,
1709
- canCreate,
1710
- tr,
1711
- ...handlers
1712
- }), refusalDialog] });
1713
- }
1714
- /**
1715
- * First-workflow onboarding checklist for the Workflows list (parity G21).
1716
- * Render it only once the list has loaded without error.
1717
- */
1718
- function FirstWorkflowChecklist({ workflows, canCreate }) {
1719
- if (workflows.length === 0) return /* @__PURE__ */ jsx(ChecklistWithoutWorkflows, { canCreate });
1720
- return /* @__PURE__ */ jsx(ChecklistWithRuns, {
1721
- workflows,
1722
- canCreate
1723
- });
1724
- }
1725
-
1726
1866
  // src/components/WorkflowMoveToProjectDialog.tsx
1727
1867
  /**
1728
1868
  * Move one workflow to another project (BOFF-9726), from its card.
@@ -1863,153 +2003,1540 @@ function DescriptionForm({ workflow, onClose, onSaved }) {
1863
2003
  save();
1864
2004
  }
1865
2005
  },
1866
- className: "resize-none"
1867
- }),
1868
- /* @__PURE__ */ jsxs("span", {
1869
- "data-testid": "workflow-description-counter",
1870
- className: cn("self-end text-xs tabular-nums text-muted-foreground", left < 0 && "text-destructive"),
1871
- children: [
1872
- 500 - left,
1873
- "/",
1874
- 500
1875
- ]
2006
+ className: "resize-none"
2007
+ }),
2008
+ /* @__PURE__ */ jsxs("span", {
2009
+ "data-testid": "workflow-description-counter",
2010
+ className: cn("self-end text-xs tabular-nums text-muted-foreground", left < 0 && "text-destructive"),
2011
+ children: [
2012
+ 500 - left,
2013
+ "/",
2014
+ 500
2015
+ ]
2016
+ })
2017
+ ]
2018
+ }),
2019
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
2020
+ variant: "outline",
2021
+ onClick: onClose,
2022
+ disabled: saving,
2023
+ children: tr("fluidgrids.workflowsList.moveToProject.cancel", "Cancel")
2024
+ }), /* @__PURE__ */ jsx(Button, {
2025
+ onClick: () => void save(),
2026
+ disabled: saving || decision.kind !== "save",
2027
+ "aria-busy": saving,
2028
+ "data-testid": "workflow-description-save",
2029
+ children: tr("fluidgrids.workflowsList.editDescription.save", "Save")
2030
+ })] })
2031
+ ]
2032
+ });
2033
+ }
2034
+
2035
+ // src/components/createWorkflowName.ts
2036
+ /**
2037
+ * Name handling for the "New workflow" dialog (Navigation v2, BOFF-11843),
2038
+ * kept out of the component file so Fast Refresh can preserve its state.
2039
+ */
2040
+ /** The name to create with, or null when the form cannot be submitted. */
2041
+ function workflowNameFromInput(value) {
2042
+ const name = value.trim();
2043
+ return name ? name : null;
2044
+ }
2045
+
2046
+ // src/components/CreateWorkflowNameDialog.tsx
2047
+ /**
2048
+ * "New workflow" asks for a name (Navigation v2, BOFF-11843).
2049
+ *
2050
+ * The name is the only required step. Starting from a template is one click
2051
+ * away ("Browse templates"), never a question asked first. Creating still runs
2052
+ * `useCreateWorkflowFirst`: the workflow is created, then the builder opens; a
2053
+ * refusal (a plan limit, a permission) keeps the person on the list, where the
2054
+ * caller's refusal dialog explains it.
2055
+ */
2056
+ function CreateWorkflowNameDialog({ open, onOpenChange, onCreate, creating, templatesHref }) {
2057
+ return /* @__PURE__ */ jsx(ResponsiveDialog, {
2058
+ open,
2059
+ onOpenChange,
2060
+ children: /* @__PURE__ */ jsx(ResponsiveDialogContent, {
2061
+ className: "sm:max-w-md",
2062
+ "data-testid": "create-workflow-name-dialog",
2063
+ children: /* @__PURE__ */ jsx(CreateWorkflowNameForm, {
2064
+ onOpenChange,
2065
+ onCreate,
2066
+ creating,
2067
+ templatesHref
2068
+ })
2069
+ })
2070
+ });
2071
+ }
2072
+ function CreateWorkflowNameForm({ onOpenChange, onCreate, creating, templatesHref }) {
2073
+ const tr = useTr();
2074
+ const id = useId();
2075
+ const inputId = `${id}-name`;
2076
+ const errorId = `${id}-error`;
2077
+ const [value, setValue] = useState("");
2078
+ const [showError, setShowError] = useState(false);
2079
+ const submit = (event) => {
2080
+ event.preventDefault();
2081
+ const name = workflowNameFromInput(value);
2082
+ if (!name) {
2083
+ setShowError(true);
2084
+ return;
2085
+ }
2086
+ onCreate(name);
2087
+ };
2088
+ return /* @__PURE__ */ jsxs("form", {
2089
+ onSubmit: submit,
2090
+ noValidate: true,
2091
+ className: "space-y-4",
2092
+ children: [
2093
+ /* @__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.") })] }),
2094
+ /* @__PURE__ */ jsxs("div", {
2095
+ className: "space-y-1.5",
2096
+ children: [
2097
+ /* @__PURE__ */ jsx(Label, {
2098
+ htmlFor: inputId,
2099
+ children: tr("fluidgrids.workflowsList.createDialog.nameLabel", "Name")
2100
+ }),
2101
+ /* @__PURE__ */ jsx(Input, {
2102
+ id: inputId,
2103
+ autoFocus: true,
2104
+ required: true,
2105
+ value,
2106
+ placeholder: tr("fluidgrids.workflowsList.createDialog.namePlaceholder", "e.g. Daily sales report"),
2107
+ "aria-invalid": showError ? true : void 0,
2108
+ "aria-describedby": showError ? errorId : void 0,
2109
+ onChange: (event) => {
2110
+ setValue(event.target.value);
2111
+ if (event.target.value.trim()) setShowError(false);
2112
+ },
2113
+ "data-testid": "create-workflow-name-input"
2114
+ }),
2115
+ showError && /* @__PURE__ */ jsx("p", {
2116
+ id: errorId,
2117
+ className: "text-xs text-destructive",
2118
+ role: "alert",
2119
+ children: tr("fluidgrids.workflowsList.createDialog.nameRequired", "Give the workflow a name.")
2120
+ })
2121
+ ]
2122
+ }),
2123
+ /* @__PURE__ */ jsxs("p", {
2124
+ className: "text-sm text-muted-foreground",
2125
+ children: [
2126
+ tr("fluidgrids.workflowsList.createDialog.templatesHint", "Want a head start?"),
2127
+ " ",
2128
+ /* @__PURE__ */ jsxs(Link, {
2129
+ to: templatesHref,
2130
+ className: "inline-flex min-h-11 items-center gap-1 font-medium text-primary underline-offset-4 hover:underline",
2131
+ "data-testid": "create-workflow-browse-templates",
2132
+ onClick: () => onOpenChange(false),
2133
+ children: [/* @__PURE__ */ jsx(Icon, {
2134
+ icon: "mynaui:grid",
2135
+ className: "size-4",
2136
+ "aria-hidden": "true"
2137
+ }), tr("fluidgrids.workflowsList.browseTemplates", "Browse templates")]
2138
+ })
2139
+ ]
2140
+ }),
2141
+ /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
2142
+ type: "button",
2143
+ variant: "outline",
2144
+ className: "min-h-11",
2145
+ onClick: () => onOpenChange(false),
2146
+ children: tr("fluidgrids.workflowsList.createDialog.cancel", "Cancel")
2147
+ }), /* @__PURE__ */ jsx(Button, {
2148
+ type: "submit",
2149
+ className: "min-h-11",
2150
+ disabled: creating,
2151
+ "aria-busy": creating,
2152
+ "data-testid": "create-workflow-name-submit",
2153
+ children: creating ? tr("fluidgrids.workflowsList.createDialog.creating", "Creating…") : tr("fluidgrids.workflowsList.createDialog.create", "Create")
2154
+ })] })
2155
+ ]
2156
+ });
2157
+ }
2158
+
2159
+ // src/onboarding/firstWorkflowSteps.tsx
2160
+ /** The first-workflow checklist steps, from progress and the handlers. */
2161
+ function firstWorkflowSteps({ progress, canCreate, onCreate, onOpen, onTemplates, tr }) {
2162
+ const { runTarget, activateTarget } = progress;
2163
+ return [
2164
+ {
2165
+ id: "create",
2166
+ label: tr("fluidgrids.onboarding.createLabel", "Build your first workflow, with a guided tour"),
2167
+ description: tr("fluidgrids.onboarding.createDescription", "Opens a new draft in the builder and walks you through adding a trigger, connecting nodes and saving."),
2168
+ icon: /* @__PURE__ */ jsx(Icon, {
2169
+ icon: "mynaui:plus",
2170
+ className: "size-4",
2171
+ "aria-hidden": "true"
2172
+ }),
2173
+ done: progress.created,
2174
+ onClick: !progress.created && canCreate ? onCreate : void 0
2175
+ },
2176
+ {
2177
+ id: "run",
2178
+ label: tr("fluidgrids.onboarding.runLabel", "Run it once to test"),
2179
+ description: tr("fluidgrids.onboarding.runDescription", "Press Run in the builder. Every execution shows up in Runs with a step-by-step timeline and logs."),
2180
+ icon: /* @__PURE__ */ jsx(Icon, {
2181
+ icon: "mdi:play-circle-outline",
2182
+ className: "size-4",
2183
+ "aria-hidden": "true"
2184
+ }),
2185
+ done: progress.ran,
2186
+ onClick: !progress.ran && runTarget ? () => onOpen(runTarget) : void 0
2187
+ },
2188
+ {
2189
+ id: "activate",
2190
+ label: tr("fluidgrids.onboarding.activateLabel", "Activate it to go live"),
2191
+ description: tr("fluidgrids.onboarding.activateDescription", "An active workflow answers its webhooks, schedules and other automatic triggers."),
2192
+ icon: /* @__PURE__ */ jsx(Icon, {
2193
+ icon: "mdi:lightning-bolt-outline",
2194
+ className: "size-4",
2195
+ "aria-hidden": "true"
2196
+ }),
2197
+ done: progress.activated,
2198
+ onClick: !progress.activated && activateTarget ? () => onOpen(activateTarget) : void 0
2199
+ },
2200
+ {
2201
+ id: "templates",
2202
+ label: tr("fluidgrids.onboarding.templatesLabel", "Or start from a template"),
2203
+ description: tr("fluidgrids.onboarding.templatesDescription", "Pick a pre-built workflow and adapt it instead of starting from a blank canvas."),
2204
+ icon: /* @__PURE__ */ jsx(Icon, {
2205
+ icon: "mynaui:layers-three",
2206
+ className: "size-4",
2207
+ "aria-hidden": "true"
2208
+ }),
2209
+ done: progress.created,
2210
+ onClick: progress.created ? void 0 : onTemplates
2211
+ }
2212
+ ];
2213
+ }
2214
+
2215
+ // src/onboarding/FirstWorkflowChecklist.tsx
2216
+ /** The checklist itself; hidden once every step is done. */
2217
+ function FirstWorkflowChecklistView(props) {
2218
+ const { progress, tr } = props;
2219
+ if (progress.complete) return null;
2220
+ return /* @__PURE__ */ jsx("div", {
2221
+ "data-tour": "fluidgrids-list-onboarding",
2222
+ children: /* @__PURE__ */ jsx(NextSteps, {
2223
+ storageKey: "fluidgrids-first-workflow",
2224
+ title: tr("fluidgrids.onboarding.title", "Get started with your first workflow"),
2225
+ steps: firstWorkflowSteps(props)
2226
+ })
2227
+ });
2228
+ }
2229
+ function useChecklistHandlers() {
2230
+ const navigate = useNavigate();
2231
+ const createFirst = useCreateWorkflowFirst({ state: GUIDED_TOUR_STATE });
2232
+ const { start } = createFirst;
2233
+ return {
2234
+ handlers: useMemo(() => ({
2235
+ onCreate: () => void start(),
2236
+ onOpen: (workflow) => navigate(builderPathFor(workflow)),
2237
+ onTemplates: () => navigate("../templates")
2238
+ }), [navigate, start]),
2239
+ refusalDialog: /* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
2240
+ surface: "builder-create",
2241
+ refusal: createFirst.refusal,
2242
+ onClose: createFirst.clearRefusal,
2243
+ onUpgrade: () => navigate(BILLING_PLANS_PATH)
2244
+ })
2245
+ };
2246
+ }
2247
+ /** With workflows: reads the run count (one row) to know whether one ran. */
2248
+ function ChecklistWithRuns({ workflows, canCreate }) {
2249
+ const tr = useTr();
2250
+ const { handlers, refusalDialog } = useChecklistHandlers();
2251
+ const { total, loading, error } = useExecutions({ limit: 1 });
2252
+ const runsTotal = loading || error ? null : total;
2253
+ const progress = useMemo(() => firstWorkflowProgress(workflows, runsTotal), [workflows, runsTotal]);
2254
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FirstWorkflowChecklistView, {
2255
+ progress,
2256
+ canCreate,
2257
+ tr,
2258
+ ...handlers
2259
+ }), refusalDialog] });
2260
+ }
2261
+ /** No workflows yet: nothing can have run, so no runs request is made. */
2262
+ function ChecklistWithoutWorkflows({ canCreate }) {
2263
+ const tr = useTr();
2264
+ const { handlers, refusalDialog } = useChecklistHandlers();
2265
+ const progress = useMemo(() => firstWorkflowProgress([], 0), []);
2266
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FirstWorkflowChecklistView, {
2267
+ progress,
2268
+ canCreate,
2269
+ tr,
2270
+ ...handlers
2271
+ }), refusalDialog] });
2272
+ }
2273
+ /**
2274
+ * First-workflow onboarding checklist for the Workflows list (parity G21).
2275
+ * Render it only once the list has loaded without error.
2276
+ */
2277
+ function FirstWorkflowChecklist({ workflows, canCreate }) {
2278
+ if (workflows.length === 0) return /* @__PURE__ */ jsx(ChecklistWithoutWorkflows, { canCreate });
2279
+ return /* @__PURE__ */ jsx(ChecklistWithRuns, {
2280
+ workflows,
2281
+ canCreate
2282
+ });
2283
+ }
2284
+
2285
+ // src/pages/workflowsListUrlState.ts
2286
+ /**
2287
+ * URL-driven filter state for the workflows list (BOFF-10854).
2288
+ *
2289
+ * The access, status and folder filters live in the query string so the
2290
+ * shell's navigation ("Shared with me", "Archived", a folder) can link
2291
+ * straight to a filtered list, and a filtered list survives reload and
2292
+ * back/forward. Supported values:
2293
+ *
2294
+ * ?access=mine | shared (absent or "all" = every visible workflow)
2295
+ * ?status=active | draft | archived | deprecated (absent = any status)
2296
+ * ?folder=<folder id> (absent = all folders)
2297
+ * ?mode=deterministic | agentic | hybrid (absent = any run mode, BOFF-9955)
2298
+ *
2299
+ * Unknown values fall back to the default rather than erroring. Writes use
2300
+ * history replace, so toggling chips does not flood the back stack, and a
2301
+ * default value removes its parameter so plain `/workflows/list` stays clean.
2302
+ */
2303
+ const WORKFLOWS_LIST_PARAMS = {
2304
+ access: "access",
2305
+ status: "status",
2306
+ folder: "folder",
2307
+ mode: "mode"
2308
+ };
2309
+ /** The workflow statuses the list's status chips offer. */
2310
+ const WORKFLOW_LIST_STATUSES = [
2311
+ "ACTIVE",
2312
+ "DRAFT",
2313
+ "ARCHIVED",
2314
+ "DEPRECATED"
2315
+ ];
2316
+ const ACCESS_BY_PARAM = {
2317
+ all: "ALL",
2318
+ mine: "OWNED_BY_ME",
2319
+ shared: "SHARED_WITH_ME"
2320
+ };
2321
+ const PARAM_BY_ACCESS = {
2322
+ ["ALL"]: null,
2323
+ ["OWNED_BY_ME"]: "mine",
2324
+ ["SHARED_WITH_ME"]: "shared"
2325
+ };
2326
+ function accessFromParam(value) {
2327
+ if (!value) return "ALL";
2328
+ return ACCESS_BY_PARAM[value.trim().toLowerCase()] ?? "ALL";
2329
+ }
2330
+ function accessToParam(access) {
2331
+ return PARAM_BY_ACCESS[access];
2332
+ }
2333
+ function isWorkflowListStatus(value) {
2334
+ return WORKFLOW_LIST_STATUSES.includes(value);
2335
+ }
2336
+ /** `archived` / `ARCHIVED` → `ARCHIVED`; anything unknown → no filter. */
2337
+ function statusFromParam(value) {
2338
+ if (!value) return null;
2339
+ const upper = value.trim().toUpperCase();
2340
+ return isWorkflowListStatus(upper) ? upper : null;
2341
+ }
2342
+ function statusToParam(status) {
2343
+ if (!status) return null;
2344
+ const upper = status.toUpperCase();
2345
+ return isWorkflowListStatus(upper) ? upper.toLowerCase() : null;
2346
+ }
2347
+ function folderFromParam(value) {
2348
+ const trimmed = value?.trim();
2349
+ return trimmed ? trimmed : null;
2350
+ }
2351
+ /** `agentic` / `AGENTIC` → AGENTIC (BOFF-9955); anything unknown → no filter. */
2352
+ function modeFromParam(value) {
2353
+ if (!value) return null;
2354
+ const upper = value.trim().toUpperCase();
2355
+ return isExecutionMode(upper) ? upper : null;
2356
+ }
2357
+ function modeToParam(mode) {
2358
+ return mode ? mode.toLowerCase() : null;
2359
+ }
2360
+ /**
2361
+ * Applies a filter patch to a copy of `params`. Keys missing from the patch
2362
+ * are left untouched; default values delete their parameter. Unrelated
2363
+ * parameters (e.g. `?action=`) are preserved.
2364
+ */
2365
+ function applyFilterPatch(params, patch) {
2366
+ const next = new URLSearchParams(params);
2367
+ const write = (key, value) => {
2368
+ if (value === null) next.delete(key);
2369
+ else next.set(key, value);
2370
+ };
2371
+ if (patch.access !== void 0) write(WORKFLOWS_LIST_PARAMS.access, accessToParam(patch.access));
2372
+ if (patch.status !== void 0) write(WORKFLOWS_LIST_PARAMS.status, statusToParam(patch.status));
2373
+ if (patch.folder !== void 0) write(WORKFLOWS_LIST_PARAMS.folder, folderFromParam(patch.folder));
2374
+ if (patch.mode !== void 0) write(WORKFLOWS_LIST_PARAMS.mode, modeToParam(patch.mode));
2375
+ return next;
2376
+ }
2377
+ function useWorkflowsListUrlState() {
2378
+ const [searchParams, setSearchParams] = useSearchParams();
2379
+ const access = accessFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.access));
2380
+ const status = statusFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.status));
2381
+ const folder = folderFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.folder));
2382
+ const mode = modeFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.mode));
2383
+ const update = useCallback((patch) => {
2384
+ setSearchParams((prev) => applyFilterPatch(prev, patch), { replace: true });
2385
+ }, [setSearchParams]);
2386
+ return useMemo(() => ({
2387
+ access,
2388
+ status,
2389
+ folder,
2390
+ mode,
2391
+ update,
2392
+ setAccess: (next) => update({ access: next }),
2393
+ setStatus: (next) => update({ status: next }),
2394
+ setFolder: (next) => update({ folder: next }),
2395
+ setMode: (next) => update({ mode: next })
2396
+ }), [
2397
+ access,
2398
+ status,
2399
+ folder,
2400
+ mode,
2401
+ update
2402
+ ]);
2403
+ }
2404
+
2405
+ // src/pages/useLoadAllWhileFiltering.ts
2406
+ /**
2407
+ * My Workflows (v2): folder, tag, project and the search box filter the LOADED
2408
+ * rows, because the service pages the list (100 a page) and cannot apply them
2409
+ * (BOFF-11843 review). While one is set, the rest of the pages are loaded, so a
2410
+ * folder opened from the sidebar shows its workflows even when they are not on
2411
+ * the first page, and "No workflows match your filters" waits until every page
2412
+ * is in.
2413
+ */
2414
+ function useLoadAllWhileFiltering({ filtered, hasMore, loading, loadingMore, loadMoreError, loadMore }) {
2415
+ useEffect(() => {
2416
+ if (filtered && hasMore && !loading && !loadingMore && !loadMoreError) loadMore();
2417
+ }, [
2418
+ filtered,
2419
+ hasMore,
2420
+ loading,
2421
+ loadingMore,
2422
+ loadMoreError,
2423
+ loadMore
2424
+ ]);
2425
+ return {
2426
+ clientFiltered: filtered,
2427
+ /** Filtered rows may still be on pages not loaded yet. */
2428
+ filteringMore: filtered && (hasMore && !loadMoreError || loadingMore)
2429
+ };
2430
+ }
2431
+
2432
+ // src/pages/workflows-list/WorkflowsLoadMore.tsx
2433
+ /**
2434
+ * "Load more" under the workflows list (BOFF-11843): the list used to stop at
2435
+ * its first 100 workflows. Shown only while the server says more exist, with
2436
+ * how many are shown out of how many, and why a page did not load.
2437
+ */
2438
+ function WorkflowsLoadMore({ hasMore, loadingMore, error, shown, total, onLoadMore }) {
2439
+ const tr = useTr();
2440
+ if (!hasMore) return null;
2441
+ return /* @__PURE__ */ jsxs("div", {
2442
+ className: "flex flex-col items-center gap-2 py-2",
2443
+ "data-testid": "workflows-load-more",
2444
+ children: [
2445
+ /* @__PURE__ */ jsx("p", {
2446
+ className: "text-xs text-muted-foreground",
2447
+ "aria-live": "polite",
2448
+ children: tr("fluidgrids.workflowsList.shownOfTotal", "Showing {{shown}} of {{total}} workflows", {
2449
+ shown: String(shown),
2450
+ total: String(Math.max(total, shown))
2451
+ })
2452
+ }),
2453
+ error && /* @__PURE__ */ jsx("p", {
2454
+ className: "text-xs text-destructive",
2455
+ role: "alert",
2456
+ children: tr("fluidgrids.workflowsList.loadMoreFailed", "Couldn't load more workflows. Try again.")
2457
+ }),
2458
+ /* @__PURE__ */ jsx(Button, {
2459
+ variant: "outline",
2460
+ className: "min-h-11",
2461
+ onClick: onLoadMore,
2462
+ disabled: loadingMore,
2463
+ "aria-busy": loadingMore,
2464
+ children: loadingMore ? tr("fluidgrids.workflowsList.loadingMore", "Loading…") : tr("fluidgrids.workflowsList.loadMore", "Load more")
2465
+ })
2466
+ ]
2467
+ });
2468
+ }
2469
+
2470
+ // src/pages/workflows-list/WorkflowRowMenu.tsx
2471
+ /**
2472
+ * A workflow row's actions on My Workflows (Navigation v2, BOFF-11843).
2473
+ *
2474
+ * Visible: Edit. Under "⋯": Duplicate and Delete, then a "More options"
2475
+ * submenu with Settings, Download a copy, Move to project, Edit description
2476
+ * and Share, and last the version, alias and version count as read-only
2477
+ * information. Every item is shown only to people who may do it (the same
2478
+ * checks the card used); Share keeps exactly today's dialog and its check.
2479
+ * Both buttons are at least 44px, so they are easy to hit on a phone.
2480
+ */
2481
+ function WorkflowRowMenu({ workflow, actions, downloading = false }) {
2482
+ const tr = useTr();
2483
+ const canCreate = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE).allowed;
2484
+ const canUpdate = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_UPDATE).allowed;
2485
+ const canDelete = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_DELETE).allowed;
2486
+ const canShare = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_SHARE).allowed;
2487
+ const editable = canEditWorkflow(workflow.myAccess);
2488
+ const shareable = canShareWorkflow(workflow.myAccess);
2489
+ const editLabel = tr("fluidgrids.workflowsList.row.edit", "Edit");
2490
+ const menuLabel = tr("fluidgrids.workflowsList.row.moreActions", "More actions for {{name}}", { name: workflow.name });
2491
+ const versionInfo = [tr("fluidgrids.workflowsList.row.version", "Version {{version}}", { version: workflow.version }), workflow.alias ? `(${workflow.alias})` : null].filter(Boolean).join(" ");
2492
+ const versionCount = workflow.totalVersions && workflow.totalVersions > 1 ? tr("fluidgrids.workflowsList.row.versionCount", "{{count}} versions", { count: String(workflow.totalVersions) }) : null;
2493
+ const downloadLabel = tr("fluidgrids.builder.cardWorkflow.exportWorkflow", "Export workflow JSON");
2494
+ return /* @__PURE__ */ jsxs("div", {
2495
+ className: "flex items-center gap-1",
2496
+ children: [/* @__PURE__ */ jsx(Button, {
2497
+ variant: "outline",
2498
+ size: "sm",
2499
+ className: "min-h-11 min-w-11",
2500
+ onClick: actions.onEdit,
2501
+ "aria-label": tr("fluidgrids.workflowsList.row.editAriaLabel", "Edit {{name}}", { name: workflow.name }),
2502
+ "data-testid": "workflow-row-edit",
2503
+ children: editLabel
2504
+ }), /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
2505
+ asChild: true,
2506
+ children: /* @__PURE__ */ jsx(Button, {
2507
+ variant: "ghost",
2508
+ size: "icon",
2509
+ className: "size-11",
2510
+ "aria-label": menuLabel,
2511
+ title: menuLabel,
2512
+ "data-testid": "workflow-row-menu",
2513
+ children: /* @__PURE__ */ jsx(Icon, {
2514
+ icon: "mdi:dots-horizontal",
2515
+ className: "size-5"
2516
+ })
2517
+ })
2518
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
2519
+ align: "end",
2520
+ className: "min-w-56",
2521
+ children: [
2522
+ /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [canCreate && /* @__PURE__ */ jsxs(DropdownMenuItem, {
2523
+ className: "min-h-11",
2524
+ onSelect: actions.onDuplicate,
2525
+ "data-testid": "workflow-row-menu-duplicate",
2526
+ children: [/* @__PURE__ */ jsx(Icon, {
2527
+ icon: "mynaui:copy",
2528
+ className: "mr-2 size-4"
2529
+ }), tr("fluidgrids.builder.cardWorkflow.duplicateWorkflow", "Duplicate workflow")]
2530
+ }), editable && canDelete && /* @__PURE__ */ jsxs(DropdownMenuItem, {
2531
+ className: "min-h-11 text-destructive focus:text-destructive",
2532
+ onSelect: actions.onDelete,
2533
+ "data-testid": "workflow-row-menu-delete",
2534
+ children: [/* @__PURE__ */ jsx(Icon, {
2535
+ icon: "mynaui:trash",
2536
+ className: "mr-2 size-4"
2537
+ }), tr("fluidgrids.builder.cardWorkflow.deleteWorkflow", "Delete workflow")]
2538
+ })] }),
2539
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
2540
+ /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [/* @__PURE__ */ jsxs(DropdownMenuSubTrigger, {
2541
+ className: "min-h-11",
2542
+ "data-testid": "workflow-row-menu-more",
2543
+ children: [/* @__PURE__ */ jsx(Icon, {
2544
+ icon: "mdi:tune-variant",
2545
+ className: "mr-2 size-4"
2546
+ }), tr("fluidgrids.builder.cardWorkflow.workflowSettings", "Workflow settings")]
2547
+ }), /* @__PURE__ */ jsxs(DropdownMenuSubContent, {
2548
+ className: "min-w-56",
2549
+ children: [
2550
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
2551
+ className: "min-h-11",
2552
+ onSelect: actions.onSettings,
2553
+ "data-testid": "workflow-row-menu-settings",
2554
+ children: [/* @__PURE__ */ jsx(Icon, {
2555
+ icon: "mdi:cog-outline",
2556
+ className: "mr-2 size-4"
2557
+ }), tr("fluidgrids.workflowsList.row.settings", "Settings")]
2558
+ }),
2559
+ actions.onDownloadAs ? /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [/* @__PURE__ */ jsxs(DropdownMenuSubTrigger, {
2560
+ className: "min-h-11",
2561
+ disabled: downloading,
2562
+ "data-testid": "workflow-row-menu-download",
2563
+ children: [/* @__PURE__ */ jsx(Icon, {
2564
+ icon: "mynaui:download",
2565
+ className: "mr-2 size-4"
2566
+ }), downloadLabel]
2567
+ }), /* @__PURE__ */ jsx(DropdownMenuSubContent, { children: CODE_EXPORT_FORMATS.map((format) => /* @__PURE__ */ jsx(DropdownMenuItem, {
2568
+ className: "min-h-11",
2569
+ onSelect: () => actions.onDownloadAs?.(format),
2570
+ "data-testid": `workflow-row-menu-download-${format.toLowerCase()}`,
2571
+ children: exportFormatLabel(tr, format)
2572
+ }, format)) })] }) : /* @__PURE__ */ jsxs(DropdownMenuItem, {
2573
+ className: "min-h-11",
2574
+ onSelect: actions.onDownload,
2575
+ disabled: downloading,
2576
+ "data-testid": "workflow-row-menu-download",
2577
+ children: [/* @__PURE__ */ jsx(Icon, {
2578
+ icon: "mynaui:download",
2579
+ className: "mr-2 size-4"
2580
+ }), downloadLabel]
2581
+ }),
2582
+ editable && canUpdate && /* @__PURE__ */ jsxs(DropdownMenuItem, {
2583
+ className: "min-h-11",
2584
+ onSelect: actions.onMoveToProject,
2585
+ "data-testid": "workflow-row-menu-move",
2586
+ children: [/* @__PURE__ */ jsx(Icon, {
2587
+ icon: "mdi:folder-move-outline",
2588
+ className: "mr-2 size-4"
2589
+ }), tr("fluidgrids.builder.cardWorkflow.moveToProject", "Move to project")]
2590
+ }),
2591
+ editable && canUpdate && /* @__PURE__ */ jsxs(DropdownMenuItem, {
2592
+ className: "min-h-11",
2593
+ onSelect: actions.onEditDescription,
2594
+ "data-testid": "workflow-row-menu-description",
2595
+ children: [/* @__PURE__ */ jsx(Icon, {
2596
+ icon: "mdi:text-box-edit-outline",
2597
+ className: "mr-2 size-4"
2598
+ }), tr("fluidgrids.builder.cardWorkflow.editDescription", "Edit description")]
2599
+ }),
2600
+ shareable && canShare && /* @__PURE__ */ jsxs(DropdownMenuItem, {
2601
+ className: "min-h-11",
2602
+ onSelect: actions.onShare,
2603
+ "data-testid": "workflow-row-menu-share",
2604
+ children: [/* @__PURE__ */ jsx(Icon, {
2605
+ icon: "mynaui:share",
2606
+ className: "mr-2 size-4"
2607
+ }), tr("fluidgrids.builder.cardWorkflow.shareWorkflow", "Share workflow")]
2608
+ })
2609
+ ]
2610
+ })] }),
2611
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
2612
+ /* @__PURE__ */ jsxs(DropdownMenuLabel, {
2613
+ className: "text-xs font-normal text-muted-foreground",
2614
+ "data-testid": "workflow-row-menu-version",
2615
+ children: [/* @__PURE__ */ jsx("span", {
2616
+ className: "font-mono",
2617
+ children: versionInfo
2618
+ }), versionCount ? /* @__PURE__ */ jsxs("span", { children: [" · ", versionCount] }) : null]
2619
+ })
2620
+ ]
2621
+ })] })]
2622
+ });
2623
+ }
2624
+
2625
+ // src/pages/workflows-list/useWorkflowListExport.ts
2626
+ /**
2627
+ * The workflows list's "Export" / "Download a copy" (BOFF-11843).
2628
+ *
2629
+ * A failed export used to reach only the browser console, so nothing visibly
2630
+ * happened. Every failure now shows a toast in the page's language with the
2631
+ * reason under it: the workflow could not be read, or the file could not be
2632
+ * built. The code-first formats (BOFF-9904) report the same way.
2633
+ */
2634
+ function useWorkflowListExport() {
2635
+ const tr = useTr();
2636
+ const { getWorkflow } = useLazyWorkflowDefinition();
2637
+ const { exportAs, exporting } = useExportWorkflowAs();
2638
+ const [exportingKey, setExportingKey] = useState(null);
2639
+ const failed = useCallback((error) => {
2640
+ toast.error(tr("fluidgrids.workflowsList.exportFailed", "Export failed"), { description: describeOperationError(error) });
2641
+ }, [tr]);
2642
+ return {
2643
+ exportJson: useCallback(async (id) => {
2644
+ const workflow = await getWorkflow(void 0, id);
2645
+ if (!workflow) {
2646
+ failed(new Error(tr("fluidgrids.workflowsList.exportNotFound", "The workflow could not be read. It may have been deleted or you may no longer have access to it.")));
2647
+ return;
2648
+ }
2649
+ try {
2650
+ downloadWorkflowExport(workflow);
2651
+ } catch (error) {
2652
+ failed(error);
2653
+ }
2654
+ }, [
2655
+ getWorkflow,
2656
+ failed,
2657
+ tr
2658
+ ]),
2659
+ exportInFormat: useCallback(async (workflowKey, version, format) => {
2660
+ setExportingKey(workflowKey);
2661
+ try {
2662
+ await exportAs({
2663
+ workflowKey,
2664
+ version,
2665
+ format
2666
+ });
2667
+ } catch (error) {
2668
+ failed(error);
2669
+ } finally {
2670
+ setExportingKey(null);
2671
+ }
2672
+ }, [exportAs, failed]),
2673
+ /** The format being prepared for `workflowKey`, else null. */
2674
+ exportingFormatOf: (workflowKey) => exportingKey === workflowKey ? exporting : null
2675
+ };
2676
+ }
2677
+
2678
+ // src/pages/WorkflowsListV2.tsx
2679
+ /**
2680
+ * My Workflows under Navigation v2 (FluidGrids only, BOFF-11843; mockup 12).
2681
+ *
2682
+ * - One table (fe-libs `ResponsiveTable`, cards on a phone): Name with its
2683
+ * tags, Status, Updated and Last run, Edit and "⋯" on each row.
2684
+ * - Status chips All / On / Off (draft) / Archived / Retired filter on the
2685
+ * server, so `?status=archived` (the shell's "Archived") matches its count.
2686
+ * The tag chips sit beside them (level 1); access (All / Mine / Shared with
2687
+ * me), project and run mode sit under "More filters".
2688
+ * - The count is the server's total, and "Load more" pages past the first
2689
+ * 100 workflows.
2690
+ * - The shell's My Workflows drill-down lists All workflows, Shared with me,
2691
+ * Folders and Archived, so the in-page folder tree is not shown. Its
2692
+ * `?access=`, `?status=`, `?folder=` and `?action=` links still work
2693
+ * (`workflowsListUrlState.ts`, `useActionParam.ts`). With a folder open,
2694
+ * the header's "⋯" offers New subfolder, Rename folder and Delete folder,
2695
+ * which the tree's per-folder menu used to hold.
2696
+ * - "New workflow" asks for a name; "Browse templates" is one click away. The
2697
+ * header's "⋯" holds Import and the bulk selection.
2698
+ *
2699
+ * The "Last run" column shows a dash until the service sends each workflow's
2700
+ * last run (BOFF-13715); nothing is guessed. There is no Owner column: the
2701
+ * list query has only the owner's id, not a name to show.
2702
+ */
2703
+ /** Where "Browse templates" goes, relative to the list. */
2704
+ const TEMPLATES_PATH = "../templates";
2705
+ /** The status chips, in the order mockup 12 shows them. */
2706
+ const STATUS_CHIPS = [
2707
+ "ACTIVE",
2708
+ "DRAFT",
2709
+ "ARCHIVED",
2710
+ "DEPRECATED"
2711
+ ];
2712
+ /** The service's status for each chip, sent as the list's `status` filter. */
2713
+ const SERVER_STATUS = {
2714
+ ACTIVE: "ACTIVE",
2715
+ DRAFT: "DRAFT",
2716
+ ARCHIVED: "ARCHIVED",
2717
+ DEPRECATED: "DEPRECATED"
2718
+ };
2719
+ /** The access choices under "More filters", in the classic list's order. */
2720
+ const ACCESS_CHOICES = [
2721
+ "ALL",
2722
+ "OWNED_BY_ME",
2723
+ "SHARED_WITH_ME"
2724
+ ];
2725
+ /** The access labels: the classic list's keys, so translations carry over. */
2726
+ function useAccessLabels() {
2727
+ const tr = useTr();
2728
+ return useMemo(() => ({
2729
+ ["ALL"]: tr("fluidgrids.workflowsList.access.all", "All"),
2730
+ ["OWNED_BY_ME"]: tr("fluidgrids.workflowsList.access.mine", "Mine"),
2731
+ ["SHARED_WITH_ME"]: tr("fluidgrids.workflowsList.access.sharedWithMe", "Shared with me")
2732
+ }), [tr]);
2733
+ }
2734
+ /** The status labels: the shared keys, which FluidGrids words as On / Off (draft) / Retired. */
2735
+ function useStatusLabels() {
2736
+ const tr = useTr();
2737
+ return useMemo(() => ({
2738
+ ACTIVE: tr("fluidgrids.workflowsList.statusActive", "Active"),
2739
+ DRAFT: tr("fluidgrids.workflowsList.statusDraft", "Draft"),
2740
+ ARCHIVED: tr("fluidgrids.workflowsList.statusArchived", "Archived"),
2741
+ DEPRECATED: tr("fluidgrids.workflowsList.statusDeprecated", "Deprecated")
2742
+ }), [tr]);
2743
+ }
2744
+ /** A pill-shaped filter chip; at least 44px tall on touch screens. */
2745
+ function FilterChip({ pressed, onClick, children, title, testId }) {
2746
+ return /* @__PURE__ */ jsx("button", {
2747
+ type: "button",
2748
+ "aria-pressed": pressed,
2749
+ title,
2750
+ onClick,
2751
+ "data-testid": testId,
2752
+ className: cn("inline-flex min-h-11 items-center gap-1 rounded-full border px-3 text-sm font-medium transition-colors sm:min-h-9", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", pressed ? "border-transparent bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground hover:text-foreground"),
2753
+ children
2754
+ });
2755
+ }
2756
+ function TableSkeleton() {
2757
+ return /* @__PURE__ */ jsx("div", {
2758
+ className: "flex flex-col gap-2 rounded-xl border border-border bg-card p-4",
2759
+ "aria-hidden": "true",
2760
+ children: Array.from({ length: 6 }, (_, i) => /* @__PURE__ */ jsxs("div", {
2761
+ className: "flex items-center gap-4 py-2",
2762
+ children: [
2763
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-1/3 bg-card-foreground/15" }),
2764
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-16 bg-card-foreground/10" }),
2765
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24 bg-card-foreground/10" }),
2766
+ /* @__PURE__ */ jsx(Skeleton, { className: "ml-auto h-8 w-20 bg-card-foreground/10" })
2767
+ ]
2768
+ }, i))
2769
+ });
2770
+ }
2771
+ function WorkflowsListV2() {
2772
+ const tr = useTr();
2773
+ const navigate = useNavigate();
2774
+ const statusLabels = useStatusLabels();
2775
+ const accessLabels = useAccessLabels();
2776
+ const modeCopy = useExecutionModeCopy();
2777
+ const workspaceId = useContext(FluidGridsContext)?.workspaceId ?? "";
2778
+ const urlFilters = useWorkflowsListUrlState();
2779
+ const { access: accessFilter, status: statusFilter, folder: folderFilter, mode: modeFilter, setAccess: setAccessFilter, setStatus: setStatusFilter, setMode: setModeFilter } = urlFilters;
2780
+ const { workflows, total, hasMore, loading, loadingMore, loadMore, loadMoreError, error, tagsByKey, refetch } = useWorkflowDefinitions({
2781
+ limit: 100,
2782
+ latestOnly: true,
2783
+ ...accessFilter === "ALL" ? {} : { access: accessFilter },
2784
+ ...statusFilter ? { status: SERVER_STATUS[statusFilter] } : {},
2785
+ ...modeFilter ? { executionMode: modeFilter } : {}
2786
+ }, { paginate: true });
2787
+ const [loadedOnce, setLoadedOnce] = useState(false);
2788
+ if (!loading && !loadedOnce) setLoadedOnce(true);
2789
+ const filteredOnServer = accessFilter !== "ALL" || modeFilter !== null || statusFilter !== null;
2790
+ const createPermission = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE);
2791
+ const canCreate = createPermission.allowed;
2792
+ const importRequest = useActionParam(ACTION_PARAM_VALUES.import, createPermission);
2793
+ const newFolderRequest = useActionParam(ACTION_PARAM_VALUES.newFolder);
2794
+ const [folderAction, setFolderAction] = useState(null);
2795
+ const clearFolderAction = useCallback(() => setFolderAction(null), []);
2796
+ const [importFromMenu, setImportFromMenu] = useState(false);
2797
+ const [search, setSearch] = useState("");
2798
+ const [tagFilter, setTagFilter] = useState(null);
2799
+ const [projectFilter, setProjectFilter] = useState(null);
2800
+ const [moreFiltersOpen, setMoreFiltersOpen] = useRememberedOpen("workflows.list.moreFilters", false);
2801
+ const [selectMode, setSelectMode] = useState(false);
2802
+ const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
2803
+ const [createOpen, setCreateOpen] = useState(false);
2804
+ const [sharing, setSharing] = useState(null);
2805
+ const [moving, setMoving] = useState(null);
2806
+ const [describing, setDescribing] = useState(null);
2807
+ const [settingsFor, setSettingsFor] = useState(null);
2808
+ const [deleteTarget, setDeleteTarget] = useState(null);
2809
+ const [deleting, setDeleting] = useState(false);
2810
+ const [quotaOpen, setQuotaOpen] = useState(false);
2811
+ const codeFirst = useFluidGridsFlag(FLUIDGRIDS_FLAGS.codeFirst);
2812
+ const { exportJson, exportInFormat, exportingFormatOf } = useWorkflowListExport();
2813
+ const { duplicate } = useDuplicateWorkflowCopy();
2814
+ const { deleteWorkflow } = useDeleteWorkflow();
2815
+ const createFirst = useCreateWorkflowFirst();
2816
+ const presentTags = useMemo(() => {
2817
+ const byId = /* @__PURE__ */ new Map();
2818
+ for (const w of workflows) for (const a of tagsByKey[w.workflowKey] ?? []) if (!byId.has(a.tagId)) byId.set(a.tagId, {
2819
+ id: a.tagId,
2820
+ label: a.tagInfo?.label ?? a.tagInfo?.key ?? tr("fluidgrids.workflowsList.tagFallbackLabel", "Tag")
2821
+ });
2822
+ return [...byId.values()].sort((a, b) => a.label.localeCompare(b.label));
2823
+ }, [
2824
+ workflows,
2825
+ tagsByKey,
2826
+ tr
2827
+ ]);
2828
+ const filtered = useMemo(() => {
2829
+ const q = search.trim().toLowerCase();
2830
+ return workflows.filter((w) => {
2831
+ if (tagFilter && !(tagsByKey[w.workflowKey] ?? []).some((a) => a.tagId === tagFilter)) return false;
2832
+ if (folderFilter && w.folderId !== folderFilter) return false;
2833
+ if (projectFilter && w.projectId !== projectFilter) return false;
2834
+ if (!q) return true;
2835
+ return [
2836
+ w.name,
2837
+ w.description,
2838
+ w.alias
2839
+ ].filter((v) => typeof v === "string").some((v) => v.toLowerCase().includes(q));
2840
+ });
2841
+ }, [
2842
+ workflows,
2843
+ search,
2844
+ tagFilter,
2845
+ tagsByKey,
2846
+ folderFilter,
2847
+ projectFilter
2848
+ ]);
2849
+ const { clientFiltered, filteringMore } = useLoadAllWhileFiltering({
2850
+ filtered: Boolean(folderFilter || tagFilter || projectFilter || search.trim()),
2851
+ hasMore,
2852
+ loading,
2853
+ loadingMore,
2854
+ loadMoreError: Boolean(loadMoreError),
2855
+ loadMore
2856
+ });
2857
+ const moreFiltersSet = (accessFilter !== "ALL" ? 1 : 0) + (projectFilter ? 1 : 0) + (modeFilter ? 1 : 0);
2858
+ const toolbarShown = loadedOnce && !error;
2859
+ const assistantControls = useMemo(() => workflowsListControls({
2860
+ page: tr("fluidgrids.workflowsList.title", "Workflows"),
2861
+ toolbarShown,
2862
+ search: setSearch,
2863
+ status: {
2864
+ label: tr("fluidgrids.executions.executionTable.colStatus", "Status"),
2865
+ allLabel: tr("fluidgrids.workflowsList.statusFilterAll", "All"),
2866
+ options: STATUS_CHIPS.map((value) => ({
2867
+ value,
2868
+ label: statusLabels[value]
2869
+ })),
2870
+ value: statusFilter,
2871
+ set: setStatusFilter
2872
+ },
2873
+ tag: {
2874
+ label: tr("fluidgrids.workflowsList.tagFallbackLabel", "Tag"),
2875
+ allLabel: tr("fluidgrids.workflowsList.statusFilterAll", "All"),
2876
+ options: presentTags.map((t) => ({
2877
+ value: t.id,
2878
+ label: t.label
2879
+ })),
2880
+ value: tagFilter,
2881
+ set: setTagFilter
2882
+ }
2883
+ }), [
2884
+ tr,
2885
+ toolbarShown,
2886
+ statusLabels,
2887
+ statusFilter,
2888
+ setStatusFilter,
2889
+ presentTags,
2890
+ tagFilter
2891
+ ]);
2892
+ useFluidGridsPageControls(assistantControls);
2893
+ const clearFilters = () => {
2894
+ setSearch("");
2895
+ setTagFilter(null);
2896
+ setProjectFilter(null);
2897
+ urlFilters.update({
2898
+ status: null,
2899
+ folder: null,
2900
+ mode: null,
2901
+ access: "ALL"
2902
+ });
2903
+ };
2904
+ const openBuilder = (w) => navigate(builderPathOf({
2905
+ workflowKey: w.workflowKey,
2906
+ version: w.version
2907
+ }));
2908
+ const handleDuplicate = async (w) => {
2909
+ try {
2910
+ const copy = await duplicate({
2911
+ workflowKey: w.workflowKey,
2912
+ version: w.version,
2913
+ name: w.name
2914
+ });
2915
+ if (copy.renameRefused) toast.warning(tr("fluidgrids.builder.cardWorkflow.copyRenameFailed", "The copy was made but kept the original name. Rename it in the editor."));
2916
+ navigate(builderPathOf(copy.workflow));
2917
+ } catch (err) {
2918
+ const cause = err instanceof Error ? err.cause : void 0;
2919
+ if (isQuotaExhaustedFailure(cause) || isQuotaExhaustedFailure(err)) {
2920
+ setQuotaOpen(true);
2921
+ return;
2922
+ }
2923
+ toast.error(tr("fluidgrids.workflowsList.duplicateFailed", "Couldn't duplicate the workflow"), { description: describeOperationError(err) });
2924
+ }
2925
+ };
2926
+ const confirmDelete = async () => {
2927
+ if (!deleteTarget) return;
2928
+ setDeleting(true);
2929
+ try {
2930
+ if (!await deleteWorkflow(deleteTarget.workflowKey)) {
2931
+ toast.error(tr("fluidgrids.workflowsList.deleteFailed", "Couldn't delete the workflow"));
2932
+ return;
2933
+ }
2934
+ setDeleteTarget(null);
2935
+ refetch();
2936
+ } finally {
2937
+ setDeleting(false);
2938
+ }
2939
+ };
2940
+ const toggleSelected = (id) => {
2941
+ setSelectedIds((prev) => {
2942
+ const next = new Set(prev);
2943
+ if (next.has(id)) next.delete(id);
2944
+ else next.add(id);
2945
+ return next;
2946
+ });
2947
+ };
2948
+ const createButton = /* @__PURE__ */ jsx(SdkPermissionButton, {
2949
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE,
2950
+ deniedTooltip: tr("fluidgrids.workflowsList.createDeniedTooltip", "You don't have permission to create workflows"),
2951
+ children: /* @__PURE__ */ jsxs(Button, {
2952
+ variant: "default",
2953
+ className: "min-h-11 font-bold text-primary-foreground",
2954
+ onClick: () => setCreateOpen(true),
2955
+ disabled: createFirst.creating,
2956
+ "aria-busy": createFirst.creating,
2957
+ "data-tour": "fluidgrids-list-create",
2958
+ children: [/* @__PURE__ */ jsx(Icon, {
2959
+ icon: "mynaui:plus",
2960
+ className: "size-5 text-primary-foreground"
2961
+ }), tr("fluidgrids.workflowsList.createButton", "Create Workflow")]
2962
+ })
2963
+ });
2964
+ const browseTemplatesButton = /* @__PURE__ */ jsx(Button, {
2965
+ asChild: true,
2966
+ variant: "outline",
2967
+ className: "min-h-11",
2968
+ children: /* @__PURE__ */ jsxs(Link, {
2969
+ to: TEMPLATES_PATH,
2970
+ "data-testid": "workflows-browse-templates",
2971
+ children: [/* @__PURE__ */ jsx(Icon, {
2972
+ icon: "mynaui:grid",
2973
+ className: "size-4",
2974
+ "aria-hidden": "true"
2975
+ }), tr("fluidgrids.workflowsList.browseTemplates", "Browse templates")]
2976
+ })
2977
+ });
2978
+ const headerMenuLabel = tr("fluidgrids.workflowsList.headerMenu", "More actions");
2979
+ const headerMenu = /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
2980
+ asChild: true,
2981
+ children: /* @__PURE__ */ jsx(Button, {
2982
+ variant: "outline",
2983
+ size: "icon",
2984
+ className: "size-11",
2985
+ "aria-label": headerMenuLabel,
2986
+ title: headerMenuLabel,
2987
+ "data-testid": "workflows-header-menu",
2988
+ "data-tour": "fluidgrids-list-import",
2989
+ children: /* @__PURE__ */ jsx(Icon, {
2990
+ icon: "mdi:dots-horizontal",
2991
+ className: "size-5"
2992
+ })
2993
+ })
2994
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
2995
+ align: "end",
2996
+ className: "min-w-52",
2997
+ children: [
2998
+ canCreate && /* @__PURE__ */ jsxs(DropdownMenuItem, {
2999
+ className: "min-h-11",
3000
+ onSelect: () => setImportFromMenu(true),
3001
+ "data-testid": "workflows-header-menu-import",
3002
+ children: [/* @__PURE__ */ jsx(Icon, {
3003
+ icon: "mynaui:upload",
3004
+ className: "mr-2 size-4"
3005
+ }), tr("fluidgrids.workflowsList.importButton", "Import")]
3006
+ }),
3007
+ /* @__PURE__ */ jsx(DropdownMenuCheckboxItem, {
3008
+ className: "min-h-11",
3009
+ checked: selectMode,
3010
+ onCheckedChange: (checked) => {
3011
+ setSelectMode(checked === true);
3012
+ setSelectedIds(/* @__PURE__ */ new Set());
3013
+ },
3014
+ "data-testid": "workflows-header-menu-select",
3015
+ children: tr("fluidgrids.workflowsList.bulk.selectToggle", "Select")
3016
+ }),
3017
+ folderFilter && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3018
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
3019
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
3020
+ className: "min-h-11",
3021
+ onSelect: () => setFolderAction({
3022
+ action: "create-child",
3023
+ folderId: folderFilter
3024
+ }),
3025
+ "data-testid": "workflows-header-menu-new-subfolder",
3026
+ children: [/* @__PURE__ */ jsx(Icon, {
3027
+ icon: "mynaui:folder-plus",
3028
+ className: "mr-2 size-4"
3029
+ }), tr("fluidgrids.workflowsList.folders.newSubfolder", "New subfolder")]
3030
+ }),
3031
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
3032
+ className: "min-h-11",
3033
+ onSelect: () => setFolderAction({
3034
+ action: "rename",
3035
+ folderId: folderFilter
3036
+ }),
3037
+ "data-testid": "workflows-header-menu-rename-folder",
3038
+ children: [/* @__PURE__ */ jsx(Icon, {
3039
+ icon: "mynaui:edit",
3040
+ className: "mr-2 size-4"
3041
+ }), tr("fluidgrids.workflowsList.folders.renameTitle", "Rename folder")]
3042
+ }),
3043
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
3044
+ className: "min-h-11 text-destructive",
3045
+ onSelect: () => setFolderAction({
3046
+ action: "delete",
3047
+ folderId: folderFilter
3048
+ }),
3049
+ "data-testid": "workflows-header-menu-delete-folder",
3050
+ children: [/* @__PURE__ */ jsx(Icon, {
3051
+ icon: "mynaui:trash",
3052
+ className: "mr-2 size-4"
3053
+ }), tr("fluidgrids.workflowsList.folders.deleteFolder", "Delete folder")]
3054
+ })
3055
+ ] })
3056
+ ]
3057
+ })] });
3058
+ const nameCell = (w) => {
3059
+ const tags = tagsByKey[w.workflowKey] ?? [];
3060
+ const description = visibleWorkflowDescription(w.description, w.name);
3061
+ return /* @__PURE__ */ jsxs("div", {
3062
+ className: "min-w-0",
3063
+ children: [
3064
+ /* @__PURE__ */ jsxs("div", {
3065
+ className: "flex min-w-0 items-center gap-1.5",
3066
+ children: [/* @__PURE__ */ jsx(Link, {
3067
+ to: builderPathOf({
3068
+ workflowKey: w.workflowKey,
3069
+ version: w.version
3070
+ }),
3071
+ onClick: (event) => event.stopPropagation(),
3072
+ className: "truncate font-semibold text-foreground underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
3073
+ "data-testid": "workflow-row-name",
3074
+ children: w.name
3075
+ }), w.visibility === "RESTRICTED" && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
3076
+ asChild: true,
3077
+ children: /* @__PURE__ */ jsx("span", {
3078
+ role: "img",
3079
+ tabIndex: 0,
3080
+ className: "shrink-0 rounded-sm text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
3081
+ "data-testid": "workflow-restricted-badge",
3082
+ "aria-label": tr("fluidgrids.builder.cardWorkflow.restricted", "Shared only with chosen people"),
3083
+ children: /* @__PURE__ */ jsx(Icon, {
3084
+ icon: "mdi:lock-outline",
3085
+ className: "size-3.5",
3086
+ "aria-hidden": "true"
3087
+ })
3088
+ })
3089
+ }), /* @__PURE__ */ jsx(TooltipContent, {
3090
+ side: "top",
3091
+ children: tr("fluidgrids.builder.cardWorkflow.restricted", "Shared only with chosen people")
3092
+ })] })]
3093
+ }),
3094
+ description && /* @__PURE__ */ jsx("p", {
3095
+ className: "mt-0.5 truncate text-xs text-muted-foreground",
3096
+ title: description,
3097
+ children: description
3098
+ }),
3099
+ /* @__PURE__ */ jsx(WorkflowRunModeBadges, {
3100
+ executionMode: w.executionMode,
3101
+ autonomyLevel: w.autonomyLevel,
3102
+ className: "mt-1"
3103
+ }),
3104
+ tags.length > 0 && /* @__PURE__ */ jsxs("div", {
3105
+ className: "mt-1 flex flex-wrap items-center gap-1",
3106
+ children: [tags.slice(0, 3).map((a) => /* @__PURE__ */ jsx(TagBadge, {
3107
+ id: a.tagId,
3108
+ label: a.tagInfo?.label ?? a.tagInfo?.key ?? tr("fluidgrids.workflowsList.cardTagFallbackLabel", "Tag"),
3109
+ color: a.tagInfo?.color ?? void 0,
3110
+ size: "sm"
3111
+ }, a.tagId)), tags.length > 3 && /* @__PURE__ */ jsxs("span", {
3112
+ className: "text-xs text-muted-foreground",
3113
+ children: ["+", tags.length - 3]
3114
+ })]
3115
+ })
3116
+ ]
3117
+ });
3118
+ };
3119
+ const noRunYet = tr("fluidgrids.workflowsList.table.lastRunUnknown", "Last run not shown yet");
3120
+ const columns = [
3121
+ ...selectMode ? [{
3122
+ key: "select",
3123
+ header: /* @__PURE__ */ jsx("span", {
3124
+ className: "sr-only",
3125
+ children: tr("fluidgrids.workflowsList.bulk.selectToggle", "Select")
3126
+ }),
3127
+ mobileLabel: tr("fluidgrids.workflowsList.bulk.selectToggle", "Select"),
3128
+ cell: (w) => /* @__PURE__ */ jsx("span", {
3129
+ onClick: (event) => event.stopPropagation(),
3130
+ children: /* @__PURE__ */ jsx(Checkbox, {
3131
+ checked: selectedIds.has(w.id),
3132
+ onCheckedChange: () => toggleSelected(w.id),
3133
+ "aria-label": tr("fluidgrids.workflowsList.bulk.selectNamedAriaLabel", "Select {{name}}", { name: w.name })
3134
+ })
3135
+ }),
3136
+ headerClassName: "w-10"
3137
+ }] : [],
3138
+ {
3139
+ key: "name",
3140
+ header: tr("fluidgrids.workflowsList.table.name", "Name"),
3141
+ priority: "primary",
3142
+ cell: nameCell,
3143
+ cellClassName: "max-w-0 w-1/2"
3144
+ },
3145
+ {
3146
+ key: "status",
3147
+ header: tr("fluidgrids.executions.executionTable.colStatus", "Status"),
3148
+ cell: (w) => /* @__PURE__ */ jsx(WorkflowStatusPill, { status: w.status ?? void 0 })
3149
+ },
3150
+ {
3151
+ key: "updated",
3152
+ header: tr("fluidgrids.workflowsList.table.updated", "Updated"),
3153
+ cell: (w) => /* @__PURE__ */ jsx("span", {
3154
+ className: "text-sm text-muted-foreground",
3155
+ title: formatExactTime(w.updatedAt),
3156
+ children: formatRelativeTime(tr, w.updatedAt)
3157
+ })
3158
+ },
3159
+ {
3160
+ key: "lastRun",
3161
+ header: tr("fluidgrids.workflowsList.table.lastRun", "Last run"),
3162
+ priority: "hidden-on-mobile",
3163
+ cell: () => /* @__PURE__ */ jsxs("span", {
3164
+ className: "text-sm text-muted-foreground",
3165
+ title: noRunYet,
3166
+ children: [/* @__PURE__ */ jsx("span", {
3167
+ "aria-hidden": "true",
3168
+ children: "—"
3169
+ }), /* @__PURE__ */ jsx("span", {
3170
+ className: "sr-only",
3171
+ children: noRunYet
3172
+ })]
3173
+ })
3174
+ }
3175
+ ];
3176
+ const isEmpty = !loading && workflows.length === 0 && !filteredOnServer && !folderFilter;
3177
+ return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs("main", {
3178
+ className: "flex min-h-screen w-full flex-col gap-5 bg-surface-canvas p-4 sm:p-6",
3179
+ children: [
3180
+ /* @__PURE__ */ jsxs("div", {
3181
+ className: "flex flex-wrap items-start justify-between gap-3",
3182
+ "data-tour": "fluidgrids-list-header",
3183
+ children: [/* @__PURE__ */ jsxs("div", {
3184
+ className: "min-w-0",
3185
+ children: [
3186
+ /* @__PURE__ */ jsxs("div", {
3187
+ className: "flex items-center gap-2.5",
3188
+ children: [/* @__PURE__ */ jsx("h1", {
3189
+ className: "text-2xl font-bold tracking-tight",
3190
+ children: tr("fluidgrids.workflowsList.title", "Workflows")
3191
+ }), toolbarShown && /* @__PURE__ */ jsx(Badge, {
3192
+ variant: "secondary",
3193
+ className: "font-mono",
3194
+ "data-testid": "workflows-total",
3195
+ children: clientFiltered ? `${filtered.length}${filteringMore ? "+" : ""}` : Math.max(total, workflows.length)
3196
+ })]
3197
+ }),
3198
+ /* @__PURE__ */ jsx("p", {
3199
+ className: "mt-1 text-sm text-muted-foreground",
3200
+ children: tr("fluidgrids.workflowsList.subtitle", "Build, run, and manage your automations. Open a workflow to edit it in the visual builder.")
3201
+ }),
3202
+ /* @__PURE__ */ jsx(FluidGridsDocsLink, {
3203
+ topic: "workflows",
3204
+ className: "mt-1"
3205
+ })
3206
+ ]
3207
+ }), /* @__PURE__ */ jsxs("div", {
3208
+ className: "flex items-center gap-2",
3209
+ children: [headerMenu, createButton]
3210
+ })]
3211
+ }),
3212
+ !loading && !error && !filteredOnServer && /* @__PURE__ */ jsx(FirstWorkflowChecklist, {
3213
+ workflows,
3214
+ canCreate
3215
+ }),
3216
+ toolbarShown && !isEmpty && /* @__PURE__ */ jsxs("div", {
3217
+ className: "flex flex-col gap-3",
3218
+ "data-tour": "fluidgrids-list-toolbar",
3219
+ children: [/* @__PURE__ */ jsxs("div", {
3220
+ className: "flex flex-wrap items-center gap-2",
3221
+ children: [
3222
+ /* @__PURE__ */ jsxs("div", {
3223
+ className: "relative w-full min-w-0 sm:max-w-md sm:flex-1",
3224
+ children: [/* @__PURE__ */ jsx(Icon, {
3225
+ icon: "mynaui:search",
3226
+ className: "pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground",
3227
+ "aria-hidden": "true"
3228
+ }), /* @__PURE__ */ jsx(Input, {
3229
+ type: "search",
3230
+ value: search,
3231
+ onChange: (e) => setSearch(e.target.value),
3232
+ placeholder: tr("fluidgrids.workflowsList.searchPlaceholder", "Search workflows…"),
3233
+ "aria-label": tr("fluidgrids.workflowsList.searchAriaLabel", "Search workflows"),
3234
+ className: "min-h-11 pl-9"
3235
+ })]
3236
+ }),
3237
+ /* @__PURE__ */ jsxs("div", {
3238
+ className: "flex flex-wrap items-center gap-1.5",
3239
+ role: "group",
3240
+ "aria-label": tr("fluidgrids.executions.executionTable.colStatus", "Status"),
3241
+ "data-testid": "workflow-status-filter",
3242
+ children: [/* @__PURE__ */ jsx(FilterChip, {
3243
+ pressed: statusFilter === null,
3244
+ onClick: () => setStatusFilter(null),
3245
+ children: tr("fluidgrids.workflowsList.statusFilterAll", "All")
3246
+ }), STATUS_CHIPS.map((status) => /* @__PURE__ */ jsx(FilterChip, {
3247
+ pressed: statusFilter === status,
3248
+ onClick: () => setStatusFilter(statusFilter === status ? null : status),
3249
+ testId: `workflow-status-chip-${status.toLowerCase()}`,
3250
+ children: statusLabels[status]
3251
+ }, status))]
3252
+ }),
3253
+ presentTags.length > 0 && /* @__PURE__ */ jsx("div", {
3254
+ className: "flex flex-wrap items-center gap-1.5",
3255
+ role: "group",
3256
+ "data-testid": "workflow-tag-filter",
3257
+ "aria-label": tr("fluidgrids.workflowsList.tagsLabel", "Tags"),
3258
+ children: presentTags.map((t) => /* @__PURE__ */ jsx(FilterChip, {
3259
+ pressed: tagFilter === t.id,
3260
+ onClick: () => setTagFilter((cur) => cur === t.id ? null : t.id),
3261
+ children: t.label
3262
+ }, t.id))
3263
+ }),
3264
+ /* @__PURE__ */ jsxs(Button, {
3265
+ variant: "ghost",
3266
+ className: "min-h-11",
3267
+ "aria-expanded": moreFiltersOpen,
3268
+ "aria-controls": "workflows-more-filters",
3269
+ onClick: () => setMoreFiltersOpen(!moreFiltersOpen),
3270
+ "data-testid": "workflows-more-filters",
3271
+ children: [
3272
+ /* @__PURE__ */ jsx(Icon, {
3273
+ icon: "mdi:tune-variant",
3274
+ className: "size-4",
3275
+ "aria-hidden": "true"
3276
+ }),
3277
+ tr("fluidgrids.workflowsList.moreFilters", "More filters"),
3278
+ moreFiltersSet > 0 && /* @__PURE__ */ jsx(Badge, {
3279
+ variant: "secondary",
3280
+ className: "ml-1",
3281
+ children: moreFiltersSet
3282
+ })
3283
+ ]
3284
+ })
3285
+ ]
3286
+ }), /* @__PURE__ */ jsxs("div", {
3287
+ id: "workflows-more-filters",
3288
+ hidden: !moreFiltersOpen,
3289
+ className: "flex flex-col gap-3 rounded-lg border border-border bg-card p-3",
3290
+ children: [
3291
+ /* @__PURE__ */ jsx("div", {
3292
+ className: "flex flex-wrap items-center gap-1.5",
3293
+ role: "group",
3294
+ "aria-label": tr("fluidgrids.workflowsList.access.label", "Access"),
3295
+ "data-testid": "workflow-access-filter",
3296
+ children: ACCESS_CHOICES.map((access) => /* @__PURE__ */ jsx(FilterChip, {
3297
+ pressed: accessFilter === access,
3298
+ onClick: () => setAccessFilter(access),
3299
+ testId: `workflow-access-chip-${access.toLowerCase()}`,
3300
+ children: accessLabels[access]
3301
+ }, access))
3302
+ }),
3303
+ /* @__PURE__ */ jsx(WorkflowProjectSelect, {
3304
+ selectedProjectId: projectFilter,
3305
+ onSelectProject: setProjectFilter
3306
+ }),
3307
+ /* @__PURE__ */ jsxs("div", {
3308
+ className: "flex flex-wrap items-center gap-1.5",
3309
+ role: "group",
3310
+ "aria-label": tr("fluidgrids.workflowsList.mode.label", "Run mode"),
3311
+ "data-testid": "workflow-mode-filter",
3312
+ children: [/* @__PURE__ */ jsx(FilterChip, {
3313
+ pressed: modeFilter === null,
3314
+ onClick: () => setModeFilter(null),
3315
+ children: tr("fluidgrids.workflowsList.mode.all", "Any mode")
3316
+ }), EXECUTION_MODES.map((mode) => /* @__PURE__ */ jsxs(FilterChip, {
3317
+ pressed: modeFilter === mode,
3318
+ title: modeCopy[mode].hint,
3319
+ onClick: () => setModeFilter(modeFilter === mode ? null : mode),
3320
+ children: [/* @__PURE__ */ jsx(Icon, {
3321
+ icon: EXECUTION_MODE_ICONS[mode],
3322
+ className: "size-3.5",
3323
+ "aria-hidden": "true"
3324
+ }), modeCopy[mode].label]
3325
+ }, mode))]
3326
+ })
3327
+ ]
3328
+ })]
3329
+ }),
3330
+ selectedIds.size > 0 && /* @__PURE__ */ jsx(WorkflowBulkActionsBar, {
3331
+ selectedIds: [...selectedIds],
3332
+ onDone: () => {
3333
+ setSelectedIds(/* @__PURE__ */ new Set());
3334
+ setSelectMode(false);
3335
+ refetch();
3336
+ }
3337
+ }),
3338
+ loading ? /* @__PURE__ */ jsx(TableSkeleton, {}) : error ? /* @__PURE__ */ jsx("div", {
3339
+ className: "grid flex-1 place-items-center",
3340
+ children: /* @__PURE__ */ jsxs("div", {
3341
+ className: "flex max-w-md flex-col items-center gap-3 rounded-xl border border-border bg-card p-8 text-center",
3342
+ role: "alert",
3343
+ children: [
3344
+ /* @__PURE__ */ jsx(Icon, {
3345
+ icon: "mynaui:danger-triangle",
3346
+ className: "size-8 text-destructive",
3347
+ "aria-hidden": "true"
3348
+ }),
3349
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
3350
+ className: "font-semibold",
3351
+ children: tr("fluidgrids.workflowsList.loadErrorTitle", "Couldn't load workflows")
3352
+ }), /* @__PURE__ */ jsx("p", {
3353
+ className: "mt-1 text-sm text-muted-foreground",
3354
+ children: error.message
3355
+ })] }),
3356
+ /* @__PURE__ */ jsxs(Button, {
3357
+ variant: "outline",
3358
+ className: "min-h-11",
3359
+ onClick: () => void refetch(),
3360
+ children: [/* @__PURE__ */ jsx(Icon, {
3361
+ icon: "mynaui:refresh",
3362
+ className: "size-4"
3363
+ }), tr("fluidgrids.workflowsList.tryAgainButton", "Try again")]
3364
+ })
3365
+ ]
3366
+ })
3367
+ }) : isEmpty ? /* @__PURE__ */ jsx("div", {
3368
+ className: "grid flex-1 place-items-center",
3369
+ children: /* @__PURE__ */ jsx(IllustratedEmptyState, {
3370
+ illustration: "onboarding",
3371
+ title: tr("fluidgrids.workflowsList.emptyStateTitle", "Create your first workflow"),
3372
+ 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."),
3373
+ action: /* @__PURE__ */ jsxs("div", {
3374
+ className: "flex flex-wrap items-center justify-center gap-2",
3375
+ children: [createButton, browseTemplatesButton]
3376
+ })
3377
+ })
3378
+ }) : filtered.length === 0 && !filteringMore ? /* @__PURE__ */ jsx("div", {
3379
+ className: "grid flex-1 place-items-center",
3380
+ children: /* @__PURE__ */ jsxs("div", {
3381
+ className: "flex flex-col items-center gap-3 text-center",
3382
+ children: [
3383
+ /* @__PURE__ */ jsx(Icon, {
3384
+ icon: "mynaui:search",
3385
+ className: "size-8 text-muted-foreground",
3386
+ "aria-hidden": "true"
3387
+ }),
3388
+ /* @__PURE__ */ jsx("p", {
3389
+ className: "font-medium",
3390
+ children: tr("fluidgrids.workflowsList.noFilterMatchTitle", "No workflows match your filters")
3391
+ }),
3392
+ /* @__PURE__ */ jsx(Button, {
3393
+ variant: "outline",
3394
+ className: "min-h-11",
3395
+ onClick: clearFilters,
3396
+ children: tr("fluidgrids.workflowsList.clearFiltersButton", "Clear filters")
3397
+ })
3398
+ ]
3399
+ })
3400
+ }) : /* @__PURE__ */ jsx("div", {
3401
+ "data-testid": "workflows-table",
3402
+ "data-tour": "fluidgrids-list-results",
3403
+ children: /* @__PURE__ */ jsx(ResponsiveTable, {
3404
+ columns,
3405
+ data: filtered,
3406
+ rowKey: (w) => w.id,
3407
+ onRowClick: openBuilder,
3408
+ rowActionsLabel: tr("fluidgrids.workflowsList.table.actions", "Actions"),
3409
+ rowActions: (w) => /* @__PURE__ */ jsx(WorkflowRowMenu, {
3410
+ workflow: {
3411
+ name: w.name,
3412
+ version: w.version,
3413
+ alias: w.alias,
3414
+ totalVersions: w.totalVersions,
3415
+ myAccess: w.myAccess
3416
+ },
3417
+ downloading: exportingFormatOf(w.workflowKey) !== null,
3418
+ actions: {
3419
+ onEdit: () => openBuilder(w),
3420
+ onDuplicate: () => void handleDuplicate(w),
3421
+ onDelete: () => setDeleteTarget({
3422
+ workflowKey: w.workflowKey,
3423
+ name: w.name
3424
+ }),
3425
+ onSettings: () => setSettingsFor({
3426
+ workflowKey: w.workflowKey,
3427
+ name: w.name
3428
+ }),
3429
+ onDownload: () => void exportJson(w.id),
3430
+ onDownloadAs: codeFirst ? (format) => void exportInFormat(w.workflowKey, w.version, format) : void 0,
3431
+ onMoveToProject: () => setMoving({
3432
+ id: w.id,
3433
+ name: w.name,
3434
+ projectId: w.projectId ?? null
3435
+ }),
3436
+ onEditDescription: () => setDescribing({
3437
+ id: w.id,
3438
+ name: w.name,
3439
+ description: w.description ?? null
3440
+ }),
3441
+ onShare: () => setSharing({
3442
+ workflowKey: w.workflowKey,
3443
+ name: w.name
3444
+ })
3445
+ }
1876
3446
  })
1877
- ]
3447
+ })
1878
3448
  }),
1879
- /* @__PURE__ */ jsxs(ResponsiveDialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
1880
- variant: "outline",
1881
- onClick: onClose,
1882
- disabled: saving,
1883
- children: tr("fluidgrids.workflowsList.moveToProject.cancel", "Cancel")
1884
- }), /* @__PURE__ */ jsx(Button, {
1885
- onClick: () => void save(),
1886
- disabled: saving || decision.kind !== "save",
1887
- "aria-busy": saving,
1888
- "data-testid": "workflow-description-save",
1889
- children: tr("fluidgrids.workflowsList.editDescription.save", "Save")
1890
- })] })
3449
+ !loading && !error && /* @__PURE__ */ jsx(WorkflowsLoadMore, {
3450
+ hasMore,
3451
+ loadingMore,
3452
+ error: loadMoreError,
3453
+ shown: workflows.length,
3454
+ total,
3455
+ onLoadMore: () => void loadMore()
3456
+ }),
3457
+ /* @__PURE__ */ jsx(WorkflowImportDialog, {
3458
+ onImported: () => void refetch(),
3459
+ openRequested: importRequest.requested || importFromMenu,
3460
+ onOpenRequestHandled: () => {
3461
+ if (importRequest.requested) importRequest.handled();
3462
+ setImportFromMenu(false);
3463
+ }
3464
+ }),
3465
+ /* @__PURE__ */ jsx(WorkflowFolderSidebar, {
3466
+ dialogsOnly: true,
3467
+ selectedFolderId: folderFilter,
3468
+ onSelectFolder: urlFilters.setFolder,
3469
+ createRequested: newFolderRequest.requested,
3470
+ onCreateRequestHandled: newFolderRequest.handled,
3471
+ folderActionRequest: folderAction,
3472
+ onFolderActionRequestHandled: clearFolderAction
3473
+ }),
3474
+ /* @__PURE__ */ jsx(CreateWorkflowNameDialog, {
3475
+ open: createOpen,
3476
+ onOpenChange: setCreateOpen,
3477
+ creating: createFirst.creating,
3478
+ templatesHref: TEMPLATES_PATH,
3479
+ onCreate: (name) => {
3480
+ createFirst.start(name).then((result) => {
3481
+ if (result) setCreateOpen(false);
3482
+ });
3483
+ }
3484
+ }),
3485
+ /* @__PURE__ */ jsx(WorkflowSettingsDrawer, {
3486
+ workflowKey: settingsFor?.workflowKey ?? null,
3487
+ workflowName: settingsFor?.name ?? "",
3488
+ onClose: () => setSettingsFor(null),
3489
+ allSettingsHref: settingsFor ? `../settings/${encodeURIComponent(settingsFor.workflowKey)}` : "../settings"
3490
+ }),
3491
+ /* @__PURE__ */ jsx(ConfirmActionDialog, {
3492
+ open: deleteTarget !== null,
3493
+ title: tr("fluidgrids.builder.cardWorkflow.deleteDialogTitle", "Delete Workflow"),
3494
+ description: tr("fluidgrids.workflowsList.deleteConfirmDescription", "“{{name}}” and all its versions will be deleted. This can't be undone.", { name: deleteTarget?.name ?? "" }),
3495
+ confirmLabel: deleting ? tr("fluidgrids.builder.cardWorkflow.deletingButton", "Deleting...") : tr("fluidgrids.builder.cardWorkflow.deleteButton", "Delete"),
3496
+ cancelLabel: tr("fluidgrids.workflowsList.deleteConfirmCancel", "Keep it"),
3497
+ destructive: true,
3498
+ busy: deleting,
3499
+ onConfirm: () => void confirmDelete(),
3500
+ onOpenChange: (open) => {
3501
+ if (!open && !deleting) setDeleteTarget(null);
3502
+ },
3503
+ "data-testid": "workflow-delete-confirm"
3504
+ }),
3505
+ /* @__PURE__ */ jsx(QuotaExhaustedDialog, {
3506
+ surface: "workflow-duplicate",
3507
+ open: quotaOpen,
3508
+ onOpenChange: setQuotaOpen,
3509
+ onUpgrade: () => {
3510
+ setQuotaOpen(false);
3511
+ navigate(BILLING_PLANS_PATH);
3512
+ }
3513
+ }),
3514
+ /* @__PURE__ */ jsx(WorkflowShareDialog, {
3515
+ open: sharing !== null,
3516
+ onClose: () => setSharing(null),
3517
+ workflowKey: sharing?.workflowKey ?? null,
3518
+ workflowName: sharing?.name ?? "",
3519
+ workspaceId,
3520
+ onShared: () => void refetch()
3521
+ }),
3522
+ /* @__PURE__ */ jsx(WorkflowMoveToProjectDialog, {
3523
+ workflow: moving,
3524
+ onClose: () => setMoving(null),
3525
+ onMoved: () => void refetch()
3526
+ }),
3527
+ /* @__PURE__ */ jsx(WorkflowDescriptionDialog, {
3528
+ workflow: describing,
3529
+ onClose: () => setDescribing(null),
3530
+ onSaved: () => void refetch()
3531
+ }),
3532
+ /* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
3533
+ surface: "builder-create",
3534
+ refusal: createFirst.refusal,
3535
+ onClose: createFirst.clearRefusal,
3536
+ onUpgrade: () => navigate(BILLING_PLANS_PATH)
3537
+ })
1891
3538
  ]
1892
- });
1893
- }
1894
-
1895
- // src/pages/workflowsListUrlState.ts
1896
- /**
1897
- * URL-driven filter state for the workflows list (BOFF-10854).
1898
- *
1899
- * The access, status and folder filters live in the query string so the
1900
- * shell's navigation ("Shared with me", "Archived", a folder) can link
1901
- * straight to a filtered list, and a filtered list survives reload and
1902
- * back/forward. Supported values:
1903
- *
1904
- * ?access=mine | shared (absent or "all" = every visible workflow)
1905
- * ?status=active | draft | archived | deprecated (absent = any status)
1906
- * ?folder=<folder id> (absent = all folders)
1907
- * ?mode=deterministic | agentic | hybrid (absent = any run mode, BOFF-9955)
1908
- *
1909
- * Unknown values fall back to the default rather than erroring. Writes use
1910
- * history replace, so toggling chips does not flood the back stack, and a
1911
- * default value removes its parameter so plain `/workflows/list` stays clean.
1912
- */
1913
- const WORKFLOWS_LIST_PARAMS = {
1914
- access: "access",
1915
- status: "status",
1916
- folder: "folder",
1917
- mode: "mode"
1918
- };
1919
- /** The workflow statuses the list's status chips offer. */
1920
- const WORKFLOW_LIST_STATUSES = [
1921
- "ACTIVE",
1922
- "DRAFT",
1923
- "ARCHIVED",
1924
- "DEPRECATED"
1925
- ];
1926
- const ACCESS_BY_PARAM = {
1927
- all: "ALL",
1928
- mine: "OWNED_BY_ME",
1929
- shared: "SHARED_WITH_ME"
1930
- };
1931
- const PARAM_BY_ACCESS = {
1932
- ["ALL"]: null,
1933
- ["OWNED_BY_ME"]: "mine",
1934
- ["SHARED_WITH_ME"]: "shared"
1935
- };
1936
- function accessFromParam(value) {
1937
- if (!value) return "ALL";
1938
- return ACCESS_BY_PARAM[value.trim().toLowerCase()] ?? "ALL";
1939
- }
1940
- function accessToParam(access) {
1941
- return PARAM_BY_ACCESS[access];
1942
- }
1943
- function isWorkflowListStatus(value) {
1944
- return WORKFLOW_LIST_STATUSES.includes(value);
1945
- }
1946
- /** `archived` / `ARCHIVED` → `ARCHIVED`; anything unknown → no filter. */
1947
- function statusFromParam(value) {
1948
- if (!value) return null;
1949
- const upper = value.trim().toUpperCase();
1950
- return isWorkflowListStatus(upper) ? upper : null;
1951
- }
1952
- function statusToParam(status) {
1953
- if (!status) return null;
1954
- const upper = status.toUpperCase();
1955
- return isWorkflowListStatus(upper) ? upper.toLowerCase() : null;
1956
- }
1957
- function folderFromParam(value) {
1958
- const trimmed = value?.trim();
1959
- return trimmed ? trimmed : null;
1960
- }
1961
- /** `agentic` / `AGENTIC` → AGENTIC (BOFF-9955); anything unknown → no filter. */
1962
- function modeFromParam(value) {
1963
- if (!value) return null;
1964
- const upper = value.trim().toUpperCase();
1965
- return isExecutionMode(upper) ? upper : null;
1966
- }
1967
- function modeToParam(mode) {
1968
- return mode ? mode.toLowerCase() : null;
1969
- }
1970
- /**
1971
- * Applies a filter patch to a copy of `params`. Keys missing from the patch
1972
- * are left untouched; default values delete their parameter. Unrelated
1973
- * parameters (e.g. `?action=`) are preserved.
1974
- */
1975
- function applyFilterPatch(params, patch) {
1976
- const next = new URLSearchParams(params);
1977
- const write = (key, value) => {
1978
- if (value === null) next.delete(key);
1979
- else next.set(key, value);
1980
- };
1981
- if (patch.access !== void 0) write(WORKFLOWS_LIST_PARAMS.access, accessToParam(patch.access));
1982
- if (patch.status !== void 0) write(WORKFLOWS_LIST_PARAMS.status, statusToParam(patch.status));
1983
- if (patch.folder !== void 0) write(WORKFLOWS_LIST_PARAMS.folder, folderFromParam(patch.folder));
1984
- if (patch.mode !== void 0) write(WORKFLOWS_LIST_PARAMS.mode, modeToParam(patch.mode));
1985
- return next;
1986
- }
1987
- function useWorkflowsListUrlState() {
1988
- const [searchParams, setSearchParams] = useSearchParams();
1989
- const access = accessFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.access));
1990
- const status = statusFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.status));
1991
- const folder = folderFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.folder));
1992
- const mode = modeFromParam(searchParams.get(WORKFLOWS_LIST_PARAMS.mode));
1993
- const update = useCallback((patch) => {
1994
- setSearchParams((prev) => applyFilterPatch(prev, patch), { replace: true });
1995
- }, [setSearchParams]);
1996
- return useMemo(() => ({
1997
- access,
1998
- status,
1999
- folder,
2000
- mode,
2001
- update,
2002
- setAccess: (next) => update({ access: next }),
2003
- setStatus: (next) => update({ status: next }),
2004
- setFolder: (next) => update({ folder: next }),
2005
- setMode: (next) => update({ mode: next })
2006
- }), [
2007
- access,
2008
- status,
2009
- folder,
2010
- mode,
2011
- update
2012
- ]);
3539
+ }) });
2013
3540
  }
2014
3541
 
2015
3542
  // src/pages/WorkflowsList.tsx
@@ -2068,7 +3595,15 @@ function SkeletonCard() {
2068
3595
  })]
2069
3596
  });
2070
3597
  }
3598
+ /**
3599
+ * My Workflows. FluidGrids turns on Navigation v2 (`NavigationV2Provider`),
3600
+ * which shows the table of `WorkflowsListV2` (BOFF-11843); every other app
3601
+ * keeps the card grid below.
3602
+ */
2071
3603
  function WorkflowsList() {
3604
+ return useNavigationV2() ? /* @__PURE__ */ jsx(WorkflowsListV2, {}) : /* @__PURE__ */ jsx(WorkflowsListClassic, {});
3605
+ }
3606
+ function WorkflowsListClassic() {
2072
3607
  const tr = useTr();
2073
3608
  const navigate = useNavigate();
2074
3609
  const STATUS_FILTERS = useStatusFilters();
@@ -2077,17 +3612,16 @@ function WorkflowsList() {
2077
3612
  const urlFilters = useWorkflowsListUrlState();
2078
3613
  const { access: accessFilter, status: statusFilter, folder: folderFilter, mode: modeFilter, setAccess: setAccessFilter, setStatus: setStatusFilter, setFolder: setFolderFilter, setMode: setModeFilter } = urlFilters;
2079
3614
  const modeCopy = useExecutionModeCopy();
2080
- const { workflows, loading, error, tagsByKey, refetch } = useWorkflowDefinitions({
3615
+ const { workflows, total, hasMore, loading, loadingMore, loadMore, loadMoreError, error, tagsByKey, refetch } = useWorkflowDefinitions({
2081
3616
  limit: 100,
2082
3617
  latestOnly: true,
2083
3618
  ...accessFilter === "ALL" ? {} : { access: accessFilter },
2084
3619
  ...modeFilter ? { executionMode: modeFilter } : {}
2085
- });
3620
+ }, { paginate: true });
2086
3621
  const [sharing, setSharing] = useState(null);
2087
3622
  const [moving, setMoving] = useState(null);
2088
3623
  const [describing, setDescribing] = useState(null);
2089
3624
  const filteredOnServer = accessFilter !== "ALL" || modeFilter !== null;
2090
- const { getWorkflow } = useLazyWorkflowDefinition();
2091
3625
  const createPermission = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE);
2092
3626
  const canCreate = createPermission.allowed;
2093
3627
  const importRequest = useActionParam(ACTION_PARAM_VALUES.import, createPermission);
@@ -2187,31 +3721,7 @@ function WorkflowsList() {
2187
3721
  ]);
2188
3722
  useFluidGridsPageControls(assistantControls);
2189
3723
  const codeFirst = useFluidGridsFlag(FLUIDGRIDS_FLAGS.codeFirst);
2190
- const { exportAs, exporting } = useExportWorkflowAs();
2191
- const [exportingKey, setExportingKey] = useState(null);
2192
- const handleExportAs = async (workflowKey, version, format) => {
2193
- setExportingKey(workflowKey);
2194
- try {
2195
- await exportAs({
2196
- workflowKey,
2197
- version,
2198
- format
2199
- });
2200
- } catch (error) {
2201
- toast.error(tr("fluidgrids.workflowsList.exportFailed", "Export failed"), { description: describeOperationError(error) });
2202
- } finally {
2203
- setExportingKey(null);
2204
- }
2205
- };
2206
- const handleExport = async (id) => {
2207
- const workflow = await getWorkflow(void 0, id);
2208
- if (!workflow) return;
2209
- try {
2210
- downloadWorkflowExport(workflow);
2211
- } catch (error) {
2212
- console.error("Unable to export workflow", error);
2213
- }
2214
- };
3724
+ const { exportJson, exportInFormat, exportingFormatOf } = useWorkflowListExport();
2215
3725
  const createFirst = useCreateWorkflowFirst();
2216
3726
  const createButton = /* @__PURE__ */ jsx(SdkPermissionButton, {
2217
3727
  permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE,
@@ -2258,7 +3768,7 @@ function WorkflowsList() {
2258
3768
  }), !loading && !error && /* @__PURE__ */ jsx(Badge, {
2259
3769
  variant: "secondary",
2260
3770
  className: "font-mono",
2261
- children: workflows.length
3771
+ children: Math.max(total, workflows.length)
2262
3772
  })]
2263
3773
  }),
2264
3774
  /* @__PURE__ */ jsx("p", {
@@ -2499,11 +4009,19 @@ function WorkflowsList() {
2499
4009
  name: workflow.name,
2500
4010
  description: workflow.description ?? null
2501
4011
  }),
2502
- onExport: () => void handleExport(workflow.id),
2503
- onExportAs: codeFirst ? (format) => void handleExportAs(workflow.workflowKey, workflow.version, format) : void 0,
2504
- exportingFormat: exportingKey === workflow.workflowKey ? exporting : null
4012
+ onExport: () => void exportJson(workflow.id),
4013
+ onExportAs: codeFirst ? (format) => void exportInFormat(workflow.workflowKey, workflow.version, format) : void 0,
4014
+ exportingFormat: exportingFormatOf(workflow.workflowKey)
2505
4015
  })]
2506
4016
  }, workflow.id))
4017
+ }),
4018
+ !loading && !error && /* @__PURE__ */ jsx(WorkflowsLoadMore, {
4019
+ hasMore,
4020
+ loadingMore,
4021
+ error: loadMoreError,
4022
+ shown: workflows.length,
4023
+ total,
4024
+ onLoadMore: () => void loadMore()
2507
4025
  })
2508
4026
  ]
2509
4027
  }),