@burdenoff/fluidgrids-fe-sdk 2026.1027.4 → 2026.1027.6
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.
- package/dist/{ExecutionDetailPage-3CSVGEQS.js → ExecutionDetailPage-USR2FHJG.js} +4 -4
- package/dist/{ExecutionsListPage-M67JKEW4.js → ExecutionsListPage-DXB5JW5M.js} +5 -5
- package/dist/{WorkflowBuilder-IFRXDZUI.js → WorkflowBuilder-AB4W7EDV.js} +6 -6
- package/dist/{WorkflowsList-53WA4UXO.js → WorkflowsList-UMWRE2A4.js} +6 -6
- package/dist/{chunk-B2FNI7YZ.js → chunk-2MB4S2SF.js} +5 -5
- package/dist/{chunk-72LNGKWQ.js → chunk-544OG2D2.js} +3 -3
- package/dist/{chunk-E5OMG6SN.js → chunk-6X63BRAK.js} +2 -82
- package/dist/{chunk-ROG5NACW.js → chunk-7FJRQYOB.js} +1 -1
- package/dist/{chunk-HDQZGCUY.js → chunk-BJNYCF7W.js} +21 -7
- package/dist/{chunk-IONVLVGN.js → chunk-HPGKUGAM.js} +3 -3
- package/dist/{chunk-3MLOFJW3.js → chunk-HXR6ZXEW.js} +1601 -736
- package/dist/{chunk-SCPH5T5I.js → chunk-KHBG2QSU.js} +620 -189
- package/dist/{chunk-5TRLB2QS.js → chunk-LGYV42R5.js} +1 -1
- package/dist/{chunk-SRIK33ZQ.js → chunk-M2RWCZMW.js} +1 -1
- package/dist/{chunk-UA6EZLBP.js → chunk-N6OJA6HB.js} +1 -1
- package/dist/{chunk-SPJ4WF7V.js → chunk-OCFDAYAP.js} +1 -1
- package/dist/{chunk-BAPA4FLZ.js → chunk-QYIWDYAM.js} +1 -1
- package/dist/{chunk-4JPNZ3M6.js → chunk-SNYCDFUI.js} +3 -3
- package/dist/{chunk-5RZAO2ZF.js → chunk-SUW5TEBQ.js} +4 -4
- package/dist/{chunk-JF3VJKHF.js → chunk-TGPNLCFM.js} +4 -4
- package/dist/{chunk-V7LANF6T.js → chunk-VEBGREBC.js} +1 -1
- package/dist/executions.js +6 -6
- package/dist/history.js +3 -3
- package/dist/index.d.ts +10 -4
- package/dist/index.js +25 -25
- package/dist/observability.js +3 -3
- package/dist/settings.js +3 -3
- package/dist/templates.js +5 -5
- package/dist/{workflow-builder-hl-BbuPF.d.ts → workflow-builder-C7qKY7LD.d.ts} +12 -0
- package/dist/workflow-builder.d.ts +1 -1
- package/dist/workflow-builder.js +7 -7
- package/dist/workflows-list.js +6 -6
- package/package.json +1 -1
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { deepClone, applyTemplateInputs } from './chunk-GEMNVFPK.js';
|
|
2
|
-
import { Input
|
|
2
|
+
import { Input } from './chunk-IEVSFCFS.js';
|
|
3
3
|
import { Dialog as Dialog$1, DialogContent as DialogContent$1, DialogHeader as DialogHeader$1, DialogTitle as DialogTitle$1, DialogDescription as DialogDescription$1, DialogFooter } from './chunk-YXMFRQYV.js';
|
|
4
4
|
import { Badge as Badge$1, Button } from './chunk-BQXVT32O.js';
|
|
5
|
-
import { QuotaExhaustedDialog } from './chunk-
|
|
5
|
+
import { QuotaExhaustedDialog } from './chunk-VEBGREBC.js';
|
|
6
6
|
import { EntityTagPicker } from './chunk-LON27G5P.js';
|
|
7
|
-
import { useWorkflowVersions, useRestoreWorkflowVersion, useActivateWorkflow, useDeleteWorkflow, useLazyWorkflowDefinition, useDeactivateWorkflow } from './chunk-
|
|
7
|
+
import { useWorkflowVersions, useRestoreWorkflowVersion, useActivateWorkflow, useDeleteWorkflow, useLazyWorkflowDefinition, useDeactivateWorkflow } from './chunk-LGYV42R5.js';
|
|
8
8
|
import { FluidGridsDocsLink } from './chunk-4VJ3MDOV.js';
|
|
9
|
-
import { NODE_CONFIGS, createConfiguredNode, resolveOutputHandles, resolveInputHandles, useFlowStore, getNodeDetail, resolveNodeOperation, parseParameterValue, resolveUiSpec, RUNS_QUOTA_NAME, throwIfResultError, BILLING_PLANS_PATH, emitUpgradeClicked, FluidGridsContext, emitWorkflowCreated, emitTemplateUsed, ensureNodeConfigsLoaded, registerWorkflowNodeTypes, emitNodeInstalled, useNodeExecution, onNodeTypesUpdate, NODE_TYPES, getNodeMetadata, useIsValidConnection, refetchStoreNodes, AVAILABLE_NODES, useInsertNode, NODE_TYPE_DRAG_DATA_FORMAT, NODE_OPERATION_DRAG_DATA_FORMAT,
|
|
9
|
+
import { NODE_CONFIGS, createConfiguredNode, resolveOutputHandles, resolveInputHandles, isNodeConfigsInitialized, useFlowStore, getNodeDetail, resolveNodeOperation, parseParameterValue, resolveUiSpec, RUNS_QUOTA_NAME, throwIfResultError, BILLING_PLANS_PATH, emitUpgradeClicked, FluidGridsContext, emitWorkflowCreated, emitTemplateUsed, ensureNodeConfigsLoaded, registerWorkflowNodeTypes, emitNodeInstalled, useNodeExecution, onNodeTypesUpdate, NODE_TYPES, getNodeMetadata, useIsValidConnection, refetchStoreNodes, AVAILABLE_NODES, useInsertNode, NODE_TYPE_DRAG_DATA_FORMAT, NODE_OPERATION_DRAG_DATA_FORMAT, STICKY_NOTE_TYPE, fieldsFromValue, useFluidGridsAnalytics, useSaveWorkflow, useSaveStatusStore, workflowFingerprint, buildStickyNode, fieldsFromIO, ConnectionSelector, structuredParameterType, nodeAccent, NodeTypeIcon, NODES_METADATA, useConnections, ConnectionFormDialog, SdkPermissionButton, FLUIDGRIDS_PERMISSIONS, saveIndicatorOf, inAppLeaveTarget, declaredOutputFields, subscribeWorkflowSaved, pathToExpression, ExpressionEditor, formatParameterValue, leaveNeedsConfirmation, buildOperationSeed, snapshotForSave, isNodeTrigger, editStateOf, canAutosave, isImageIcon, NODES, synchronizeOperationUpdate, NodePropertyPanel, openRunQuotaUpgradePrompt, describeOperationError, isTriggerOperation, canRenderOperationPanel, resolveOperationName, AUTOSAVE_RETRY_DELAYS_MS, AUTOSAVE_DEBOUNCE_MS } from './chunk-KHBG2QSU.js';
|
|
10
10
|
import { cn } from './chunk-JL7CASN5.js';
|
|
11
11
|
import { getGlobalStoreClient } from './chunk-PXIFUMLA.js';
|
|
12
12
|
import { getFluidGridsConfig } from './chunk-CY6KX4RG.js';
|
|
13
13
|
import { GetMyNodeInstallationsDocument, BrowseWorkflowTemplatesDocument, InstallWorkflowNodeDocument, InstallPurchasedNodeDocument, BrowseWorkflowNodesDocument, UninstallWorkflowNodeDocument, CreateStoreOrderDocument, GetNodeInstallableVersionsDocument } from './chunk-WBH2XEWO.js';
|
|
14
|
-
import { WorkspaceRunsQuotaDocument, NodeSchemaIntrospectionDocument, useWorkflowPinnedDataQuery, usePinNodeDataMutation, useUnpinNodeDataMutation, WorkflowGenerationTemplatesDocument, WorkflowGenerationDocument, GenerateWorkflowFromPromptDocument, WorkflowEnvironmentsDocument, WorkflowPromotionRequestsDocument, DeployWorkflowVersionToDevDocument, RequestWorkflowPromotionDocument, ApproveWorkflowPromotionDocument, RejectWorkflowPromotionDocument, CancelWorkflowPromotionDocument, UpdateWorkflowEnvironmentPolicyDocument, WorkflowGitRepositoryDocument, WorkflowGitPushesDocument, WorkflowGitCommitsDocument, LinkWorkflowGitRepositoryDocument, UnlinkWorkflowGitRepositoryDocument, PushWorkflowToGitDocument, WorkflowGitDiffDocument, RestoreWorkflowFromGitDocument,
|
|
14
|
+
import { WorkspaceRunsQuotaDocument, NodeSchemaIntrospectionDocument, useWorkflowPinnedDataQuery, usePinNodeDataMutation, useUnpinNodeDataMutation, useRunFromNodeEligibilityQuery, EventRegistrationsDocument, WorkflowGenerationTemplatesDocument, WorkflowGenerationDocument, GenerateWorkflowFromPromptDocument, WorkflowEnvironmentsDocument, WorkflowPromotionRequestsDocument, DeployWorkflowVersionToDevDocument, RequestWorkflowPromotionDocument, ApproveWorkflowPromotionDocument, RejectWorkflowPromotionDocument, CancelWorkflowPromotionDocument, UpdateWorkflowEnvironmentPolicyDocument, WorkflowGitRepositoryDocument, WorkflowGitPushesDocument, WorkflowGitCommitsDocument, LinkWorkflowGitRepositoryDocument, UnlinkWorkflowGitRepositoryDocument, PushWorkflowToGitDocument, WorkflowGitDiffDocument, RestoreWorkflowFromGitDocument, WebhookTestListenerDocument, StopWebhookTestListenerDocument, ListenForWebhookTestEventDocument, NodeUsageStatusDocument, RemoveNodeFromWorkflowsDocument } from './chunk-2NUE2X74.js';
|
|
15
15
|
import { useTr } from './chunk-UULVIT25.js';
|
|
16
16
|
import { getFluidGridsClient, waitForFluidGridsClient, getFluidGridsClientSafe } from './chunk-NTWG3CJX.js';
|
|
17
17
|
import { __export } from './chunk-62GWEYJ5.js';
|
|
18
18
|
import * as React3 from 'react';
|
|
19
|
-
import React3__default, { forwardRef, lazy as lazy$1, memo as memo$1, createContext, useState, useRef, useCallback, useEffect, useContext, useMemo, useLayoutEffect, Suspense,
|
|
19
|
+
import React3__default, { forwardRef, lazy as lazy$1, memo as memo$1, createContext, useState, useRef, useCallback, useEffect, useContext, useMemo, useLayoutEffect, Suspense, useId, useDeferredValue } from 'react';
|
|
20
20
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
21
21
|
import { gql } from '@apollo/client';
|
|
22
22
|
import { cn as cn$1 } from '@burdenoff/fe-libs/utils';
|
|
23
|
-
import { Card as Card$1, Badge, CardContent as CardContent$1, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Button as Button$1,
|
|
24
|
-
import { Link,
|
|
23
|
+
import { Card as Card$1, Badge, CardContent as CardContent$1, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Button as Button$1, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Popover, PopoverTrigger, PopoverContent, AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, Toaster, Tabs, TabsList, TabsTrigger, TabsContent, CardHeader as CardHeader$1, CardTitle as CardTitle$1, CardDescription as CardDescription$1, ScrollArea, Sheet, SheetTrigger, SheetContent, SheetHeader, SheetTitle, SheetDescription, Label, Textarea, AlertDialogAction, TooltipProvider, Switch, Input as Input$1, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, Tooltip, TooltipTrigger, TooltipContent, DropdownMenuLabel, DropdownMenuSeparator } from '@burdenoff/fe-libs/ui';
|
|
24
|
+
import { Link, useParams, useNavigate } from 'react-router';
|
|
25
25
|
import { useEventBus } from '@burdenoff/fe-libs/shared/events';
|
|
26
26
|
import { useQuery, useMutation } from '@apollo/client/react';
|
|
27
27
|
import { gql as gql$1 } from '@apollo/client/core';
|
|
28
28
|
import 'jszip';
|
|
29
|
-
import { Sparkles, Star, Download, Eye,
|
|
29
|
+
import { Sparkles, Star, Download, Eye, Maximize2, Undo2, Redo2, LayoutGrid, Keyboard, Plus, Trash2, GitBranch, Loader2, AlertCircle, Search, RefreshCw, History, GitCompareArrows, Play, RotateCcw, Layers, Upload, Rocket, ArrowRight, Check, X, Link2, Unlink, GitCompare, ExternalLink, GitCommitHorizontal, CircleHelp, CheckCircle2, Package, Info, Copy, BadgeCheck, DollarSign, Type, Code, Hash, List, Braces, Workflow, PlusCircle, ChevronDown, ChevronRight, AlertTriangle } from 'lucide-react';
|
|
30
30
|
import { Icon } from '@iconify/react';
|
|
31
31
|
import { toast } from 'sonner';
|
|
32
32
|
import { useShallow, shallow } from 'zustand/shallow';
|
|
33
|
-
import { Handle, Position, getBezierPath, MarkerType, ReactFlowProvider, useReactFlow, ReactFlow, Background, useOnSelectionChange, useStore, MiniMap, EdgeLabelRenderer,
|
|
33
|
+
import { Handle, Position, getBezierPath, MarkerType, ReactFlowProvider, useReactFlow, ReactFlow, Background, useOnSelectionChange, useStore, MiniMap, EdgeLabelRenderer, useNodes, getConnectedEdges, useNodesState, useEdgesState, addEdge, Controls, Panel } from '@xyflow/react';
|
|
34
34
|
import { produce } from 'immer';
|
|
35
35
|
import { isEmpty } from 'radash';
|
|
36
36
|
import ReactMarkdown from 'react-markdown';
|
|
@@ -43,9 +43,10 @@ import { buildSchema, GraphQLObjectType, GraphQLInputObjectType, GraphQLEnumType
|
|
|
43
43
|
import { create } from 'zustand';
|
|
44
44
|
import { nanoid as nanoid$1 } from 'nanoid/non-secure';
|
|
45
45
|
import { defineAgentTool, AgentToolError, useAgentTools } from '@burdenoff/fe-libs/shared/agent-tools';
|
|
46
|
-
import CodeMirror from '@uiw/react-codemirror';
|
|
46
|
+
import CodeMirror, { EditorView } from '@uiw/react-codemirror';
|
|
47
47
|
import { javascript } from '@codemirror/lang-javascript';
|
|
48
48
|
import { python } from '@codemirror/lang-python';
|
|
49
|
+
import { Button as Button$2 } from '@burdenoff/fe-libs/button';
|
|
49
50
|
import { useActorProfiles, buildActorFallback } from '@burdenoff/fe-libs/shared';
|
|
50
51
|
|
|
51
52
|
var Card = forwardRef(
|
|
@@ -431,8 +432,10 @@ var TEXT_CLASS = {
|
|
|
431
432
|
};
|
|
432
433
|
function RunsUsageMeterView({
|
|
433
434
|
quota,
|
|
434
|
-
className
|
|
435
|
+
className,
|
|
436
|
+
variant = "stacked"
|
|
435
437
|
}) {
|
|
438
|
+
const pill = variant === "pill";
|
|
436
439
|
const tr = useTr();
|
|
437
440
|
const bus = useEventBus();
|
|
438
441
|
const level = runsQuotaLevel(quota);
|
|
@@ -464,12 +467,16 @@ function RunsUsageMeterView({
|
|
|
464
467
|
{
|
|
465
468
|
"data-testid": "fluidgrids-runs-meter",
|
|
466
469
|
"data-level": level,
|
|
467
|
-
className: cn$1(
|
|
470
|
+
className: cn$1(
|
|
471
|
+
"flex items-center gap-2 text-xs",
|
|
472
|
+
pill && "rounded-full border border-card-foreground/15 px-2.5 py-1",
|
|
473
|
+
className
|
|
474
|
+
),
|
|
468
475
|
children: [
|
|
469
476
|
/* @__PURE__ */ jsxs(
|
|
470
477
|
"div",
|
|
471
478
|
{
|
|
472
|
-
className: "flex
|
|
479
|
+
className: cn$1("flex gap-1", pill ? "items-center gap-2" : "flex-col"),
|
|
473
480
|
title: label,
|
|
474
481
|
role: "meter",
|
|
475
482
|
"aria-label": label,
|
|
@@ -485,13 +492,22 @@ function RunsUsageMeterView({
|
|
|
485
492
|
limit
|
|
486
493
|
}
|
|
487
494
|
) }),
|
|
488
|
-
/* @__PURE__ */ jsx(
|
|
495
|
+
/* @__PURE__ */ jsx(
|
|
489
496
|
"span",
|
|
490
497
|
{
|
|
491
|
-
className: cn$1(
|
|
492
|
-
|
|
498
|
+
className: cn$1(
|
|
499
|
+
"block h-1 overflow-hidden rounded-full bg-muted",
|
|
500
|
+
pill ? "w-10" : "w-24"
|
|
501
|
+
),
|
|
502
|
+
children: /* @__PURE__ */ jsx(
|
|
503
|
+
"span",
|
|
504
|
+
{
|
|
505
|
+
className: cn$1("block h-full rounded-full", BAR_CLASS[level]),
|
|
506
|
+
style: { width: `${percent}%` }
|
|
507
|
+
}
|
|
508
|
+
)
|
|
493
509
|
}
|
|
494
|
-
)
|
|
510
|
+
)
|
|
495
511
|
]
|
|
496
512
|
}
|
|
497
513
|
),
|
|
@@ -512,10 +528,13 @@ function RunsUsageMeterView({
|
|
|
512
528
|
}
|
|
513
529
|
);
|
|
514
530
|
}
|
|
515
|
-
function RunsUsageMeter({
|
|
531
|
+
function RunsUsageMeter({
|
|
532
|
+
className,
|
|
533
|
+
variant
|
|
534
|
+
}) {
|
|
516
535
|
const quota = useRunsQuota();
|
|
517
536
|
if (!quota) return null;
|
|
518
|
-
return /* @__PURE__ */ jsx(RunsUsageMeterView, { quota, className });
|
|
537
|
+
return /* @__PURE__ */ jsx(RunsUsageMeterView, { quota, className, variant });
|
|
519
538
|
}
|
|
520
539
|
function useGlobalStoreClient() {
|
|
521
540
|
const context = useContext(FluidGridsContext);
|
|
@@ -21538,6 +21557,157 @@ function FluidGridsGlyph() {
|
|
|
21538
21557
|
}
|
|
21539
21558
|
);
|
|
21540
21559
|
}
|
|
21560
|
+
function findEdges(node2, connectedEdges) {
|
|
21561
|
+
const outgoingEdges = connectedEdges.filter(
|
|
21562
|
+
(edge) => edge.source === node2.id
|
|
21563
|
+
);
|
|
21564
|
+
const incomingEdges = connectedEdges.filter(
|
|
21565
|
+
(edge) => edge.target === node2.id
|
|
21566
|
+
);
|
|
21567
|
+
return { outgoingEdges, incomingEdges };
|
|
21568
|
+
}
|
|
21569
|
+
function checkFlowTerminalNode(outgoingEdges, incomingEdges, isTrigger, type) {
|
|
21570
|
+
if (isTrigger) {
|
|
21571
|
+
return outgoingEdges.length >= 1;
|
|
21572
|
+
}
|
|
21573
|
+
switch (type) {
|
|
21574
|
+
case "end" /* END */:
|
|
21575
|
+
return incomingEdges.length >= 1;
|
|
21576
|
+
default:
|
|
21577
|
+
return false;
|
|
21578
|
+
}
|
|
21579
|
+
}
|
|
21580
|
+
function checkLoneNode(outgoingEdges, incomingEdges, isTrigger) {
|
|
21581
|
+
if (isTrigger) {
|
|
21582
|
+
return outgoingEdges.length === 0;
|
|
21583
|
+
}
|
|
21584
|
+
return incomingEdges.length === 0;
|
|
21585
|
+
}
|
|
21586
|
+
function isFlowComplete(nodes, edges) {
|
|
21587
|
+
const connectedEdges = getConnectedEdges(nodes, edges);
|
|
21588
|
+
let isTriggerConnected = false;
|
|
21589
|
+
let hasTriggerNode = false;
|
|
21590
|
+
let hasEndNode = false;
|
|
21591
|
+
let isEndConnected = false;
|
|
21592
|
+
const nodesWithEmptyTarget = [];
|
|
21593
|
+
for (const node2 of nodes) {
|
|
21594
|
+
if (node2.type === STICKY_NOTE_TYPE) continue;
|
|
21595
|
+
const { outgoingEdges, incomingEdges } = findEdges(node2, connectedEdges);
|
|
21596
|
+
const isTrigger = isNodeTrigger(node2);
|
|
21597
|
+
if (isTrigger) {
|
|
21598
|
+
hasTriggerNode = true;
|
|
21599
|
+
if (checkFlowTerminalNode(
|
|
21600
|
+
outgoingEdges,
|
|
21601
|
+
incomingEdges,
|
|
21602
|
+
true,
|
|
21603
|
+
node2.type
|
|
21604
|
+
)) {
|
|
21605
|
+
isTriggerConnected = true;
|
|
21606
|
+
}
|
|
21607
|
+
} else if (node2.type === "end" /* END */) {
|
|
21608
|
+
hasEndNode = true;
|
|
21609
|
+
isEndConnected = checkFlowTerminalNode(
|
|
21610
|
+
outgoingEdges,
|
|
21611
|
+
incomingEdges,
|
|
21612
|
+
false,
|
|
21613
|
+
"end" /* END */
|
|
21614
|
+
);
|
|
21615
|
+
}
|
|
21616
|
+
if (checkLoneNode(outgoingEdges, incomingEdges, isTrigger))
|
|
21617
|
+
nodesWithEmptyTarget.push(node2);
|
|
21618
|
+
}
|
|
21619
|
+
const hasAnyLoneNode = nodesWithEmptyTarget.length > 0;
|
|
21620
|
+
const isEndValid = !hasEndNode || isEndConnected;
|
|
21621
|
+
return hasTriggerNode && isTriggerConnected && isEndValid && !hasAnyLoneNode;
|
|
21622
|
+
}
|
|
21623
|
+
function useFlowValidator(onValidate) {
|
|
21624
|
+
const [isValidating, setIsValidating] = useState(false);
|
|
21625
|
+
const { getNodes, getEdges } = useReactFlow();
|
|
21626
|
+
const validate2 = useCallback(async () => {
|
|
21627
|
+
setIsValidating(true);
|
|
21628
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
21629
|
+
onValidate?.(isFlowComplete(getNodes(), getEdges()));
|
|
21630
|
+
setIsValidating(false);
|
|
21631
|
+
}, [getNodes, getEdges, onValidate]);
|
|
21632
|
+
return [isValidating, validate2];
|
|
21633
|
+
}
|
|
21634
|
+
|
|
21635
|
+
// src/builder/lib/save-guards.ts
|
|
21636
|
+
function autosaveAllowedFor(workflow) {
|
|
21637
|
+
return useSaveStatusStore.getState().autosaveEnabled && canAutosave(workflow);
|
|
21638
|
+
}
|
|
21639
|
+
function editStateFor(state) {
|
|
21640
|
+
return editStateOf(
|
|
21641
|
+
useSaveStatusStore.getState().baseline,
|
|
21642
|
+
{
|
|
21643
|
+
fingerprint: workflowFingerprint(state.workflow),
|
|
21644
|
+
generation: state.loadGeneration,
|
|
21645
|
+
editRevision: state.editRevision
|
|
21646
|
+
},
|
|
21647
|
+
Date.now()
|
|
21648
|
+
);
|
|
21649
|
+
}
|
|
21650
|
+
function departingSave(state) {
|
|
21651
|
+
const status = useSaveStatusStore.getState();
|
|
21652
|
+
if (status.autosavePaused) return null;
|
|
21653
|
+
if (editStateFor(state) !== "dirty") return null;
|
|
21654
|
+
if (!autosaveAllowedFor(state.workflow)) return null;
|
|
21655
|
+
const { nodes, edges } = state.workflow;
|
|
21656
|
+
if (!isFlowComplete(nodes, edges)) return null;
|
|
21657
|
+
return snapshotForSave(state.workflow, state.loadGeneration);
|
|
21658
|
+
}
|
|
21659
|
+
function leavingLosesChanges() {
|
|
21660
|
+
const flow = useFlowStore.getState();
|
|
21661
|
+
const status = useSaveStatusStore.getState();
|
|
21662
|
+
return leaveNeedsConfirmation({
|
|
21663
|
+
// Checked fresh: the dirty flag trails the last edit by a moment.
|
|
21664
|
+
dirty: status.dirty || editStateFor(flow) === "dirty",
|
|
21665
|
+
autosaveAllowed: autosaveAllowedFor(flow.workflow),
|
|
21666
|
+
incomplete: status.incomplete || !isFlowComplete(flow.workflow.nodes, flow.workflow.edges),
|
|
21667
|
+
failed: status.failure !== null
|
|
21668
|
+
});
|
|
21669
|
+
}
|
|
21670
|
+
function savedEverythingBeforeLeaving() {
|
|
21671
|
+
return editStateFor(useFlowStore.getState()) !== "dirty";
|
|
21672
|
+
}
|
|
21673
|
+
|
|
21674
|
+
// src/builder/hooks/use-builder-save.ts
|
|
21675
|
+
function useManualSave() {
|
|
21676
|
+
const tr = useTr();
|
|
21677
|
+
const { saveToBackend } = useSaveWorkflow();
|
|
21678
|
+
return useCallback(async () => {
|
|
21679
|
+
const { nodes, edges } = useFlowStore.getState().workflow;
|
|
21680
|
+
if (!isFlowComplete(nodes, edges)) {
|
|
21681
|
+
toast.error(
|
|
21682
|
+
tr(
|
|
21683
|
+
"fluidgrids.builder.saveFlowButton.invalidToastTitle",
|
|
21684
|
+
"Flow is invalid"
|
|
21685
|
+
),
|
|
21686
|
+
{
|
|
21687
|
+
description: tr(
|
|
21688
|
+
"fluidgrids.builder.saveFlowButton.invalidToastDescription",
|
|
21689
|
+
"Please check if the flow is complete and has no lone nodes"
|
|
21690
|
+
)
|
|
21691
|
+
}
|
|
21692
|
+
);
|
|
21693
|
+
return false;
|
|
21694
|
+
}
|
|
21695
|
+
return saveToBackend();
|
|
21696
|
+
}, [saveToBackend, tr]);
|
|
21697
|
+
}
|
|
21698
|
+
function useGuardedNavigate() {
|
|
21699
|
+
const navigate = useNavigate();
|
|
21700
|
+
return useCallback(
|
|
21701
|
+
(to, options) => {
|
|
21702
|
+
if (leavingLosesChanges()) {
|
|
21703
|
+
useSaveStatusStore.getState().actions.requestLeave({ to, options });
|
|
21704
|
+
return;
|
|
21705
|
+
}
|
|
21706
|
+
navigate(to, options);
|
|
21707
|
+
},
|
|
21708
|
+
[navigate]
|
|
21709
|
+
);
|
|
21710
|
+
}
|
|
21541
21711
|
function useNodeList(nodes) {
|
|
21542
21712
|
return useMemo(() => {
|
|
21543
21713
|
return nodes.slice().sort((a, b) => {
|
|
@@ -22165,7 +22335,7 @@ function ChannelAuth({
|
|
|
22165
22335
|
) }),
|
|
22166
22336
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
22167
22337
|
/* @__PURE__ */ jsx(
|
|
22168
|
-
Input,
|
|
22338
|
+
Input$1,
|
|
22169
22339
|
{
|
|
22170
22340
|
type: "text",
|
|
22171
22341
|
placeholder: tr(
|
|
@@ -22946,7 +23116,7 @@ function StoreCategoryList({
|
|
|
22946
23116
|
}
|
|
22947
23117
|
),
|
|
22948
23118
|
/* @__PURE__ */ jsx(
|
|
22949
|
-
Input
|
|
23119
|
+
Input,
|
|
22950
23120
|
{
|
|
22951
23121
|
ref: searchRef,
|
|
22952
23122
|
value: searchTerm,
|
|
@@ -23220,7 +23390,7 @@ function StoreCategoryNodes({
|
|
|
23220
23390
|
}
|
|
23221
23391
|
),
|
|
23222
23392
|
/* @__PURE__ */ jsx(
|
|
23223
|
-
Input
|
|
23393
|
+
Input,
|
|
23224
23394
|
{
|
|
23225
23395
|
value: searchTerm,
|
|
23226
23396
|
onChange: (e) => setSearchTerm(e.target.value),
|
|
@@ -24474,7 +24644,7 @@ function TemplatesModal({
|
|
|
24474
24644
|
/* @__PURE__ */ jsx("div", { className: "pt-4", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
24475
24645
|
/* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" }),
|
|
24476
24646
|
/* @__PURE__ */ jsx(
|
|
24477
|
-
Input
|
|
24647
|
+
Input,
|
|
24478
24648
|
{
|
|
24479
24649
|
placeholder: tr(
|
|
24480
24650
|
"fluidgrids.builder.templatesModal.searchPlaceholder",
|
|
@@ -24586,7 +24756,7 @@ function DesktopSidebarFragment({
|
|
|
24586
24756
|
const [configNodeCheck, setConfigNodeCheck] = useState(null);
|
|
24587
24757
|
const [importing, setImporting] = useState(false);
|
|
24588
24758
|
const [installProgress, setInstallProgress] = useState(null);
|
|
24589
|
-
const navigate =
|
|
24759
|
+
const navigate = useGuardedNavigate();
|
|
24590
24760
|
const { installedAppIds } = useInstalledNodes();
|
|
24591
24761
|
const buildNodeCheck2 = useCallback(
|
|
24592
24762
|
(content) => {
|
|
@@ -26164,8 +26334,8 @@ var reducer = (state, action) => {
|
|
|
26164
26334
|
if (toastId) {
|
|
26165
26335
|
addToRemoveQueue(toastId);
|
|
26166
26336
|
} else {
|
|
26167
|
-
state.toasts.forEach((
|
|
26168
|
-
addToRemoveQueue(
|
|
26337
|
+
state.toasts.forEach((toast15) => {
|
|
26338
|
+
addToRemoveQueue(toast15.id);
|
|
26169
26339
|
});
|
|
26170
26340
|
}
|
|
26171
26341
|
return {
|
|
@@ -26199,7 +26369,7 @@ function dispatch(action) {
|
|
|
26199
26369
|
listener(memoryState);
|
|
26200
26370
|
});
|
|
26201
26371
|
}
|
|
26202
|
-
function
|
|
26372
|
+
function toast4({ ...props }) {
|
|
26203
26373
|
const id = genId();
|
|
26204
26374
|
const update = (props2) => dispatch({
|
|
26205
26375
|
type: actionTypes.UPDATE_TOAST,
|
|
@@ -26236,7 +26406,7 @@ function useToast() {
|
|
|
26236
26406
|
}, [state]);
|
|
26237
26407
|
return {
|
|
26238
26408
|
...state,
|
|
26239
|
-
toast:
|
|
26409
|
+
toast: toast4,
|
|
26240
26410
|
dismiss: (toastId) => dispatch({ type: actionTypes.DISMISS_TOAST, toastId })
|
|
26241
26411
|
};
|
|
26242
26412
|
}
|
|
@@ -26763,7 +26933,7 @@ function MappingDialogContent({
|
|
|
26763
26933
|
"Or enter a custom field name:"
|
|
26764
26934
|
) }),
|
|
26765
26935
|
/* @__PURE__ */ jsx(
|
|
26766
|
-
Input,
|
|
26936
|
+
Input$1,
|
|
26767
26937
|
{
|
|
26768
26938
|
id: "target-field-name",
|
|
26769
26939
|
placeholder: tr(
|
|
@@ -26776,7 +26946,7 @@ function MappingDialogContent({
|
|
|
26776
26946
|
}
|
|
26777
26947
|
)
|
|
26778
26948
|
] }) : /* @__PURE__ */ jsx(
|
|
26779
|
-
Input,
|
|
26949
|
+
Input$1,
|
|
26780
26950
|
{
|
|
26781
26951
|
id: "target-field-name",
|
|
26782
26952
|
placeholder: tr(
|
|
@@ -26840,7 +27010,7 @@ function MappingDialogContent({
|
|
|
26840
27010
|
"No array fields found in schema. Enter the array path manually:"
|
|
26841
27011
|
) }),
|
|
26842
27012
|
/* @__PURE__ */ jsx(
|
|
26843
|
-
Input,
|
|
27013
|
+
Input$1,
|
|
26844
27014
|
{
|
|
26845
27015
|
placeholder: tr(
|
|
26846
27016
|
"fluidgrids.builder.mappingDialog.arrayPathPlaceholder",
|
|
@@ -26881,7 +27051,7 @@ function MappingDialogContent({
|
|
|
26881
27051
|
"Click a field above or enter a custom path:"
|
|
26882
27052
|
) }),
|
|
26883
27053
|
/* @__PURE__ */ jsx(
|
|
26884
|
-
Input,
|
|
27054
|
+
Input$1,
|
|
26885
27055
|
{
|
|
26886
27056
|
placeholder: tr(
|
|
26887
27057
|
"fluidgrids.builder.mappingDialog.itemPropertyPlaceholder",
|
|
@@ -26893,7 +27063,7 @@ function MappingDialogContent({
|
|
|
26893
27063
|
}
|
|
26894
27064
|
)
|
|
26895
27065
|
] }) : /* @__PURE__ */ jsx(
|
|
26896
|
-
Input,
|
|
27066
|
+
Input$1,
|
|
26897
27067
|
{
|
|
26898
27068
|
placeholder: tr(
|
|
26899
27069
|
"fluidgrids.builder.mappingDialog.itemPropertyPlaceholderShort",
|
|
@@ -27541,7 +27711,7 @@ function VisualMapperContent({
|
|
|
27541
27711
|
mapping,
|
|
27542
27712
|
onMappingChange
|
|
27543
27713
|
}) {
|
|
27544
|
-
const { toast:
|
|
27714
|
+
const { toast: toast15 } = useToast();
|
|
27545
27715
|
const tr = useTr();
|
|
27546
27716
|
const reactFlowWrapper = useRef(null);
|
|
27547
27717
|
const [selectedSourceNode, setSelectedSourceNode] = useState(null);
|
|
@@ -27561,7 +27731,7 @@ function VisualMapperContent({
|
|
|
27561
27731
|
targetOperation
|
|
27562
27732
|
);
|
|
27563
27733
|
if (generatedNodes.length === 0) {
|
|
27564
|
-
|
|
27734
|
+
toast15({
|
|
27565
27735
|
title: tr(
|
|
27566
27736
|
"fluidgrids.builder.visualMapper.noFieldsFoundTitle",
|
|
27567
27737
|
"No fields found"
|
|
@@ -27587,7 +27757,7 @@ function VisualMapperContent({
|
|
|
27587
27757
|
targetNode,
|
|
27588
27758
|
targetOperation,
|
|
27589
27759
|
setNodes,
|
|
27590
|
-
|
|
27760
|
+
toast15,
|
|
27591
27761
|
tr
|
|
27592
27762
|
]);
|
|
27593
27763
|
useEffect(() => {
|
|
@@ -27694,7 +27864,7 @@ function VisualMapperContent({
|
|
|
27694
27864
|
}
|
|
27695
27865
|
onMappingChange(updatedMapping);
|
|
27696
27866
|
if (isCompatible) {
|
|
27697
|
-
|
|
27867
|
+
toast15({
|
|
27698
27868
|
title: tr(
|
|
27699
27869
|
"fluidgrids.builder.visualMapper.mappingCreatedTitle",
|
|
27700
27870
|
"Mapping created"
|
|
@@ -27702,7 +27872,7 @@ function VisualMapperContent({
|
|
|
27702
27872
|
description: `Mapped ${sourcePath} (${sourceType}) to ${targetPath} (${targetType})`
|
|
27703
27873
|
});
|
|
27704
27874
|
} else {
|
|
27705
|
-
|
|
27875
|
+
toast15({
|
|
27706
27876
|
title: tr(
|
|
27707
27877
|
"fluidgrids.builder.visualMapper.typeMismatchTitle",
|
|
27708
27878
|
"Type mismatch warning"
|
|
@@ -27712,7 +27882,7 @@ function VisualMapperContent({
|
|
|
27712
27882
|
});
|
|
27713
27883
|
}
|
|
27714
27884
|
} else {
|
|
27715
|
-
|
|
27885
|
+
toast15({
|
|
27716
27886
|
title: tr(
|
|
27717
27887
|
"fluidgrids.builder.visualMapper.invalidMappingTitle",
|
|
27718
27888
|
"Invalid mapping"
|
|
@@ -27725,7 +27895,7 @@ function VisualMapperContent({
|
|
|
27725
27895
|
});
|
|
27726
27896
|
}
|
|
27727
27897
|
},
|
|
27728
|
-
[nodes, mapping, onMappingChange,
|
|
27898
|
+
[nodes, mapping, onMappingChange, toast15, tr, setEdges]
|
|
27729
27899
|
);
|
|
27730
27900
|
const onEdgeDelete = useCallback(
|
|
27731
27901
|
(edge) => {
|
|
@@ -27782,7 +27952,7 @@ function VisualMapperContent({
|
|
|
27782
27952
|
const handleSaveMappingDialog = (expression, targetFieldName) => {
|
|
27783
27953
|
const targetPath = targetFieldName || selectedTargetNode?.data?.path;
|
|
27784
27954
|
if (!targetPath) {
|
|
27785
|
-
|
|
27955
|
+
toast15({
|
|
27786
27956
|
title: tr(
|
|
27787
27957
|
"fluidgrids.builder.visualMapper.noTargetFieldTitle",
|
|
27788
27958
|
"No target field specified"
|
|
@@ -27814,7 +27984,7 @@ function VisualMapperContent({
|
|
|
27814
27984
|
}
|
|
27815
27985
|
onMappingChange(updatedMapping);
|
|
27816
27986
|
const mappingType = detectMappingType(expression);
|
|
27817
|
-
|
|
27987
|
+
toast15({
|
|
27818
27988
|
title: `${mappingType.charAt(0).toUpperCase() + mappingType.slice(1)} mapping created`,
|
|
27819
27989
|
description: `${tr("fluidgrids.builder.visualMapper.appliedMappingTo", "Applied mapping to")} ${targetPath}`
|
|
27820
27990
|
});
|
|
@@ -28113,7 +28283,7 @@ function MappingEditor({
|
|
|
28113
28283
|
setEdges,
|
|
28114
28284
|
edgeId
|
|
28115
28285
|
}) {
|
|
28116
|
-
const { toast:
|
|
28286
|
+
const { toast: toast15 } = useToast();
|
|
28117
28287
|
const tr = useTr();
|
|
28118
28288
|
const [mappingJson, setMappingJson] = useState({});
|
|
28119
28289
|
const [jsonDataString, setJsonDataString] = useState(
|
|
@@ -28237,7 +28407,7 @@ function MappingEditor({
|
|
|
28237
28407
|
const handleSaveMapping = () => {
|
|
28238
28408
|
try {
|
|
28239
28409
|
checkJsonValidity();
|
|
28240
|
-
|
|
28410
|
+
toast15({
|
|
28241
28411
|
title: tr(
|
|
28242
28412
|
"fluidgrids.builder.mappingEditor.mappingSavedTitle",
|
|
28243
28413
|
"Mapping saved"
|
|
@@ -28248,7 +28418,7 @@ function MappingEditor({
|
|
|
28248
28418
|
)
|
|
28249
28419
|
});
|
|
28250
28420
|
} catch (error62) {
|
|
28251
|
-
|
|
28421
|
+
toast15({
|
|
28252
28422
|
title: tr(
|
|
28253
28423
|
"fluidgrids.builder.mappingEditor.errorSavingTitle",
|
|
28254
28424
|
"Error saving mapping"
|
|
@@ -28267,7 +28437,7 @@ function MappingEditor({
|
|
|
28267
28437
|
const parsedData = checkJsonValidity();
|
|
28268
28438
|
const result = await applyMapping(parsedData, sampleInput);
|
|
28269
28439
|
setPreviewOutput(result);
|
|
28270
|
-
|
|
28440
|
+
toast15({
|
|
28271
28441
|
title: tr(
|
|
28272
28442
|
"fluidgrids.builder.mappingEditor.mappingTestedTitle",
|
|
28273
28443
|
"Mapping tested"
|
|
@@ -28279,7 +28449,7 @@ function MappingEditor({
|
|
|
28279
28449
|
});
|
|
28280
28450
|
} catch (error62) {
|
|
28281
28451
|
console.error("Test mapping error:", error62);
|
|
28282
|
-
|
|
28452
|
+
toast15({
|
|
28283
28453
|
title: tr(
|
|
28284
28454
|
"fluidgrids.builder.mappingEditor.mappingTestFailedTitle",
|
|
28285
28455
|
"Mapping test failed"
|
|
@@ -29731,7 +29901,7 @@ var ConditionNodeDisplay = ({
|
|
|
29731
29901
|
case "number":
|
|
29732
29902
|
case "integer":
|
|
29733
29903
|
return /* @__PURE__ */ jsx(
|
|
29734
|
-
Input,
|
|
29904
|
+
Input$1,
|
|
29735
29905
|
{
|
|
29736
29906
|
type: "number",
|
|
29737
29907
|
placeholder: tr(
|
|
@@ -29753,7 +29923,7 @@ var ConditionNodeDisplay = ({
|
|
|
29753
29923
|
case "string":
|
|
29754
29924
|
default:
|
|
29755
29925
|
return /* @__PURE__ */ jsx(
|
|
29756
|
-
Input,
|
|
29926
|
+
Input$1,
|
|
29757
29927
|
{
|
|
29758
29928
|
type: "text",
|
|
29759
29929
|
placeholder: tr(
|
|
@@ -32211,6 +32381,12 @@ function computeMinimapRect(panelRect, bounds, margin) {
|
|
|
32211
32381
|
return { left, top };
|
|
32212
32382
|
}
|
|
32213
32383
|
var SHORTCUT_ROWS = [
|
|
32384
|
+
{
|
|
32385
|
+
labelKey: "fluidgrids.builder.shortcutsHelp.save",
|
|
32386
|
+
labelDefault: "Save workflow",
|
|
32387
|
+
mac: "\u2318S",
|
|
32388
|
+
other: "Ctrl+S"
|
|
32389
|
+
},
|
|
32214
32390
|
{
|
|
32215
32391
|
labelKey: "fluidgrids.builder.shortcutsHelp.undo",
|
|
32216
32392
|
labelDefault: "Undo",
|
|
@@ -32298,7 +32474,7 @@ function ShortcutsHelpPanel({
|
|
|
32298
32474
|
onOpenChange
|
|
32299
32475
|
}) {
|
|
32300
32476
|
const tr = useTr();
|
|
32301
|
-
const
|
|
32477
|
+
const isMac2 = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform ?? "");
|
|
32302
32478
|
return /* @__PURE__ */ jsx(Dialog$1, { open: open2, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent$1, { className: "max-w-lg", children: [
|
|
32303
32479
|
/* @__PURE__ */ jsxs(DialogHeader$1, { children: [
|
|
32304
32480
|
/* @__PURE__ */ jsx(DialogTitle$1, { children: tr("fluidgrids.builder.shortcutsHelp.title", "Keyboard shortcuts") }),
|
|
@@ -32313,7 +32489,7 @@ function ShortcutsHelpPanel({
|
|
|
32313
32489
|
className: "flex items-center justify-between gap-4 rounded-md px-2 py-1.5 text-sm hover:bg-muted/50",
|
|
32314
32490
|
children: [
|
|
32315
32491
|
/* @__PURE__ */ jsx("span", { className: "text-foreground/80", children: tr(row.labelKey, row.labelDefault) }),
|
|
32316
|
-
/* @__PURE__ */ jsx(Kbd, { children:
|
|
32492
|
+
/* @__PURE__ */ jsx(Kbd, { children: isMac2 ? row.mac : row.other })
|
|
32317
32493
|
]
|
|
32318
32494
|
},
|
|
32319
32495
|
row.labelKey
|
|
@@ -32992,6 +33168,50 @@ function AddNodeFloatingMenu({
|
|
|
32992
33168
|
] });
|
|
32993
33169
|
}
|
|
32994
33170
|
|
|
33171
|
+
// src/builder/components/ndv/field-label.ts
|
|
33172
|
+
var UPPERCASE_WORDS = /* @__PURE__ */ new Set([
|
|
33173
|
+
"api",
|
|
33174
|
+
"csv",
|
|
33175
|
+
"html",
|
|
33176
|
+
"http",
|
|
33177
|
+
"https",
|
|
33178
|
+
"id",
|
|
33179
|
+
"ip",
|
|
33180
|
+
"json",
|
|
33181
|
+
"jwt",
|
|
33182
|
+
"sql",
|
|
33183
|
+
"ssl",
|
|
33184
|
+
"url",
|
|
33185
|
+
"uri",
|
|
33186
|
+
"utc",
|
|
33187
|
+
"xml"
|
|
33188
|
+
]);
|
|
33189
|
+
var PLURAL_ACRONYMS = /* @__PURE__ */ new Map([
|
|
33190
|
+
["apis", "APIs"],
|
|
33191
|
+
["ids", "IDs"],
|
|
33192
|
+
["ips", "IPs"],
|
|
33193
|
+
["uris", "URIs"],
|
|
33194
|
+
["urls", "URLs"]
|
|
33195
|
+
]);
|
|
33196
|
+
function titleWord(word) {
|
|
33197
|
+
const lower = word.toLowerCase();
|
|
33198
|
+
const plural2 = PLURAL_ACRONYMS.get(lower);
|
|
33199
|
+
if (plural2) return plural2;
|
|
33200
|
+
if (UPPERCASE_WORDS.has(lower)) return lower.toUpperCase();
|
|
33201
|
+
return lower.charAt(0).toUpperCase() + lower.slice(1);
|
|
33202
|
+
}
|
|
33203
|
+
function humanizeFieldName(name) {
|
|
33204
|
+
const words = name.split(".").pop().replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s_-]+/).filter(Boolean);
|
|
33205
|
+
return words.length > 0 ? words.map(titleWord).join(" ") : name;
|
|
33206
|
+
}
|
|
33207
|
+
function fieldLabel(name, spec) {
|
|
33208
|
+
for (const key of ["label", "displayName", "title"]) {
|
|
33209
|
+
const value = spec?.[key];
|
|
33210
|
+
if (typeof value === "string" && value.trim() !== "") return value.trim();
|
|
33211
|
+
}
|
|
33212
|
+
return humanizeFieldName(name);
|
|
33213
|
+
}
|
|
33214
|
+
|
|
32995
33215
|
// src/builder/lib/mapping-input.ts
|
|
32996
33216
|
function latestNodeLog(logs, nodeId2, runId) {
|
|
32997
33217
|
return nodeId2 && runId ? logs.filter((log) => log.nodeId === nodeId2 && log.runId === runId).at(-1) : void 0;
|
|
@@ -33857,6 +34077,33 @@ function fallbackOperations(type) {
|
|
|
33857
34077
|
function selectedOperationOf(data, type) {
|
|
33858
34078
|
return resolveNodeOperation(data, fallbackOperations(type)).selected;
|
|
33859
34079
|
}
|
|
34080
|
+
function readOptionLabels(map2, options) {
|
|
34081
|
+
const labels = /* @__PURE__ */ Object.create(null);
|
|
34082
|
+
for (const [value, text] of Object.entries(asRecord(map2) ?? {})) {
|
|
34083
|
+
if (typeof text === "string" && text.trim() !== "") labels[value] = text;
|
|
34084
|
+
}
|
|
34085
|
+
if (Array.isArray(options)) {
|
|
34086
|
+
for (const option of options) {
|
|
34087
|
+
const rec = asRecord(option);
|
|
34088
|
+
const value = rec?.value ?? rec?.name;
|
|
34089
|
+
const text = [
|
|
34090
|
+
rec?.title,
|
|
34091
|
+
rec?.label,
|
|
34092
|
+
rec?.value !== void 0 ? rec?.name : void 0
|
|
34093
|
+
].find(
|
|
34094
|
+
(candidate) => typeof candidate === "string" && candidate.trim() !== ""
|
|
34095
|
+
);
|
|
34096
|
+
if (typeof value === "string" && typeof text === "string" && text !== value) {
|
|
34097
|
+
if (!Object.hasOwn(labels, value)) labels[value] = text;
|
|
34098
|
+
}
|
|
34099
|
+
}
|
|
34100
|
+
}
|
|
34101
|
+
return Object.keys(labels).length > 0 ? labels : void 0;
|
|
34102
|
+
}
|
|
34103
|
+
function optionText(param, value) {
|
|
34104
|
+
const labels = param.optionLabels;
|
|
34105
|
+
return labels && Object.hasOwn(labels, value) ? labels[value] : value;
|
|
34106
|
+
}
|
|
33860
34107
|
function paramsFromOperation(op) {
|
|
33861
34108
|
const io = asRecord(op?.input_fields);
|
|
33862
34109
|
if (!io) return [];
|
|
@@ -33868,8 +34115,12 @@ function paramsFromOperation(op) {
|
|
|
33868
34115
|
(o) => typeof o === "string" ? o : asRecord(o)?.value ?? asRecord(o)?.name
|
|
33869
34116
|
).filter((v) => typeof v === "string") : void 0;
|
|
33870
34117
|
const loadOptions = readLoadOptionsSpec(rec?.loadOptions);
|
|
34118
|
+
const optionLabels = readOptionLabels(rec?.optionLabels, optsRaw);
|
|
33871
34119
|
return {
|
|
33872
34120
|
name,
|
|
34121
|
+
label: fieldLabel(name, rec),
|
|
34122
|
+
placeholder: typeof rec?.placeholder === "string" && rec.placeholder.trim() !== "" ? rec.placeholder : void 0,
|
|
34123
|
+
...optionLabels ? { optionLabels } : {},
|
|
33873
34124
|
type: typeof spec === "string" ? spec : typeof rec?.type === "string" ? rec.type : "any",
|
|
33874
34125
|
required: rec?.required === true,
|
|
33875
34126
|
description: typeof rec?.description === "string" ? rec.description : void 0,
|
|
@@ -34228,6 +34479,15 @@ function findNode(id) {
|
|
|
34228
34479
|
);
|
|
34229
34480
|
return node2;
|
|
34230
34481
|
}
|
|
34482
|
+
var defaultCatalogueReady = () => isNodeConfigsInitialized() && NODE_CONFIGS.length > 0;
|
|
34483
|
+
function requireCatalogue(ready) {
|
|
34484
|
+
if (!ready())
|
|
34485
|
+
throw new AgentToolError(
|
|
34486
|
+
"CONFLICT",
|
|
34487
|
+
"The node catalogue is still loading. Try again in a few seconds.",
|
|
34488
|
+
{ retryable: true }
|
|
34489
|
+
);
|
|
34490
|
+
}
|
|
34231
34491
|
function dataOf(node2) {
|
|
34232
34492
|
return node2.data && typeof node2.data === "object" ? node2.data : {};
|
|
34233
34493
|
}
|
|
@@ -34242,7 +34502,8 @@ function freePosition(nodes) {
|
|
|
34242
34502
|
);
|
|
34243
34503
|
return { x: rightMost.position.x + POSITION_GAP_X, y: rightMost.position.y };
|
|
34244
34504
|
}
|
|
34245
|
-
function createBuilderAgentTools() {
|
|
34505
|
+
function createBuilderAgentTools(options = {}) {
|
|
34506
|
+
const catalogueReady = options.catalogueReady ?? defaultCatalogueReady;
|
|
34246
34507
|
const read = defineAgentTool({
|
|
34247
34508
|
name: "fg_canvas_read",
|
|
34248
34509
|
title: "Read the canvas",
|
|
@@ -34292,6 +34553,7 @@ function createBuilderAgentTools() {
|
|
|
34292
34553
|
}),
|
|
34293
34554
|
annotations: { readOnly: true },
|
|
34294
34555
|
execute: ({ query }) => {
|
|
34556
|
+
requireCatalogue(catalogueReady);
|
|
34295
34557
|
const words = query.toLowerCase().split(/\s+/);
|
|
34296
34558
|
const matches = NODE_CONFIGS.filter((config2) => {
|
|
34297
34559
|
const text = `${config2.type} ${config2.detail.title} ${config2.detail.description ?? ""}`.toLowerCase();
|
|
@@ -34317,6 +34579,7 @@ function createBuilderAgentTools() {
|
|
|
34317
34579
|
afterNodeId: nodeId.optional().describe("Place the new node after this node and connect it.")
|
|
34318
34580
|
}),
|
|
34319
34581
|
execute: ({ nodeType, operation, afterNodeId }) => {
|
|
34582
|
+
requireCatalogue(catalogueReady);
|
|
34320
34583
|
if (!NODE_CONFIGS.some((config2) => config2.type === nodeType))
|
|
34321
34584
|
throw new AgentToolError(
|
|
34322
34585
|
"NOT_FOUND",
|
|
@@ -34511,387 +34774,6 @@ function createBuilderAgentTools() {
|
|
|
34511
34774
|
return [read, nodeTypes3, addNode, connect, rename, toggle, setParam];
|
|
34512
34775
|
}
|
|
34513
34776
|
var BUILDER_AGENT_TOOLS = createBuilderAgentTools();
|
|
34514
|
-
function findEdges(node2, connectedEdges) {
|
|
34515
|
-
const outgoingEdges = connectedEdges.filter(
|
|
34516
|
-
(edge) => edge.source === node2.id
|
|
34517
|
-
);
|
|
34518
|
-
const incomingEdges = connectedEdges.filter(
|
|
34519
|
-
(edge) => edge.target === node2.id
|
|
34520
|
-
);
|
|
34521
|
-
return { outgoingEdges, incomingEdges };
|
|
34522
|
-
}
|
|
34523
|
-
function checkFlowTerminalNode(outgoingEdges, incomingEdges, isTrigger, type) {
|
|
34524
|
-
if (isTrigger) {
|
|
34525
|
-
return outgoingEdges.length >= 1;
|
|
34526
|
-
}
|
|
34527
|
-
switch (type) {
|
|
34528
|
-
case "end" /* END */:
|
|
34529
|
-
return incomingEdges.length >= 1;
|
|
34530
|
-
default:
|
|
34531
|
-
return false;
|
|
34532
|
-
}
|
|
34533
|
-
}
|
|
34534
|
-
function checkLoneNode(outgoingEdges, incomingEdges, isTrigger) {
|
|
34535
|
-
if (isTrigger) {
|
|
34536
|
-
return outgoingEdges.length === 0;
|
|
34537
|
-
}
|
|
34538
|
-
return incomingEdges.length === 0;
|
|
34539
|
-
}
|
|
34540
|
-
function useFlowValidator(onValidate) {
|
|
34541
|
-
const [isValidating, setIsValidating] = useState(false);
|
|
34542
|
-
const { getNodes, getEdges } = useReactFlow();
|
|
34543
|
-
const validate2 = useCallback(async () => {
|
|
34544
|
-
setIsValidating(true);
|
|
34545
|
-
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
34546
|
-
const nodes = getNodes();
|
|
34547
|
-
const edges = getEdges();
|
|
34548
|
-
const connectedEdges = getConnectedEdges(nodes, edges);
|
|
34549
|
-
let isTriggerConnected = false;
|
|
34550
|
-
let hasTriggerNode = false;
|
|
34551
|
-
let hasEndNode = false;
|
|
34552
|
-
let isEndConnected = false;
|
|
34553
|
-
const nodesWithEmptyTarget = [];
|
|
34554
|
-
for (const node2 of nodes) {
|
|
34555
|
-
if (node2.type === STICKY_NOTE_TYPE) continue;
|
|
34556
|
-
const { outgoingEdges, incomingEdges } = findEdges(node2, connectedEdges);
|
|
34557
|
-
const isTrigger = isNodeTrigger(node2);
|
|
34558
|
-
if (isTrigger) {
|
|
34559
|
-
hasTriggerNode = true;
|
|
34560
|
-
if (checkFlowTerminalNode(
|
|
34561
|
-
outgoingEdges,
|
|
34562
|
-
incomingEdges,
|
|
34563
|
-
true,
|
|
34564
|
-
node2.type
|
|
34565
|
-
)) {
|
|
34566
|
-
isTriggerConnected = true;
|
|
34567
|
-
}
|
|
34568
|
-
} else if (node2.type === "end" /* END */) {
|
|
34569
|
-
hasEndNode = true;
|
|
34570
|
-
isEndConnected = checkFlowTerminalNode(
|
|
34571
|
-
outgoingEdges,
|
|
34572
|
-
incomingEdges,
|
|
34573
|
-
false,
|
|
34574
|
-
"end" /* END */
|
|
34575
|
-
);
|
|
34576
|
-
}
|
|
34577
|
-
if (checkLoneNode(outgoingEdges, incomingEdges, isTrigger))
|
|
34578
|
-
nodesWithEmptyTarget.push(node2);
|
|
34579
|
-
}
|
|
34580
|
-
const hasAnyLoneNode = nodesWithEmptyTarget.length > 0;
|
|
34581
|
-
const isEndValid = !hasEndNode || isEndConnected;
|
|
34582
|
-
const isFlowComplete = hasTriggerNode && isTriggerConnected && isEndValid && !hasAnyLoneNode;
|
|
34583
|
-
onValidate?.(isFlowComplete);
|
|
34584
|
-
setIsValidating(false);
|
|
34585
|
-
}, [getNodes, getEdges, onValidate]);
|
|
34586
|
-
return [isValidating, validate2];
|
|
34587
|
-
}
|
|
34588
|
-
var SaveFlowButton = ({ className }) => {
|
|
34589
|
-
const tr = useTr();
|
|
34590
|
-
const navigate = useNavigate();
|
|
34591
|
-
const { saveToBackend, isSaving, quotaExhausted, dismissQuotaExhausted } = useSaveWorkflow();
|
|
34592
|
-
const [isValidating, validateFlow] = useFlowValidator(async (isValid) => {
|
|
34593
|
-
if (isValid) {
|
|
34594
|
-
await saveToBackend();
|
|
34595
|
-
} else {
|
|
34596
|
-
toast.error(
|
|
34597
|
-
tr(
|
|
34598
|
-
"fluidgrids.builder.saveFlowButton.invalidToastTitle",
|
|
34599
|
-
"Flow is invalid"
|
|
34600
|
-
),
|
|
34601
|
-
{
|
|
34602
|
-
description: tr(
|
|
34603
|
-
"fluidgrids.builder.saveFlowButton.invalidToastDescription",
|
|
34604
|
-
"Please check if the flow is complete and has no lone nodes"
|
|
34605
|
-
)
|
|
34606
|
-
}
|
|
34607
|
-
);
|
|
34608
|
-
}
|
|
34609
|
-
});
|
|
34610
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
34611
|
-
/* @__PURE__ */ jsx(
|
|
34612
|
-
SdkPermissionButton,
|
|
34613
|
-
{
|
|
34614
|
-
permission: [
|
|
34615
|
-
FLUIDGRIDS_PERMISSIONS.WORKFLOW_UPDATE,
|
|
34616
|
-
FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE
|
|
34617
|
-
],
|
|
34618
|
-
deniedTooltip: tr(
|
|
34619
|
-
"fluidgrids.builder.saveFlowButton.permissionDeniedTooltip",
|
|
34620
|
-
"You don't have permission to save workflows"
|
|
34621
|
-
),
|
|
34622
|
-
children: /* @__PURE__ */ jsxs(
|
|
34623
|
-
Button$1,
|
|
34624
|
-
{
|
|
34625
|
-
"data-tour": "fluidgrids-builder-save",
|
|
34626
|
-
onClick: validateFlow,
|
|
34627
|
-
disabled: isValidating || isSaving,
|
|
34628
|
-
variant: "outline",
|
|
34629
|
-
size: "sm",
|
|
34630
|
-
className: cn$1("flex gap-4", className),
|
|
34631
|
-
children: [
|
|
34632
|
-
/* @__PURE__ */ jsx(Icon, { icon: "fluent:save-28-filled" }),
|
|
34633
|
-
isSaving ? tr("fluidgrids.builder.saveFlowButton.savingLabel", "Saving...") : tr("fluidgrids.builder.saveFlowButton.saveLabel", "Save")
|
|
34634
|
-
]
|
|
34635
|
-
}
|
|
34636
|
-
)
|
|
34637
|
-
}
|
|
34638
|
-
),
|
|
34639
|
-
/* @__PURE__ */ jsx(
|
|
34640
|
-
QuotaExhaustedDialog,
|
|
34641
|
-
{
|
|
34642
|
-
surface: "builder-save",
|
|
34643
|
-
open: quotaExhausted,
|
|
34644
|
-
onOpenChange: (open2) => {
|
|
34645
|
-
if (!open2) dismissQuotaExhausted();
|
|
34646
|
-
},
|
|
34647
|
-
onUpgrade: () => {
|
|
34648
|
-
dismissQuotaExhausted();
|
|
34649
|
-
navigate(BILLING_PLANS_PATH);
|
|
34650
|
-
}
|
|
34651
|
-
}
|
|
34652
|
-
)
|
|
34653
|
-
] });
|
|
34654
|
-
};
|
|
34655
|
-
var PLACEHOLDER_JSON = `{
|
|
34656
|
-
"message": "Hello, what can you help me with?",
|
|
34657
|
-
"agentName": "faq_agent"
|
|
34658
|
-
}`;
|
|
34659
|
-
function TriggerDataDialog({
|
|
34660
|
-
open: open2,
|
|
34661
|
-
onOpenChange,
|
|
34662
|
-
onExecute,
|
|
34663
|
-
isExecuting
|
|
34664
|
-
}) {
|
|
34665
|
-
const [jsonValue, setJsonValue] = useState("");
|
|
34666
|
-
const [parseError, setParseError] = useState(null);
|
|
34667
|
-
const [submitted, setSubmitted] = useState(false);
|
|
34668
|
-
useEffect(() => {
|
|
34669
|
-
if (!open2) {
|
|
34670
|
-
setJsonValue("");
|
|
34671
|
-
setParseError(null);
|
|
34672
|
-
setSubmitted(false);
|
|
34673
|
-
} else {
|
|
34674
|
-
setParseError(null);
|
|
34675
|
-
}
|
|
34676
|
-
}, [open2]);
|
|
34677
|
-
useEffect(() => {
|
|
34678
|
-
if (submitted && isExecuting) {
|
|
34679
|
-
onOpenChange(false);
|
|
34680
|
-
setSubmitted(false);
|
|
34681
|
-
}
|
|
34682
|
-
}, [submitted, isExecuting, onOpenChange]);
|
|
34683
|
-
const handleExecute = useCallback(() => {
|
|
34684
|
-
const valueToparse = jsonValue.trim() || "{}";
|
|
34685
|
-
try {
|
|
34686
|
-
const parsed = JSON.parse(valueToparse);
|
|
34687
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
34688
|
-
setParseError(
|
|
34689
|
-
"Trigger data must be a JSON object (not an array or primitive)"
|
|
34690
|
-
);
|
|
34691
|
-
return;
|
|
34692
|
-
}
|
|
34693
|
-
setParseError(null);
|
|
34694
|
-
setSubmitted(true);
|
|
34695
|
-
onExecute(parsed);
|
|
34696
|
-
} catch {
|
|
34697
|
-
setParseError("Invalid JSON. Please check your syntax.");
|
|
34698
|
-
}
|
|
34699
|
-
}, [jsonValue, onExecute]);
|
|
34700
|
-
const handleRunEmpty = useCallback(() => {
|
|
34701
|
-
setParseError(null);
|
|
34702
|
-
setSubmitted(true);
|
|
34703
|
-
onExecute({});
|
|
34704
|
-
}, [onExecute]);
|
|
34705
|
-
return /* @__PURE__ */ jsx(Dialog$1, { open: open2, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent$1, { className: "sm:max-w-lg", children: [
|
|
34706
|
-
/* @__PURE__ */ jsxs(DialogHeader$1, { children: [
|
|
34707
|
-
/* @__PURE__ */ jsxs(DialogTitle$1, { className: "flex items-center gap-2", children: [
|
|
34708
|
-
/* @__PURE__ */ jsx(
|
|
34709
|
-
Icon,
|
|
34710
|
-
{
|
|
34711
|
-
icon: "mdi:play-circle-outline",
|
|
34712
|
-
className: "size-5 text-[var(--color-status-success-text)]"
|
|
34713
|
-
}
|
|
34714
|
-
),
|
|
34715
|
-
"Execute Workflow"
|
|
34716
|
-
] }),
|
|
34717
|
-
/* @__PURE__ */ jsx(DialogDescription$1, { children: "Provide the trigger data (JSON) that will be passed to the first node in the workflow. This is the input your workflow will process." })
|
|
34718
|
-
] }),
|
|
34719
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
34720
|
-
/* @__PURE__ */ jsx(
|
|
34721
|
-
"label",
|
|
34722
|
-
{
|
|
34723
|
-
htmlFor: "trigger-data-json",
|
|
34724
|
-
className: "text-sm font-medium text-foreground",
|
|
34725
|
-
children: "Trigger Data (JSON)"
|
|
34726
|
-
}
|
|
34727
|
-
),
|
|
34728
|
-
/* @__PURE__ */ jsx(
|
|
34729
|
-
"textarea",
|
|
34730
|
-
{
|
|
34731
|
-
id: "trigger-data-json",
|
|
34732
|
-
value: jsonValue,
|
|
34733
|
-
onChange: (e) => {
|
|
34734
|
-
setJsonValue(e.target.value);
|
|
34735
|
-
setParseError(null);
|
|
34736
|
-
},
|
|
34737
|
-
className: "w-full h-48 rounded-md border border-input bg-background px-3 py-2 text-sm font-mono ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 resize-y",
|
|
34738
|
-
placeholder: PLACEHOLDER_JSON,
|
|
34739
|
-
spellCheck: false
|
|
34740
|
-
}
|
|
34741
|
-
),
|
|
34742
|
-
parseError && /* @__PURE__ */ jsx("p", { className: "text-sm text-[var(--color-status-error-text)]", children: parseError }),
|
|
34743
|
-
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
34744
|
-
"This data is available to nodes as trigger input. For example, a Botlit node expects",
|
|
34745
|
-
" ",
|
|
34746
|
-
/* @__PURE__ */ jsx("code", { className: "bg-muted px-1 rounded", children: "message" }),
|
|
34747
|
-
" and",
|
|
34748
|
-
" ",
|
|
34749
|
-
/* @__PURE__ */ jsx("code", { className: "bg-muted px-1 rounded", children: "agentName" }),
|
|
34750
|
-
". A Web Scraper node expects",
|
|
34751
|
-
" ",
|
|
34752
|
-
/* @__PURE__ */ jsx("code", { className: "bg-muted px-1 rounded", children: "url" }),
|
|
34753
|
-
"."
|
|
34754
|
-
] })
|
|
34755
|
-
] }),
|
|
34756
|
-
/* @__PURE__ */ jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [
|
|
34757
|
-
/* @__PURE__ */ jsx(
|
|
34758
|
-
Button$1,
|
|
34759
|
-
{
|
|
34760
|
-
variant: "outline",
|
|
34761
|
-
size: "sm",
|
|
34762
|
-
onClick: handleRunEmpty,
|
|
34763
|
-
disabled: isExecuting,
|
|
34764
|
-
children: "Run Empty"
|
|
34765
|
-
}
|
|
34766
|
-
),
|
|
34767
|
-
/* @__PURE__ */ jsxs(
|
|
34768
|
-
Button$1,
|
|
34769
|
-
{
|
|
34770
|
-
variant: "default",
|
|
34771
|
-
size: "sm",
|
|
34772
|
-
onClick: handleExecute,
|
|
34773
|
-
disabled: isExecuting,
|
|
34774
|
-
className: "bg-[var(--color-status-success-bg)] hover:bg-[var(--color-status-success-bg)]/90 text-[var(--color-text-on-status)]",
|
|
34775
|
-
children: [
|
|
34776
|
-
/* @__PURE__ */ jsx(Icon, { icon: "mdi:play", className: "size-4 mr-1" }),
|
|
34777
|
-
isExecuting ? "Running..." : "Execute"
|
|
34778
|
-
]
|
|
34779
|
-
}
|
|
34780
|
-
)
|
|
34781
|
-
] })
|
|
34782
|
-
] }) });
|
|
34783
|
-
}
|
|
34784
|
-
var ExecuteWorkflowButton = ({
|
|
34785
|
-
className
|
|
34786
|
-
}) => {
|
|
34787
|
-
const tr = useTr();
|
|
34788
|
-
const { executeFullWorkflow } = useNodeExecution();
|
|
34789
|
-
const [dialogOpen, setDialogOpen] = useState(false);
|
|
34790
|
-
const [isExecuting] = useFlowStore(
|
|
34791
|
-
useShallow((s) => [s.execution.isExecuting])
|
|
34792
|
-
);
|
|
34793
|
-
const executeWorkflow = useCallback(
|
|
34794
|
-
async (triggerData) => {
|
|
34795
|
-
try {
|
|
34796
|
-
const result = await executeFullWorkflow(triggerData);
|
|
34797
|
-
if (result.success) {
|
|
34798
|
-
toast.success(
|
|
34799
|
-
tr(
|
|
34800
|
-
"fluidgrids.builder.executeWorkflowButton.executionStartedToast",
|
|
34801
|
-
"Workflow execution started"
|
|
34802
|
-
),
|
|
34803
|
-
{
|
|
34804
|
-
description: `Run ID: ${result.runId}`,
|
|
34805
|
-
dismissible: true
|
|
34806
|
-
}
|
|
34807
|
-
);
|
|
34808
|
-
} else if ("quotaExhausted" in result && result.quotaExhausted) {
|
|
34809
|
-
setDialogOpen(false);
|
|
34810
|
-
} else {
|
|
34811
|
-
throw new Error(result.error || "Failed to trigger workflow");
|
|
34812
|
-
}
|
|
34813
|
-
} catch (error62) {
|
|
34814
|
-
const message = error62 instanceof Error ? error62.message : tr(
|
|
34815
|
-
"fluidgrids.builder.executeWorkflowButton.unknownError",
|
|
34816
|
-
"Unknown error"
|
|
34817
|
-
);
|
|
34818
|
-
console.error("[ExecuteWorkflowButton] Error:", message);
|
|
34819
|
-
toast.error(
|
|
34820
|
-
tr(
|
|
34821
|
-
"fluidgrids.builder.executeWorkflowButton.executeFailedToast",
|
|
34822
|
-
"Failed to execute workflow"
|
|
34823
|
-
),
|
|
34824
|
-
{
|
|
34825
|
-
description: message
|
|
34826
|
-
}
|
|
34827
|
-
);
|
|
34828
|
-
}
|
|
34829
|
-
},
|
|
34830
|
-
[executeFullWorkflow, tr]
|
|
34831
|
-
);
|
|
34832
|
-
const [isValidating, validateFlow] = useFlowValidator(async (isValid) => {
|
|
34833
|
-
if (isValid) {
|
|
34834
|
-
setDialogOpen(true);
|
|
34835
|
-
} else {
|
|
34836
|
-
toast.error(
|
|
34837
|
-
tr(
|
|
34838
|
-
"fluidgrids.builder.executeWorkflowButton.invalidToastTitle",
|
|
34839
|
-
"Flow is invalid"
|
|
34840
|
-
),
|
|
34841
|
-
{
|
|
34842
|
-
description: tr(
|
|
34843
|
-
"fluidgrids.builder.executeWorkflowButton.invalidToastDescription",
|
|
34844
|
-
"Please fix the flow before executing. Ensure trigger node is connected."
|
|
34845
|
-
)
|
|
34846
|
-
}
|
|
34847
|
-
);
|
|
34848
|
-
}
|
|
34849
|
-
});
|
|
34850
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
34851
|
-
/* @__PURE__ */ jsx(
|
|
34852
|
-
SdkPermissionButton,
|
|
34853
|
-
{
|
|
34854
|
-
permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_EXECUTE,
|
|
34855
|
-
deniedTooltip: tr(
|
|
34856
|
-
"fluidgrids.builder.executeWorkflowButton.permissionDeniedTooltip",
|
|
34857
|
-
"You don't have permission to execute workflows"
|
|
34858
|
-
),
|
|
34859
|
-
children: /* @__PURE__ */ jsxs(
|
|
34860
|
-
Button$1,
|
|
34861
|
-
{
|
|
34862
|
-
onClick: validateFlow,
|
|
34863
|
-
disabled: isValidating || isExecuting,
|
|
34864
|
-
variant: "default",
|
|
34865
|
-
size: "sm",
|
|
34866
|
-
className: cn$1(
|
|
34867
|
-
"flex items-center justify-center gap-2 h-8 rounded-l-lg rounded-r-none px-3 bg-[var(--color-status-success-bg)] hover:bg-[var(--color-status-success-bg)]/90 text-[var(--color-text-on-status)] font-medium",
|
|
34868
|
-
className
|
|
34869
|
-
),
|
|
34870
|
-
children: [
|
|
34871
|
-
/* @__PURE__ */ jsx(Icon, { icon: "mdi:play", className: "size-4" }),
|
|
34872
|
-
isExecuting ? tr(
|
|
34873
|
-
"fluidgrids.builder.executeWorkflowButton.runningLabel",
|
|
34874
|
-
"Running..."
|
|
34875
|
-
) : isValidating ? tr(
|
|
34876
|
-
"fluidgrids.builder.executeWorkflowButton.validatingLabel",
|
|
34877
|
-
"Validating..."
|
|
34878
|
-
) : tr("fluidgrids.builder.executeWorkflowButton.runLabel", "Run")
|
|
34879
|
-
]
|
|
34880
|
-
}
|
|
34881
|
-
)
|
|
34882
|
-
}
|
|
34883
|
-
),
|
|
34884
|
-
/* @__PURE__ */ jsx(
|
|
34885
|
-
TriggerDataDialog,
|
|
34886
|
-
{
|
|
34887
|
-
open: dialogOpen,
|
|
34888
|
-
onOpenChange: setDialogOpen,
|
|
34889
|
-
onExecute: executeWorkflow,
|
|
34890
|
-
isExecuting
|
|
34891
|
-
}
|
|
34892
|
-
)
|
|
34893
|
-
] });
|
|
34894
|
-
};
|
|
34895
34777
|
var JsonView = ({
|
|
34896
34778
|
data
|
|
34897
34779
|
}) => {
|
|
@@ -35655,14 +35537,19 @@ function CodeEditorField({
|
|
|
35655
35537
|
value,
|
|
35656
35538
|
language,
|
|
35657
35539
|
placeholder,
|
|
35540
|
+
label,
|
|
35658
35541
|
onChange,
|
|
35659
35542
|
className,
|
|
35660
35543
|
"data-testid": testId
|
|
35661
35544
|
}) {
|
|
35662
35545
|
const dark = useIsDarkTheme();
|
|
35663
35546
|
const extensions = useMemo(
|
|
35664
|
-
() => [
|
|
35665
|
-
|
|
35547
|
+
() => [
|
|
35548
|
+
language === "python" ? python() : javascript(),
|
|
35549
|
+
// CodeMirror's contenteditable is the control assistive tech focuses; name it.
|
|
35550
|
+
...label ? [EditorView.contentAttributes.of({ "aria-label": label })] : []
|
|
35551
|
+
],
|
|
35552
|
+
[language, label]
|
|
35666
35553
|
);
|
|
35667
35554
|
return /* @__PURE__ */ jsx(
|
|
35668
35555
|
"div",
|
|
@@ -36532,7 +36419,8 @@ function OptionListInput({
|
|
|
36532
36419
|
onChange,
|
|
36533
36420
|
className,
|
|
36534
36421
|
testId,
|
|
36535
|
-
fieldName
|
|
36422
|
+
fieldName,
|
|
36423
|
+
label
|
|
36536
36424
|
}) {
|
|
36537
36425
|
const tr = useTr();
|
|
36538
36426
|
const [draft, setDraft] = useState(() => optionListText(value));
|
|
@@ -36563,7 +36451,7 @@ function OptionListInput({
|
|
|
36563
36451
|
"fluidgrids.builder.nodeParamsForm.loadOptionsListPlaceholder",
|
|
36564
36452
|
"Comma-separated IDs or a JSON array of IDs"
|
|
36565
36453
|
),
|
|
36566
|
-
"aria-label": fieldName,
|
|
36454
|
+
"aria-label": label ?? fieldName,
|
|
36567
36455
|
"aria-invalid": invalid,
|
|
36568
36456
|
"data-testid": testId,
|
|
36569
36457
|
className,
|
|
@@ -36589,7 +36477,8 @@ function NodeLoadOptionsSelect({
|
|
|
36589
36477
|
parameterDefaults = EMPTY_VALUES,
|
|
36590
36478
|
unavailableParameters = EMPTY_PARAMETERS,
|
|
36591
36479
|
multiple = false,
|
|
36592
|
-
fieldName = "Options"
|
|
36480
|
+
fieldName = "Options",
|
|
36481
|
+
label
|
|
36593
36482
|
}) {
|
|
36594
36483
|
const tr = useTr();
|
|
36595
36484
|
const [manual, setManual] = useState(false);
|
|
@@ -36620,7 +36509,8 @@ function NodeLoadOptionsSelect({
|
|
|
36620
36509
|
onChange,
|
|
36621
36510
|
className,
|
|
36622
36511
|
testId,
|
|
36623
|
-
fieldName
|
|
36512
|
+
fieldName,
|
|
36513
|
+
label
|
|
36624
36514
|
}
|
|
36625
36515
|
) : /* @__PURE__ */ jsx(
|
|
36626
36516
|
"input",
|
|
@@ -36632,7 +36522,7 @@ function NodeLoadOptionsSelect({
|
|
|
36632
36522
|
"fluidgrids.builder.nodeParamsForm.loadOptionsErrorPlaceholder",
|
|
36633
36523
|
"Enter a value"
|
|
36634
36524
|
),
|
|
36635
|
-
"aria-label": fieldName,
|
|
36525
|
+
"aria-label": label ?? fieldName,
|
|
36636
36526
|
"data-testid": testId,
|
|
36637
36527
|
className
|
|
36638
36528
|
}
|
|
@@ -36649,7 +36539,7 @@ function NodeLoadOptionsSelect({
|
|
|
36649
36539
|
) : event.target.value
|
|
36650
36540
|
),
|
|
36651
36541
|
disabled: loading,
|
|
36652
|
-
"aria-label": fieldName,
|
|
36542
|
+
"aria-label": label ?? fieldName,
|
|
36653
36543
|
"data-testid": testId,
|
|
36654
36544
|
className: cn$1(className, loading && "opacity-60"),
|
|
36655
36545
|
children: [
|
|
@@ -36731,6 +36621,7 @@ function booleanParameterValue(value) {
|
|
|
36731
36621
|
}
|
|
36732
36622
|
function StructuredParameterInput({
|
|
36733
36623
|
name,
|
|
36624
|
+
label,
|
|
36734
36625
|
schema,
|
|
36735
36626
|
value,
|
|
36736
36627
|
onChange,
|
|
@@ -36750,7 +36641,7 @@ function StructuredParameterInput({
|
|
|
36750
36641
|
/* @__PURE__ */ jsx(
|
|
36751
36642
|
"textarea",
|
|
36752
36643
|
{
|
|
36753
|
-
"aria-label": name,
|
|
36644
|
+
"aria-label": label ?? name,
|
|
36754
36645
|
"aria-describedby": descriptionId,
|
|
36755
36646
|
"aria-invalid": !result.valid,
|
|
36756
36647
|
value: text,
|
|
@@ -36790,6 +36681,7 @@ function StructuredParameterInput({
|
|
|
36790
36681
|
}
|
|
36791
36682
|
function JsonMappingInput({
|
|
36792
36683
|
name,
|
|
36684
|
+
label,
|
|
36793
36685
|
value,
|
|
36794
36686
|
onChange
|
|
36795
36687
|
}) {
|
|
@@ -36803,7 +36695,7 @@ function JsonMappingInput({
|
|
|
36803
36695
|
/* @__PURE__ */ jsx(
|
|
36804
36696
|
"textarea",
|
|
36805
36697
|
{
|
|
36806
|
-
"aria-label": name,
|
|
36698
|
+
"aria-label": label ?? name,
|
|
36807
36699
|
"aria-describedby": descriptionId,
|
|
36808
36700
|
"aria-invalid": !result.valid,
|
|
36809
36701
|
className: "w-full rounded-md border border-input bg-background px-2.5 py-1.5 font-mono text-sm outline-none focus:border-primary",
|
|
@@ -36861,6 +36753,7 @@ function JsonMappingInput({
|
|
|
36861
36753
|
}
|
|
36862
36754
|
function MappedParameterInput({
|
|
36863
36755
|
name,
|
|
36756
|
+
label,
|
|
36864
36757
|
value,
|
|
36865
36758
|
onChange,
|
|
36866
36759
|
nodeId: nodeId2,
|
|
@@ -36871,6 +36764,7 @@ function MappedParameterInput({
|
|
|
36871
36764
|
JsonMappingInput,
|
|
36872
36765
|
{
|
|
36873
36766
|
name,
|
|
36767
|
+
label,
|
|
36874
36768
|
value,
|
|
36875
36769
|
onChange
|
|
36876
36770
|
},
|
|
@@ -36884,7 +36778,8 @@ function MappedParameterInput({
|
|
|
36884
36778
|
onChange,
|
|
36885
36779
|
rows: 2,
|
|
36886
36780
|
nodeId: nodeId2,
|
|
36887
|
-
placeholder
|
|
36781
|
+
placeholder,
|
|
36782
|
+
ariaLabel: label ?? name
|
|
36888
36783
|
}
|
|
36889
36784
|
);
|
|
36890
36785
|
}
|
|
@@ -36894,6 +36789,7 @@ function NodeParamsForm({
|
|
|
36894
36789
|
nodeType,
|
|
36895
36790
|
testIdPrefix = "ndv"
|
|
36896
36791
|
}) {
|
|
36792
|
+
const formId = useId();
|
|
36897
36793
|
const tr = useTr();
|
|
36898
36794
|
const edges = useFlowStore((state) => state.workflow.edges);
|
|
36899
36795
|
const loopStatus = (nodeType === "internal:loop" || nodeType === "loop") && config2.node ? loopReturnStatus(
|
|
@@ -37010,7 +36906,7 @@ function NodeParamsForm({
|
|
|
37010
36906
|
/* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-foreground", children: p.name === "conditionTree" ? tr(
|
|
37011
36907
|
"fluidgrids.builder.nodeParamsForm.conditionsLabel",
|
|
37012
36908
|
"Conditions"
|
|
37013
|
-
) : p.name }),
|
|
36909
|
+
) : p.label ?? p.name }),
|
|
37014
36910
|
/* @__PURE__ */ jsx(
|
|
37015
36911
|
ConditionTreeBuilder,
|
|
37016
36912
|
{
|
|
@@ -37073,6 +36969,8 @@ function NodeParamsForm({
|
|
|
37073
36969
|
const booleanChecked = p.type === "boolean" && booleanParameterValue(fixedValue) === true;
|
|
37074
36970
|
const isCodeParam = p.type === "code" || nodeType === "internal:code" && p.name === "code";
|
|
37075
36971
|
const highlight = dragField === p.name;
|
|
36972
|
+
const controlId = `${formId}-param-${p.name}`;
|
|
36973
|
+
const nativeControl = mode !== "expression" && !isCodeParam && !(structuredType && !optionList) && !p.loadOptions;
|
|
37076
36974
|
const inputCx2 = cn$1(
|
|
37077
36975
|
"w-full rounded-md border bg-background px-2.5 py-1.5 text-sm outline-none transition-colors disabled:opacity-50",
|
|
37078
36976
|
highlight ? "border-primary ring-1 ring-primary" : "border-input focus:border-primary"
|
|
@@ -37087,7 +36985,15 @@ function NodeParamsForm({
|
|
|
37087
36985
|
onDrop: handleDropOnParam(p.name),
|
|
37088
36986
|
children: [
|
|
37089
36987
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
37090
|
-
/* @__PURE__ */ jsx(
|
|
36988
|
+
/* @__PURE__ */ jsx(
|
|
36989
|
+
"label",
|
|
36990
|
+
{
|
|
36991
|
+
htmlFor: nativeControl ? controlId : void 0,
|
|
36992
|
+
className: "text-xs font-medium text-foreground",
|
|
36993
|
+
title: p.label && p.label !== p.name ? p.name : void 0,
|
|
36994
|
+
children: p.label ?? p.name
|
|
36995
|
+
}
|
|
36996
|
+
),
|
|
37091
36997
|
p.required && /* @__PURE__ */ jsx("span", { className: "text-destructive", children: "*" }),
|
|
37092
36998
|
/* @__PURE__ */ jsx("span", { className: "ml-auto text-[10px] uppercase tracking-wide text-muted-foreground", children: p.type }),
|
|
37093
36999
|
/* @__PURE__ */ jsx(
|
|
@@ -37128,6 +37034,7 @@ function NodeParamsForm({
|
|
|
37128
37034
|
MappedParameterInput,
|
|
37129
37035
|
{
|
|
37130
37036
|
name: p.name,
|
|
37037
|
+
label: p.label,
|
|
37131
37038
|
value: exprValue,
|
|
37132
37039
|
onChange: (value) => writeMapping(p.name, value),
|
|
37133
37040
|
nodeId: config2.node?.id,
|
|
@@ -37149,7 +37056,8 @@ function NodeParamsForm({
|
|
|
37149
37056
|
language: normalizeCodeLanguage(
|
|
37150
37057
|
argsState.runtime ?? params.find((f) => f.name === "runtime")?.defaultValue
|
|
37151
37058
|
),
|
|
37152
|
-
placeholder: typeof p.defaultValue === "string" ? p.defaultValue : p.description,
|
|
37059
|
+
placeholder: typeof p.defaultValue === "string" ? p.defaultValue : p.placeholder ?? p.description,
|
|
37060
|
+
label: p.label ?? p.name,
|
|
37153
37061
|
onChange: (v) => writeFixed(p.name, v),
|
|
37154
37062
|
"data-testid": `${testIdPrefix}-param-${p.name}`
|
|
37155
37063
|
}
|
|
@@ -37157,6 +37065,7 @@ function NodeParamsForm({
|
|
|
37157
37065
|
StructuredParameterInput,
|
|
37158
37066
|
{
|
|
37159
37067
|
name: p.name,
|
|
37068
|
+
label: p.label,
|
|
37160
37069
|
schema: p.schema ?? p.type,
|
|
37161
37070
|
value: fixedValue,
|
|
37162
37071
|
onChange: (value) => writeFixed(p.name, value),
|
|
@@ -37187,6 +37096,7 @@ function NodeParamsForm({
|
|
|
37187
37096
|
).map((parameter) => parameter.name),
|
|
37188
37097
|
multiple: optionList,
|
|
37189
37098
|
fieldName: p.name,
|
|
37099
|
+
label: p.label,
|
|
37190
37100
|
connectionId: loadOptionsConnectionId,
|
|
37191
37101
|
value: fixedValue,
|
|
37192
37102
|
onChange: (v) => writeFixed(p.name, v),
|
|
@@ -37201,6 +37111,7 @@ function NodeParamsForm({
|
|
|
37201
37111
|
type: "checkbox",
|
|
37202
37112
|
checked: booleanChecked,
|
|
37203
37113
|
onChange: (event) => writeFixed(p.name, event.target.checked),
|
|
37114
|
+
id: controlId,
|
|
37204
37115
|
"data-testid": `${testIdPrefix}-param-${p.name}`,
|
|
37205
37116
|
className: "size-4"
|
|
37206
37117
|
}
|
|
@@ -37222,7 +37133,7 @@ function NodeParamsForm({
|
|
|
37222
37133
|
"aria-label": tr(
|
|
37223
37134
|
"fluidgrids.builder.nodeParamsForm.unsetBooleanLabel",
|
|
37224
37135
|
"Not set: {{field}}",
|
|
37225
|
-
{ field: p.name }
|
|
37136
|
+
{ field: p.label ?? p.name }
|
|
37226
37137
|
),
|
|
37227
37138
|
"data-testid": `${testIdPrefix}-param-${p.name}-unset`,
|
|
37228
37139
|
className: "rounded px-1 text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-disabled:opacity-50",
|
|
@@ -37237,17 +37148,19 @@ function NodeParamsForm({
|
|
|
37237
37148
|
{
|
|
37238
37149
|
value: typeof fixedValue === "string" ? fixedValue : "",
|
|
37239
37150
|
onChange: (e) => writeFixed(p.name, e.target.value),
|
|
37151
|
+
"aria-label": p.label ?? p.name,
|
|
37152
|
+
id: controlId,
|
|
37240
37153
|
"data-testid": `${testIdPrefix}-param-${p.name}`,
|
|
37241
37154
|
className: cn$1(
|
|
37242
37155
|
inputCx2,
|
|
37243
37156
|
"scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary"
|
|
37244
37157
|
),
|
|
37245
37158
|
children: [
|
|
37246
|
-
/* @__PURE__ */ jsx("option", { value: "", children: p.defaultValue !== void 0 ? `Default (${String(p.defaultValue)})` : tr(
|
|
37159
|
+
/* @__PURE__ */ jsx("option", { value: "", children: p.defaultValue !== void 0 ? `Default (${optionText(p, String(p.defaultValue))})` : tr(
|
|
37247
37160
|
"fluidgrids.builder.nodeParamsForm.selectPlaceholder",
|
|
37248
37161
|
"Select\u2026"
|
|
37249
37162
|
) }),
|
|
37250
|
-
p.options.map((o) => /* @__PURE__ */ jsx("option", { value: o, children: o }, o))
|
|
37163
|
+
p.options.map((o) => /* @__PURE__ */ jsx("option", { value: o, children: optionText(p, o) }, o))
|
|
37251
37164
|
]
|
|
37252
37165
|
}
|
|
37253
37166
|
) : p.type === "integer" || p.type === "number" ? /* @__PURE__ */ jsx(
|
|
@@ -37256,11 +37169,13 @@ function NodeParamsForm({
|
|
|
37256
37169
|
type: "number",
|
|
37257
37170
|
step: p.type === "integer" ? "1" : "any",
|
|
37258
37171
|
value: typeof fixedValue === "number" ? String(fixedValue) : "",
|
|
37259
|
-
placeholder: p.defaultValue !== void 0 ? `Default: ${String(p.defaultValue)}` : tr(
|
|
37172
|
+
placeholder: p.defaultValue !== void 0 ? `Default: ${String(p.defaultValue)}` : p.placeholder ?? tr(
|
|
37260
37173
|
"fluidgrids.builder.nodeParamsForm.numberPlaceholder",
|
|
37261
37174
|
"Enter a number"
|
|
37262
37175
|
),
|
|
37176
|
+
"aria-label": p.label ?? p.name,
|
|
37263
37177
|
onChange: (e) => writeFixed(p.name, coerceNumber(p.type, e.target.value)),
|
|
37178
|
+
id: controlId,
|
|
37264
37179
|
"data-testid": `${testIdPrefix}-param-${p.name}`,
|
|
37265
37180
|
className: inputCx2
|
|
37266
37181
|
}
|
|
@@ -37269,12 +37184,13 @@ function NodeParamsForm({
|
|
|
37269
37184
|
{
|
|
37270
37185
|
rows: 4,
|
|
37271
37186
|
value: fixedValue === void 0 || fixedValue === null ? "" : String(fixedValue),
|
|
37272
|
-
placeholder: p.defaultValue !== void 0 ? `Default: ${String(p.defaultValue)}` : tr(
|
|
37187
|
+
placeholder: p.defaultValue !== void 0 ? `Default: ${String(p.defaultValue)}` : p.placeholder ?? tr(
|
|
37273
37188
|
"fluidgrids.builder.nodeParamsForm.textPlaceholder",
|
|
37274
37189
|
"Enter a value"
|
|
37275
37190
|
),
|
|
37276
37191
|
onChange: (event) => writeFixed(p.name, event.target.value),
|
|
37277
|
-
"aria-label": p.name,
|
|
37192
|
+
"aria-label": p.label ?? p.name,
|
|
37193
|
+
id: controlId,
|
|
37278
37194
|
"data-testid": `${testIdPrefix}-param-${p.name}`,
|
|
37279
37195
|
className: cn$1(inputCx2, "min-h-24 resize-y")
|
|
37280
37196
|
}
|
|
@@ -37283,11 +37199,13 @@ function NodeParamsForm({
|
|
|
37283
37199
|
{
|
|
37284
37200
|
type: "text",
|
|
37285
37201
|
value: fixedValue === void 0 || fixedValue === null ? "" : String(fixedValue),
|
|
37286
|
-
placeholder: p.defaultValue !== void 0 ? `Default: ${String(p.defaultValue)}` : tr(
|
|
37202
|
+
placeholder: p.defaultValue !== void 0 ? `Default: ${String(p.defaultValue)}` : p.placeholder ?? tr(
|
|
37287
37203
|
"fluidgrids.builder.nodeParamsForm.textPlaceholder",
|
|
37288
37204
|
"Enter a value"
|
|
37289
37205
|
),
|
|
37290
37206
|
onChange: (e) => writeFixed(p.name, e.target.value),
|
|
37207
|
+
"aria-label": p.label ?? p.name,
|
|
37208
|
+
id: controlId,
|
|
37291
37209
|
"data-testid": `${testIdPrefix}-param-${p.name}`,
|
|
37292
37210
|
className: inputCx2
|
|
37293
37211
|
}
|
|
@@ -39192,6 +39110,908 @@ function QuickConfigPanelInner({
|
|
|
39192
39110
|
] });
|
|
39193
39111
|
}
|
|
39194
39112
|
|
|
39113
|
+
// src/builder/lib/autosave-runner.ts
|
|
39114
|
+
function createAutosaveRunner(deps) {
|
|
39115
|
+
let timer;
|
|
39116
|
+
let attempt = 0;
|
|
39117
|
+
const clear = () => {
|
|
39118
|
+
if (timer !== void 0) deps.clearTimer(timer);
|
|
39119
|
+
timer = void 0;
|
|
39120
|
+
};
|
|
39121
|
+
async function run() {
|
|
39122
|
+
timer = void 0;
|
|
39123
|
+
const retriesSoFar = attempt;
|
|
39124
|
+
attempt = 0;
|
|
39125
|
+
if (deps.gate() !== "run") return;
|
|
39126
|
+
if (await deps.save()) {
|
|
39127
|
+
deps.onSaved();
|
|
39128
|
+
return;
|
|
39129
|
+
}
|
|
39130
|
+
const failure2 = deps.failure();
|
|
39131
|
+
if (failure2?.kind === "transient" && retriesSoFar < deps.retryDelaysMs.length) {
|
|
39132
|
+
deps.onRetryScheduled();
|
|
39133
|
+
attempt = retriesSoFar + 1;
|
|
39134
|
+
timer = deps.setTimer(
|
|
39135
|
+
() => void run(),
|
|
39136
|
+
deps.retryDelaysMs[retriesSoFar] ?? 0
|
|
39137
|
+
);
|
|
39138
|
+
return;
|
|
39139
|
+
}
|
|
39140
|
+
deps.onGiveUp(failure2);
|
|
39141
|
+
}
|
|
39142
|
+
return {
|
|
39143
|
+
schedule() {
|
|
39144
|
+
if (attempt > 0 || !deps.mayStart()) return;
|
|
39145
|
+
clear();
|
|
39146
|
+
timer = deps.setTimer(() => void run(), deps.debounceMs);
|
|
39147
|
+
},
|
|
39148
|
+
/** Drop the pending autosave or retry. */
|
|
39149
|
+
cancel() {
|
|
39150
|
+
clear();
|
|
39151
|
+
attempt = 0;
|
|
39152
|
+
},
|
|
39153
|
+
get retryPending() {
|
|
39154
|
+
return attempt > 0;
|
|
39155
|
+
}
|
|
39156
|
+
};
|
|
39157
|
+
}
|
|
39158
|
+
|
|
39159
|
+
// src/builder/hooks/use-builder-autosave.ts
|
|
39160
|
+
var SETTLE_MS = 1500;
|
|
39161
|
+
var CHECK_DELAY_MS = 200;
|
|
39162
|
+
function useLatest(value) {
|
|
39163
|
+
const ref = useRef(value);
|
|
39164
|
+
useEffect(() => {
|
|
39165
|
+
ref.current = value;
|
|
39166
|
+
});
|
|
39167
|
+
return ref;
|
|
39168
|
+
}
|
|
39169
|
+
function takeBaseline() {
|
|
39170
|
+
const flow = useFlowStore.getState();
|
|
39171
|
+
useSaveStatusStore.getState().actions.setBaseline({
|
|
39172
|
+
fingerprint: workflowFingerprint(flow.workflow),
|
|
39173
|
+
generation: flow.loadGeneration,
|
|
39174
|
+
settleUntil: Date.now() + SETTLE_MS,
|
|
39175
|
+
editRevision: flow.editRevision
|
|
39176
|
+
});
|
|
39177
|
+
}
|
|
39178
|
+
function touchesSavedFields(state, previous) {
|
|
39179
|
+
return state.workflow.nodes !== previous.workflow.nodes || state.workflow.edges !== previous.workflow.edges || state.workflow.name !== previous.workflow.name || state.workflow.alias !== previous.workflow.alias || state.workflow.status !== previous.workflow.status || state.loadGeneration !== previous.loadGeneration;
|
|
39180
|
+
}
|
|
39181
|
+
function useAutosave(readOnly) {
|
|
39182
|
+
const tr = useTr();
|
|
39183
|
+
const { saveToBackend } = useSaveWorkflow();
|
|
39184
|
+
const saveRef = useLatest(saveToBackend);
|
|
39185
|
+
const trRef = useLatest(tr);
|
|
39186
|
+
useEffect(() => {
|
|
39187
|
+
if (readOnly) return;
|
|
39188
|
+
const status = () => useSaveStatusStore.getState();
|
|
39189
|
+
const actions = status().actions;
|
|
39190
|
+
actions.reset();
|
|
39191
|
+
let checkTimer;
|
|
39192
|
+
const saveDeparting = (state) => {
|
|
39193
|
+
const snapshot = departingSave(state);
|
|
39194
|
+
if (!snapshot) return;
|
|
39195
|
+
void saveRef.current({ silent: true, snapshot }).then((saved) => {
|
|
39196
|
+
if (saved) return;
|
|
39197
|
+
toast.error(
|
|
39198
|
+
trRef.current(
|
|
39199
|
+
"fluidgrids.builder.autosave.leaveSaveFailedToast",
|
|
39200
|
+
"Your last changes could not be saved"
|
|
39201
|
+
)
|
|
39202
|
+
);
|
|
39203
|
+
});
|
|
39204
|
+
};
|
|
39205
|
+
const autosave = createAutosaveRunner({
|
|
39206
|
+
mayStart: () => !status().autosavePaused && autosaveAllowedFor(useFlowStore.getState().workflow),
|
|
39207
|
+
gate: () => {
|
|
39208
|
+
const { workflow } = useFlowStore.getState();
|
|
39209
|
+
if (status().autosavePaused || !status().dirty) return "skip";
|
|
39210
|
+
if (!autosaveAllowedFor(workflow)) return "skip";
|
|
39211
|
+
const complete = isFlowComplete(workflow.nodes, workflow.edges);
|
|
39212
|
+
actions.setIncomplete(!complete);
|
|
39213
|
+
return complete ? "run" : "skip";
|
|
39214
|
+
},
|
|
39215
|
+
save: () => saveRef.current({ silent: true }),
|
|
39216
|
+
failure: () => status().failure,
|
|
39217
|
+
onSaved: () => scheduleCheck(),
|
|
39218
|
+
onRetryScheduled: () => actions.clearFailure(),
|
|
39219
|
+
onGiveUp: (failure2) => actions.setAutosavePaused(!!failure2 && failure2.kind !== "transient"),
|
|
39220
|
+
debounceMs: AUTOSAVE_DEBOUNCE_MS,
|
|
39221
|
+
retryDelaysMs: AUTOSAVE_RETRY_DELAYS_MS,
|
|
39222
|
+
setTimer: (run, ms) => setTimeout(run, ms),
|
|
39223
|
+
clearTimer: (timer) => clearTimeout(timer)
|
|
39224
|
+
});
|
|
39225
|
+
const check2 = () => {
|
|
39226
|
+
checkTimer = void 0;
|
|
39227
|
+
const flow = useFlowStore.getState();
|
|
39228
|
+
const { baseline } = status();
|
|
39229
|
+
if (!baseline || baseline.generation !== flow.loadGeneration) {
|
|
39230
|
+
autosave.cancel();
|
|
39231
|
+
takeBaseline();
|
|
39232
|
+
return;
|
|
39233
|
+
}
|
|
39234
|
+
const state = editStateFor(flow);
|
|
39235
|
+
if (state === "settling") {
|
|
39236
|
+
takeBaseline();
|
|
39237
|
+
return;
|
|
39238
|
+
}
|
|
39239
|
+
if (state === "clean") {
|
|
39240
|
+
if (status().dirty) actions.setDirty(false);
|
|
39241
|
+
autosave.cancel();
|
|
39242
|
+
return;
|
|
39243
|
+
}
|
|
39244
|
+
if (!status().dirty) actions.setDirty(true);
|
|
39245
|
+
autosave.schedule();
|
|
39246
|
+
};
|
|
39247
|
+
function scheduleCheck() {
|
|
39248
|
+
if (checkTimer) return;
|
|
39249
|
+
checkTimer = setTimeout(check2, CHECK_DELAY_MS);
|
|
39250
|
+
}
|
|
39251
|
+
takeBaseline();
|
|
39252
|
+
const unsubscribeFlow = useFlowStore.subscribe((state, previous) => {
|
|
39253
|
+
if (state.loadGeneration !== previous.loadGeneration) {
|
|
39254
|
+
autosave.cancel();
|
|
39255
|
+
saveDeparting(previous);
|
|
39256
|
+
}
|
|
39257
|
+
if (touchesSavedFields(state, previous)) scheduleCheck();
|
|
39258
|
+
});
|
|
39259
|
+
const unsubscribeStatus = useSaveStatusStore.subscribe(
|
|
39260
|
+
(state, previous) => {
|
|
39261
|
+
if (state.baseline !== previous.baseline || state.autosaveEnabled !== previous.autosaveEnabled) {
|
|
39262
|
+
scheduleCheck();
|
|
39263
|
+
}
|
|
39264
|
+
}
|
|
39265
|
+
);
|
|
39266
|
+
return () => {
|
|
39267
|
+
unsubscribeFlow();
|
|
39268
|
+
unsubscribeStatus();
|
|
39269
|
+
if (checkTimer) clearTimeout(checkTimer);
|
|
39270
|
+
autosave.cancel();
|
|
39271
|
+
saveDeparting(useFlowStore.getState());
|
|
39272
|
+
};
|
|
39273
|
+
}, [readOnly, saveRef, trRef]);
|
|
39274
|
+
}
|
|
39275
|
+
function useSaveShortcut(readOnly) {
|
|
39276
|
+
const manualSaveRef = useLatest(useManualSave());
|
|
39277
|
+
useEffect(() => {
|
|
39278
|
+
if (readOnly) return;
|
|
39279
|
+
const onKeyDown = (e) => {
|
|
39280
|
+
if (!(e.metaKey || e.ctrlKey) || e.altKey || e.shiftKey) return;
|
|
39281
|
+
if (e.key.toLowerCase() !== "s") return;
|
|
39282
|
+
e.preventDefault();
|
|
39283
|
+
if (useSaveStatusStore.getState().saving) return;
|
|
39284
|
+
void manualSaveRef.current();
|
|
39285
|
+
};
|
|
39286
|
+
window.addEventListener("keydown", onKeyDown, { capture: true });
|
|
39287
|
+
return () => window.removeEventListener("keydown", onKeyDown, { capture: true });
|
|
39288
|
+
}, [readOnly, manualSaveRef]);
|
|
39289
|
+
}
|
|
39290
|
+
function useLeaveGuards(readOnly) {
|
|
39291
|
+
useEffect(() => {
|
|
39292
|
+
if (readOnly) return;
|
|
39293
|
+
const onBeforeUnload = (e) => {
|
|
39294
|
+
const { dirty, saving } = useSaveStatusStore.getState();
|
|
39295
|
+
if (!dirty && !saving && editStateFor(useFlowStore.getState()) !== "dirty")
|
|
39296
|
+
return;
|
|
39297
|
+
e.preventDefault();
|
|
39298
|
+
e.returnValue = "";
|
|
39299
|
+
};
|
|
39300
|
+
const onClick = (e) => {
|
|
39301
|
+
if (e.defaultPrevented) return;
|
|
39302
|
+
const anchor2 = e.target instanceof Element ? e.target.closest("a[href]") : null;
|
|
39303
|
+
if (!(anchor2 instanceof HTMLAnchorElement)) return;
|
|
39304
|
+
const to = inAppLeaveTarget(
|
|
39305
|
+
{
|
|
39306
|
+
href: anchor2.href,
|
|
39307
|
+
target: anchor2.target,
|
|
39308
|
+
download: anchor2.hasAttribute("download")
|
|
39309
|
+
},
|
|
39310
|
+
{
|
|
39311
|
+
button: e.button,
|
|
39312
|
+
modified: e.metaKey || e.ctrlKey || e.shiftKey || e.altKey
|
|
39313
|
+
},
|
|
39314
|
+
window.location
|
|
39315
|
+
);
|
|
39316
|
+
if (!to || !leavingLosesChanges()) return;
|
|
39317
|
+
e.preventDefault();
|
|
39318
|
+
e.stopPropagation();
|
|
39319
|
+
useSaveStatusStore.getState().actions.requestLeave({ to });
|
|
39320
|
+
};
|
|
39321
|
+
window.addEventListener("beforeunload", onBeforeUnload);
|
|
39322
|
+
document.addEventListener("click", onClick, { capture: true });
|
|
39323
|
+
return () => {
|
|
39324
|
+
window.removeEventListener("beforeunload", onBeforeUnload);
|
|
39325
|
+
document.removeEventListener("click", onClick, { capture: true });
|
|
39326
|
+
};
|
|
39327
|
+
}, [readOnly]);
|
|
39328
|
+
}
|
|
39329
|
+
function LeaveChangesDialog() {
|
|
39330
|
+
const tr = useTr();
|
|
39331
|
+
const navigate = useNavigate();
|
|
39332
|
+
const manualSave = useManualSave();
|
|
39333
|
+
const leaveRequest = useSaveStatusStore((s) => s.leaveRequest);
|
|
39334
|
+
const statusActions = useSaveStatusStore((s) => s.actions);
|
|
39335
|
+
const [saving, setSaving] = useState(false);
|
|
39336
|
+
const leave = useCallback(() => {
|
|
39337
|
+
const request = useSaveStatusStore.getState().leaveRequest;
|
|
39338
|
+
statusActions.requestLeave(null);
|
|
39339
|
+
if (!request) return;
|
|
39340
|
+
const flow = useFlowStore.getState();
|
|
39341
|
+
statusActions.setBaseline({
|
|
39342
|
+
fingerprint: workflowFingerprint(flow.workflow),
|
|
39343
|
+
generation: flow.loadGeneration
|
|
39344
|
+
});
|
|
39345
|
+
navigate(request.to, request.options);
|
|
39346
|
+
}, [navigate, statusActions]);
|
|
39347
|
+
const saveAndLeave = useCallback(async () => {
|
|
39348
|
+
const request = useSaveStatusStore.getState().leaveRequest;
|
|
39349
|
+
if (!request) return;
|
|
39350
|
+
setSaving(true);
|
|
39351
|
+
try {
|
|
39352
|
+
if (!await manualSave() || !savedEverythingBeforeLeaving()) return;
|
|
39353
|
+
statusActions.requestLeave(null);
|
|
39354
|
+
navigate(request.to, request.options);
|
|
39355
|
+
} finally {
|
|
39356
|
+
setSaving(false);
|
|
39357
|
+
}
|
|
39358
|
+
}, [manualSave, navigate, statusActions]);
|
|
39359
|
+
return /* @__PURE__ */ jsx(
|
|
39360
|
+
AlertDialog,
|
|
39361
|
+
{
|
|
39362
|
+
open: leaveRequest !== null,
|
|
39363
|
+
onOpenChange: (open2) => {
|
|
39364
|
+
if (!open2 && !saving) statusActions.requestLeave(null);
|
|
39365
|
+
},
|
|
39366
|
+
children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
|
|
39367
|
+
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
39368
|
+
/* @__PURE__ */ jsx(AlertDialogTitle, { children: tr(
|
|
39369
|
+
"fluidgrids.builder.autosave.leaveDialogTitle",
|
|
39370
|
+
"Save changes before leaving?"
|
|
39371
|
+
) }),
|
|
39372
|
+
/* @__PURE__ */ jsx(AlertDialogDescription, { children: tr(
|
|
39373
|
+
"fluidgrids.builder.autosave.leaveDialogDescription",
|
|
39374
|
+
"This workflow has changes that are not saved. If you leave now, they are lost."
|
|
39375
|
+
) })
|
|
39376
|
+
] }),
|
|
39377
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
39378
|
+
/* @__PURE__ */ jsx(AlertDialogCancel, { disabled: saving, children: tr("fluidgrids.builder.autosave.stayButton", "Stay") }),
|
|
39379
|
+
/* @__PURE__ */ jsx(Button$2, { variant: "outline", onClick: leave, disabled: saving, children: tr(
|
|
39380
|
+
"fluidgrids.builder.autosave.leaveButton",
|
|
39381
|
+
"Leave without saving"
|
|
39382
|
+
) }),
|
|
39383
|
+
/* @__PURE__ */ jsx(Button$2, { onClick: () => void saveAndLeave(), disabled: saving, children: saving ? tr("fluidgrids.builder.autosave.savingButton", "Saving\u2026") : tr(
|
|
39384
|
+
"fluidgrids.builder.autosave.saveAndLeaveButton",
|
|
39385
|
+
"Save and leave"
|
|
39386
|
+
) })
|
|
39387
|
+
] })
|
|
39388
|
+
] })
|
|
39389
|
+
}
|
|
39390
|
+
);
|
|
39391
|
+
}
|
|
39392
|
+
function SaveQuotaDialog() {
|
|
39393
|
+
const navigate = useNavigate();
|
|
39394
|
+
const quotaExhausted = useSaveStatusStore((s) => s.quotaExhausted);
|
|
39395
|
+
const statusActions = useSaveStatusStore((s) => s.actions);
|
|
39396
|
+
return /* @__PURE__ */ jsx(
|
|
39397
|
+
QuotaExhaustedDialog,
|
|
39398
|
+
{
|
|
39399
|
+
surface: "builder-save",
|
|
39400
|
+
open: quotaExhausted,
|
|
39401
|
+
onOpenChange: (open2) => {
|
|
39402
|
+
if (!open2) statusActions.setQuotaExhausted(false);
|
|
39403
|
+
},
|
|
39404
|
+
onUpgrade: () => {
|
|
39405
|
+
statusActions.setQuotaExhausted(false);
|
|
39406
|
+
navigate(BILLING_PLANS_PATH);
|
|
39407
|
+
}
|
|
39408
|
+
}
|
|
39409
|
+
);
|
|
39410
|
+
}
|
|
39411
|
+
function BuilderSaveController({ readOnly }) {
|
|
39412
|
+
useAutosave(readOnly);
|
|
39413
|
+
useSaveShortcut(readOnly);
|
|
39414
|
+
useLeaveGuards(readOnly);
|
|
39415
|
+
if (readOnly) return null;
|
|
39416
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39417
|
+
/* @__PURE__ */ jsx(LeaveChangesDialog, {}),
|
|
39418
|
+
/* @__PURE__ */ jsx(SaveQuotaDialog, {})
|
|
39419
|
+
] });
|
|
39420
|
+
}
|
|
39421
|
+
|
|
39422
|
+
// src/builder/lib/header-tier.ts
|
|
39423
|
+
var HEADER_FULL_MIN_PX = 1024;
|
|
39424
|
+
var HEADER_MID_MIN_PX = 720;
|
|
39425
|
+
function headerTierFor(width) {
|
|
39426
|
+
if (width >= HEADER_FULL_MIN_PX) return "full";
|
|
39427
|
+
if (width >= HEADER_MID_MIN_PX) return "mid";
|
|
39428
|
+
return "compact";
|
|
39429
|
+
}
|
|
39430
|
+
function BuilderHeaderLayout({
|
|
39431
|
+
identity,
|
|
39432
|
+
actions
|
|
39433
|
+
}) {
|
|
39434
|
+
const ref = useRef(null);
|
|
39435
|
+
const [tier, setTier] = useState("full");
|
|
39436
|
+
useLayoutEffect(() => {
|
|
39437
|
+
const el = ref.current;
|
|
39438
|
+
if (!el) return;
|
|
39439
|
+
const update = () => setTier(headerTierFor(el.clientWidth));
|
|
39440
|
+
update();
|
|
39441
|
+
const observer = new ResizeObserver(update);
|
|
39442
|
+
observer.observe(el);
|
|
39443
|
+
return () => observer.disconnect();
|
|
39444
|
+
}, []);
|
|
39445
|
+
return (
|
|
39446
|
+
// min-h-14 (not h-14) so the identity group may wrap onto a second line
|
|
39447
|
+
// on phones instead of pushing the actions menu off-screen.
|
|
39448
|
+
/* @__PURE__ */ jsxs(
|
|
39449
|
+
Card$1,
|
|
39450
|
+
{
|
|
39451
|
+
ref,
|
|
39452
|
+
"data-testid": "fluidgrids-builder-header",
|
|
39453
|
+
"data-tier": tier,
|
|
39454
|
+
className: "min-h-14 shrink-0 border-0 from-primary/40 px-2 py-1.5 to-transparent rounded-t-xl rounded-b-none bg-gradient-to-l backdrop-blur-sm mt-2 mx-4 items-center flex gap-2 justify-between border border-card-foreground/10 border-b-0",
|
|
39455
|
+
children: [
|
|
39456
|
+
/* @__PURE__ */ jsx(
|
|
39457
|
+
"div",
|
|
39458
|
+
{
|
|
39459
|
+
className: tier === "compact" ? "flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1" : "flex min-w-0 flex-1 flex-nowrap items-center gap-2 overflow-hidden",
|
|
39460
|
+
children: identity(tier)
|
|
39461
|
+
}
|
|
39462
|
+
),
|
|
39463
|
+
/* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: actions(tier) })
|
|
39464
|
+
]
|
|
39465
|
+
}
|
|
39466
|
+
)
|
|
39467
|
+
);
|
|
39468
|
+
}
|
|
39469
|
+
var isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
39470
|
+
var SAVE_SHORTCUT = isMac ? "\u2318S" : "Ctrl+S";
|
|
39471
|
+
function StatusFrame({
|
|
39472
|
+
state,
|
|
39473
|
+
title,
|
|
39474
|
+
tone,
|
|
39475
|
+
className,
|
|
39476
|
+
children
|
|
39477
|
+
}) {
|
|
39478
|
+
return /* @__PURE__ */ jsx(
|
|
39479
|
+
"span",
|
|
39480
|
+
{
|
|
39481
|
+
role: "status",
|
|
39482
|
+
"data-testid": "fluidgrids-save-status",
|
|
39483
|
+
"data-state": state,
|
|
39484
|
+
title,
|
|
39485
|
+
className: cn$1(
|
|
39486
|
+
"inline-flex shrink-0 items-center gap-1 text-xs",
|
|
39487
|
+
tone,
|
|
39488
|
+
className
|
|
39489
|
+
),
|
|
39490
|
+
children
|
|
39491
|
+
}
|
|
39492
|
+
);
|
|
39493
|
+
}
|
|
39494
|
+
function Label3({ compact, children }) {
|
|
39495
|
+
return /* @__PURE__ */ jsx("span", { className: compact ? "sr-only" : void 0, children });
|
|
39496
|
+
}
|
|
39497
|
+
function SavingStatus({ className, compact }) {
|
|
39498
|
+
const tr = useTr();
|
|
39499
|
+
return /* @__PURE__ */ jsxs(
|
|
39500
|
+
StatusFrame,
|
|
39501
|
+
{
|
|
39502
|
+
state: "saving",
|
|
39503
|
+
tone: "text-muted-foreground",
|
|
39504
|
+
className,
|
|
39505
|
+
children: [
|
|
39506
|
+
/* @__PURE__ */ jsx(Icon, { icon: "mynaui:spinner", className: "size-3.5 animate-spin" }),
|
|
39507
|
+
/* @__PURE__ */ jsx(Label3, { compact, children: tr("fluidgrids.builder.saveStatus.saving", "Saving\u2026") })
|
|
39508
|
+
]
|
|
39509
|
+
}
|
|
39510
|
+
);
|
|
39511
|
+
}
|
|
39512
|
+
function FailedStatus({ className, compact }) {
|
|
39513
|
+
const tr = useTr();
|
|
39514
|
+
const manualSave = useManualSave();
|
|
39515
|
+
const message = useSaveStatusStore((s) => s.failure?.message);
|
|
39516
|
+
return /* @__PURE__ */ jsxs(
|
|
39517
|
+
StatusFrame,
|
|
39518
|
+
{
|
|
39519
|
+
state: "failed",
|
|
39520
|
+
title: message,
|
|
39521
|
+
tone: "text-status-error-text",
|
|
39522
|
+
className,
|
|
39523
|
+
children: [
|
|
39524
|
+
/* @__PURE__ */ jsx(Icon, { icon: "mynaui:danger-triangle", className: "size-3.5" }),
|
|
39525
|
+
/* @__PURE__ */ jsx(Label3, { compact, children: tr("fluidgrids.builder.saveStatus.failed", "Save failed") }),
|
|
39526
|
+
/* @__PURE__ */ jsx(
|
|
39527
|
+
"button",
|
|
39528
|
+
{
|
|
39529
|
+
type: "button",
|
|
39530
|
+
onClick: () => void manualSave(),
|
|
39531
|
+
className: "ml-1 rounded px-1 font-medium underline-offset-2 hover:underline",
|
|
39532
|
+
children: tr("fluidgrids.builder.saveStatus.retry", "Retry")
|
|
39533
|
+
}
|
|
39534
|
+
)
|
|
39535
|
+
]
|
|
39536
|
+
}
|
|
39537
|
+
);
|
|
39538
|
+
}
|
|
39539
|
+
function useUnsavedHint() {
|
|
39540
|
+
const tr = useTr();
|
|
39541
|
+
const [dbId, status] = useFlowStore(
|
|
39542
|
+
useShallow((s) => [s.workflow.dbId, s.workflow.status])
|
|
39543
|
+
);
|
|
39544
|
+
const [autosaveEnabled, incomplete] = useSaveStatusStore(
|
|
39545
|
+
useShallow((s) => [s.autosaveEnabled, s.incomplete])
|
|
39546
|
+
);
|
|
39547
|
+
if (!canAutosave({ dbId, status })) {
|
|
39548
|
+
return tr(
|
|
39549
|
+
"fluidgrids.builder.saveStatus.unsavedVersionHint",
|
|
39550
|
+
"This version is not a draft. Save ({{shortcut}}) to keep your changes as a new draft version.",
|
|
39551
|
+
{ shortcut: SAVE_SHORTCUT }
|
|
39552
|
+
);
|
|
39553
|
+
}
|
|
39554
|
+
if (!autosaveEnabled) {
|
|
39555
|
+
return tr(
|
|
39556
|
+
"fluidgrids.builder.saveStatus.unsavedManualHint",
|
|
39557
|
+
"Auto-save is off. Save with {{shortcut}}.",
|
|
39558
|
+
{ shortcut: SAVE_SHORTCUT }
|
|
39559
|
+
);
|
|
39560
|
+
}
|
|
39561
|
+
if (incomplete) {
|
|
39562
|
+
return tr(
|
|
39563
|
+
"fluidgrids.builder.saveStatus.unsavedIncompleteHint",
|
|
39564
|
+
"Saves once every node is connected to a trigger."
|
|
39565
|
+
);
|
|
39566
|
+
}
|
|
39567
|
+
return tr(
|
|
39568
|
+
"fluidgrids.builder.saveStatus.unsavedAutosaveHint",
|
|
39569
|
+
"Saving automatically in a moment."
|
|
39570
|
+
);
|
|
39571
|
+
}
|
|
39572
|
+
function UnsavedStatus({ className, compact }) {
|
|
39573
|
+
const tr = useTr();
|
|
39574
|
+
const hint = useUnsavedHint();
|
|
39575
|
+
const label = tr("fluidgrids.builder.saveStatus.unsaved", "Unsaved changes");
|
|
39576
|
+
return /* @__PURE__ */ jsxs(
|
|
39577
|
+
StatusFrame,
|
|
39578
|
+
{
|
|
39579
|
+
state: "unsaved",
|
|
39580
|
+
title: compact ? `${label}. ${hint}` : hint,
|
|
39581
|
+
tone: "gap-1.5 text-status-warning-text",
|
|
39582
|
+
className,
|
|
39583
|
+
children: [
|
|
39584
|
+
/* @__PURE__ */ jsx(
|
|
39585
|
+
"span",
|
|
39586
|
+
{
|
|
39587
|
+
className: cn$1(
|
|
39588
|
+
"rounded-full bg-current",
|
|
39589
|
+
compact ? "size-2" : "size-1.5"
|
|
39590
|
+
),
|
|
39591
|
+
"aria-hidden": true
|
|
39592
|
+
}
|
|
39593
|
+
),
|
|
39594
|
+
/* @__PURE__ */ jsx(Label3, { compact, children: label })
|
|
39595
|
+
]
|
|
39596
|
+
}
|
|
39597
|
+
);
|
|
39598
|
+
}
|
|
39599
|
+
function SavedStatus({
|
|
39600
|
+
className,
|
|
39601
|
+
compact,
|
|
39602
|
+
savedAt
|
|
39603
|
+
}) {
|
|
39604
|
+
const tr = useTr();
|
|
39605
|
+
return /* @__PURE__ */ jsxs(
|
|
39606
|
+
StatusFrame,
|
|
39607
|
+
{
|
|
39608
|
+
state: "saved",
|
|
39609
|
+
title: tr("fluidgrids.builder.saveStatus.savedAt", "Saved at {{time}}", {
|
|
39610
|
+
time: new Date(savedAt).toLocaleTimeString()
|
|
39611
|
+
}),
|
|
39612
|
+
tone: "text-muted-foreground",
|
|
39613
|
+
className,
|
|
39614
|
+
children: [
|
|
39615
|
+
/* @__PURE__ */ jsx(Icon, { icon: "mynaui:check-circle", className: "size-3.5" }),
|
|
39616
|
+
/* @__PURE__ */ jsx(Label3, { compact, children: tr("fluidgrids.builder.saveStatus.saved", "Saved") })
|
|
39617
|
+
]
|
|
39618
|
+
}
|
|
39619
|
+
);
|
|
39620
|
+
}
|
|
39621
|
+
function SaveStatusIndicator({
|
|
39622
|
+
className,
|
|
39623
|
+
compact = false
|
|
39624
|
+
}) {
|
|
39625
|
+
const state = useSaveStatusStore(
|
|
39626
|
+
useShallow((s) => ({
|
|
39627
|
+
saving: s.saving,
|
|
39628
|
+
dirty: s.dirty,
|
|
39629
|
+
failure: s.failure,
|
|
39630
|
+
lastSavedAt: s.lastSavedAt
|
|
39631
|
+
}))
|
|
39632
|
+
);
|
|
39633
|
+
const props = { className, compact };
|
|
39634
|
+
switch (saveIndicatorOf(state)) {
|
|
39635
|
+
case "saving":
|
|
39636
|
+
return /* @__PURE__ */ jsx(SavingStatus, { ...props });
|
|
39637
|
+
case "failed":
|
|
39638
|
+
return /* @__PURE__ */ jsx(FailedStatus, { ...props });
|
|
39639
|
+
case "unsaved":
|
|
39640
|
+
return /* @__PURE__ */ jsx(UnsavedStatus, { ...props });
|
|
39641
|
+
case "saved":
|
|
39642
|
+
return /* @__PURE__ */ jsx(SavedStatus, { ...props, savedAt: state.lastSavedAt ?? 0 });
|
|
39643
|
+
default:
|
|
39644
|
+
return null;
|
|
39645
|
+
}
|
|
39646
|
+
}
|
|
39647
|
+
var SaveFlowButton = ({ className }) => {
|
|
39648
|
+
const tr = useTr();
|
|
39649
|
+
const { saveToBackend, isSaving } = useSaveWorkflow();
|
|
39650
|
+
const [isValidating, validateFlow] = useFlowValidator(async (isValid) => {
|
|
39651
|
+
if (isValid) {
|
|
39652
|
+
await saveToBackend();
|
|
39653
|
+
} else {
|
|
39654
|
+
toast.error(
|
|
39655
|
+
tr(
|
|
39656
|
+
"fluidgrids.builder.saveFlowButton.invalidToastTitle",
|
|
39657
|
+
"Flow is invalid"
|
|
39658
|
+
),
|
|
39659
|
+
{
|
|
39660
|
+
description: tr(
|
|
39661
|
+
"fluidgrids.builder.saveFlowButton.invalidToastDescription",
|
|
39662
|
+
"Please check if the flow is complete and has no lone nodes"
|
|
39663
|
+
)
|
|
39664
|
+
}
|
|
39665
|
+
);
|
|
39666
|
+
}
|
|
39667
|
+
});
|
|
39668
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
39669
|
+
SdkPermissionButton,
|
|
39670
|
+
{
|
|
39671
|
+
permission: [
|
|
39672
|
+
FLUIDGRIDS_PERMISSIONS.WORKFLOW_UPDATE,
|
|
39673
|
+
FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE
|
|
39674
|
+
],
|
|
39675
|
+
deniedTooltip: tr(
|
|
39676
|
+
"fluidgrids.builder.saveFlowButton.permissionDeniedTooltip",
|
|
39677
|
+
"You don't have permission to save workflows"
|
|
39678
|
+
),
|
|
39679
|
+
children: /* @__PURE__ */ jsxs(
|
|
39680
|
+
Button$1,
|
|
39681
|
+
{
|
|
39682
|
+
"data-tour": "fluidgrids-builder-save",
|
|
39683
|
+
onClick: validateFlow,
|
|
39684
|
+
disabled: isValidating || isSaving,
|
|
39685
|
+
variant: "outline",
|
|
39686
|
+
size: "sm",
|
|
39687
|
+
className: cn$1("flex gap-4", className),
|
|
39688
|
+
children: [
|
|
39689
|
+
/* @__PURE__ */ jsx(Icon, { icon: "fluent:save-28-filled" }),
|
|
39690
|
+
isSaving ? tr("fluidgrids.builder.saveFlowButton.savingLabel", "Saving...") : tr("fluidgrids.builder.saveFlowButton.saveLabel", "Save")
|
|
39691
|
+
]
|
|
39692
|
+
}
|
|
39693
|
+
)
|
|
39694
|
+
}
|
|
39695
|
+
) });
|
|
39696
|
+
};
|
|
39697
|
+
var PLACEHOLDER_JSON = `{
|
|
39698
|
+
"message": "Hello, what can you help me with?",
|
|
39699
|
+
"agentName": "faq_agent"
|
|
39700
|
+
}`;
|
|
39701
|
+
function TriggerDataDialog({
|
|
39702
|
+
open: open2,
|
|
39703
|
+
onOpenChange,
|
|
39704
|
+
onExecute,
|
|
39705
|
+
isExecuting
|
|
39706
|
+
}) {
|
|
39707
|
+
const [jsonValue, setJsonValue] = useState("");
|
|
39708
|
+
const [parseError, setParseError] = useState(null);
|
|
39709
|
+
const [submitted, setSubmitted] = useState(false);
|
|
39710
|
+
useEffect(() => {
|
|
39711
|
+
if (!open2) {
|
|
39712
|
+
setJsonValue("");
|
|
39713
|
+
setParseError(null);
|
|
39714
|
+
setSubmitted(false);
|
|
39715
|
+
} else {
|
|
39716
|
+
setParseError(null);
|
|
39717
|
+
}
|
|
39718
|
+
}, [open2]);
|
|
39719
|
+
useEffect(() => {
|
|
39720
|
+
if (submitted && isExecuting) {
|
|
39721
|
+
onOpenChange(false);
|
|
39722
|
+
setSubmitted(false);
|
|
39723
|
+
}
|
|
39724
|
+
}, [submitted, isExecuting, onOpenChange]);
|
|
39725
|
+
const handleExecute = useCallback(() => {
|
|
39726
|
+
const valueToparse = jsonValue.trim() || "{}";
|
|
39727
|
+
try {
|
|
39728
|
+
const parsed = JSON.parse(valueToparse);
|
|
39729
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
39730
|
+
setParseError(
|
|
39731
|
+
"Trigger data must be a JSON object (not an array or primitive)"
|
|
39732
|
+
);
|
|
39733
|
+
return;
|
|
39734
|
+
}
|
|
39735
|
+
setParseError(null);
|
|
39736
|
+
setSubmitted(true);
|
|
39737
|
+
onExecute(parsed);
|
|
39738
|
+
} catch {
|
|
39739
|
+
setParseError("Invalid JSON. Please check your syntax.");
|
|
39740
|
+
}
|
|
39741
|
+
}, [jsonValue, onExecute]);
|
|
39742
|
+
const handleRunEmpty = useCallback(() => {
|
|
39743
|
+
setParseError(null);
|
|
39744
|
+
setSubmitted(true);
|
|
39745
|
+
onExecute({});
|
|
39746
|
+
}, [onExecute]);
|
|
39747
|
+
return /* @__PURE__ */ jsx(Dialog$1, { open: open2, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent$1, { className: "sm:max-w-lg", children: [
|
|
39748
|
+
/* @__PURE__ */ jsxs(DialogHeader$1, { children: [
|
|
39749
|
+
/* @__PURE__ */ jsxs(DialogTitle$1, { className: "flex items-center gap-2", children: [
|
|
39750
|
+
/* @__PURE__ */ jsx(
|
|
39751
|
+
Icon,
|
|
39752
|
+
{
|
|
39753
|
+
icon: "mdi:play-circle-outline",
|
|
39754
|
+
className: "size-5 text-[var(--color-status-success-text)]"
|
|
39755
|
+
}
|
|
39756
|
+
),
|
|
39757
|
+
"Execute Workflow"
|
|
39758
|
+
] }),
|
|
39759
|
+
/* @__PURE__ */ jsx(DialogDescription$1, { children: "Provide the trigger data (JSON) that will be passed to the first node in the workflow. This is the input your workflow will process." })
|
|
39760
|
+
] }),
|
|
39761
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
39762
|
+
/* @__PURE__ */ jsx(
|
|
39763
|
+
"label",
|
|
39764
|
+
{
|
|
39765
|
+
htmlFor: "trigger-data-json",
|
|
39766
|
+
className: "text-sm font-medium text-foreground",
|
|
39767
|
+
children: "Trigger Data (JSON)"
|
|
39768
|
+
}
|
|
39769
|
+
),
|
|
39770
|
+
/* @__PURE__ */ jsx(
|
|
39771
|
+
"textarea",
|
|
39772
|
+
{
|
|
39773
|
+
id: "trigger-data-json",
|
|
39774
|
+
value: jsonValue,
|
|
39775
|
+
onChange: (e) => {
|
|
39776
|
+
setJsonValue(e.target.value);
|
|
39777
|
+
setParseError(null);
|
|
39778
|
+
},
|
|
39779
|
+
className: "w-full h-48 rounded-md border border-input bg-background px-3 py-2 text-sm font-mono ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 resize-y",
|
|
39780
|
+
placeholder: PLACEHOLDER_JSON,
|
|
39781
|
+
spellCheck: false
|
|
39782
|
+
}
|
|
39783
|
+
),
|
|
39784
|
+
parseError && /* @__PURE__ */ jsx("p", { className: "text-sm text-[var(--color-status-error-text)]", children: parseError }),
|
|
39785
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
39786
|
+
"This data is available to nodes as trigger input. For example, a Botlit node expects",
|
|
39787
|
+
" ",
|
|
39788
|
+
/* @__PURE__ */ jsx("code", { className: "bg-muted px-1 rounded", children: "message" }),
|
|
39789
|
+
" and",
|
|
39790
|
+
" ",
|
|
39791
|
+
/* @__PURE__ */ jsx("code", { className: "bg-muted px-1 rounded", children: "agentName" }),
|
|
39792
|
+
". A Web Scraper node expects",
|
|
39793
|
+
" ",
|
|
39794
|
+
/* @__PURE__ */ jsx("code", { className: "bg-muted px-1 rounded", children: "url" }),
|
|
39795
|
+
"."
|
|
39796
|
+
] })
|
|
39797
|
+
] }),
|
|
39798
|
+
/* @__PURE__ */ jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [
|
|
39799
|
+
/* @__PURE__ */ jsx(
|
|
39800
|
+
Button$1,
|
|
39801
|
+
{
|
|
39802
|
+
variant: "outline",
|
|
39803
|
+
size: "sm",
|
|
39804
|
+
onClick: handleRunEmpty,
|
|
39805
|
+
disabled: isExecuting,
|
|
39806
|
+
children: "Run Empty"
|
|
39807
|
+
}
|
|
39808
|
+
),
|
|
39809
|
+
/* @__PURE__ */ jsxs(
|
|
39810
|
+
Button$1,
|
|
39811
|
+
{
|
|
39812
|
+
variant: "default",
|
|
39813
|
+
size: "sm",
|
|
39814
|
+
onClick: handleExecute,
|
|
39815
|
+
disabled: isExecuting,
|
|
39816
|
+
className: "bg-[var(--color-status-success-bg)] hover:bg-[var(--color-status-success-bg)]/90 text-[var(--color-text-on-status)]",
|
|
39817
|
+
children: [
|
|
39818
|
+
/* @__PURE__ */ jsx(Icon, { icon: "mdi:play", className: "size-4 mr-1" }),
|
|
39819
|
+
isExecuting ? "Running..." : "Execute"
|
|
39820
|
+
]
|
|
39821
|
+
}
|
|
39822
|
+
)
|
|
39823
|
+
] })
|
|
39824
|
+
] }) });
|
|
39825
|
+
}
|
|
39826
|
+
var ExecuteWorkflowButton = ({
|
|
39827
|
+
className
|
|
39828
|
+
}) => {
|
|
39829
|
+
const tr = useTr();
|
|
39830
|
+
const { executeFullWorkflow } = useNodeExecution();
|
|
39831
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
39832
|
+
const [isExecuting] = useFlowStore(
|
|
39833
|
+
useShallow((s) => [s.execution.isExecuting])
|
|
39834
|
+
);
|
|
39835
|
+
const executeWorkflow = useCallback(
|
|
39836
|
+
async (triggerData) => {
|
|
39837
|
+
try {
|
|
39838
|
+
const result = await executeFullWorkflow(triggerData);
|
|
39839
|
+
if (result.success) {
|
|
39840
|
+
toast.success(
|
|
39841
|
+
tr(
|
|
39842
|
+
"fluidgrids.builder.executeWorkflowButton.executionStartedToast",
|
|
39843
|
+
"Workflow execution started"
|
|
39844
|
+
),
|
|
39845
|
+
{
|
|
39846
|
+
description: `Run ID: ${result.runId}`,
|
|
39847
|
+
dismissible: true
|
|
39848
|
+
}
|
|
39849
|
+
);
|
|
39850
|
+
} else if ("quotaExhausted" in result && result.quotaExhausted) {
|
|
39851
|
+
setDialogOpen(false);
|
|
39852
|
+
} else {
|
|
39853
|
+
throw new Error(result.error || "Failed to trigger workflow");
|
|
39854
|
+
}
|
|
39855
|
+
} catch (error62) {
|
|
39856
|
+
const message = error62 instanceof Error ? error62.message : tr(
|
|
39857
|
+
"fluidgrids.builder.executeWorkflowButton.unknownError",
|
|
39858
|
+
"Unknown error"
|
|
39859
|
+
);
|
|
39860
|
+
console.error("[ExecuteWorkflowButton] Error:", message);
|
|
39861
|
+
toast.error(
|
|
39862
|
+
tr(
|
|
39863
|
+
"fluidgrids.builder.executeWorkflowButton.executeFailedToast",
|
|
39864
|
+
"Failed to execute workflow"
|
|
39865
|
+
),
|
|
39866
|
+
{
|
|
39867
|
+
description: message
|
|
39868
|
+
}
|
|
39869
|
+
);
|
|
39870
|
+
}
|
|
39871
|
+
},
|
|
39872
|
+
[executeFullWorkflow, tr]
|
|
39873
|
+
);
|
|
39874
|
+
const [isValidating, validateFlow] = useFlowValidator(async (isValid) => {
|
|
39875
|
+
if (isValid) {
|
|
39876
|
+
setDialogOpen(true);
|
|
39877
|
+
} else {
|
|
39878
|
+
toast.error(
|
|
39879
|
+
tr(
|
|
39880
|
+
"fluidgrids.builder.executeWorkflowButton.invalidToastTitle",
|
|
39881
|
+
"Flow is invalid"
|
|
39882
|
+
),
|
|
39883
|
+
{
|
|
39884
|
+
description: tr(
|
|
39885
|
+
"fluidgrids.builder.executeWorkflowButton.invalidToastDescription",
|
|
39886
|
+
"Please fix the flow before executing. Ensure trigger node is connected."
|
|
39887
|
+
)
|
|
39888
|
+
}
|
|
39889
|
+
);
|
|
39890
|
+
}
|
|
39891
|
+
});
|
|
39892
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39893
|
+
/* @__PURE__ */ jsx(
|
|
39894
|
+
SdkPermissionButton,
|
|
39895
|
+
{
|
|
39896
|
+
permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_EXECUTE,
|
|
39897
|
+
deniedTooltip: tr(
|
|
39898
|
+
"fluidgrids.builder.executeWorkflowButton.permissionDeniedTooltip",
|
|
39899
|
+
"You don't have permission to execute workflows"
|
|
39900
|
+
),
|
|
39901
|
+
children: /* @__PURE__ */ jsxs(
|
|
39902
|
+
Button$1,
|
|
39903
|
+
{
|
|
39904
|
+
onClick: validateFlow,
|
|
39905
|
+
disabled: isValidating || isExecuting,
|
|
39906
|
+
variant: "default",
|
|
39907
|
+
size: "sm",
|
|
39908
|
+
className: cn$1(
|
|
39909
|
+
"flex items-center justify-center gap-2 h-8 rounded-l-lg rounded-r-none px-3 bg-[var(--color-status-success-bg)] hover:bg-[var(--color-status-success-bg)]/90 text-[var(--color-text-on-status)] font-medium",
|
|
39910
|
+
className
|
|
39911
|
+
),
|
|
39912
|
+
children: [
|
|
39913
|
+
/* @__PURE__ */ jsx(Icon, { icon: "mdi:play", className: "size-4" }),
|
|
39914
|
+
isExecuting ? tr(
|
|
39915
|
+
"fluidgrids.builder.executeWorkflowButton.runningLabel",
|
|
39916
|
+
"Running..."
|
|
39917
|
+
) : isValidating ? tr(
|
|
39918
|
+
"fluidgrids.builder.executeWorkflowButton.validatingLabel",
|
|
39919
|
+
"Validating..."
|
|
39920
|
+
) : tr("fluidgrids.builder.executeWorkflowButton.runLabel", "Run")
|
|
39921
|
+
]
|
|
39922
|
+
}
|
|
39923
|
+
)
|
|
39924
|
+
}
|
|
39925
|
+
),
|
|
39926
|
+
/* @__PURE__ */ jsx(
|
|
39927
|
+
TriggerDataDialog,
|
|
39928
|
+
{
|
|
39929
|
+
open: dialogOpen,
|
|
39930
|
+
onOpenChange: setDialogOpen,
|
|
39931
|
+
onExecute: executeWorkflow,
|
|
39932
|
+
isExecuting
|
|
39933
|
+
}
|
|
39934
|
+
)
|
|
39935
|
+
] });
|
|
39936
|
+
};
|
|
39937
|
+
var ActivateWorkflowButton = ({
|
|
39938
|
+
className
|
|
39939
|
+
}) => {
|
|
39940
|
+
const [isProcessing, setIsProcessing] = useState(false);
|
|
39941
|
+
const [dbId, status, setWorkflow] = useFlowStore(
|
|
39942
|
+
useShallow((s) => [
|
|
39943
|
+
s.workflow.dbId,
|
|
39944
|
+
s.workflow.status,
|
|
39945
|
+
s.actions.setWorkflow
|
|
39946
|
+
])
|
|
39947
|
+
);
|
|
39948
|
+
const { activateWorkflow } = useActivateWorkflow();
|
|
39949
|
+
const { deactivateWorkflow } = useDeactivateWorkflow();
|
|
39950
|
+
const isDraft = !status || status === "DRAFT";
|
|
39951
|
+
const handleToggle = async () => {
|
|
39952
|
+
if (!dbId) {
|
|
39953
|
+
toast.error("Please save the workflow first before activating.");
|
|
39954
|
+
return;
|
|
39955
|
+
}
|
|
39956
|
+
setIsProcessing(true);
|
|
39957
|
+
try {
|
|
39958
|
+
if (isDraft) {
|
|
39959
|
+
const result = await activateWorkflow(dbId, {
|
|
39960
|
+
definition: useFlowStore.getState().workflow
|
|
39961
|
+
});
|
|
39962
|
+
if (result) {
|
|
39963
|
+
setWorkflow({ status: result.status });
|
|
39964
|
+
toast.success("Workflow activated", {
|
|
39965
|
+
description: `Version ${result.version} is now ACTIVE. Future saves will create a new draft version.`,
|
|
39966
|
+
dismissible: true
|
|
39967
|
+
});
|
|
39968
|
+
}
|
|
39969
|
+
} else {
|
|
39970
|
+
const result = await deactivateWorkflow(dbId);
|
|
39971
|
+
if (result) {
|
|
39972
|
+
setWorkflow({ status: result.status });
|
|
39973
|
+
toast.success("Workflow deactivated", {
|
|
39974
|
+
description: `Version ${result.version} is now a DRAFT. Saves will update in-place.`,
|
|
39975
|
+
dismissible: true
|
|
39976
|
+
});
|
|
39977
|
+
}
|
|
39978
|
+
}
|
|
39979
|
+
} catch (error62) {
|
|
39980
|
+
const message = error62 instanceof Error ? error62.message : "Unknown error";
|
|
39981
|
+
toast.error(isDraft ? "Failed to activate" : "Failed to deactivate", {
|
|
39982
|
+
description: message
|
|
39983
|
+
});
|
|
39984
|
+
} finally {
|
|
39985
|
+
setIsProcessing(false);
|
|
39986
|
+
}
|
|
39987
|
+
};
|
|
39988
|
+
return /* @__PURE__ */ jsxs(
|
|
39989
|
+
Button$1,
|
|
39990
|
+
{
|
|
39991
|
+
"data-tour": "fluidgrids-builder-activate",
|
|
39992
|
+
onClick: handleToggle,
|
|
39993
|
+
disabled: isProcessing || !dbId,
|
|
39994
|
+
variant: isDraft ? "default" : "outline",
|
|
39995
|
+
size: "sm",
|
|
39996
|
+
className: cn$1(
|
|
39997
|
+
"flex gap-1",
|
|
39998
|
+
isDraft && "bg-status-success-bg hover:bg-status-success-bg/90 text-action-primary-text",
|
|
39999
|
+
className
|
|
40000
|
+
),
|
|
40001
|
+
children: [
|
|
40002
|
+
/* @__PURE__ */ jsx(
|
|
40003
|
+
Icon,
|
|
40004
|
+
{
|
|
40005
|
+
icon: isDraft ? "mynaui:check-circle" : "mynaui:pause-circle",
|
|
40006
|
+
className: "size-4"
|
|
40007
|
+
}
|
|
40008
|
+
),
|
|
40009
|
+
isProcessing ? "Processing..." : isDraft ? "Activate" : "Deactivate"
|
|
40010
|
+
]
|
|
40011
|
+
}
|
|
40012
|
+
);
|
|
40013
|
+
};
|
|
40014
|
+
|
|
39195
40015
|
// src/utils/workflow-definition-diff.ts
|
|
39196
40016
|
function isRecord3(value) {
|
|
39197
40017
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -39333,7 +40153,10 @@ function ActionButton({
|
|
|
39333
40153
|
/* @__PURE__ */ jsx(TooltipContent, { className: "z-[130]", children: label })
|
|
39334
40154
|
] });
|
|
39335
40155
|
}
|
|
39336
|
-
function VersionHistoryPanel({
|
|
40156
|
+
function VersionHistoryPanel({
|
|
40157
|
+
className,
|
|
40158
|
+
compact = false
|
|
40159
|
+
}) {
|
|
39337
40160
|
const tr = useTr();
|
|
39338
40161
|
const STATUS_STYLES = {
|
|
39339
40162
|
DRAFT: {
|
|
@@ -39357,7 +40180,7 @@ function VersionHistoryPanel({ className }) {
|
|
|
39357
40180
|
}
|
|
39358
40181
|
};
|
|
39359
40182
|
const params = useParams();
|
|
39360
|
-
const navigate =
|
|
40183
|
+
const navigate = useGuardedNavigate();
|
|
39361
40184
|
const workflowKey = params?.id ?? "";
|
|
39362
40185
|
const currentVersion = params?.version ?? "";
|
|
39363
40186
|
const { versions, loading, refetch } = useWorkflowVersions(workflowKey);
|
|
@@ -39543,12 +40366,20 @@ function VersionHistoryPanel({ className }) {
|
|
|
39543
40366
|
{
|
|
39544
40367
|
"data-tour": "fluidgrids-builder-versions",
|
|
39545
40368
|
variant: "outline",
|
|
39546
|
-
size: "sm",
|
|
39547
|
-
className: cn$1("flex gap-1", className),
|
|
40369
|
+
size: compact ? "icon" : "sm",
|
|
40370
|
+
className: cn$1(!compact && "flex gap-1", className),
|
|
40371
|
+
"aria-label": tr(
|
|
40372
|
+
"fluidgrids.builder.versionHistory.triggerButton",
|
|
40373
|
+
"Versions"
|
|
40374
|
+
),
|
|
40375
|
+
title: compact ? tr(
|
|
40376
|
+
"fluidgrids.builder.versionHistory.triggerButton",
|
|
40377
|
+
"Versions"
|
|
40378
|
+
) : void 0,
|
|
39548
40379
|
onClick: () => refetch(),
|
|
39549
40380
|
children: [
|
|
39550
40381
|
/* @__PURE__ */ jsx(History, { className: "size-4" }),
|
|
39551
|
-
tr("fluidgrids.builder.versionHistory.triggerButton", "Versions")
|
|
40382
|
+
!compact && tr("fluidgrids.builder.versionHistory.triggerButton", "Versions")
|
|
39552
40383
|
]
|
|
39553
40384
|
}
|
|
39554
40385
|
) }),
|
|
@@ -40338,6 +41169,10 @@ function EnvironmentsPanel({
|
|
|
40338
41169
|
"fluidgrids.builder.environments.triggerButton",
|
|
40339
41170
|
"Environments"
|
|
40340
41171
|
),
|
|
41172
|
+
title: compact ? tr(
|
|
41173
|
+
"fluidgrids.builder.environments.triggerButton",
|
|
41174
|
+
"Environments"
|
|
41175
|
+
) : void 0,
|
|
40341
41176
|
disabled: !workflowKey,
|
|
40342
41177
|
children: [
|
|
40343
41178
|
/* @__PURE__ */ jsx(Layers, { className: "size-4" }),
|
|
@@ -40980,7 +41815,7 @@ function GitSyncPanel({
|
|
|
40980
41815
|
compact = false
|
|
40981
41816
|
}) {
|
|
40982
41817
|
const tr = useTr();
|
|
40983
|
-
const navigate =
|
|
41818
|
+
const navigate = useGuardedNavigate();
|
|
40984
41819
|
const params = useParams();
|
|
40985
41820
|
const workflowKey = params?.id ?? "";
|
|
40986
41821
|
const currentVersion = params?.version ?? "";
|
|
@@ -41243,7 +42078,7 @@ function GitSyncPanel({
|
|
|
41243
42078
|
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
41244
42079
|
/* @__PURE__ */ jsx(Label, { htmlFor: "fg-git-repository", className: "text-xs", children: tr("fluidgrids.builder.git.repository", "Repository") }),
|
|
41245
42080
|
/* @__PURE__ */ jsx(
|
|
41246
|
-
Input,
|
|
42081
|
+
Input$1,
|
|
41247
42082
|
{
|
|
41248
42083
|
id: "fg-git-repository",
|
|
41249
42084
|
className: "h-8 font-mono text-xs",
|
|
@@ -41257,7 +42092,7 @@ function GitSyncPanel({
|
|
|
41257
42092
|
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
41258
42093
|
/* @__PURE__ */ jsx(Label, { htmlFor: "fg-git-branch", className: "text-xs", children: tr("fluidgrids.builder.git.branch", "Branch") }),
|
|
41259
42094
|
/* @__PURE__ */ jsx(
|
|
41260
|
-
Input,
|
|
42095
|
+
Input$1,
|
|
41261
42096
|
{
|
|
41262
42097
|
id: "fg-git-branch",
|
|
41263
42098
|
className: "h-8 font-mono text-xs",
|
|
@@ -41269,7 +42104,7 @@ function GitSyncPanel({
|
|
|
41269
42104
|
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
41270
42105
|
/* @__PURE__ */ jsx(Label, { htmlFor: "fg-git-folder", className: "text-xs", children: tr("fluidgrids.builder.git.folder", "Folder") }),
|
|
41271
42106
|
/* @__PURE__ */ jsx(
|
|
41272
|
-
Input,
|
|
42107
|
+
Input$1,
|
|
41273
42108
|
{
|
|
41274
42109
|
id: "fg-git-folder",
|
|
41275
42110
|
className: "h-8 font-mono text-xs",
|
|
@@ -41357,6 +42192,7 @@ function GitSyncPanel({
|
|
|
41357
42192
|
size: compact ? "icon" : "sm",
|
|
41358
42193
|
className: cn$1(!compact && "flex gap-1", className),
|
|
41359
42194
|
"aria-label": tr("fluidgrids.builder.git.triggerButton", "Git"),
|
|
42195
|
+
title: compact ? tr("fluidgrids.builder.git.triggerButton", "Git") : void 0,
|
|
41360
42196
|
disabled: !workflowKey,
|
|
41361
42197
|
children: [
|
|
41362
42198
|
/* @__PURE__ */ jsx(GitBranch, { className: "size-4" }),
|
|
@@ -42297,83 +43133,6 @@ function AiDraftPanel({
|
|
|
42297
43133
|
] }) })
|
|
42298
43134
|
] });
|
|
42299
43135
|
}
|
|
42300
|
-
var ActivateWorkflowButton = ({
|
|
42301
|
-
className
|
|
42302
|
-
}) => {
|
|
42303
|
-
const [isProcessing, setIsProcessing] = useState(false);
|
|
42304
|
-
const [dbId, status, setWorkflow] = useFlowStore(
|
|
42305
|
-
useShallow((s) => [
|
|
42306
|
-
s.workflow.dbId,
|
|
42307
|
-
s.workflow.status,
|
|
42308
|
-
s.actions.setWorkflow
|
|
42309
|
-
])
|
|
42310
|
-
);
|
|
42311
|
-
const { activateWorkflow } = useActivateWorkflow();
|
|
42312
|
-
const { deactivateWorkflow } = useDeactivateWorkflow();
|
|
42313
|
-
const isDraft = !status || status === "DRAFT";
|
|
42314
|
-
const handleToggle = async () => {
|
|
42315
|
-
if (!dbId) {
|
|
42316
|
-
toast.error("Please save the workflow first before activating.");
|
|
42317
|
-
return;
|
|
42318
|
-
}
|
|
42319
|
-
setIsProcessing(true);
|
|
42320
|
-
try {
|
|
42321
|
-
if (isDraft) {
|
|
42322
|
-
const result = await activateWorkflow(dbId, {
|
|
42323
|
-
definition: useFlowStore.getState().workflow
|
|
42324
|
-
});
|
|
42325
|
-
if (result) {
|
|
42326
|
-
setWorkflow({ status: result.status });
|
|
42327
|
-
toast.success("Workflow activated", {
|
|
42328
|
-
description: `Version ${result.version} is now ACTIVE. Future saves will create a new draft version.`,
|
|
42329
|
-
dismissible: true
|
|
42330
|
-
});
|
|
42331
|
-
}
|
|
42332
|
-
} else {
|
|
42333
|
-
const result = await deactivateWorkflow(dbId);
|
|
42334
|
-
if (result) {
|
|
42335
|
-
setWorkflow({ status: result.status });
|
|
42336
|
-
toast.success("Workflow deactivated", {
|
|
42337
|
-
description: `Version ${result.version} is now a DRAFT. Saves will update in-place.`,
|
|
42338
|
-
dismissible: true
|
|
42339
|
-
});
|
|
42340
|
-
}
|
|
42341
|
-
}
|
|
42342
|
-
} catch (error62) {
|
|
42343
|
-
const message = error62 instanceof Error ? error62.message : "Unknown error";
|
|
42344
|
-
toast.error(isDraft ? "Failed to activate" : "Failed to deactivate", {
|
|
42345
|
-
description: message
|
|
42346
|
-
});
|
|
42347
|
-
} finally {
|
|
42348
|
-
setIsProcessing(false);
|
|
42349
|
-
}
|
|
42350
|
-
};
|
|
42351
|
-
return /* @__PURE__ */ jsxs(
|
|
42352
|
-
Button$1,
|
|
42353
|
-
{
|
|
42354
|
-
"data-tour": "fluidgrids-builder-activate",
|
|
42355
|
-
onClick: handleToggle,
|
|
42356
|
-
disabled: isProcessing || !dbId,
|
|
42357
|
-
variant: isDraft ? "default" : "outline",
|
|
42358
|
-
size: "sm",
|
|
42359
|
-
className: cn$1(
|
|
42360
|
-
"flex gap-1",
|
|
42361
|
-
isDraft && "bg-status-success-bg hover:bg-status-success-bg/90 text-action-primary-text",
|
|
42362
|
-
className
|
|
42363
|
-
),
|
|
42364
|
-
children: [
|
|
42365
|
-
/* @__PURE__ */ jsx(
|
|
42366
|
-
Icon,
|
|
42367
|
-
{
|
|
42368
|
-
icon: isDraft ? "mynaui:check-circle" : "mynaui:pause-circle",
|
|
42369
|
-
className: "size-4"
|
|
42370
|
-
}
|
|
42371
|
-
),
|
|
42372
|
-
isProcessing ? "Processing..." : isDraft ? "Activate" : "Deactivate"
|
|
42373
|
-
]
|
|
42374
|
-
}
|
|
42375
|
-
);
|
|
42376
|
-
};
|
|
42377
43136
|
function RunWithViewRuns({
|
|
42378
43137
|
onViewRuns,
|
|
42379
43138
|
canViewRuns,
|
|
@@ -42411,6 +43170,301 @@ function RunWithViewRuns({
|
|
|
42411
43170
|
}
|
|
42412
43171
|
);
|
|
42413
43172
|
}
|
|
43173
|
+
function WorkflowNameField({
|
|
43174
|
+
value,
|
|
43175
|
+
onChange
|
|
43176
|
+
}) {
|
|
43177
|
+
const tr = useTr();
|
|
43178
|
+
const [editing, setEditing] = useState(false);
|
|
43179
|
+
const shown = value || tr("fluidgrids.builder.flowBuilder.untitledWorkflow", "Untitled Workflow");
|
|
43180
|
+
if (editing) {
|
|
43181
|
+
return /* @__PURE__ */ jsx(
|
|
43182
|
+
Input$1,
|
|
43183
|
+
{
|
|
43184
|
+
autoFocus: true,
|
|
43185
|
+
onFocus: (e) => e.currentTarget.select(),
|
|
43186
|
+
className: "h-8 min-w-0 max-w-full text-card-foreground font-bold",
|
|
43187
|
+
style: {
|
|
43188
|
+
width: `${Math.min(Math.max(value.length + 4, 16), 60)}ch`
|
|
43189
|
+
},
|
|
43190
|
+
type: "text",
|
|
43191
|
+
placeholder: tr(
|
|
43192
|
+
"fluidgrids.builder.flowBuilder.workflowNamePlaceholder",
|
|
43193
|
+
"Workflow Name"
|
|
43194
|
+
),
|
|
43195
|
+
value,
|
|
43196
|
+
onChange: (e) => onChange(e.target.value),
|
|
43197
|
+
onBlur: () => setEditing(false),
|
|
43198
|
+
onKeyDown: (e) => {
|
|
43199
|
+
if (e.key === "Enter" || e.key === "Escape") setEditing(false);
|
|
43200
|
+
}
|
|
43201
|
+
}
|
|
43202
|
+
);
|
|
43203
|
+
}
|
|
43204
|
+
return /* @__PURE__ */ jsx(
|
|
43205
|
+
"button",
|
|
43206
|
+
{
|
|
43207
|
+
type: "button",
|
|
43208
|
+
"data-tour": "fluidgrids-builder-workflow-name",
|
|
43209
|
+
title: `${value || "Untitled Workflow"} \u2014 click to rename`,
|
|
43210
|
+
className: "-mx-1 min-w-0 shrink cursor-text truncate rounded px-1 text-left font-bold text-card-foreground transition-colors hover:bg-card-foreground/10 sm:max-w-[24rem]",
|
|
43211
|
+
onClick: () => setEditing(true),
|
|
43212
|
+
children: shown
|
|
43213
|
+
}
|
|
43214
|
+
);
|
|
43215
|
+
}
|
|
43216
|
+
function VersionAliasChip({
|
|
43217
|
+
value,
|
|
43218
|
+
onChange,
|
|
43219
|
+
iconOnly
|
|
43220
|
+
}) {
|
|
43221
|
+
const tr = useTr();
|
|
43222
|
+
const [editing, setEditing] = useState(false);
|
|
43223
|
+
const addLabel = tr("fluidgrids.builder.flowBuilder.addAlias", "Add alias");
|
|
43224
|
+
if (editing) {
|
|
43225
|
+
return /* @__PURE__ */ jsx(
|
|
43226
|
+
Input$1,
|
|
43227
|
+
{
|
|
43228
|
+
autoFocus: true,
|
|
43229
|
+
className: "h-7 w-40 shrink-0 text-xs text-card-foreground",
|
|
43230
|
+
type: "text",
|
|
43231
|
+
"aria-label": tr(
|
|
43232
|
+
"fluidgrids.builder.flowBuilder.versionAliasLabel",
|
|
43233
|
+
"Version alias"
|
|
43234
|
+
),
|
|
43235
|
+
placeholder: tr(
|
|
43236
|
+
"fluidgrids.builder.flowBuilder.versionAliasPlaceholder",
|
|
43237
|
+
"Version Alias (optional)"
|
|
43238
|
+
),
|
|
43239
|
+
value,
|
|
43240
|
+
onChange: (e) => onChange(e.target.value),
|
|
43241
|
+
onBlur: () => setEditing(false),
|
|
43242
|
+
onKeyDown: (e) => {
|
|
43243
|
+
if (e.key === "Enter" || e.key === "Escape") setEditing(false);
|
|
43244
|
+
}
|
|
43245
|
+
}
|
|
43246
|
+
);
|
|
43247
|
+
}
|
|
43248
|
+
let label = value || addLabel;
|
|
43249
|
+
if (!value && iconOnly) {
|
|
43250
|
+
label = /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center", children: [
|
|
43251
|
+
/* @__PURE__ */ jsx(Plus, { className: "size-3", "aria-hidden": true }),
|
|
43252
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: addLabel })
|
|
43253
|
+
] });
|
|
43254
|
+
}
|
|
43255
|
+
return /* @__PURE__ */ jsx(
|
|
43256
|
+
"button",
|
|
43257
|
+
{
|
|
43258
|
+
type: "button",
|
|
43259
|
+
"data-testid": "fluidgrids-version-alias",
|
|
43260
|
+
title: tr(
|
|
43261
|
+
"fluidgrids.builder.flowBuilder.versionAliasHint",
|
|
43262
|
+
"Version alias: a name that points at this version. Click to edit."
|
|
43263
|
+
),
|
|
43264
|
+
className: cn$1(
|
|
43265
|
+
"min-w-0 max-w-40 shrink-[4] truncate rounded-full border px-2 py-0.5 text-xs transition-colors hover:bg-card-foreground/10",
|
|
43266
|
+
value ? "border-card-foreground/20 text-card-foreground" : "border-dashed border-card-foreground/25 text-muted-foreground"
|
|
43267
|
+
),
|
|
43268
|
+
onClick: () => setEditing(true),
|
|
43269
|
+
children: label
|
|
43270
|
+
}
|
|
43271
|
+
);
|
|
43272
|
+
}
|
|
43273
|
+
function HeaderIdentity({ tier }) {
|
|
43274
|
+
const tr = useTr();
|
|
43275
|
+
const { id } = useParams();
|
|
43276
|
+
const guardedNavigate = useGuardedNavigate();
|
|
43277
|
+
const [name, alias, setWorkflow] = useFlowStore(
|
|
43278
|
+
useShallow((s) => [
|
|
43279
|
+
s.workflow.name,
|
|
43280
|
+
s.workflow.alias,
|
|
43281
|
+
s.actions.setWorkflow
|
|
43282
|
+
])
|
|
43283
|
+
);
|
|
43284
|
+
const [workflowName, setWorkflowName] = useState(name);
|
|
43285
|
+
const [workflowAlias, setWorkflowAlias] = useState(alias || "");
|
|
43286
|
+
useEffect(() => setWorkflowName(name), [name]);
|
|
43287
|
+
useEffect(() => setWorkflowAlias(alias || ""), [alias]);
|
|
43288
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43289
|
+
/* @__PURE__ */ jsx(
|
|
43290
|
+
Button$1,
|
|
43291
|
+
{
|
|
43292
|
+
variant: "ghost",
|
|
43293
|
+
size: "icon",
|
|
43294
|
+
className: "shrink-0 text-primary-foreground font-bold",
|
|
43295
|
+
"aria-label": tr(
|
|
43296
|
+
"fluidgrids.builder.flowBuilder.backToList",
|
|
43297
|
+
"Back to workflows"
|
|
43298
|
+
),
|
|
43299
|
+
onClick: () => guardedNavigate("../list"),
|
|
43300
|
+
children: /* @__PURE__ */ jsx(
|
|
43301
|
+
Icon,
|
|
43302
|
+
{
|
|
43303
|
+
icon: "ion:arrow-back-outline",
|
|
43304
|
+
className: "size-6 text-card-foreground"
|
|
43305
|
+
}
|
|
43306
|
+
)
|
|
43307
|
+
}
|
|
43308
|
+
),
|
|
43309
|
+
/* @__PURE__ */ jsx(
|
|
43310
|
+
WorkflowNameField,
|
|
43311
|
+
{
|
|
43312
|
+
value: workflowName || name,
|
|
43313
|
+
onChange: (newName) => {
|
|
43314
|
+
setWorkflowName(newName);
|
|
43315
|
+
setWorkflow({ name: newName, id, alias: workflowAlias });
|
|
43316
|
+
}
|
|
43317
|
+
}
|
|
43318
|
+
),
|
|
43319
|
+
/* @__PURE__ */ jsx(
|
|
43320
|
+
VersionAliasChip,
|
|
43321
|
+
{
|
|
43322
|
+
value: workflowAlias,
|
|
43323
|
+
iconOnly: tier === "mid",
|
|
43324
|
+
onChange: (newAlias) => {
|
|
43325
|
+
setWorkflowAlias(newAlias);
|
|
43326
|
+
setWorkflow({ name: workflowName, id, alias: newAlias });
|
|
43327
|
+
}
|
|
43328
|
+
}
|
|
43329
|
+
),
|
|
43330
|
+
id && /* @__PURE__ */ jsx(
|
|
43331
|
+
EntityTagPicker,
|
|
43332
|
+
{
|
|
43333
|
+
entityType: "FLUIDGRIDS_WORKFLOW",
|
|
43334
|
+
entityId: id,
|
|
43335
|
+
className: "shrink-0"
|
|
43336
|
+
}
|
|
43337
|
+
),
|
|
43338
|
+
/* @__PURE__ */ jsx(SaveStatusIndicator, { className: "ml-1", compact: tier === "mid" })
|
|
43339
|
+
] });
|
|
43340
|
+
}
|
|
43341
|
+
function GuideIcon() {
|
|
43342
|
+
const tr = useTr();
|
|
43343
|
+
const label = tr("fluidgrids.docs.builderGuide", "Builder guide");
|
|
43344
|
+
return /* @__PURE__ */ jsx("span", { className: "inline-flex", title: label, children: /* @__PURE__ */ jsxs(
|
|
43345
|
+
FluidGridsDocsLink,
|
|
43346
|
+
{
|
|
43347
|
+
topic: "builder",
|
|
43348
|
+
hideIcon: true,
|
|
43349
|
+
className: "inline-flex size-9 items-center justify-center rounded-md text-card-foreground hover:bg-card-foreground/10",
|
|
43350
|
+
"data-tour": "fluidgrids-builder-guide",
|
|
43351
|
+
children: [
|
|
43352
|
+
/* @__PURE__ */ jsx(CircleHelp, { className: "size-4", "aria-hidden": true }),
|
|
43353
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: label })
|
|
43354
|
+
]
|
|
43355
|
+
}
|
|
43356
|
+
) });
|
|
43357
|
+
}
|
|
43358
|
+
function ActionsMenu({ children }) {
|
|
43359
|
+
const tr = useTr();
|
|
43360
|
+
return (
|
|
43361
|
+
// Tour anchor on the trigger, never on the items: a closed menu's items
|
|
43362
|
+
// are not in the DOM.
|
|
43363
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
43364
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
43365
|
+
Button$1,
|
|
43366
|
+
{
|
|
43367
|
+
variant: "ghost",
|
|
43368
|
+
size: "icon",
|
|
43369
|
+
className: "text-card-foreground",
|
|
43370
|
+
"aria-label": tr(
|
|
43371
|
+
"fluidgrids.builder.flowBuilder.moreActions",
|
|
43372
|
+
"More actions"
|
|
43373
|
+
),
|
|
43374
|
+
"data-tour": "fluidgrids-builder-actions-menu",
|
|
43375
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: "mynaui:dots-vertical", className: "size-5" })
|
|
43376
|
+
}
|
|
43377
|
+
) }),
|
|
43378
|
+
/* @__PURE__ */ jsxs(
|
|
43379
|
+
DropdownMenuContent,
|
|
43380
|
+
{
|
|
43381
|
+
align: "end",
|
|
43382
|
+
className: "flex flex-col gap-1.5 p-2 w-56",
|
|
43383
|
+
children: [
|
|
43384
|
+
/* @__PURE__ */ jsx(RunsUsageMeter, { className: "px-2 py-1" }),
|
|
43385
|
+
/* @__PURE__ */ jsx(VersionHistoryPanel, { className: "w-full justify-start" }),
|
|
43386
|
+
children,
|
|
43387
|
+
/* @__PURE__ */ jsx(
|
|
43388
|
+
FluidGridsDocsLink,
|
|
43389
|
+
{
|
|
43390
|
+
topic: "builder",
|
|
43391
|
+
className: "w-full rounded-md px-3 py-2",
|
|
43392
|
+
children: tr("fluidgrids.docs.builderGuide", "Builder guide")
|
|
43393
|
+
}
|
|
43394
|
+
)
|
|
43395
|
+
]
|
|
43396
|
+
}
|
|
43397
|
+
)
|
|
43398
|
+
] })
|
|
43399
|
+
);
|
|
43400
|
+
}
|
|
43401
|
+
var Divider = () => /* @__PURE__ */ jsx("span", { className: "mx-1 h-6 w-px bg-card-foreground/15", "aria-hidden": true });
|
|
43402
|
+
function PanelIcons() {
|
|
43403
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43404
|
+
/* @__PURE__ */ jsx(AiDraftPanel, { compact: true }),
|
|
43405
|
+
/* @__PURE__ */ jsx(EnvironmentsPanel, { compact: true }),
|
|
43406
|
+
/* @__PURE__ */ jsx(GitSyncPanel, { compact: true })
|
|
43407
|
+
] });
|
|
43408
|
+
}
|
|
43409
|
+
function HeaderActions({ tier }) {
|
|
43410
|
+
const { id } = useParams();
|
|
43411
|
+
const guardedNavigate = useGuardedNavigate();
|
|
43412
|
+
const handleViewRuns = useCallback(() => {
|
|
43413
|
+
if (!id) return;
|
|
43414
|
+
guardedNavigate(`../runs?workflowKey=${encodeURIComponent(id)}`);
|
|
43415
|
+
}, [id, guardedNavigate]);
|
|
43416
|
+
const run = /* @__PURE__ */ jsx(RunWithViewRuns, { onViewRuns: handleViewRuns, canViewRuns: !!id });
|
|
43417
|
+
if (tier === "full") {
|
|
43418
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43419
|
+
/* @__PURE__ */ jsx(RunsUsageMeter, { variant: "pill", className: "mr-1" }),
|
|
43420
|
+
/* @__PURE__ */ jsx(AiDraftPanel, { compact: true }),
|
|
43421
|
+
/* @__PURE__ */ jsx(VersionHistoryPanel, { compact: true }),
|
|
43422
|
+
/* @__PURE__ */ jsx(EnvironmentsPanel, { compact: true }),
|
|
43423
|
+
/* @__PURE__ */ jsx(GitSyncPanel, { compact: true }),
|
|
43424
|
+
/* @__PURE__ */ jsx(GuideIcon, {}),
|
|
43425
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
43426
|
+
/* @__PURE__ */ jsx(SaveFlowButton, {}),
|
|
43427
|
+
/* @__PURE__ */ jsx(ActivateWorkflowButton, {}),
|
|
43428
|
+
run
|
|
43429
|
+
] });
|
|
43430
|
+
}
|
|
43431
|
+
if (tier === "mid") {
|
|
43432
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43433
|
+
/* @__PURE__ */ jsx(PanelIcons, {}),
|
|
43434
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
43435
|
+
/* @__PURE__ */ jsx(SaveFlowButton, {}),
|
|
43436
|
+
/* @__PURE__ */ jsx(ActivateWorkflowButton, {}),
|
|
43437
|
+
run,
|
|
43438
|
+
/* @__PURE__ */ jsx(ActionsMenu, {})
|
|
43439
|
+
] });
|
|
43440
|
+
}
|
|
43441
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43442
|
+
/* @__PURE__ */ jsx(PanelIcons, {}),
|
|
43443
|
+
/* @__PURE__ */ jsxs(ActionsMenu, { children: [
|
|
43444
|
+
/* @__PURE__ */ jsx(SaveFlowButton, { className: "w-full justify-start" }),
|
|
43445
|
+
/* @__PURE__ */ jsx(ActivateWorkflowButton, { className: "w-full justify-start" }),
|
|
43446
|
+
/* @__PURE__ */ jsx(
|
|
43447
|
+
RunWithViewRuns,
|
|
43448
|
+
{
|
|
43449
|
+
onViewRuns: handleViewRuns,
|
|
43450
|
+
canViewRuns: !!id,
|
|
43451
|
+
className: "w-full",
|
|
43452
|
+
runButtonClassName: "flex-1 justify-start rounded-l-lg"
|
|
43453
|
+
}
|
|
43454
|
+
)
|
|
43455
|
+
] })
|
|
43456
|
+
] });
|
|
43457
|
+
}
|
|
43458
|
+
function BuilderHeader() {
|
|
43459
|
+
const name = useFlowStore((s) => s.workflow.name);
|
|
43460
|
+
return /* @__PURE__ */ jsx(
|
|
43461
|
+
BuilderHeaderLayout,
|
|
43462
|
+
{
|
|
43463
|
+
identity: (tier) => /* @__PURE__ */ jsx(HeaderIdentity, { tier }),
|
|
43464
|
+
actions: (tier) => name === "" ? null : /* @__PURE__ */ jsx(HeaderActions, { tier })
|
|
43465
|
+
}
|
|
43466
|
+
);
|
|
43467
|
+
}
|
|
42414
43468
|
var edgeTypes2 = {
|
|
42415
43469
|
deletable: CustomDeletableEdge
|
|
42416
43470
|
};
|
|
@@ -42428,20 +43482,14 @@ var edgeOptions = {
|
|
|
42428
43482
|
}
|
|
42429
43483
|
};
|
|
42430
43484
|
var FlowBuilder = ({ readOnly = false }) => {
|
|
42431
|
-
const tr = useTr();
|
|
42432
43485
|
const searchParams = new URLSearchParams(window.location.search);
|
|
42433
43486
|
const isReadOnly = readOnly || searchParams.get("readonly") === "true";
|
|
42434
43487
|
useAgentTools(BUILDER_AGENT_TOOLS, !isReadOnly);
|
|
42435
|
-
const
|
|
42436
|
-
const navigate = useNavigate();
|
|
42437
|
-
const { id } = useParams();
|
|
42438
|
-
const [name, nodes, edges, alias, onNodesChange, onEdgesChange, onConnect] = useFlowStore(
|
|
43488
|
+
const [nodes, edges, onNodesChange, onEdgesChange, onConnect] = useFlowStore(
|
|
42439
43489
|
useShallow((s) => {
|
|
42440
43490
|
return [
|
|
42441
|
-
s.workflow.name,
|
|
42442
43491
|
s.workflow.nodes,
|
|
42443
43492
|
s.workflow.edges,
|
|
42444
|
-
s.workflow.alias,
|
|
42445
43493
|
s.actions.nodes.onNodesChange,
|
|
42446
43494
|
s.actions.edges.onEdgesChange,
|
|
42447
43495
|
s.actions.edges.onConnect
|
|
@@ -42472,25 +43520,6 @@ var FlowBuilder = ({ readOnly = false }) => {
|
|
|
42472
43520
|
}
|
|
42473
43521
|
return merged;
|
|
42474
43522
|
}, [nodeTypesVersion, nodes]);
|
|
42475
|
-
const [workflowName, setWorkflowName] = useState(name);
|
|
42476
|
-
const [workflowAlias, setWorkflowAlias] = useState(alias || "");
|
|
42477
|
-
const [isEditingName, setIsEditingName] = useState(false);
|
|
42478
|
-
useEffect(() => {
|
|
42479
|
-
setWorkflowName(name);
|
|
42480
|
-
}, [name]);
|
|
42481
|
-
useEffect(() => {
|
|
42482
|
-
setWorkflowAlias(alias || "");
|
|
42483
|
-
}, [alias]);
|
|
42484
|
-
const handleNameChange = (e) => {
|
|
42485
|
-
const newName = e.target.value;
|
|
42486
|
-
setWorkflowName(newName);
|
|
42487
|
-
setWorkflow({ name: newName, id, alias: workflowAlias });
|
|
42488
|
-
};
|
|
42489
|
-
const handleAliasChange = (e) => {
|
|
42490
|
-
const newAlias = e.target.value;
|
|
42491
|
-
setWorkflowAlias(newAlias);
|
|
42492
|
-
setWorkflow({ name: workflowName, id, alias: newAlias });
|
|
42493
|
-
};
|
|
42494
43523
|
const { getNodes } = useReactFlow();
|
|
42495
43524
|
const {
|
|
42496
43525
|
handleOnEdgeDropConnectEnd,
|
|
@@ -42507,14 +43536,14 @@ var FlowBuilder = ({ readOnly = false }) => {
|
|
|
42507
43536
|
}
|
|
42508
43537
|
);
|
|
42509
43538
|
const handleAutoAdjustNodeAfterNodeMeasured = useCallback(
|
|
42510
|
-
(
|
|
43539
|
+
(id) => {
|
|
42511
43540
|
setTimeout(() => {
|
|
42512
|
-
const node2 = getNodes().find((n) => n.id ===
|
|
43541
|
+
const node2 = getNodes().find((n) => n.id === id);
|
|
42513
43542
|
if (!node2) {
|
|
42514
43543
|
return;
|
|
42515
43544
|
}
|
|
42516
43545
|
if (node2.measured === void 0) {
|
|
42517
|
-
handleAutoAdjustNodeAfterNodeMeasuredRef.current(
|
|
43546
|
+
handleAutoAdjustNodeAfterNodeMeasuredRef.current(id);
|
|
42518
43547
|
return;
|
|
42519
43548
|
}
|
|
42520
43549
|
autoAdjustNode(node2);
|
|
@@ -42525,10 +43554,6 @@ var FlowBuilder = ({ readOnly = false }) => {
|
|
|
42525
43554
|
useEffect(() => {
|
|
42526
43555
|
handleAutoAdjustNodeAfterNodeMeasuredRef.current = handleAutoAdjustNodeAfterNodeMeasured;
|
|
42527
43556
|
}, [handleAutoAdjustNodeAfterNodeMeasured]);
|
|
42528
|
-
const handleViewRuns = useCallback(() => {
|
|
42529
|
-
if (!id) return;
|
|
42530
|
-
navigate(`../runs?workflowKey=${encodeURIComponent(id)}`);
|
|
42531
|
-
}, [id, navigate]);
|
|
42532
43557
|
const handleNodesChange = useCallback(
|
|
42533
43558
|
(changes) => {
|
|
42534
43559
|
changes.forEach((change) => {
|
|
@@ -42552,168 +43577,8 @@ var FlowBuilder = ({ readOnly = false }) => {
|
|
|
42552
43577
|
]
|
|
42553
43578
|
);
|
|
42554
43579
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full w-full overflow-hidden", children: [
|
|
42555
|
-
!isReadOnly &&
|
|
42556
|
-
|
|
42557
|
-
/* @__PURE__ */ jsxs(Card$1, { className: "min-h-14 shrink-0 border-0 from-primary/40 p-2 to-transparent rounded-t-xl rounded-b-none bg-gradient-to-l backdrop-blur-sm mt-2 mx-4 items-center flex gap-2 justify-between border border-card-foreground/10 border-b-0", children: [
|
|
42558
|
-
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-2", children: [
|
|
42559
|
-
/* @__PURE__ */ jsx(
|
|
42560
|
-
Button$1,
|
|
42561
|
-
{
|
|
42562
|
-
variant: "ghost",
|
|
42563
|
-
size: "icon",
|
|
42564
|
-
className: "shrink-0 text-primary-foreground font-bold",
|
|
42565
|
-
onClick: () => {
|
|
42566
|
-
navigate("../list");
|
|
42567
|
-
},
|
|
42568
|
-
children: /* @__PURE__ */ jsx(
|
|
42569
|
-
Icon,
|
|
42570
|
-
{
|
|
42571
|
-
icon: "ion:arrow-back-outline",
|
|
42572
|
-
className: "size-6 text-card-foreground"
|
|
42573
|
-
}
|
|
42574
|
-
)
|
|
42575
|
-
}
|
|
42576
|
-
),
|
|
42577
|
-
isEditingName ? /* @__PURE__ */ jsx(
|
|
42578
|
-
Input,
|
|
42579
|
-
{
|
|
42580
|
-
autoFocus: true,
|
|
42581
|
-
onFocus: (e) => e.currentTarget.select(),
|
|
42582
|
-
className: "text-card-foreground font-bold",
|
|
42583
|
-
style: {
|
|
42584
|
-
width: `${Math.min(
|
|
42585
|
-
Math.max((workflowName || name || "").length + 4, 16),
|
|
42586
|
-
60
|
|
42587
|
-
)}ch`
|
|
42588
|
-
},
|
|
42589
|
-
type: "text",
|
|
42590
|
-
placeholder: tr(
|
|
42591
|
-
"fluidgrids.builder.flowBuilder.workflowNamePlaceholder",
|
|
42592
|
-
"Workflow Name"
|
|
42593
|
-
),
|
|
42594
|
-
value: workflowName || name,
|
|
42595
|
-
onChange: handleNameChange,
|
|
42596
|
-
onBlur: () => setIsEditingName(false),
|
|
42597
|
-
onKeyDown: (e) => {
|
|
42598
|
-
if (e.key === "Enter" || e.key === "Escape")
|
|
42599
|
-
setIsEditingName(false);
|
|
42600
|
-
}
|
|
42601
|
-
}
|
|
42602
|
-
) : (
|
|
42603
|
-
// n8n-style: the name itself is the edit affordance — click to
|
|
42604
|
-
// rename (no pencil button). Long names truncate with an
|
|
42605
|
-
// ellipsis (full name in the tooltip) instead of scrolling.
|
|
42606
|
-
/* @__PURE__ */ jsx(
|
|
42607
|
-
"button",
|
|
42608
|
-
{
|
|
42609
|
-
type: "button",
|
|
42610
|
-
"data-tour": "fluidgrids-builder-workflow-name",
|
|
42611
|
-
title: `${workflowName || name || "Untitled Workflow"} \u2014 click to rename`,
|
|
42612
|
-
className: "-mx-1 min-w-0 flex-1 basis-40 cursor-text truncate rounded px-1 text-left font-bold text-card-foreground transition-colors hover:bg-card-foreground/10 sm:min-w-[15rem] sm:max-w-[38vw] sm:flex-none sm:basis-auto",
|
|
42613
|
-
onClick: () => setIsEditingName(true),
|
|
42614
|
-
children: workflowName || name || tr(
|
|
42615
|
-
"fluidgrids.builder.flowBuilder.untitledWorkflow",
|
|
42616
|
-
"Untitled Workflow"
|
|
42617
|
-
)
|
|
42618
|
-
}
|
|
42619
|
-
)
|
|
42620
|
-
),
|
|
42621
|
-
/* @__PURE__ */ jsx(
|
|
42622
|
-
Input,
|
|
42623
|
-
{
|
|
42624
|
-
className: "text-card-foreground font-bold ml-2 min-w-0 flex-1 basis-32 sm:w-52 sm:flex-none sm:basis-auto",
|
|
42625
|
-
type: "text",
|
|
42626
|
-
placeholder: tr(
|
|
42627
|
-
"fluidgrids.builder.flowBuilder.versionAliasPlaceholder",
|
|
42628
|
-
"Version Alias (optional)"
|
|
42629
|
-
),
|
|
42630
|
-
value: workflowAlias,
|
|
42631
|
-
onChange: handleAliasChange
|
|
42632
|
-
}
|
|
42633
|
-
),
|
|
42634
|
-
id && /* @__PURE__ */ jsx(
|
|
42635
|
-
EntityTagPicker,
|
|
42636
|
-
{
|
|
42637
|
-
entityType: "FLUIDGRIDS_WORKFLOW",
|
|
42638
|
-
entityId: id,
|
|
42639
|
-
className: "ml-2 shrink-0"
|
|
42640
|
-
}
|
|
42641
|
-
),
|
|
42642
|
-
name !== "" && /* @__PURE__ */ jsx(RunsUsageMeter, { className: "ml-2 shrink-0" })
|
|
42643
|
-
] }),
|
|
42644
|
-
name !== "" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42645
|
-
/* @__PURE__ */ jsxs("div", { className: "hidden shrink-0 lg:inline-flex items-center gap-2", children: [
|
|
42646
|
-
!isReadOnly && /* @__PURE__ */ jsx(AiDraftPanel, {}),
|
|
42647
|
-
/* @__PURE__ */ jsx(VersionHistoryPanel, {}),
|
|
42648
|
-
/* @__PURE__ */ jsx(EnvironmentsPanel, {}),
|
|
42649
|
-
/* @__PURE__ */ jsx(GitSyncPanel, {}),
|
|
42650
|
-
/* @__PURE__ */ jsx(SaveFlowButton, {}),
|
|
42651
|
-
/* @__PURE__ */ jsx(ActivateWorkflowButton, {}),
|
|
42652
|
-
/* @__PURE__ */ jsx(
|
|
42653
|
-
RunWithViewRuns,
|
|
42654
|
-
{
|
|
42655
|
-
onViewRuns: handleViewRuns,
|
|
42656
|
-
canViewRuns: !!id
|
|
42657
|
-
}
|
|
42658
|
-
),
|
|
42659
|
-
/* @__PURE__ */ jsx(
|
|
42660
|
-
FluidGridsDocsLink,
|
|
42661
|
-
{
|
|
42662
|
-
topic: "builder",
|
|
42663
|
-
className: "px-2",
|
|
42664
|
-
"data-tour": "fluidgrids-builder-guide",
|
|
42665
|
-
children: tr("fluidgrids.docs.builderGuide", "Builder guide")
|
|
42666
|
-
}
|
|
42667
|
-
)
|
|
42668
|
-
] }),
|
|
42669
|
-
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1 lg:hidden", children: [
|
|
42670
|
-
!isReadOnly && /* @__PURE__ */ jsx(AiDraftPanel, { compact: true }),
|
|
42671
|
-
/* @__PURE__ */ jsx(EnvironmentsPanel, { compact: true }),
|
|
42672
|
-
/* @__PURE__ */ jsx(GitSyncPanel, { compact: true }),
|
|
42673
|
-
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
42674
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
42675
|
-
Button$1,
|
|
42676
|
-
{
|
|
42677
|
-
variant: "ghost",
|
|
42678
|
-
size: "icon",
|
|
42679
|
-
className: "text-card-foreground",
|
|
42680
|
-
"data-tour": "fluidgrids-builder-actions-menu",
|
|
42681
|
-
children: /* @__PURE__ */ jsx(Icon, { icon: "mynaui:dots-vertical", className: "size-5" })
|
|
42682
|
-
}
|
|
42683
|
-
) }),
|
|
42684
|
-
/* @__PURE__ */ jsxs(
|
|
42685
|
-
DropdownMenuContent,
|
|
42686
|
-
{
|
|
42687
|
-
align: "end",
|
|
42688
|
-
className: "flex flex-col gap-1.5 p-2 w-56",
|
|
42689
|
-
children: [
|
|
42690
|
-
/* @__PURE__ */ jsx(VersionHistoryPanel, { className: "w-full justify-start" }),
|
|
42691
|
-
/* @__PURE__ */ jsx(SaveFlowButton, { className: "w-full justify-start" }),
|
|
42692
|
-
/* @__PURE__ */ jsx(ActivateWorkflowButton, { className: "w-full justify-start" }),
|
|
42693
|
-
/* @__PURE__ */ jsx(
|
|
42694
|
-
RunWithViewRuns,
|
|
42695
|
-
{
|
|
42696
|
-
onViewRuns: handleViewRuns,
|
|
42697
|
-
canViewRuns: !!id,
|
|
42698
|
-
className: "w-full",
|
|
42699
|
-
runButtonClassName: "flex-1 justify-start rounded-l-lg"
|
|
42700
|
-
}
|
|
42701
|
-
),
|
|
42702
|
-
/* @__PURE__ */ jsx(
|
|
42703
|
-
FluidGridsDocsLink,
|
|
42704
|
-
{
|
|
42705
|
-
topic: "builder",
|
|
42706
|
-
className: "w-full rounded-md px-3 py-2",
|
|
42707
|
-
children: tr("fluidgrids.docs.builderGuide", "Builder guide")
|
|
42708
|
-
}
|
|
42709
|
-
)
|
|
42710
|
-
]
|
|
42711
|
-
}
|
|
42712
|
-
)
|
|
42713
|
-
] })
|
|
42714
|
-
] })
|
|
42715
|
-
] })
|
|
42716
|
-
] }),
|
|
43580
|
+
!isReadOnly && /* @__PURE__ */ jsx(BuilderHeader, {}),
|
|
43581
|
+
/* @__PURE__ */ jsx(BuilderSaveController, { readOnly: isReadOnly }),
|
|
42717
43582
|
/* @__PURE__ */ jsxs(
|
|
42718
43583
|
"div",
|
|
42719
43584
|
{
|