@powerhousedao/workflow 6.2.3-dev.45 → 6.2.3-dev.47
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/browser/{BlockSelector-B41mSc0W.js → BlockSelector-Do2fNhEF.js} +2 -2
- package/dist/browser/BlockSelector-Do2fNhEF.js.map +1 -0
- package/dist/browser/{connection-form-CkRzKggD.js → connection-form-BfIxO-uq.js} +2 -2
- package/dist/browser/{connection-form-CkRzKggD.js.map → connection-form-BfIxO-uq.js.map} +1 -1
- package/dist/browser/{data-tree-BugZMgLk.js → data-tree-CEBkvtSf.js} +2 -2
- package/dist/browser/{data-tree-BugZMgLk.js.map → data-tree-CEBkvtSf.js.map} +1 -1
- package/dist/browser/{editor-ldDYxtLV.js → editor-C6NhkZ3S.js} +3 -3
- package/dist/browser/{editor-ldDYxtLV.js.map → editor-C6NhkZ3S.js.map} +1 -1
- package/dist/browser/{editor-DvK4LPwF.js → editor-YRMQ2K-6.js} +724 -136
- package/dist/browser/editor-YRMQ2K-6.js.map +1 -0
- package/dist/browser/{editor-9eSmoDTm.js → editor-h6Fo7DOI.js} +52 -10
- package/dist/browser/editor-h6Fo7DOI.js.map +1 -0
- package/dist/browser/editors/connection-editor/module.js +1 -1
- package/dist/browser/editors/workflow-editor/module.js +1 -1
- package/dist/browser/editors/workflow-studio/module.js +1 -1
- package/dist/browser/{trigger-text-C37YRggR.js → trigger-text-CmtISlSW.js} +3 -3
- package/dist/browser/trigger-text-CmtISlSW.js.map +1 -0
- package/dist/node/{BlockSelector-BMnBzXcA.mjs → BlockSelector-CrPnitOU.mjs} +2 -2
- package/dist/node/BlockSelector-CrPnitOU.mjs.map +1 -0
- package/dist/node/{connection-form-DZFudcoD.mjs → connection-form-MHDKPohk.mjs} +2 -2
- package/dist/node/{connection-form-DZFudcoD.mjs.map → connection-form-MHDKPohk.mjs.map} +1 -1
- package/dist/node/{data-tree-CR8IOshA.mjs → data-tree-Ccyc8y8I.mjs} +2 -2
- package/dist/node/{data-tree-CR8IOshA.mjs.map → data-tree-Ccyc8y8I.mjs.map} +1 -1
- package/dist/node/{editor-NUaiiO4B.mjs → editor-C8kHYBz1.mjs} +52 -10
- package/dist/node/editor-C8kHYBz1.mjs.map +1 -0
- package/dist/node/{editor-BV5CYmUI.mjs → editor-CFYv3eBu.mjs} +724 -136
- package/dist/node/editor-CFYv3eBu.mjs.map +1 -0
- package/dist/node/{editor-D_P9-st9.mjs → editor-J42uGqnf.mjs} +3 -3
- package/dist/node/{editor-D_P9-st9.mjs.map → editor-J42uGqnf.mjs.map} +1 -1
- package/dist/node/editors/connection-editor/module.mjs +1 -1
- package/dist/node/editors/workflow-editor/module.mjs +1 -1
- package/dist/node/editors/workflow-studio/module.mjs +1 -1
- package/dist/node/pieces/reactor/descriptor.json +1 -1
- package/dist/node/pieces/reactor/package.json +1 -1
- package/dist/node/{trigger-text-78ZhfT-b.mjs → trigger-text-CaAEQV69.mjs} +3 -3
- package/dist/node/trigger-text-CaAEQV69.mjs.map +1 -0
- package/dist/powerhouse.manifest.json +1 -1
- package/dist/style.css +158 -10
- package/dist/types/editors/shared/controls.d.ts +1 -0
- package/dist/types/editors/shared/controls.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/document/useWorkflowModel.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-contract.test.d.ts +2 -0
- package/dist/types/editors/workflow-editor/runtime-contract.test.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/ui/ConnectionField.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/ConnectionName.d.ts +8 -0
- package/dist/types/editors/workflow-editor/ui/ConnectionName.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/ui/ReactorConnectionField.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/model.d.ts +2 -0
- package/dist/types/editors/workflow-editor/ui/model.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/Sidebar.d.ts +1 -0
- package/dist/types/editors/workflow-studio/components/Sidebar.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts +1 -0
- package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/WorkflowGraph.d.ts +10 -0
- package/dist/types/editors/workflow-studio/components/WorkflowGraph.d.ts.map +1 -0
- package/dist/types/editors/workflow-studio/components/WorkflowMenu.d.ts +2 -0
- package/dist/types/editors/workflow-studio/components/WorkflowMenu.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/WorkflowSteps.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/WorkflowStudio.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/chain.d.ts +1 -0
- package/dist/types/editors/workflow-studio/components/chain.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/graph-layout.d.ts +29 -0
- package/dist/types/editors/workflow-studio/components/graph-layout.d.ts.map +1 -0
- package/dist/types/editors/workflow-studio/components/graph-layout.test.d.ts +2 -0
- package/dist/types/editors/workflow-studio/components/graph-layout.test.d.ts.map +1 -0
- package/dist/types/editors/workflow-studio/components/use-hash-selection.d.ts +4 -4
- package/dist/types/editors/workflow-studio/components/use-hash-selection.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/workflow-order.d.ts +19 -0
- package/dist/types/editors/workflow-studio/components/workflow-order.d.ts.map +1 -0
- package/dist/types/editors/workflow-studio/components/workflow-order.test.d.ts +2 -0
- package/dist/types/editors/workflow-studio/components/workflow-order.test.d.ts.map +1 -0
- package/dist/types/scripts/ui-stack.d.ts +8 -2
- package/dist/types/scripts/ui-stack.d.ts.map +1 -1
- package/dist/types/test/drive-window.d.ts +6 -0
- package/dist/types/test/drive-window.d.ts.map +1 -0
- package/dist/types/test/runtime-schema.d.ts +17 -0
- package/dist/types/test/runtime-schema.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/browser/BlockSelector-B41mSc0W.js.map +0 -1
- package/dist/browser/editor-9eSmoDTm.js.map +0 -1
- package/dist/browser/editor-DvK4LPwF.js.map +0 -1
- package/dist/browser/trigger-text-C37YRggR.js.map +0 -1
- package/dist/node/BlockSelector-BMnBzXcA.mjs.map +0 -1
- package/dist/node/editor-BV5CYmUI.mjs.map +0 -1
- package/dist/node/editor-NUaiiO4B.mjs.map +0 -1
- package/dist/node/trigger-text-78ZhfT-b.mjs.map +0 -1
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { K as CORE_PIECE, it as triggerBlock, l as runsOfPages, nt as stepBlock, q as MANUAL_TRIGGER, tt as sameBlock } from "./runtime-queries-IZG_nonR.js";
|
|
2
2
|
import { y as actions } from "./module-D4UiG9ii.js";
|
|
3
|
-
import { A as runTone, C as formatDuration, D as runStats, E as formatWhen, Et as Select, It as DocumentErrorBoundary, Lt as DocumentLoadError, M as toneOf, N as workflowHealth, Nt as textInputClass, O as runStatusLabel, Pt as Icon, Rt as errorMessage, S as formatAbsolute, T as formatTrigger, _ as RUN_TONE, b as TONE_TEXT, bt as Button, g as RUN_STATUSES, h as CONNECTION_TONE, ht as useRunQuery, j as statusLabel, k as runTimeline, m as usePieceLogos, mt as useRunPagesQuery, t as BlockLogo, u as blockMeta, ut as WorkflowRuntimeProvider, v as STEP_TONE, vt as useRuntimeActions, w as formatMs, x as durationMs, y as TONE_DOT } from "./BlockSelector-
|
|
3
|
+
import { A as runTone, C as formatDuration, D as runStats, E as formatWhen, Et as Select, It as DocumentErrorBoundary, Lt as DocumentLoadError, M as toneOf, N as workflowHealth, Nt as textInputClass, O as runStatusLabel, Pt as Icon, Rt as errorMessage, S as formatAbsolute, T as formatTrigger, _ as RUN_TONE, b as TONE_TEXT, bt as Button, g as RUN_STATUSES, h as CONNECTION_TONE, ht as useRunQuery, j as statusLabel, k as runTimeline, m as usePieceLogos, mt as useRunPagesQuery, t as BlockLogo, u as blockMeta, ut as WorkflowRuntimeProvider, v as STEP_TONE, vt as useRuntimeActions, w as formatMs, x as durationMs, y as TONE_DOT } from "./BlockSelector-Do2fNhEF.js";
|
|
4
4
|
import { r as useWorkflowDocumentsInSelectedDrive } from "./workflow-DFLQ2cFr.js";
|
|
5
|
-
import { a as StepError, f as StatusToggle, i as DataViewer, l as PublishState, o as Modal, r as describeTrigger } from "./trigger-text-
|
|
5
|
+
import { a as StepError, f as StatusToggle, i as DataViewer, l as PublishState, o as Modal, r as describeTrigger } from "./trigger-text-CmtISlSW.js";
|
|
6
6
|
import { Fragment, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import {
|
|
8
|
+
import { generateId } from "document-model";
|
|
9
|
+
import { addDocument, addFolder, deleteNode, setSelectedNode, showDeleteNodeModal, useDispatch, useDocumentSafe, useFileNodesInSelectedDrive, useNodesInSelectedDrive, usePHToast, useSelectedDrive, useSelectedNode, useSetPHAppConfig } from "@powerhousedao/reactor-browser";
|
|
10
|
+
import { addFolder as addFolder$1, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
11
|
+
import { ConnectTooltip, ConnectTooltipProvider } from "@powerhousedao/design-system/connect";
|
|
9
12
|
//#region editors/workflow-studio/components/chain.tsx
|
|
10
|
-
const RING$
|
|
13
|
+
const RING$2 = {
|
|
11
14
|
ok: "ring-wf-ok",
|
|
12
15
|
fail: "ring-wf-fail",
|
|
13
16
|
warn: "ring-wf-warn",
|
|
14
17
|
run: "ring-wf-run",
|
|
15
|
-
idle: "ring-foreground/15"
|
|
18
|
+
idle: "ring-foreground/15 dark:ring-foreground/30"
|
|
16
19
|
};
|
|
17
20
|
const RAIL$1 = {
|
|
18
21
|
ok: "bg-wf-ok",
|
|
19
22
|
fail: "bg-wf-fail",
|
|
20
23
|
warn: "bg-wf-warn",
|
|
21
24
|
run: "bg-wf-run",
|
|
22
|
-
idle: "bg-foreground/15"
|
|
25
|
+
idle: "bg-foreground/15 dark:bg-foreground/30"
|
|
23
26
|
};
|
|
24
27
|
const MAX_STOPS = 6;
|
|
25
28
|
function MiniChain(props) {
|
|
@@ -38,11 +41,14 @@ function MiniChain(props) {
|
|
|
38
41
|
className: `h-0.5 ${md ? "w-5" : "w-3"} ${RAIL$1[tones[index]]}`
|
|
39
42
|
}) : null, /* @__PURE__ */ jsx("span", {
|
|
40
43
|
title: link.status ? `${link.label}: ${link.status.toLowerCase()}` : link.label,
|
|
41
|
-
className: `flex shrink-0 items-center justify-center rounded-full bg-card
|
|
42
|
-
children: /* @__PURE__ */ jsx(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
className: `flex shrink-0 items-center justify-center rounded-full bg-card ${md ? "h-8 w-8" : "h-6 w-6"} ${link.status === "SKIPPED" ? "border-[1.5px] border-dashed border-foreground/40" : `ring-[1.5px] dark:bg-white ${RING$2[tones[index]]}`}`,
|
|
45
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
46
|
+
className: link.status === "SKIPPED" ? "flex opacity-40" : "flex",
|
|
47
|
+
children: /* @__PURE__ */ jsx(BlockLogo, {
|
|
48
|
+
bare: true,
|
|
49
|
+
block: link.block,
|
|
50
|
+
size: md ? 16 : 14
|
|
51
|
+
})
|
|
46
52
|
})
|
|
47
53
|
})]
|
|
48
54
|
}, link.id)), overflow ? /* @__PURE__ */ jsxs("li", {
|
|
@@ -103,7 +109,7 @@ function RunStrip(props) {
|
|
|
103
109
|
const recent = props.runs.slice(0, STRIP_LENGTH).reverse();
|
|
104
110
|
const padding = STRIP_LENGTH - recent.length;
|
|
105
111
|
return /* @__PURE__ */ jsxs("span", {
|
|
106
|
-
className:
|
|
112
|
+
className: `flex h-5 gap-[3px] ${props.centered ? "items-center" : "items-end"}`,
|
|
107
113
|
"aria-label": recent.length === 0 ? "No runs yet" : `Last ${recent.length} runs: ${recent.map((run) => run.status.toLowerCase()).join(", ")}`,
|
|
108
114
|
children: [Array.from({ length: padding }, (_, index) => /* @__PURE__ */ jsx("span", {
|
|
109
115
|
"aria-hidden": true,
|
|
@@ -766,7 +772,124 @@ function RunsView(props) {
|
|
|
766
772
|
});
|
|
767
773
|
}
|
|
768
774
|
//#endregion
|
|
775
|
+
//#region editors/workflow-studio/components/workflow-order.ts
|
|
776
|
+
const DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
777
|
+
const HOME_FOLDER = /^([0-9A-Za-z]+) · (.*)$/s;
|
|
778
|
+
function compareKeys(a, b) {
|
|
779
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
780
|
+
}
|
|
781
|
+
function midpoint(a, b) {
|
|
782
|
+
if (b !== null) {
|
|
783
|
+
let n = 0;
|
|
784
|
+
while ((a[n] ?? "0") === b[n]) n++;
|
|
785
|
+
if (n > 0) return b.slice(0, n) + midpoint(a.slice(n), b.slice(n));
|
|
786
|
+
}
|
|
787
|
+
const digitA = a ? DIGITS.indexOf(a[0]) : 0;
|
|
788
|
+
const digitB = b !== null ? DIGITS.indexOf(b[0]) : 62;
|
|
789
|
+
if (digitB - digitA > 1) return DIGITS[Math.round((digitA + digitB) / 2)];
|
|
790
|
+
if (b !== null && b.length > 1) return b.slice(0, 1);
|
|
791
|
+
return DIGITS[digitA] + midpoint(a.slice(1), null);
|
|
792
|
+
}
|
|
793
|
+
/** A key that sorts after `before` and before `after`. */
|
|
794
|
+
function keyBetween(before, after) {
|
|
795
|
+
return midpoint(before ?? "", after ?? null);
|
|
796
|
+
}
|
|
797
|
+
/** `count` ascending keys, evenly spread. */
|
|
798
|
+
function spreadKeys(count) {
|
|
799
|
+
let width = 1;
|
|
800
|
+
while (62 ** width <= count) width++;
|
|
801
|
+
const span = 62 ** width;
|
|
802
|
+
return Array.from({ length: count }, (_, i) => {
|
|
803
|
+
let value = Math.floor((i + 1) * span / (count + 1));
|
|
804
|
+
let key = "";
|
|
805
|
+
for (let d = 0; d < width; d++) {
|
|
806
|
+
key = DIGITS[value % 62] + key;
|
|
807
|
+
value = Math.floor(value / 62);
|
|
808
|
+
}
|
|
809
|
+
return key.replace(/0+$/, "");
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
function homeFolderName(key, name) {
|
|
813
|
+
return `${key} · ${name || "Workflow"}`;
|
|
814
|
+
}
|
|
815
|
+
function orderWorkflows(workflows, nodes) {
|
|
816
|
+
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
817
|
+
const childCount = /* @__PURE__ */ new Map();
|
|
818
|
+
for (const node of nodes) if (node.parentFolder) childCount.set(node.parentFolder, (childCount.get(node.parentFolder) ?? 0) + 1);
|
|
819
|
+
return workflows.map((node) => {
|
|
820
|
+
const parent = node.parentFolder ? byId.get(node.parentFolder) : void 0;
|
|
821
|
+
if (parent?.kind !== "folder" || parent.parentFolder || childCount.get(parent.id) !== 1) return { node };
|
|
822
|
+
const match = HOME_FOLDER.exec(parent.name);
|
|
823
|
+
return match ? {
|
|
824
|
+
node,
|
|
825
|
+
folder: parent,
|
|
826
|
+
key: match[1]
|
|
827
|
+
} : { node };
|
|
828
|
+
}).sort((a, b) => {
|
|
829
|
+
if (a.key === void 0 || b.key === void 0) {
|
|
830
|
+
if (a.key !== b.key) return a.key === void 0 ? -1 : 1;
|
|
831
|
+
} else {
|
|
832
|
+
const byKey = compareKeys(a.key, b.key);
|
|
833
|
+
if (byKey !== 0) return byKey;
|
|
834
|
+
}
|
|
835
|
+
return compareKeys(a.node.id, b.node.id);
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
/** The key for a new workflow, after every other one. */
|
|
839
|
+
function nextKey(ordered) {
|
|
840
|
+
return keyBetween(ordered.at(-1)?.key, null);
|
|
841
|
+
}
|
|
842
|
+
/** The node to delete to remove a workflow: its home folder, if it has one. */
|
|
843
|
+
function deletionTarget(workflowId, nodes) {
|
|
844
|
+
const node = nodes.find((n) => n.id === workflowId);
|
|
845
|
+
if (node?.kind !== "file") return node;
|
|
846
|
+
return orderWorkflows([node], nodes)[0].folder ?? node;
|
|
847
|
+
}
|
|
848
|
+
function folderTail(item, names) {
|
|
849
|
+
const name = names.get(item.node.id) || item.node.name;
|
|
850
|
+
return item.folder ? HOME_FOLDER.exec(item.folder.name)?.[2] ?? name : name;
|
|
851
|
+
}
|
|
852
|
+
function reorderActions(ordered, from, to, names = /* @__PURE__ */ new Map()) {
|
|
853
|
+
if (from === to || !ordered[from]) return [];
|
|
854
|
+
const next = [...ordered];
|
|
855
|
+
const [moved] = next.splice(from, 1);
|
|
856
|
+
next.splice(to, 0, moved);
|
|
857
|
+
const before = to > 0 ? next[to - 1] : void 0;
|
|
858
|
+
const after = to < next.length - 1 ? next[to + 1] : void 0;
|
|
859
|
+
if (moved.folder && (!before || before.key !== void 0) && (!after || after.key !== void 0) && (!before || !after || compareKeys(before.key, after.key) < 0)) {
|
|
860
|
+
const key = keyBetween(before?.key, after?.key);
|
|
861
|
+
return [updateNode({
|
|
862
|
+
id: moved.folder.id,
|
|
863
|
+
name: homeFolderName(key, folderTail(moved, names))
|
|
864
|
+
})];
|
|
865
|
+
}
|
|
866
|
+
const keys = spreadKeys(next.length);
|
|
867
|
+
return next.flatMap((item, i) => {
|
|
868
|
+
const name = homeFolderName(keys[i], folderTail(item, names));
|
|
869
|
+
if (item.folder) return item.folder.name === name ? [] : [updateNode({
|
|
870
|
+
id: item.folder.id,
|
|
871
|
+
name
|
|
872
|
+
})];
|
|
873
|
+
const folderId = generateId();
|
|
874
|
+
return [addFolder$1({
|
|
875
|
+
id: folderId,
|
|
876
|
+
name,
|
|
877
|
+
parentFolder: null
|
|
878
|
+
}), moveNode({
|
|
879
|
+
srcFolder: item.node.id,
|
|
880
|
+
targetParentFolder: folderId
|
|
881
|
+
})];
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
//#endregion
|
|
769
885
|
//#region editors/workflow-studio/components/WorkflowMenu.tsx
|
|
886
|
+
/** Deletes a workflow with its home folder, reading the drive's nodes now. */
|
|
887
|
+
async function deleteWorkflow(workflowId) {
|
|
888
|
+
const driveId = window.ph?.selectedDriveId;
|
|
889
|
+
if (!driveId) throw new Error("No drive is selected");
|
|
890
|
+
const nodes = window.ph?.drives?.find((drive) => drive.header.id === driveId)?.state.global.nodes ?? [];
|
|
891
|
+
await deleteNode(driveId, deletionTarget(workflowId, nodes)?.id ?? workflowId);
|
|
892
|
+
}
|
|
770
893
|
function DeleteWorkflowDialog(props) {
|
|
771
894
|
const [typed, setTyped] = useState("");
|
|
772
895
|
const [error, setError] = useState(null);
|
|
@@ -867,7 +990,6 @@ function WorkflowMenu(props) {
|
|
|
867
990
|
const [open, setOpen] = useState(false);
|
|
868
991
|
const [confirming, setConfirming] = useState(false);
|
|
869
992
|
const [, dispatch] = useDispatch(props.document);
|
|
870
|
-
const driveId = useSelectedDriveId();
|
|
871
993
|
const ref = useRef(null);
|
|
872
994
|
const state = props.document.state.global;
|
|
873
995
|
const name = state.name || props.nodeName || "Untitled workflow";
|
|
@@ -931,8 +1053,7 @@ function WorkflowMenu(props) {
|
|
|
931
1053
|
name,
|
|
932
1054
|
onCancel: () => setConfirming(false),
|
|
933
1055
|
onConfirm: async () => {
|
|
934
|
-
|
|
935
|
-
await deleteNode(driveId, props.document.header.id);
|
|
1056
|
+
await deleteWorkflow(props.document.header.id);
|
|
936
1057
|
setConfirming(false);
|
|
937
1058
|
props.onDeleted?.();
|
|
938
1059
|
}
|
|
@@ -961,6 +1082,8 @@ function Row(props) {
|
|
|
961
1082
|
"aria-current": props.active ? "true" : void 0,
|
|
962
1083
|
className: `flex min-w-0 grow items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-[13px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${props.active ? "font-medium text-foreground" : "text-foreground/80"}`,
|
|
963
1084
|
onClick: props.onClick,
|
|
1085
|
+
onKeyDown: props.onKeyDown,
|
|
1086
|
+
"aria-keyshortcuts": props.keyShortcuts,
|
|
964
1087
|
children: props.children
|
|
965
1088
|
}), props.trailing]
|
|
966
1089
|
});
|
|
@@ -968,17 +1091,26 @@ function Row(props) {
|
|
|
968
1091
|
const ROW_ACTION = "flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground opacity-0 hover:bg-background hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100";
|
|
969
1092
|
const DELETE_ACTION = `${ROW_ACTION} hover:text-wf-fail`;
|
|
970
1093
|
function DeleteButton(props) {
|
|
971
|
-
|
|
1094
|
+
const [confirming, setConfirming] = useState(false);
|
|
1095
|
+
const isWorkflow = props.node.documentType === WORKFLOW_TYPE$2;
|
|
1096
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
972
1097
|
type: "button",
|
|
973
1098
|
title: "Delete",
|
|
974
1099
|
"aria-label": `Delete ${props.label}`,
|
|
975
1100
|
className: DELETE_ACTION,
|
|
976
|
-
onClick: () => showDeleteNodeModal(props.node),
|
|
1101
|
+
onClick: () => isWorkflow ? setConfirming(true) : showDeleteNodeModal(props.node),
|
|
977
1102
|
children: /* @__PURE__ */ jsx(Icon, {
|
|
978
1103
|
name: "trash",
|
|
979
1104
|
className: "h-3.5 w-3.5"
|
|
980
1105
|
})
|
|
981
|
-
})
|
|
1106
|
+
}), confirming ? /* @__PURE__ */ jsx(DeleteWorkflowDialog, {
|
|
1107
|
+
name: props.label,
|
|
1108
|
+
onCancel: () => setConfirming(false),
|
|
1109
|
+
onConfirm: async () => {
|
|
1110
|
+
await deleteWorkflow(props.node.id);
|
|
1111
|
+
setConfirming(false);
|
|
1112
|
+
}
|
|
1113
|
+
}) : null] });
|
|
982
1114
|
}
|
|
983
1115
|
function NodeRow(props) {
|
|
984
1116
|
const { node } = props;
|
|
@@ -989,6 +1121,8 @@ function NodeRow(props) {
|
|
|
989
1121
|
if (error !== void 0) return /* @__PURE__ */ jsxs(Row, {
|
|
990
1122
|
active: props.active,
|
|
991
1123
|
onClick: props.onOpen,
|
|
1124
|
+
onKeyDown: props.onKeyDown,
|
|
1125
|
+
keyShortcuts: props.keyShortcuts,
|
|
992
1126
|
trailing: /* @__PURE__ */ jsx("span", {
|
|
993
1127
|
className: "mr-1.5 flex shrink-0 items-center",
|
|
994
1128
|
children: /* @__PURE__ */ jsx(DeleteButton, {
|
|
@@ -1016,6 +1150,8 @@ function NodeRow(props) {
|
|
|
1016
1150
|
return /* @__PURE__ */ jsxs(Row, {
|
|
1017
1151
|
active: props.active,
|
|
1018
1152
|
onClick: props.onOpen,
|
|
1153
|
+
onKeyDown: props.onKeyDown,
|
|
1154
|
+
keyShortcuts: props.keyShortcuts,
|
|
1019
1155
|
trailing: /* @__PURE__ */ jsxs("span", {
|
|
1020
1156
|
className: "mr-1.5 flex shrink-0 items-center",
|
|
1021
1157
|
children: [props.onEdit ? /* @__PURE__ */ jsx("button", {
|
|
@@ -1050,12 +1186,30 @@ function NodeRow(props) {
|
|
|
1050
1186
|
})]
|
|
1051
1187
|
});
|
|
1052
1188
|
}
|
|
1189
|
+
function DropLine(props) {
|
|
1190
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1191
|
+
"aria-hidden": true,
|
|
1192
|
+
className: `pointer-events-none absolute inset-x-3 z-10 h-0.5 rounded-full bg-primary ${props.edge === "top" ? "-top-px" : "-bottom-px"}`
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1053
1195
|
function Section(props) {
|
|
1196
|
+
const { onReorder } = props;
|
|
1197
|
+
const headingId = useId();
|
|
1198
|
+
const [drag, setDrag] = useState(null);
|
|
1199
|
+
const count = props.nodes.length;
|
|
1200
|
+
const drop = (from, at) => {
|
|
1201
|
+
const to = at > from ? at - 1 : at;
|
|
1202
|
+
if (to !== from) onReorder?.(from, to);
|
|
1203
|
+
};
|
|
1204
|
+
const showLine = (at) => drag !== null && drag.at === at && at !== drag.from && at !== drag.from + 1;
|
|
1054
1205
|
return /* @__PURE__ */ jsxs("div", {
|
|
1055
1206
|
className: "mt-5",
|
|
1207
|
+
role: "group",
|
|
1208
|
+
"aria-labelledby": headingId,
|
|
1056
1209
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1057
1210
|
className: "mb-1 flex items-center justify-between pl-4 pr-3",
|
|
1058
1211
|
children: [/* @__PURE__ */ jsx("h3", {
|
|
1212
|
+
id: headingId,
|
|
1059
1213
|
className: "text-xs font-medium text-muted-foreground",
|
|
1060
1214
|
children: props.title
|
|
1061
1215
|
}), /* @__PURE__ */ jsx("button", {
|
|
@@ -1075,12 +1229,56 @@ function Section(props) {
|
|
|
1075
1229
|
children: props.empty
|
|
1076
1230
|
}) : /* @__PURE__ */ jsx("div", {
|
|
1077
1231
|
className: "flex flex-col gap-0.5",
|
|
1078
|
-
children: props.nodes.map((node) => /* @__PURE__ */
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1232
|
+
children: props.nodes.map((node, i) => /* @__PURE__ */ jsxs("div", {
|
|
1233
|
+
className: `relative ${drag?.from === i ? "opacity-50" : ""}`,
|
|
1234
|
+
draggable: Boolean(onReorder),
|
|
1235
|
+
onDragStart: (event) => {
|
|
1236
|
+
event.dataTransfer.effectAllowed = "move";
|
|
1237
|
+
event.dataTransfer.setData("text/plain", node.id);
|
|
1238
|
+
setDrag({
|
|
1239
|
+
from: i,
|
|
1240
|
+
at: i
|
|
1241
|
+
});
|
|
1242
|
+
},
|
|
1243
|
+
onDragOver: (event) => {
|
|
1244
|
+
if (!drag) return;
|
|
1245
|
+
event.preventDefault();
|
|
1246
|
+
event.dataTransfer.dropEffect = "move";
|
|
1247
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
1248
|
+
const at = event.clientY < box.top + box.height / 2 ? i : i + 1;
|
|
1249
|
+
if (at !== drag.at) setDrag({
|
|
1250
|
+
...drag,
|
|
1251
|
+
at
|
|
1252
|
+
});
|
|
1253
|
+
},
|
|
1254
|
+
onDrop: (event) => {
|
|
1255
|
+
event.preventDefault();
|
|
1256
|
+
if (drag) drop(drag.from, drag.at);
|
|
1257
|
+
setDrag(null);
|
|
1258
|
+
},
|
|
1259
|
+
onDragEnd: () => setDrag(null),
|
|
1260
|
+
children: [
|
|
1261
|
+
showLine(i) ? /* @__PURE__ */ jsx(DropLine, { edge: "top" }) : null,
|
|
1262
|
+
/* @__PURE__ */ jsx(NodeRow, {
|
|
1263
|
+
node,
|
|
1264
|
+
lastRunStatus: props.lastRuns?.get(node.id),
|
|
1265
|
+
active: props.activeId === node.id,
|
|
1266
|
+
onOpen: () => props.onOpen(node),
|
|
1267
|
+
onEdit: props.onEdit ? () => props.onEdit(node) : void 0,
|
|
1268
|
+
keyShortcuts: onReorder ? "Alt+ArrowUp Alt+ArrowDown" : void 0,
|
|
1269
|
+
onKeyDown: onReorder ? (event) => {
|
|
1270
|
+
if (!event.altKey) return;
|
|
1271
|
+
if (event.key === "ArrowUp" && i > 0) {
|
|
1272
|
+
event.preventDefault();
|
|
1273
|
+
onReorder(i, i - 1);
|
|
1274
|
+
} else if (event.key === "ArrowDown" && i < count - 1) {
|
|
1275
|
+
event.preventDefault();
|
|
1276
|
+
onReorder(i, i + 1);
|
|
1277
|
+
}
|
|
1278
|
+
} : void 0
|
|
1279
|
+
}),
|
|
1280
|
+
i === count - 1 && showLine(count) ? /* @__PURE__ */ jsx(DropLine, { edge: "bottom" }) : null
|
|
1281
|
+
]
|
|
1084
1282
|
}, node.id))
|
|
1085
1283
|
})]
|
|
1086
1284
|
});
|
|
@@ -1107,6 +1305,7 @@ function Sidebar(props) {
|
|
|
1107
1305
|
onOpen: props.onOpenWorkflow,
|
|
1108
1306
|
onEdit: props.onEditWorkflow,
|
|
1109
1307
|
onCreate: props.onCreateWorkflow,
|
|
1308
|
+
onReorder: props.onReorderWorkflow,
|
|
1110
1309
|
creating: props.creating
|
|
1111
1310
|
}),
|
|
1112
1311
|
/* @__PURE__ */ jsx(Section, {
|
|
@@ -1138,11 +1337,13 @@ function useHashSelection() {
|
|
|
1138
1337
|
window.removeEventListener("popstate", sync);
|
|
1139
1338
|
};
|
|
1140
1339
|
}, []);
|
|
1141
|
-
return [selected, useCallback((id) => {
|
|
1340
|
+
return [selected, useCallback((id, options) => {
|
|
1142
1341
|
setSelected(id);
|
|
1143
1342
|
const url = new URL(window.location.href);
|
|
1144
1343
|
url.hash = id ?? "";
|
|
1145
|
-
window.
|
|
1344
|
+
if (url.href === window.location.href) return;
|
|
1345
|
+
if (options?.replace) window.history.replaceState(null, "", url);
|
|
1346
|
+
else window.history.pushState(null, "", url);
|
|
1146
1347
|
}, [])];
|
|
1147
1348
|
}
|
|
1148
1349
|
//#endregion
|
|
@@ -1208,6 +1409,412 @@ function stepOutline(args) {
|
|
|
1208
1409
|
};
|
|
1209
1410
|
}
|
|
1210
1411
|
//#endregion
|
|
1412
|
+
//#region editors/workflow-studio/components/graph-layout.ts
|
|
1413
|
+
const TRIGGER_NODE = "trigger";
|
|
1414
|
+
const SIDE_PORTS = /* @__PURE__ */ new Set(["false", "error"]);
|
|
1415
|
+
function graphLayout(args) {
|
|
1416
|
+
const { rows } = stepOutline(args);
|
|
1417
|
+
const nodeId = (id) => id === args.triggerId ? TRIGGER_NODE : id;
|
|
1418
|
+
const placed = /* @__PURE__ */ new Map([[TRIGGER_NODE, {
|
|
1419
|
+
col: 0,
|
|
1420
|
+
lane: 0
|
|
1421
|
+
}]]);
|
|
1422
|
+
const taken = /* @__PURE__ */ new Set();
|
|
1423
|
+
const inbound = /* @__PURE__ */ new Map();
|
|
1424
|
+
for (const edge of args.edges) {
|
|
1425
|
+
const list = inbound.get(edge.to) ?? [];
|
|
1426
|
+
list.push(edge);
|
|
1427
|
+
inbound.set(edge.to, list);
|
|
1428
|
+
}
|
|
1429
|
+
const nodes = [];
|
|
1430
|
+
for (const { step } of rows) {
|
|
1431
|
+
const from = (inbound.get(step.id) ?? []).filter((edge) => placed.has(nodeId(edge.from)));
|
|
1432
|
+
const col = Math.max(1, ...from.map((edge) => placed.get(nodeId(edge.from)).col + 1));
|
|
1433
|
+
let lane = Math.min(...from.map((edge) => placed.get(nodeId(edge.from)).lane + (SIDE_PORTS.has(edge.port) ? 1 : 0)), from.length === 0 ? 0 : Infinity);
|
|
1434
|
+
const port = from.length === 1 && from[0].port !== "next" ? from[0].port : null;
|
|
1435
|
+
while (taken.has(`${col}:${lane}`)) lane++;
|
|
1436
|
+
taken.add(`${col}:${lane}`);
|
|
1437
|
+
placed.set(step.id, {
|
|
1438
|
+
col,
|
|
1439
|
+
lane
|
|
1440
|
+
});
|
|
1441
|
+
nodes.push({
|
|
1442
|
+
step,
|
|
1443
|
+
col,
|
|
1444
|
+
lane,
|
|
1445
|
+
port
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
return {
|
|
1449
|
+
nodes,
|
|
1450
|
+
edges: args.edges.map((edge) => ({
|
|
1451
|
+
...edge,
|
|
1452
|
+
from: nodeId(edge.from)
|
|
1453
|
+
})).filter((edge) => placed.has(edge.from) && placed.has(edge.to)).map((edge) => {
|
|
1454
|
+
const a = placed.get(edge.from);
|
|
1455
|
+
const b = placed.get(edge.to);
|
|
1456
|
+
const clear = (lane) => !nodes.some((node) => node.lane === lane && node.col > a.col && node.col < b.col);
|
|
1457
|
+
const low = Math.max(a.lane, b.lane);
|
|
1458
|
+
const high = Math.min(a.lane, b.lane);
|
|
1459
|
+
const track = clear(low) ? {
|
|
1460
|
+
lane: low,
|
|
1461
|
+
under: false
|
|
1462
|
+
} : clear(high) ? {
|
|
1463
|
+
lane: high,
|
|
1464
|
+
under: false
|
|
1465
|
+
} : {
|
|
1466
|
+
lane: high,
|
|
1467
|
+
under: true
|
|
1468
|
+
};
|
|
1469
|
+
return {
|
|
1470
|
+
from: edge.from,
|
|
1471
|
+
to: edge.to,
|
|
1472
|
+
port: edge.port,
|
|
1473
|
+
track
|
|
1474
|
+
};
|
|
1475
|
+
}),
|
|
1476
|
+
cols: Math.max(0, ...nodes.map((node) => node.col)),
|
|
1477
|
+
lanes: Math.max(1, ...nodes.map((node) => node.lane + 1))
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region editors/workflow-studio/components/WorkflowGraph.tsx
|
|
1482
|
+
const GEOMETRY = {
|
|
1483
|
+
sm: {
|
|
1484
|
+
r: 12,
|
|
1485
|
+
col: 120,
|
|
1486
|
+
lane: 72,
|
|
1487
|
+
lead: 20,
|
|
1488
|
+
top: 14,
|
|
1489
|
+
dip: 50,
|
|
1490
|
+
label: 18,
|
|
1491
|
+
subtitle: false,
|
|
1492
|
+
nameText: "text-xs",
|
|
1493
|
+
logo: 14,
|
|
1494
|
+
circle: "h-6 w-6",
|
|
1495
|
+
pill: "h-7 pl-1 pr-2.5 text-[12px]",
|
|
1496
|
+
pillLogo: "h-5 w-5",
|
|
1497
|
+
portText: "text-[10px]"
|
|
1498
|
+
},
|
|
1499
|
+
md: {
|
|
1500
|
+
r: 18,
|
|
1501
|
+
col: 136,
|
|
1502
|
+
lane: 100,
|
|
1503
|
+
lead: 28,
|
|
1504
|
+
top: 18,
|
|
1505
|
+
dip: 72,
|
|
1506
|
+
label: 36,
|
|
1507
|
+
subtitle: true,
|
|
1508
|
+
nameText: "text-[13px]",
|
|
1509
|
+
logo: 20,
|
|
1510
|
+
circle: "h-9 w-9",
|
|
1511
|
+
pill: "h-9 pl-1.5 pr-3 text-[13px]",
|
|
1512
|
+
pillLogo: "h-6 w-6",
|
|
1513
|
+
portText: "text-[11px]"
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1516
|
+
const RING$1 = {
|
|
1517
|
+
ok: "ring-wf-ok",
|
|
1518
|
+
fail: "ring-wf-fail",
|
|
1519
|
+
warn: "ring-wf-warn",
|
|
1520
|
+
run: "ring-wf-run",
|
|
1521
|
+
idle: "ring-foreground/15 dark:ring-foreground/30"
|
|
1522
|
+
};
|
|
1523
|
+
const STROKE = {
|
|
1524
|
+
ok: "text-wf-ok",
|
|
1525
|
+
fail: "text-wf-fail",
|
|
1526
|
+
warn: "text-wf-warn",
|
|
1527
|
+
run: "text-wf-run",
|
|
1528
|
+
idle: "text-foreground/15 dark:text-foreground/30"
|
|
1529
|
+
};
|
|
1530
|
+
const PORT_PILL = {
|
|
1531
|
+
true: "bg-wf-ok/10 text-wf-ok ring-wf-ok/30",
|
|
1532
|
+
false: "bg-wf-fail/10 text-wf-fail ring-wf-fail/30",
|
|
1533
|
+
error: "bg-wf-warn/10 text-wf-warn ring-wf-warn/30"
|
|
1534
|
+
};
|
|
1535
|
+
const PORT_TEXT = {
|
|
1536
|
+
true: "Runs when the condition is true",
|
|
1537
|
+
false: "Runs when the condition is false",
|
|
1538
|
+
error: "Runs when the step before it fails"
|
|
1539
|
+
};
|
|
1540
|
+
function roundedPath(points, radius = 6) {
|
|
1541
|
+
let d = `M ${points[0][0]} ${points[0][1]}`;
|
|
1542
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
1543
|
+
const [px, py] = points[i - 1];
|
|
1544
|
+
const [x, y] = points[i];
|
|
1545
|
+
const [nx, ny] = points[i + 1];
|
|
1546
|
+
const r = Math.min(radius, Math.hypot(x - px, y - py) / 2, Math.hypot(nx - x, ny - y) / 2);
|
|
1547
|
+
const inX = x - Math.sign(x - px) * r;
|
|
1548
|
+
const inY = y - Math.sign(y - py) * r;
|
|
1549
|
+
const outX = x + Math.sign(nx - x) * r;
|
|
1550
|
+
const outY = y + Math.sign(ny - y) * r;
|
|
1551
|
+
d += ` L ${inX} ${inY} Q ${x} ${y} ${outX} ${outY}`;
|
|
1552
|
+
}
|
|
1553
|
+
const [lx, ly] = points[points.length - 1];
|
|
1554
|
+
return `${d} L ${lx} ${ly}`;
|
|
1555
|
+
}
|
|
1556
|
+
function edgeRoute(g, source, target, trackY) {
|
|
1557
|
+
const x1 = source ? source.x + g.r : 0;
|
|
1558
|
+
const y1 = source ? source.y : g.top;
|
|
1559
|
+
const x2 = target.x - g.r;
|
|
1560
|
+
const y2 = target.y;
|
|
1561
|
+
const after = source ? source.x + g.col / 2 : g.lead / 2;
|
|
1562
|
+
const before = target.x - g.col / 2;
|
|
1563
|
+
const route = [
|
|
1564
|
+
[x1, y1],
|
|
1565
|
+
[after, y1],
|
|
1566
|
+
[after, trackY],
|
|
1567
|
+
[before, trackY],
|
|
1568
|
+
[before, y2],
|
|
1569
|
+
[x2, y2]
|
|
1570
|
+
];
|
|
1571
|
+
return {
|
|
1572
|
+
points: route.filter((point, index) => {
|
|
1573
|
+
const prev = route[index - 1];
|
|
1574
|
+
const next = route[index + 1];
|
|
1575
|
+
if (!prev || !next) return true;
|
|
1576
|
+
return !(prev[0] === point[0] && point[0] === next[0] || prev[1] === point[1] && point[1] === next[1]);
|
|
1577
|
+
}),
|
|
1578
|
+
label: {
|
|
1579
|
+
x: ((trackY === y1 ? x1 : after) + (trackY === y2 ? x2 : before)) / 2,
|
|
1580
|
+
y: trackY
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
function Mark({ label, className, onOpen, children, ref, onClick, ...rest }) {
|
|
1585
|
+
return onOpen ? /* @__PURE__ */ jsx("button", {
|
|
1586
|
+
...rest,
|
|
1587
|
+
ref,
|
|
1588
|
+
type: "button",
|
|
1589
|
+
"aria-label": label,
|
|
1590
|
+
className: `${className} focus-visible:outline-none focus-visible:ring-[3px]`,
|
|
1591
|
+
onClick: (event) => {
|
|
1592
|
+
onClick?.(event);
|
|
1593
|
+
onOpen();
|
|
1594
|
+
},
|
|
1595
|
+
children
|
|
1596
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
1597
|
+
...rest,
|
|
1598
|
+
ref,
|
|
1599
|
+
onClick,
|
|
1600
|
+
className,
|
|
1601
|
+
children
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
function Tip(props) {
|
|
1605
|
+
return /* @__PURE__ */ jsx(ConnectTooltip, {
|
|
1606
|
+
content: props.content,
|
|
1607
|
+
side: "bottom",
|
|
1608
|
+
delayDuration: 100,
|
|
1609
|
+
className: "max-w-64 rounded-md border-solid border-foreground/10 bg-card px-2.5 py-1.5 text-foreground shadow-lg",
|
|
1610
|
+
children: props.children
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
function stepSummary(record, ran) {
|
|
1614
|
+
if (!ran) return "Not run yet";
|
|
1615
|
+
if (!record) return "Not reached in the latest run";
|
|
1616
|
+
const took = record.startedAt && record.endedAt ? ` · ${formatDuration(record.startedAt, record.endedAt)}` : "";
|
|
1617
|
+
return `${statusLabel(record.status)} in the latest run${took}`;
|
|
1618
|
+
}
|
|
1619
|
+
function StepTip(props) {
|
|
1620
|
+
const { step } = props.node;
|
|
1621
|
+
const meta = blockMeta(stepBlock(step));
|
|
1622
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
1623
|
+
className: "flex flex-col gap-0.5",
|
|
1624
|
+
children: [
|
|
1625
|
+
/* @__PURE__ */ jsx("span", {
|
|
1626
|
+
className: "font-medium",
|
|
1627
|
+
children: step.name || step.key
|
|
1628
|
+
}),
|
|
1629
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1630
|
+
className: "text-muted-foreground",
|
|
1631
|
+
children: [
|
|
1632
|
+
meta.displayName,
|
|
1633
|
+
" · ",
|
|
1634
|
+
meta.subtitle
|
|
1635
|
+
]
|
|
1636
|
+
}),
|
|
1637
|
+
props.node.port ? /* @__PURE__ */ jsx("span", {
|
|
1638
|
+
className: "text-muted-foreground",
|
|
1639
|
+
children: PORT_TEXT[props.node.port] ?? `Runs on "${props.node.port}"`
|
|
1640
|
+
}) : null,
|
|
1641
|
+
/* @__PURE__ */ jsx("span", {
|
|
1642
|
+
className: "mt-1",
|
|
1643
|
+
children: stepSummary(props.record, props.ran)
|
|
1644
|
+
}),
|
|
1645
|
+
props.record?.error ? /* @__PURE__ */ jsx("span", {
|
|
1646
|
+
className: "line-clamp-3 text-wf-fail",
|
|
1647
|
+
children: props.record.error
|
|
1648
|
+
}) : null
|
|
1649
|
+
]
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
function WorkflowGraph(props) {
|
|
1653
|
+
const { state, latest } = props;
|
|
1654
|
+
const g = GEOMETRY[props.size ?? "sm"];
|
|
1655
|
+
const centerX = (col) => g.lead + (col - 1) * g.col + g.r;
|
|
1656
|
+
const centerY = (lane) => g.top + lane * g.lane;
|
|
1657
|
+
const layout = graphLayout({
|
|
1658
|
+
triggerId: state.trigger?.id,
|
|
1659
|
+
steps: state.steps,
|
|
1660
|
+
edges: state.edges
|
|
1661
|
+
});
|
|
1662
|
+
const records = new Map((latest?.steps ?? []).map((record) => [record.stepKey, record]));
|
|
1663
|
+
const toneOfStep = (key) => {
|
|
1664
|
+
const status = records.get(key)?.status;
|
|
1665
|
+
return status ? toneOf(STEP_TONE, status) : "idle";
|
|
1666
|
+
};
|
|
1667
|
+
const at = new Map(layout.nodes.map((node) => [node.step.id, node]));
|
|
1668
|
+
const width = layout.cols > 0 ? centerX(layout.cols) + (g.label ? g.col / 2 : g.r) : 0;
|
|
1669
|
+
const trackY = (edge) => centerY(edge.track.lane) + (edge.track.under ? g.dip : 0);
|
|
1670
|
+
const dips = layout.edges.filter((edge) => edge.track.under).map((edge) => trackY(edge) + (PORT_PILL[edge.port] ? 10 : 4));
|
|
1671
|
+
const height = Math.max(centerY(layout.lanes - 1) + (g.label ? g.r + 6 + g.label : g.top), ...dips);
|
|
1672
|
+
const routes = layout.edges.map((edge) => {
|
|
1673
|
+
const source = edge.from === "trigger" ? null : at.get(edge.from);
|
|
1674
|
+
const target = at.get(edge.to);
|
|
1675
|
+
return {
|
|
1676
|
+
key: `${edge.from}-${edge.port}-${edge.to}`,
|
|
1677
|
+
edge,
|
|
1678
|
+
tone: toneOfStep(target.step.key),
|
|
1679
|
+
route: edgeRoute(g, source ? {
|
|
1680
|
+
x: centerX(source.col),
|
|
1681
|
+
y: centerY(source.lane)
|
|
1682
|
+
} : null, {
|
|
1683
|
+
x: centerX(target.col),
|
|
1684
|
+
y: centerY(target.lane)
|
|
1685
|
+
}, trackY(edge))
|
|
1686
|
+
};
|
|
1687
|
+
});
|
|
1688
|
+
const trigger = state.trigger ? triggerBlock(state.trigger) : null;
|
|
1689
|
+
const triggerMeta = trigger ? blockMeta(trigger) : null;
|
|
1690
|
+
return /* @__PURE__ */ jsx(ConnectTooltipProvider, {
|
|
1691
|
+
disableHoverableContent: true,
|
|
1692
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1693
|
+
className: "flex items-start",
|
|
1694
|
+
children: [/* @__PURE__ */ jsx(Tip, {
|
|
1695
|
+
content: /* @__PURE__ */ jsxs("span", {
|
|
1696
|
+
className: "flex flex-col gap-0.5",
|
|
1697
|
+
children: [
|
|
1698
|
+
/* @__PURE__ */ jsx("span", {
|
|
1699
|
+
className: "font-medium",
|
|
1700
|
+
children: triggerMeta?.displayName ?? "No trigger"
|
|
1701
|
+
}),
|
|
1702
|
+
triggerMeta ? /* @__PURE__ */ jsx("span", {
|
|
1703
|
+
className: "text-muted-foreground",
|
|
1704
|
+
children: triggerMeta.subtitle
|
|
1705
|
+
}) : null,
|
|
1706
|
+
/* @__PURE__ */ jsx("span", {
|
|
1707
|
+
className: "mt-1",
|
|
1708
|
+
children: latest ? `Last fired ${formatWhen(latest.startedAt)}` : "Not fired yet"
|
|
1709
|
+
})
|
|
1710
|
+
]
|
|
1711
|
+
}),
|
|
1712
|
+
children: /* @__PURE__ */ jsxs(Mark, {
|
|
1713
|
+
label: `Trigger: ${props.triggerText}`,
|
|
1714
|
+
onOpen: props.onOpen,
|
|
1715
|
+
className: `flex shrink-0 items-center gap-1.5 rounded-full bg-card font-medium text-foreground ring-[1.5px] ${g.pill} ${latest ? RING$1.ok : RING$1.idle}`,
|
|
1716
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1717
|
+
className: `flex items-center justify-center rounded-full dark:bg-white ${g.pillLogo}`,
|
|
1718
|
+
children: trigger ? /* @__PURE__ */ jsx(BlockLogo, {
|
|
1719
|
+
bare: true,
|
|
1720
|
+
block: trigger,
|
|
1721
|
+
size: g.logo - 2
|
|
1722
|
+
}) : null
|
|
1723
|
+
}), props.triggerText]
|
|
1724
|
+
})
|
|
1725
|
+
}), layout.nodes.length > 0 ? /* @__PURE__ */ jsxs("ol", {
|
|
1726
|
+
className: "relative -ml-px shrink-0",
|
|
1727
|
+
style: {
|
|
1728
|
+
width,
|
|
1729
|
+
height
|
|
1730
|
+
},
|
|
1731
|
+
"aria-label": layout.nodes.map((node) => {
|
|
1732
|
+
const status = records.get(node.step.key)?.status;
|
|
1733
|
+
const label = node.step.name || node.step.key;
|
|
1734
|
+
return status ? `${label}: ${status.toLowerCase()}` : label;
|
|
1735
|
+
}).join(", "),
|
|
1736
|
+
children: [
|
|
1737
|
+
/* @__PURE__ */ jsx("svg", {
|
|
1738
|
+
"aria-hidden": true,
|
|
1739
|
+
className: "absolute inset-0 overflow-visible",
|
|
1740
|
+
width,
|
|
1741
|
+
height,
|
|
1742
|
+
children: routes.map(({ key, edge, route, tone }) => /* @__PURE__ */ jsx("path", {
|
|
1743
|
+
d: roundedPath(route.points),
|
|
1744
|
+
fill: "none",
|
|
1745
|
+
stroke: "currentColor",
|
|
1746
|
+
strokeWidth: 2,
|
|
1747
|
+
strokeDasharray: edge.port === "error" ? "3 3" : void 0,
|
|
1748
|
+
className: STROKE[tone]
|
|
1749
|
+
}, key))
|
|
1750
|
+
}),
|
|
1751
|
+
routes.map(({ key, edge, route }) => PORT_PILL[edge.port] ? /* @__PURE__ */ jsx("span", {
|
|
1752
|
+
"aria-hidden": true,
|
|
1753
|
+
className: "pointer-events-none absolute z-[1] -translate-x-1/2 -translate-y-1/2 rounded-full bg-card",
|
|
1754
|
+
style: {
|
|
1755
|
+
left: route.label.x,
|
|
1756
|
+
top: route.label.y
|
|
1757
|
+
},
|
|
1758
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1759
|
+
className: `block rounded-full px-1.5 font-medium leading-4 ring-1 ring-inset ${g.portText} ${PORT_PILL[edge.port]}`,
|
|
1760
|
+
children: edge.port
|
|
1761
|
+
})
|
|
1762
|
+
}, key) : null),
|
|
1763
|
+
layout.nodes.map((node) => {
|
|
1764
|
+
const record = records.get(node.step.key);
|
|
1765
|
+
const skipped = record?.status === "SKIPPED";
|
|
1766
|
+
const name = node.step.name || node.step.key;
|
|
1767
|
+
const x = centerX(node.col);
|
|
1768
|
+
const y = centerY(node.lane);
|
|
1769
|
+
return /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("span", {
|
|
1770
|
+
className: "absolute",
|
|
1771
|
+
style: {
|
|
1772
|
+
left: x - g.r,
|
|
1773
|
+
top: y - g.r
|
|
1774
|
+
},
|
|
1775
|
+
children: /* @__PURE__ */ jsx(Tip, {
|
|
1776
|
+
content: /* @__PURE__ */ jsx(StepTip, {
|
|
1777
|
+
node,
|
|
1778
|
+
record,
|
|
1779
|
+
ran: Boolean(latest)
|
|
1780
|
+
}),
|
|
1781
|
+
children: /* @__PURE__ */ jsx(Mark, {
|
|
1782
|
+
label: `${name}: ${record ? record.status.toLowerCase() : "not run"}`,
|
|
1783
|
+
onOpen: props.onOpen,
|
|
1784
|
+
className: `flex items-center justify-center rounded-full bg-card transition-shadow ${g.circle} ${skipped ? "border-[1.5px] border-dashed border-foreground/40" : `ring-[1.5px] hover:ring-[3px] dark:bg-white ${RING$1[toneOfStep(node.step.key)]}`}`,
|
|
1785
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1786
|
+
className: skipped ? "flex opacity-40" : "flex",
|
|
1787
|
+
children: /* @__PURE__ */ jsx(BlockLogo, {
|
|
1788
|
+
bare: true,
|
|
1789
|
+
block: stepBlock(node.step),
|
|
1790
|
+
size: g.logo
|
|
1791
|
+
})
|
|
1792
|
+
})
|
|
1793
|
+
})
|
|
1794
|
+
})
|
|
1795
|
+
}), g.label ? /* @__PURE__ */ jsxs("span", {
|
|
1796
|
+
"aria-hidden": true,
|
|
1797
|
+
className: "pointer-events-none absolute flex flex-col items-center text-center",
|
|
1798
|
+
style: {
|
|
1799
|
+
left: x - (g.col - 16) / 2,
|
|
1800
|
+
top: y + g.r + 6,
|
|
1801
|
+
width: g.col - 16
|
|
1802
|
+
},
|
|
1803
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1804
|
+
className: `max-w-full truncate font-medium text-foreground ${g.nameText}`,
|
|
1805
|
+
children: name
|
|
1806
|
+
}), g.subtitle ? /* @__PURE__ */ jsx("span", {
|
|
1807
|
+
className: "max-w-full truncate text-xs text-muted-foreground",
|
|
1808
|
+
children: blockMeta(stepBlock(node.step)).displayName
|
|
1809
|
+
}) : null]
|
|
1810
|
+
}) : null] }, node.step.id);
|
|
1811
|
+
})
|
|
1812
|
+
]
|
|
1813
|
+
}) : null]
|
|
1814
|
+
})
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
//#endregion
|
|
1211
1818
|
//#region editors/workflow-studio/components/WorkflowBoard.tsx
|
|
1212
1819
|
function RowToggle(props) {
|
|
1213
1820
|
const [, dispatch] = useDispatch(props.document);
|
|
@@ -1230,42 +1837,21 @@ function WorkflowBoard(props) {
|
|
|
1230
1837
|
usePieceLogos();
|
|
1231
1838
|
const documents = useWorkflowDocumentsInSelectedDrive() ?? [];
|
|
1232
1839
|
const runs = props.runs ?? [];
|
|
1840
|
+
const positions = new Map(props.order.map((id, i) => [id, i]));
|
|
1841
|
+
const position = (id) => positions.get(id) ?? positions.size;
|
|
1233
1842
|
const rows = documents.map((document) => {
|
|
1234
1843
|
const state = document.state.global;
|
|
1235
1844
|
const workflowRuns = runs.filter((run) => run.workflowId === document.header.id);
|
|
1236
|
-
const latest = workflowRuns.at(0);
|
|
1237
|
-
const statusByKey = new Map((latest?.steps ?? []).map((step) => [step.stepKey, step.status]));
|
|
1238
|
-
const outline = stepOutline({
|
|
1239
|
-
triggerId: state.trigger?.id,
|
|
1240
|
-
steps: state.steps,
|
|
1241
|
-
edges: state.edges
|
|
1242
|
-
});
|
|
1243
|
-
const links = [...state.trigger ? [{
|
|
1244
|
-
id: state.trigger.id,
|
|
1245
|
-
block: triggerBlock(state.trigger),
|
|
1246
|
-
label: "Trigger",
|
|
1247
|
-
status: latest ? "SUCCEEDED" : void 0
|
|
1248
|
-
}] : [], ...outline.rows.map((row) => ({
|
|
1249
|
-
id: row.step.id,
|
|
1250
|
-
block: stepBlock(row.step),
|
|
1251
|
-
label: row.step.name || row.step.key,
|
|
1252
|
-
status: statusByKey.get(row.step.key)
|
|
1253
|
-
}))];
|
|
1254
1845
|
return {
|
|
1255
1846
|
document,
|
|
1256
1847
|
id: document.header.id,
|
|
1257
1848
|
name: state.name || document.header.name || "Untitled workflow",
|
|
1849
|
+
description: state.description,
|
|
1258
1850
|
status: state.status,
|
|
1259
1851
|
trigger: describeTrigger(state.trigger),
|
|
1260
|
-
links,
|
|
1261
1852
|
runs: workflowRuns
|
|
1262
1853
|
};
|
|
1263
|
-
}).sort((a, b) =>
|
|
1264
|
-
const at = a.runs[0]?.startedAt ?? "";
|
|
1265
|
-
const bt = b.runs[0]?.startedAt ?? "";
|
|
1266
|
-
if (at !== bt) return bt.localeCompare(at);
|
|
1267
|
-
return a.name.localeCompare(b.name);
|
|
1268
|
-
});
|
|
1854
|
+
}).sort((a, b) => position(a.id) - position(b.id));
|
|
1269
1855
|
return /* @__PURE__ */ jsxs("section", {
|
|
1270
1856
|
className: "mb-10",
|
|
1271
1857
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -1296,22 +1882,22 @@ function WorkflowBoard(props) {
|
|
|
1296
1882
|
})]
|
|
1297
1883
|
}) : /* @__PURE__ */ jsx("ul", {
|
|
1298
1884
|
"aria-label": "Workflows",
|
|
1299
|
-
className: "
|
|
1885
|
+
className: "rounded-xl border border-solid border-foreground/10 bg-card",
|
|
1300
1886
|
children: rows.map((row) => {
|
|
1301
1887
|
const latest = row.runs.at(0);
|
|
1302
1888
|
const latestTone = toneOf(RUN_TONE, latest?.status);
|
|
1303
1889
|
const health = workflowHealth(row.status, latest?.status, Boolean(row.document.state.global.published));
|
|
1304
1890
|
return /* @__PURE__ */ jsxs("li", {
|
|
1305
|
-
className: "flex items-
|
|
1891
|
+
className: "flex items-start border-b border-solid border-foreground/10 transition-colors first:rounded-t-xl last:rounded-b-xl last:border-b-0 hover:bg-accent/50 has-[>button:focus-visible]:bg-accent/50",
|
|
1306
1892
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
1307
1893
|
type: "button",
|
|
1308
|
-
className: "
|
|
1894
|
+
className: "flex min-w-0 flex-1 flex-col gap-3 px-5 py-4 text-left focus-visible:outline-none",
|
|
1309
1895
|
onClick: () => props.onOpen(row.id),
|
|
1310
|
-
children: [
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
className: "flex items-center gap-2",
|
|
1896
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
1897
|
+
className: "grid h-6 w-full grid-cols-[minmax(0,1fr)_auto] items-center gap-x-6 md:grid-cols-[minmax(0,1fr)_minmax(0,10rem)_auto]",
|
|
1898
|
+
children: [
|
|
1899
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1900
|
+
className: "flex min-w-0 items-center gap-2",
|
|
1315
1901
|
children: [
|
|
1316
1902
|
/* @__PURE__ */ jsx("span", {
|
|
1317
1903
|
title: health.label,
|
|
@@ -1322,41 +1908,49 @@ function WorkflowBoard(props) {
|
|
|
1322
1908
|
})
|
|
1323
1909
|
}),
|
|
1324
1910
|
/* @__PURE__ */ jsx("span", {
|
|
1325
|
-
className: "truncate text-[15px] font-semibold text-foreground",
|
|
1911
|
+
className: "max-w-[60%] shrink-0 truncate text-[15px] font-semibold text-foreground",
|
|
1326
1912
|
children: row.name
|
|
1327
1913
|
}),
|
|
1328
1914
|
row.status !== "ENABLED" ? /* @__PURE__ */ jsx("span", {
|
|
1329
1915
|
className: "shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",
|
|
1330
1916
|
children: statusLabel(row.status)
|
|
1917
|
+
}) : null,
|
|
1918
|
+
row.description ? /* @__PURE__ */ jsx("span", {
|
|
1919
|
+
title: row.description,
|
|
1920
|
+
className: "ml-1 min-w-0 truncate text-[13px] text-muted-foreground",
|
|
1921
|
+
children: row.description
|
|
1331
1922
|
}) : null
|
|
1332
1923
|
]
|
|
1333
|
-
}),
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
})] }) : /* @__PURE__ */ jsx("span", {
|
|
1352
|
-
className: "text-muted-foreground",
|
|
1353
|
-
children: "Not run yet"
|
|
1924
|
+
}),
|
|
1925
|
+
/* @__PURE__ */ jsx("span", {
|
|
1926
|
+
className: "hidden text-[13px] md:block",
|
|
1927
|
+
title: latest ? formatAbsolute(latest.startedAt) : void 0,
|
|
1928
|
+
children: latest ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
1929
|
+
className: `font-medium ${latestTone === "fail" ? "text-wf-fail" : latestTone === "ok" ? "text-wf-ok" : "text-foreground"}`,
|
|
1930
|
+
children: statusLabel(latest.status)
|
|
1931
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1932
|
+
className: "ml-1.5 text-xs text-muted-foreground",
|
|
1933
|
+
children: formatWhen(latest.startedAt)
|
|
1934
|
+
})] }) : /* @__PURE__ */ jsx("span", {
|
|
1935
|
+
className: "text-muted-foreground",
|
|
1936
|
+
children: "Not run yet"
|
|
1937
|
+
})
|
|
1938
|
+
}),
|
|
1939
|
+
/* @__PURE__ */ jsx(RunStrip, {
|
|
1940
|
+
centered: true,
|
|
1941
|
+
runs: row.runs
|
|
1354
1942
|
})
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1943
|
+
]
|
|
1944
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1945
|
+
className: "block max-w-full overflow-x-auto py-1 pl-4 pr-1",
|
|
1946
|
+
children: /* @__PURE__ */ jsx(WorkflowGraph, {
|
|
1947
|
+
state: row.document.state.global,
|
|
1948
|
+
triggerText: row.trigger,
|
|
1949
|
+
latest
|
|
1950
|
+
})
|
|
1951
|
+
})]
|
|
1358
1952
|
}), /* @__PURE__ */ jsxs("span", {
|
|
1359
|
-
className: "flex shrink-0 items-center gap-1 pr-3",
|
|
1953
|
+
className: "mt-4 flex h-6 shrink-0 items-center gap-1 pr-3",
|
|
1360
1954
|
children: [/* @__PURE__ */ jsx(RowToggle, { document: row.document }), /* @__PURE__ */ jsx(WorkflowMenu, { document: row.document })]
|
|
1361
1955
|
})]
|
|
1362
1956
|
}, row.id);
|
|
@@ -1422,20 +2016,6 @@ function TrackStop(props) {
|
|
|
1422
2016
|
]
|
|
1423
2017
|
});
|
|
1424
2018
|
}
|
|
1425
|
-
function Track(props) {
|
|
1426
|
-
const tones = props.stops.map((stop) => stop.status ? toneOf(STEP_TONE, stop.status) : "idle");
|
|
1427
|
-
return /* @__PURE__ */ jsx("ol", {
|
|
1428
|
-
className: "-mx-6 flex overflow-x-auto px-6 py-1.5",
|
|
1429
|
-
children: props.stops.map((stop, index) => /* @__PURE__ */ jsx(TrackStop, {
|
|
1430
|
-
stop,
|
|
1431
|
-
first: index === 0,
|
|
1432
|
-
last: index === props.stops.length - 1,
|
|
1433
|
-
inbound: tones[index],
|
|
1434
|
-
outbound: tones[index + 1] ?? "idle",
|
|
1435
|
-
onClick: props.onOpenEditor
|
|
1436
|
-
}, stop.id))
|
|
1437
|
-
});
|
|
1438
|
-
}
|
|
1439
2019
|
function WorkflowSteps(props) {
|
|
1440
2020
|
const { state } = props;
|
|
1441
2021
|
usePieceLogos();
|
|
@@ -1475,15 +2055,6 @@ function WorkflowSteps(props) {
|
|
|
1475
2055
|
]
|
|
1476
2056
|
})
|
|
1477
2057
|
});
|
|
1478
|
-
const trigger = state.trigger ? triggerBlock(state.trigger) : null;
|
|
1479
|
-
const triggerMeta = trigger ? blockMeta(trigger) : null;
|
|
1480
|
-
const stops = [...state.trigger && trigger && triggerMeta ? [{
|
|
1481
|
-
id: state.trigger.id,
|
|
1482
|
-
title: triggerMeta.displayName,
|
|
1483
|
-
subtitle: "Trigger",
|
|
1484
|
-
block: trigger,
|
|
1485
|
-
status: props.latestRun ? "SUCCEEDED" : void 0
|
|
1486
|
-
}] : [], ...outline.rows.map((row) => stopFor(row.step, row.port))];
|
|
1487
2058
|
return /* @__PURE__ */ jsxs("section", {
|
|
1488
2059
|
className: "mt-8 border-t border-solid border-border pt-6",
|
|
1489
2060
|
children: [
|
|
@@ -1501,9 +2072,15 @@ function WorkflowSteps(props) {
|
|
|
1501
2072
|
className: "mb-3 text-xs text-wf-warn",
|
|
1502
2073
|
children: "No trigger set, so this workflow never starts on its own."
|
|
1503
2074
|
}) : null,
|
|
1504
|
-
/* @__PURE__ */ jsx(
|
|
1505
|
-
|
|
1506
|
-
|
|
2075
|
+
/* @__PURE__ */ jsx("div", {
|
|
2076
|
+
className: "-mx-1 overflow-x-auto px-1 py-1.5",
|
|
2077
|
+
children: /* @__PURE__ */ jsx(WorkflowGraph, {
|
|
2078
|
+
state,
|
|
2079
|
+
triggerText: describeTrigger(state.trigger),
|
|
2080
|
+
latest: props.latestRun,
|
|
2081
|
+
onOpen: props.onOpenEditor,
|
|
2082
|
+
size: "md"
|
|
2083
|
+
})
|
|
1507
2084
|
}),
|
|
1508
2085
|
outline.orphans.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
1509
2086
|
className: "mt-5",
|
|
@@ -1613,7 +2190,10 @@ function WorkflowHeader(props) {
|
|
|
1613
2190
|
}),
|
|
1614
2191
|
/* @__PURE__ */ jsx(Fact, {
|
|
1615
2192
|
label: "Recent runs",
|
|
1616
|
-
children: stats.total > 0 ? /* @__PURE__ */ jsx(RunStrip, {
|
|
2193
|
+
children: stats.total > 0 ? /* @__PURE__ */ jsx(RunStrip, {
|
|
2194
|
+
centered: true,
|
|
2195
|
+
runs: props.runs ?? []
|
|
2196
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
1617
2197
|
className: "text-muted-foreground",
|
|
1618
2198
|
children: "None yet"
|
|
1619
2199
|
})
|
|
@@ -1648,36 +2228,48 @@ function WorkflowStudio(props) {
|
|
|
1648
2228
|
}
|
|
1649
2229
|
function Studio(props) {
|
|
1650
2230
|
const { fireWorkflow } = useRuntimeActions();
|
|
1651
|
-
const [drive] = useSelectedDrive();
|
|
2231
|
+
const [drive, dispatchDrive] = useSelectedDrive();
|
|
2232
|
+
const nodes = useNodesInSelectedDrive() ?? [];
|
|
1652
2233
|
const fileNodes = useFileNodesInSelectedDrive() ?? [];
|
|
2234
|
+
const workflowDocuments = useWorkflowDocumentsInSelectedDrive() ?? [];
|
|
1653
2235
|
const selectedNode = useSelectedNode();
|
|
1654
2236
|
const selectedNodeId = selectedNode?.id;
|
|
1655
2237
|
const toast = usePHToast();
|
|
1656
2238
|
const [selectedId, select] = useHashSelection();
|
|
1657
2239
|
const [creating, setCreating] = useState(false);
|
|
1658
2240
|
const driveId = drive.header.id;
|
|
1659
|
-
const
|
|
2241
|
+
const orderedWorkflows = orderWorkflows(fileNodes.filter((node) => node.documentType === WORKFLOW_TYPE), nodes);
|
|
2242
|
+
const workflows = orderedWorkflows.map((item) => item.node);
|
|
1660
2243
|
const connections = fileNodes.filter((node) => node.documentType === CONNECTION_TYPE);
|
|
1661
2244
|
const editorOpen = Boolean(props.children && selectedNodeId);
|
|
1662
2245
|
const create = (documentType, baseName, count) => {
|
|
1663
2246
|
if (creating) return;
|
|
1664
2247
|
setCreating(true);
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
2248
|
+
const name = `${baseName} ${count + 1}`;
|
|
2249
|
+
(documentType === WORKFLOW_TYPE ? addFolder(driveId, homeFolderName(nextKey(orderedWorkflows), name)).then((folder) => addDocument(driveId, name, documentType, folder.id).catch(async (error) => {
|
|
2250
|
+
await deleteNode(driveId, folder.id).catch(() => void 0);
|
|
2251
|
+
throw error;
|
|
2252
|
+
})) : addDocument(driveId, name, documentType)).then((node) => go(node.id, node.id)).catch((error) => {
|
|
1669
2253
|
toast?.(error instanceof Error ? error.message : `Failed to create ${baseName}`, { type: "error" });
|
|
1670
2254
|
}).finally(() => setCreating(false));
|
|
1671
2255
|
};
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1674
|
-
|
|
2256
|
+
const reorder = (from, to) => {
|
|
2257
|
+
const names = new Map(workflowDocuments.map((doc) => [doc.header.id, doc.state.global.name]));
|
|
2258
|
+
const actions = reorderActions(orderedWorkflows, from, to, names);
|
|
2259
|
+
if (actions.length === 0) return;
|
|
2260
|
+
dispatchDrive(actions, (errors) => toast?.(errors[0]?.message ?? "Failed to reorder workflows", { type: "error" }));
|
|
2261
|
+
};
|
|
2262
|
+
const go = (id, editor) => {
|
|
2263
|
+
const before = window.location.pathname;
|
|
2264
|
+
if ((editor ?? null) !== (selectedNodeId ?? null)) setSelectedNode(editor);
|
|
2265
|
+
select(id, { replace: window.location.pathname !== before });
|
|
1675
2266
|
};
|
|
2267
|
+
const showRuns = (node) => go(node?.id);
|
|
1676
2268
|
const liveTarget = workflows.find((node) => node.id === selectedId) ?? null;
|
|
1677
2269
|
const connectionSelected = connections.some((node) => node.id === selectedId);
|
|
1678
2270
|
const wasEditing = useRef(editorOpen);
|
|
1679
2271
|
useEffect(() => {
|
|
1680
|
-
if (wasEditing.current && !editorOpen && connectionSelected) select(void 0);
|
|
2272
|
+
if (wasEditing.current && !editorOpen && connectionSelected) select(void 0, { replace: true });
|
|
1681
2273
|
wasEditing.current = editorOpen;
|
|
1682
2274
|
}, [
|
|
1683
2275
|
editorOpen,
|
|
@@ -1686,7 +2278,7 @@ function Studio(props) {
|
|
|
1686
2278
|
]);
|
|
1687
2279
|
const selectionExists = fileNodes.some((node) => node.id === selectedId);
|
|
1688
2280
|
useEffect(() => {
|
|
1689
|
-
if (selectedId && fileNodes.length > 0 && !selectionExists) select(void 0);
|
|
2281
|
+
if (selectedId && fileNodes.length > 0 && !selectionExists) select(void 0, { replace: true });
|
|
1690
2282
|
}, [
|
|
1691
2283
|
fileNodes.length,
|
|
1692
2284
|
select,
|
|
@@ -1712,20 +2304,15 @@ function Studio(props) {
|
|
|
1712
2304
|
activeId: selectedId,
|
|
1713
2305
|
allRunsActive: !selectedId,
|
|
1714
2306
|
creating,
|
|
2307
|
+
onReorderWorkflow: reorder,
|
|
1715
2308
|
onShowAllRuns: () => showRuns(null),
|
|
1716
2309
|
onOpenWorkflow: (node) => showRuns(node),
|
|
1717
|
-
onEditWorkflow: (node) =>
|
|
1718
|
-
|
|
1719
|
-
setSelectedNode(node.id);
|
|
1720
|
-
},
|
|
1721
|
-
onOpenConnection: (node) => {
|
|
1722
|
-
select(node.id);
|
|
1723
|
-
setSelectedNode(node.id);
|
|
1724
|
-
},
|
|
2310
|
+
onEditWorkflow: (node) => go(node.id, node.id),
|
|
2311
|
+
onOpenConnection: (node) => go(node.id, node.id),
|
|
1725
2312
|
onCreateWorkflow: () => create(WORKFLOW_TYPE, "Workflow", workflows.length),
|
|
1726
2313
|
onCreateConnection: () => create(CONNECTION_TYPE, "Connection", connections.length)
|
|
1727
2314
|
}), /* @__PURE__ */ jsx("main", {
|
|
1728
|
-
className: "min-w-0 flex-1 overflow-y-auto",
|
|
2315
|
+
className: "relative min-w-0 flex-1 overflow-y-auto",
|
|
1729
2316
|
children: editorOpen ? /* @__PURE__ */ jsx("div", {
|
|
1730
2317
|
className: "flex h-full min-h-0 flex-col",
|
|
1731
2318
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -1742,12 +2329,13 @@ function Studio(props) {
|
|
|
1742
2329
|
children: [liveTarget ? /* @__PURE__ */ jsx(WorkflowHeader, {
|
|
1743
2330
|
node: liveTarget,
|
|
1744
2331
|
runs,
|
|
1745
|
-
onEdit: () =>
|
|
1746
|
-
onDeleted: () => select(void 0)
|
|
2332
|
+
onEdit: () => go(liveTarget.id, liveTarget.id),
|
|
2333
|
+
onDeleted: () => select(void 0, { replace: true })
|
|
1747
2334
|
}, liveTarget.id) : /* @__PURE__ */ jsx(WorkflowBoard, {
|
|
1748
2335
|
runs,
|
|
2336
|
+
order: workflows.map((node) => node.id),
|
|
1749
2337
|
creating,
|
|
1750
|
-
onOpen: (workflowId) =>
|
|
2338
|
+
onOpen: (workflowId) => go(workflowId),
|
|
1751
2339
|
onCreate: () => create(WORKFLOW_TYPE, "Workflow", workflows.length)
|
|
1752
2340
|
}), /* @__PURE__ */ jsx(RunsView, {
|
|
1753
2341
|
title: liveTarget ? "Runs" : "Recent runs",
|
|
@@ -1787,4 +2375,4 @@ function Editor(props) {
|
|
|
1787
2375
|
//#endregion
|
|
1788
2376
|
export { Editor as default };
|
|
1789
2377
|
|
|
1790
|
-
//# sourceMappingURL=editor-
|
|
2378
|
+
//# sourceMappingURL=editor-YRMQ2K-6.js.map
|