@powerhousedao/workflow 6.2.3-dev.88 → 6.2.3-dev.90
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-BKAJwJ4Y.js → BlockSelector-DFzzAWXh.js} +65 -7
- package/dist/browser/BlockSelector-DFzzAWXh.js.map +1 -0
- package/dist/browser/{connection-form-DltdMa8F.js → connection-form-B6zpGmAm.js} +3 -3
- package/dist/browser/{connection-form-DltdMa8F.js.map → connection-form-B6zpGmAm.js.map} +1 -1
- package/dist/browser/{data-tree-DAw8e0j8.js → data-tree-DKS0EQys.js} +2 -2
- package/dist/browser/{data-tree-DAw8e0j8.js.map → data-tree-DKS0EQys.js.map} +1 -1
- package/dist/browser/{editor-Dl6lzxkM.js → editor-Yt-_V04R.js} +207 -58
- package/dist/browser/editor-Yt-_V04R.js.map +1 -0
- package/dist/browser/{editor-CZLe6CAF.js → editor-bHCkW_XB.js} +4 -4
- package/dist/browser/{editor-CZLe6CAF.js.map → editor-bHCkW_XB.js.map} +1 -1
- package/dist/browser/{editor--J61vLSC.js → editor-gCkAwv09.js} +64 -132
- package/dist/browser/editor-gCkAwv09.js.map +1 -0
- package/dist/browser/editors/connection-editor/module.js +1 -1
- package/dist/browser/editors/runtime/index.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/index.js +2 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/{runtime-queries-D81Ghpok.js → runtime-queries-C5bqAgQy.js} +84 -13
- package/dist/browser/runtime-queries-C5bqAgQy.js.map +1 -0
- package/dist/browser/{trigger-text-BSVi5oGZ.js → trigger-text-BfIu-QcC.js} +176 -11
- package/dist/browser/trigger-text-BfIu-QcC.js.map +1 -0
- package/dist/node/document-models/connection/index.mjs +67 -3
- package/dist/node/document-models/connection/index.mjs.map +1 -0
- package/dist/node/document-models/index.mjs +3 -3
- package/dist/node/document-models/workflow/index.mjs +86 -3
- package/dist/node/document-models/workflow/index.mjs.map +1 -0
- package/dist/node/editors/index.mjs +6 -4
- package/dist/node/editors/index.mjs.map +1 -0
- package/dist/node/index.mjs +5 -411
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{module-CuTg45ct.mjs → module-BXKUB58R.mjs} +9 -4
- package/dist/node/module-BXKUB58R.mjs.map +1 -0
- package/dist/node/{module-BEEASith.mjs → module-CaBtkQmd.mjs} +16 -16
- package/dist/node/module-CaBtkQmd.mjs.map +1 -0
- package/dist/node/pieces/ai/descriptor.json +70 -1
- package/dist/node/pieces/ai/index.mjs +125 -125
- package/dist/node/pieces/ai/package.json +1 -1
- package/dist/node/pieces/reactor/descriptor.json +35 -1
- package/dist/node/pieces/reactor/index.mjs +39 -39
- package/dist/node/pieces/reactor/package.json +1 -1
- package/dist/node/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/node/upgrade-manifests-BCCpSD1J.mjs +8 -0
- package/dist/node/{upgrade-manifests-BA5OaR4H.mjs.map → upgrade-manifests-BCCpSD1J.mjs.map} +1 -1
- package/dist/powerhouse.manifest.json +2 -2
- package/dist/style.css +1 -1
- package/dist/types/ai/workflow-tools.d.ts.map +1 -1
- package/dist/types/document-models/connection/v1/actions.d.ts +1 -0
- package/dist/types/document-models/connection/v1/actions.d.ts.map +1 -1
- package/dist/types/document-models/connection/v1/module.d.ts +1 -0
- package/dist/types/document-models/connection/v1/module.d.ts.map +1 -1
- package/dist/types/document-models/document-models.d.ts +2 -0
- package/dist/types/document-models/document-models.d.ts.map +1 -1
- package/dist/types/document-models/workflow/v1/actions.d.ts +1 -0
- package/dist/types/document-models/workflow/v1/actions.d.ts.map +1 -1
- package/dist/types/document-models/workflow/v1/module.d.ts +1 -0
- package/dist/types/document-models/workflow/v1/module.d.ts.map +1 -1
- package/dist/types/editors/shared/icons.d.ts +4 -0
- package/dist/types/editors/shared/icons.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-client.d.ts +5 -1
- package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts +1 -0
- package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts +1 -0
- package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/ap-layout.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts +4 -0
- package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/block-meta.d.ts +3 -0
- package/dist/types/editors/workflow-editor/ui/block-meta.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/blocks.d.ts +8 -0
- package/dist/types/editors/workflow-editor/ui/blocks.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/canvas-menu.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/flow-control.test.d.ts +2 -0
- package/dist/types/editors/workflow-editor/ui/flow-control.test.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts +1 -0
- package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/prop-layout.test.d.ts +2 -0
- package/dist/types/editors/workflow-editor/ui/prop-layout.test.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/ui/trigger-text.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/use-validity.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/validation.d.ts +4 -1
- package/dist/types/editors/workflow-editor/ui/validation.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/RunsTable.d.ts +4 -1
- package/dist/types/editors/workflow-studio/components/RunsTable.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts +9 -1
- package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/WorkflowGraph.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/graph-layout.d.ts +1 -0
- package/dist/types/editors/workflow-studio/components/graph-layout.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/tips.d.ts.map +1 -1
- package/dist/types/pieces/ai/lib/actions/decide-on-documents.d.ts.map +1 -1
- package/dist/types/pieces/ai/lib/actions/extract.d.ts.map +1 -1
- package/dist/types/pieces/ai/lib/actions/propose-actions.d.ts.map +1 -1
- package/dist/types/pieces/ai/lib/actions/summarize.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/actions/document-find.d.ts.map +1 -1
- package/dist/types/test/ui/flow-control.spec.d.ts +2 -0
- package/dist/types/test/ui/flow-control.spec.d.ts.map +1 -0
- package/package.json +22 -10
- package/dist/browser/BlockSelector-BKAJwJ4Y.js.map +0 -1
- package/dist/browser/editor--J61vLSC.js.map +0 -1
- package/dist/browser/editor-Dl6lzxkM.js.map +0 -1
- package/dist/browser/runtime-queries-D81Ghpok.js.map +0 -1
- package/dist/browser/trigger-text-BSVi5oGZ.js.map +0 -1
- package/dist/node/BlockSelector-DnTRF-C7.mjs +0 -8669
- package/dist/node/BlockSelector-DnTRF-C7.mjs.map +0 -1
- package/dist/node/PieceMarkdown-CUSdTMH4.mjs +0 -23307
- package/dist/node/PieceMarkdown-CUSdTMH4.mjs.map +0 -1
- package/dist/node/block-type-kX-27vVt.mjs +0 -44
- package/dist/node/block-type-kX-27vVt.mjs.map +0 -1
- package/dist/node/connection-BZxipUlb.mjs +0 -90
- package/dist/node/connection-BZxipUlb.mjs.map +0 -1
- package/dist/node/connection-form-DwSHfIRw.mjs +0 -1364
- package/dist/node/connection-form-DwSHfIRw.mjs.map +0 -1
- package/dist/node/data-tree-uSJU9Ost.mjs +0 -1916
- package/dist/node/data-tree-uSJU9Ost.mjs.map +0 -1
- package/dist/node/editor-B4ZwM3pR.mjs +0 -3286
- package/dist/node/editor-B4ZwM3pR.mjs.map +0 -1
- package/dist/node/editor-_4XHbqGl.mjs +0 -15424
- package/dist/node/editor-_4XHbqGl.mjs.map +0 -1
- package/dist/node/editor-cXi5dIsd.mjs +0 -370
- package/dist/node/editor-cXi5dIsd.mjs.map +0 -1
- package/dist/node/editors/connection-editor/module.mjs +0 -15
- package/dist/node/editors/connection-editor/module.mjs.map +0 -1
- package/dist/node/editors/runtime/index.mjs +0 -2
- package/dist/node/editors/workflow-editor/module.mjs +0 -15
- package/dist/node/editors/workflow-editor/module.mjs.map +0 -1
- package/dist/node/editors/workflow-studio/module.mjs +0 -15
- package/dist/node/editors/workflow-studio/module.mjs.map +0 -1
- package/dist/node/graphql-D76E1YiQ.mjs +0 -14554
- package/dist/node/graphql-D76E1YiQ.mjs.map +0 -1
- package/dist/node/module-BEEASith.mjs.map +0 -1
- package/dist/node/module-CuTg45ct.mjs.map +0 -1
- package/dist/node/piece-auth-C0u0XTO8.mjs +0 -154
- package/dist/node/piece-auth-C0u0XTO8.mjs.map +0 -1
- package/dist/node/rolldown-runtime-B4iAMlE-.mjs +0 -35
- package/dist/node/runtime-queries-VXJsWno5.mjs +0 -2891
- package/dist/node/runtime-queries-VXJsWno5.mjs.map +0 -1
- package/dist/node/style.css +0 -667
- package/dist/node/trigger-text-BBP7QVLj.mjs +0 -3045
- package/dist/node/trigger-text-BBP7QVLj.mjs.map +0 -1
- package/dist/node/upgrade-manifests-BA5OaR4H.mjs +0 -8
- package/dist/node/workflow-BgURVzdc.mjs +0 -109
- package/dist/node/workflow-BgURVzdc.mjs.map +0 -1
|
@@ -1,3286 +0,0 @@
|
|
|
1
|
-
import { Dt as parseManualInputs, Et as manualDefault, Q as CORE_PIECE, _t as ManualPayloadError, bt as coerceManualPayload, dt as stepBlock, et as MANUAL_TRIGGER, l as runsOfPages, pt as triggerBlock, ut as sameBlock } from "./runtime-queries-VXJsWno5.mjs";
|
|
2
|
-
import { A as formatWhen, Bt as textAreaClass, C as canRerun, D as formatMs, Dt as useSearchParamDraft, E as formatDuration, Et as useSearchParam, F as statusLabel, Ft as Switch, Gt as DocumentLoadError, Ht as Icon, I as toneOf, Kt as errorMessage, L as workflowHealth, M as runStatusLabel, N as runTimeline, O as formatTrigger, Ot as Button, P as runTone, Pt as Select, S as TONE_TEXT, St as useRuntimeActions, T as formatAbsolute, Tt as ITEM_PARAM, Vt as textInputClass, Wt as DocumentErrorBoundary, _ as CONNECTION_TONE, b as STEP_TONE, f as blockMeta, g as usePieceLogos, j as runStats, k as formatUntil, mt as WorkflowRuntimeProvider, t as BlockLogo, v as RUN_STATUSES, vt as useRunPagesQuery, w as durationMs, wt as useWaitingRunsQuery, x as TONE_DOT, y as RUN_TONE, yt as useRunQuery } from "./BlockSelector-DnTRF-C7.mjs";
|
|
3
|
-
import { y as actions } from "./module-CuTg45ct.mjs";
|
|
4
|
-
import { r as useWorkflowDocumentsInSelectedDrive } from "./workflow-BgURVzdc.mjs";
|
|
5
|
-
import { a as StepError, b as PropertyForm, f as StatusToggle, i as DataViewer, l as PublishState, r as describeTrigger } from "./trigger-text-BBP7QVLj.mjs";
|
|
6
|
-
import { addDocument, addFolder, deleteNode, getPHStore, showDeleteNodeModal, useDispatch, useDocumentSafe, useFileNodesInSelectedDrive, useNodesInSelectedDrive, usePHToast, useSearchParams, useSelectedDrive, useSelectedNode, useSetPHAppConfig, useSetSearchParams, useSetSelectedNode } from "@powerhousedao/reactor-browser";
|
|
7
|
-
import { generateId } from "document-model";
|
|
8
|
-
import { Fragment, Suspense, lazy, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
9
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { addFolder as addFolder$1, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
11
|
-
import { ConnectTooltip, ConnectTooltipProvider, Modal } from "@powerhousedao/design-system/connect";
|
|
12
|
-
//#region editors/workflow-editor/ui/manual-inputs.ts
|
|
13
|
-
const PROPERTY_TYPES = {
|
|
14
|
-
text: "SHORT_TEXT",
|
|
15
|
-
text_area: "LONG_TEXT",
|
|
16
|
-
number: "NUMBER",
|
|
17
|
-
toggle: "CHECKBOX",
|
|
18
|
-
date: "DATE_TIME",
|
|
19
|
-
dropdown: "STATIC_DROPDOWN",
|
|
20
|
-
json: "JSON"
|
|
21
|
-
};
|
|
22
|
-
function manualInputProp(input) {
|
|
23
|
-
const defaultValue = manualDefault(input);
|
|
24
|
-
return {
|
|
25
|
-
name: input.name,
|
|
26
|
-
displayName: input.displayName,
|
|
27
|
-
type: PROPERTY_TYPES[input.type],
|
|
28
|
-
required: input.type === "toggle" ? false : input.required,
|
|
29
|
-
...input.description ? { description: input.description } : {},
|
|
30
|
-
...defaultValue !== void 0 ? { defaultValue } : {},
|
|
31
|
-
...input.type === "dropdown" ? { staticOptions: (input.options ?? []).map(({ value, label }) => ({
|
|
32
|
-
value,
|
|
33
|
-
label
|
|
34
|
-
})) } : {}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function manualRunPayload(inputs, values) {
|
|
38
|
-
try {
|
|
39
|
-
return coerceManualPayload(inputs, values);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
if (!(error instanceof ManualPayloadError)) throw error;
|
|
42
|
-
const label = (name) => inputs.find((input) => input.name === name)?.displayName ?? name;
|
|
43
|
-
throw new Error(error.fields.map((entry) => `${label(entry.field)} ${entry.message}`).join("; "), { cause: error });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function manualInputValues(inputs) {
|
|
47
|
-
const values = {};
|
|
48
|
-
for (const input of inputs) {
|
|
49
|
-
const value = manualDefault(input);
|
|
50
|
-
if (value !== void 0) values[input.name] = value;
|
|
51
|
-
else if (input.type === "toggle") values[input.name] = false;
|
|
52
|
-
}
|
|
53
|
-
return values;
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region editors/workflow-studio/components/ui.tsx
|
|
57
|
-
function StatusDot(props) {
|
|
58
|
-
const hollow = props.hollow ?? props.tone === "idle";
|
|
59
|
-
return /* @__PURE__ */ jsx("span", {
|
|
60
|
-
"aria-hidden": true,
|
|
61
|
-
className: `inline-block h-2 w-2 shrink-0 rounded-full ${hollow ? "border border-solid border-muted-foreground/60" : TONE_DOT[props.tone]} ${props.className ?? ""}`
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function StatusText(props) {
|
|
65
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
66
|
-
className: `inline-flex items-center gap-1.5 font-medium ${TONE_TEXT[props.tone]} ${props.className ?? ""}`,
|
|
67
|
-
children: [/* @__PURE__ */ jsx(StatusDot, { tone: props.tone }), props.label ?? statusLabel(props.status)]
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/** A label/value pair for a header's facts line. */
|
|
71
|
-
function Fact(props) {
|
|
72
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
73
|
-
className: "flex min-w-0 flex-col gap-0.5",
|
|
74
|
-
title: props.title,
|
|
75
|
-
children: [/* @__PURE__ */ jsx("dt", {
|
|
76
|
-
className: "text-xs text-muted-foreground",
|
|
77
|
-
children: props.label
|
|
78
|
-
}), /* @__PURE__ */ jsx("dd", {
|
|
79
|
-
className: "truncate text-[13px] tabular-nums text-foreground",
|
|
80
|
-
children: props.children
|
|
81
|
-
})]
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region editors/workflow-studio/components/RunDialog.tsx
|
|
86
|
-
function RunDialog(props) {
|
|
87
|
-
const fields = useMemo(() => props.inputs.map(manualInputProp), [props.inputs]);
|
|
88
|
-
const [values, setValues] = useState(() => manualInputValues(props.inputs));
|
|
89
|
-
const latest = useRef(values);
|
|
90
|
-
const [raw, setRaw] = useState(null);
|
|
91
|
-
const [error, setError] = useState(null);
|
|
92
|
-
const [firing, setFiring] = useState(false);
|
|
93
|
-
const rawId = useId();
|
|
94
|
-
const payload = () => {
|
|
95
|
-
if (raw === null) return manualRunPayload(props.inputs, latest.current);
|
|
96
|
-
try {
|
|
97
|
-
return JSON.parse(raw === "" ? "{}" : raw);
|
|
98
|
-
} catch {
|
|
99
|
-
throw new Error("The payload is not valid JSON.");
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
return /* @__PURE__ */ jsx(Modal, {
|
|
103
|
-
open: true,
|
|
104
|
-
title: "Run workflow",
|
|
105
|
-
onOpenChange: (open) => {
|
|
106
|
-
if (!open) props.onCancel();
|
|
107
|
-
},
|
|
108
|
-
contentProps: {
|
|
109
|
-
className: "max-h-[85vh] w-[32rem] max-w-[92vw] overflow-y-auto rounded-xl border border-solid border-foreground/10",
|
|
110
|
-
"aria-label": "Run workflow"
|
|
111
|
-
},
|
|
112
|
-
children: /* @__PURE__ */ jsxs("form", {
|
|
113
|
-
className: "flex flex-col gap-4 p-6",
|
|
114
|
-
noValidate: true,
|
|
115
|
-
onSubmit: (event) => {
|
|
116
|
-
event.preventDefault();
|
|
117
|
-
if (firing) return;
|
|
118
|
-
document.activeElement?.blur();
|
|
119
|
-
let body;
|
|
120
|
-
try {
|
|
121
|
-
body = payload();
|
|
122
|
-
} catch (cause) {
|
|
123
|
-
setError(cause instanceof Error ? cause.message : String(cause));
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
setFiring(true);
|
|
127
|
-
setError(null);
|
|
128
|
-
props.onFire(body).then((fireError) => fireError, (cause) => cause instanceof Error ? cause.message : String(cause)).then((fireError) => {
|
|
129
|
-
setFiring(false);
|
|
130
|
-
if (fireError) setError(fireError);
|
|
131
|
-
else props.onCancel();
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
children: [
|
|
135
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
|
|
136
|
-
className: "text-[15px] font-semibold text-foreground",
|
|
137
|
-
children: "Run workflow"
|
|
138
|
-
}), /* @__PURE__ */ jsxs("p", {
|
|
139
|
-
className: "mt-1 text-[13px] text-muted-foreground",
|
|
140
|
-
children: [
|
|
141
|
-
"The run reads these as ",
|
|
142
|
-
"{{trigger.payload.<key>}}",
|
|
143
|
-
"."
|
|
144
|
-
]
|
|
145
|
-
})] }),
|
|
146
|
-
/* @__PURE__ */ jsx(Switch, {
|
|
147
|
-
label: "Raw JSON",
|
|
148
|
-
checked: raw !== null,
|
|
149
|
-
onChange: (on) => {
|
|
150
|
-
setError(null);
|
|
151
|
-
if (!on) return setRaw(null);
|
|
152
|
-
setRaw(JSON.stringify(latest.current, null, 2));
|
|
153
|
-
}
|
|
154
|
-
}),
|
|
155
|
-
raw === null ? /* @__PURE__ */ jsx(PropertyForm, {
|
|
156
|
-
props: fields,
|
|
157
|
-
value: values,
|
|
158
|
-
onChange: (next) => {
|
|
159
|
-
latest.current = next;
|
|
160
|
-
setValues(next);
|
|
161
|
-
}
|
|
162
|
-
}) : /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
163
|
-
htmlFor: rawId,
|
|
164
|
-
className: "mb-1.5 block text-[13px] font-medium text-foreground",
|
|
165
|
-
children: "Payload"
|
|
166
|
-
}), /* @__PURE__ */ jsx("textarea", {
|
|
167
|
-
id: rawId,
|
|
168
|
-
className: `${textAreaClass} min-h-40 font-mono text-xs`,
|
|
169
|
-
value: raw,
|
|
170
|
-
spellCheck: false,
|
|
171
|
-
onChange: (event) => setRaw(event.target.value)
|
|
172
|
-
})] }),
|
|
173
|
-
error ? /* @__PURE__ */ jsx("p", {
|
|
174
|
-
role: "alert",
|
|
175
|
-
className: "rounded-md bg-wf-fail/10 px-3 py-2 text-[13px] text-wf-fail",
|
|
176
|
-
children: error
|
|
177
|
-
}) : null,
|
|
178
|
-
/* @__PURE__ */ jsxs("div", {
|
|
179
|
-
className: "flex justify-end gap-2",
|
|
180
|
-
children: [/* @__PURE__ */ jsx(Button, {
|
|
181
|
-
onClick: props.onCancel,
|
|
182
|
-
children: "Cancel"
|
|
183
|
-
}), /* @__PURE__ */ jsxs(Button, {
|
|
184
|
-
type: "submit",
|
|
185
|
-
variant: "primary",
|
|
186
|
-
disabled: firing,
|
|
187
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
188
|
-
name: "play",
|
|
189
|
-
className: "h-3.5 w-3.5"
|
|
190
|
-
}), firing ? "Running…" : "Run"]
|
|
191
|
-
})]
|
|
192
|
-
})
|
|
193
|
-
]
|
|
194
|
-
})
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region editors/workflow-studio/components/step-outline.ts
|
|
199
|
-
function stepOutline(args) {
|
|
200
|
-
const inbound = /* @__PURE__ */ new Map();
|
|
201
|
-
for (const edge of args.edges) {
|
|
202
|
-
const list = inbound.get(edge.to) ?? [];
|
|
203
|
-
list.push(edge);
|
|
204
|
-
inbound.set(edge.to, list);
|
|
205
|
-
}
|
|
206
|
-
const decided = args.triggerId ? [args.triggerId] : [];
|
|
207
|
-
const rows = [];
|
|
208
|
-
const seen = /* @__PURE__ */ new Set();
|
|
209
|
-
const firstDecided = (edges) => edges.reduce((first, edge) => decided.indexOf(edge.from) < decided.indexOf(first.from) ? edge : first);
|
|
210
|
-
let progressed = true;
|
|
211
|
-
while (progressed) {
|
|
212
|
-
progressed = false;
|
|
213
|
-
for (const step of args.steps) {
|
|
214
|
-
if (seen.has(step.id)) continue;
|
|
215
|
-
const edges = inbound.get(step.id) ?? [];
|
|
216
|
-
const entry = !args.triggerId && edges.length === 0;
|
|
217
|
-
if (!entry) {
|
|
218
|
-
if (edges.length === 0) continue;
|
|
219
|
-
if (!edges.every((edge) => decided.includes(edge.from))) continue;
|
|
220
|
-
}
|
|
221
|
-
seen.add(step.id);
|
|
222
|
-
decided.push(step.id);
|
|
223
|
-
const port = entry ? null : firstDecided(edges).port;
|
|
224
|
-
rows.push({
|
|
225
|
-
step,
|
|
226
|
-
port: port === "next" ? null : port
|
|
227
|
-
});
|
|
228
|
-
progressed = true;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return {
|
|
232
|
-
rows,
|
|
233
|
-
orphans: args.steps.filter((step) => !seen.has(step.id))
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region editors/workflow-studio/components/graph-layout.ts
|
|
238
|
-
const TRIGGER_NODE = "trigger";
|
|
239
|
-
const SIDE_PORTS = /* @__PURE__ */ new Set(["false", "error"]);
|
|
240
|
-
function graphLayout(args) {
|
|
241
|
-
const { rows } = stepOutline(args);
|
|
242
|
-
const nodeId = (id) => id === args.triggerId ? TRIGGER_NODE : id;
|
|
243
|
-
const placed = /* @__PURE__ */ new Map([[TRIGGER_NODE, {
|
|
244
|
-
col: 0,
|
|
245
|
-
lane: 0
|
|
246
|
-
}]]);
|
|
247
|
-
const taken = /* @__PURE__ */ new Set();
|
|
248
|
-
const inbound = /* @__PURE__ */ new Map();
|
|
249
|
-
const outbound = /* @__PURE__ */ new Map();
|
|
250
|
-
for (const edge of args.edges) {
|
|
251
|
-
const list = inbound.get(edge.to) ?? [];
|
|
252
|
-
list.push(edge);
|
|
253
|
-
inbound.set(edge.to, list);
|
|
254
|
-
outbound.set(edge.from, (outbound.get(edge.from) ?? 0) + 1);
|
|
255
|
-
}
|
|
256
|
-
const drops = (edge) => SIDE_PORTS.has(edge.port) && (outbound.get(edge.from) ?? 0) > 1;
|
|
257
|
-
const nodes = [];
|
|
258
|
-
for (const { step } of rows) {
|
|
259
|
-
const from = (inbound.get(step.id) ?? []).filter((edge) => placed.has(nodeId(edge.from)));
|
|
260
|
-
const col = Math.max(1, ...from.map((edge) => placed.get(nodeId(edge.from)).col + 1));
|
|
261
|
-
let lane = Math.min(...from.map((edge) => placed.get(nodeId(edge.from)).lane + (drops(edge) ? 1 : 0)), from.length === 0 ? 0 : Infinity);
|
|
262
|
-
const port = from.length === 1 && from[0].port !== "next" ? from[0].port : null;
|
|
263
|
-
while (taken.has(`${col}:${lane}`)) lane++;
|
|
264
|
-
taken.add(`${col}:${lane}`);
|
|
265
|
-
placed.set(step.id, {
|
|
266
|
-
col,
|
|
267
|
-
lane
|
|
268
|
-
});
|
|
269
|
-
nodes.push({
|
|
270
|
-
step,
|
|
271
|
-
col,
|
|
272
|
-
lane,
|
|
273
|
-
port
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
return {
|
|
277
|
-
nodes,
|
|
278
|
-
edges: args.edges.map((edge) => ({
|
|
279
|
-
...edge,
|
|
280
|
-
from: nodeId(edge.from)
|
|
281
|
-
})).filter((edge) => placed.has(edge.from) && placed.has(edge.to)).map((edge) => {
|
|
282
|
-
const a = placed.get(edge.from);
|
|
283
|
-
const b = placed.get(edge.to);
|
|
284
|
-
const clear = (lane) => !nodes.some((node) => node.lane === lane && node.col > a.col && node.col < b.col);
|
|
285
|
-
const low = Math.max(a.lane, b.lane);
|
|
286
|
-
const high = Math.min(a.lane, b.lane);
|
|
287
|
-
const track = clear(low) ? {
|
|
288
|
-
lane: low,
|
|
289
|
-
under: false
|
|
290
|
-
} : clear(high) ? {
|
|
291
|
-
lane: high,
|
|
292
|
-
under: false
|
|
293
|
-
} : {
|
|
294
|
-
lane: high,
|
|
295
|
-
under: true
|
|
296
|
-
};
|
|
297
|
-
return {
|
|
298
|
-
from: edge.from,
|
|
299
|
-
to: edge.to,
|
|
300
|
-
port: edge.port,
|
|
301
|
-
track
|
|
302
|
-
};
|
|
303
|
-
}),
|
|
304
|
-
cols: Math.max(0, ...nodes.map((node) => node.col)),
|
|
305
|
-
lanes: Math.max(1, ...nodes.map((node) => node.lane + 1))
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region editors/workflow-studio/components/tips.tsx
|
|
310
|
-
function TipProvider(props) {
|
|
311
|
-
return /* @__PURE__ */ jsx(ConnectTooltipProvider, {
|
|
312
|
-
disableHoverableContent: true,
|
|
313
|
-
children: props.children
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
function Tip(props) {
|
|
317
|
-
return /* @__PURE__ */ jsx(ConnectTooltip, {
|
|
318
|
-
content: props.content,
|
|
319
|
-
side: "bottom",
|
|
320
|
-
delayDuration: 100,
|
|
321
|
-
className: "max-w-64 rounded-md border-solid border-foreground/10 bg-card px-2.5 py-1.5 text-foreground shadow-lg",
|
|
322
|
-
children: props.children
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
const PORT_TEXT = {
|
|
326
|
-
true: "Runs when the condition is true",
|
|
327
|
-
false: "Runs when the condition is false",
|
|
328
|
-
error: "Runs when the step before it fails"
|
|
329
|
-
};
|
|
330
|
-
function stepSummary(record, ran) {
|
|
331
|
-
if (!ran) return "Not run yet";
|
|
332
|
-
if (!record) return "Not reached in the latest run";
|
|
333
|
-
const took = record.startedAt && record.endedAt ? ` · ${formatDuration(record.startedAt, record.endedAt)}` : "";
|
|
334
|
-
return `${statusLabel(record.status)} in the latest run${took}`;
|
|
335
|
-
}
|
|
336
|
-
function StepTip(props) {
|
|
337
|
-
const { step } = props;
|
|
338
|
-
const meta = blockMeta(stepBlock(step));
|
|
339
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
340
|
-
className: "flex flex-col gap-0.5",
|
|
341
|
-
children: [
|
|
342
|
-
/* @__PURE__ */ jsx("span", {
|
|
343
|
-
className: "font-medium",
|
|
344
|
-
children: step.name || step.key
|
|
345
|
-
}),
|
|
346
|
-
/* @__PURE__ */ jsxs("span", {
|
|
347
|
-
className: "text-muted-foreground",
|
|
348
|
-
children: [
|
|
349
|
-
meta.displayName,
|
|
350
|
-
" · ",
|
|
351
|
-
meta.subtitle
|
|
352
|
-
]
|
|
353
|
-
}),
|
|
354
|
-
props.port ? /* @__PURE__ */ jsx("span", {
|
|
355
|
-
className: "text-muted-foreground",
|
|
356
|
-
children: PORT_TEXT[props.port] ?? `Runs on "${props.port}"`
|
|
357
|
-
}) : null,
|
|
358
|
-
/* @__PURE__ */ jsx("span", {
|
|
359
|
-
className: "mt-1",
|
|
360
|
-
children: stepSummary(props.record, props.ran)
|
|
361
|
-
}),
|
|
362
|
-
props.record?.error ? /* @__PURE__ */ jsx("span", {
|
|
363
|
-
className: "line-clamp-3 text-wf-fail",
|
|
364
|
-
children: props.record.error
|
|
365
|
-
}) : null
|
|
366
|
-
]
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
function TriggerTip(props) {
|
|
370
|
-
const meta = props.trigger ? blockMeta(props.trigger) : null;
|
|
371
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
372
|
-
className: "flex flex-col gap-0.5",
|
|
373
|
-
children: [
|
|
374
|
-
/* @__PURE__ */ jsx("span", {
|
|
375
|
-
className: "font-medium",
|
|
376
|
-
children: meta?.displayName ?? "No trigger"
|
|
377
|
-
}),
|
|
378
|
-
props.text && props.text !== meta?.displayName ? /* @__PURE__ */ jsx("span", { children: props.text }) : null,
|
|
379
|
-
meta ? /* @__PURE__ */ jsx("span", {
|
|
380
|
-
className: "text-muted-foreground",
|
|
381
|
-
children: meta.subtitle
|
|
382
|
-
}) : null,
|
|
383
|
-
/* @__PURE__ */ jsx("span", {
|
|
384
|
-
className: "mt-1",
|
|
385
|
-
children: props.latest ? `Last fired ${formatWhen(props.latest.startedAt)}` : "Not fired yet"
|
|
386
|
-
})
|
|
387
|
-
]
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
//#endregion
|
|
391
|
-
//#region editors/workflow-studio/components/chain.tsx
|
|
392
|
-
const RING$2 = {
|
|
393
|
-
ok: "ring-wf-ok",
|
|
394
|
-
fail: "ring-wf-fail",
|
|
395
|
-
warn: "ring-wf-warn",
|
|
396
|
-
run: "ring-wf-run",
|
|
397
|
-
idle: "ring-foreground/15 dark:ring-foreground/30"
|
|
398
|
-
};
|
|
399
|
-
const RAIL$1 = {
|
|
400
|
-
ok: "bg-wf-ok",
|
|
401
|
-
fail: "bg-wf-fail",
|
|
402
|
-
warn: "bg-wf-warn",
|
|
403
|
-
run: "bg-wf-run",
|
|
404
|
-
idle: "bg-foreground/15 dark:bg-foreground/30"
|
|
405
|
-
};
|
|
406
|
-
const MAX_STOPS = 6;
|
|
407
|
-
function MiniChain(props) {
|
|
408
|
-
const md = props.size === "md";
|
|
409
|
-
const overflow = props.links.length > MAX_STOPS;
|
|
410
|
-
const shown = overflow ? props.links.slice(0, 5) : props.links;
|
|
411
|
-
const hidden = props.links.length - shown.length;
|
|
412
|
-
const tones = shown.map((link) => link.status ? toneOf(STEP_TONE, link.status) : "idle");
|
|
413
|
-
return /* @__PURE__ */ jsx(TipProvider, { children: /* @__PURE__ */ jsxs("ol", {
|
|
414
|
-
className: "flex items-center",
|
|
415
|
-
"aria-label": props.links.map((link) => `${link.label}${link.status ? `: ${link.status.toLowerCase()}` : ""}`).join(", "),
|
|
416
|
-
children: [shown.map((link, index) => /* @__PURE__ */ jsxs("li", {
|
|
417
|
-
className: "flex items-center",
|
|
418
|
-
children: [index > 0 ? /* @__PURE__ */ jsx("span", {
|
|
419
|
-
"aria-hidden": true,
|
|
420
|
-
className: `h-0.5 ${md ? "w-5" : "w-3"} ${RAIL$1[tones[index]]}`
|
|
421
|
-
}) : null, /* @__PURE__ */ jsx(Tip, {
|
|
422
|
-
content: link.tip ?? (link.status ? `${link.label}: ${link.status.toLowerCase()}` : link.label),
|
|
423
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
424
|
-
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]]}`}`,
|
|
425
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
426
|
-
className: link.status === "SKIPPED" ? "flex opacity-40" : "flex",
|
|
427
|
-
children: /* @__PURE__ */ jsx(BlockLogo, {
|
|
428
|
-
bare: true,
|
|
429
|
-
block: link.block,
|
|
430
|
-
size: md ? 16 : 14
|
|
431
|
-
})
|
|
432
|
-
})
|
|
433
|
-
})
|
|
434
|
-
})]
|
|
435
|
-
}, link.id)), overflow ? /* @__PURE__ */ jsxs("li", {
|
|
436
|
-
"aria-hidden": true,
|
|
437
|
-
className: "flex items-center",
|
|
438
|
-
children: [/* @__PURE__ */ jsx("span", { className: `h-0.5 ${md ? "w-5" : "w-3"} bg-foreground/15` }), /* @__PURE__ */ jsx(Tip, {
|
|
439
|
-
content: props.links.slice(shown.length).map((link) => link.label).join(", "),
|
|
440
|
-
children: /* @__PURE__ */ jsxs("span", {
|
|
441
|
-
className: `flex shrink-0 items-center justify-center rounded-full bg-muted px-1.5 text-[11px] font-medium tabular-nums text-muted-foreground ${md ? "h-8" : "h-6"}`,
|
|
442
|
-
children: ["+", hidden]
|
|
443
|
-
})
|
|
444
|
-
})]
|
|
445
|
-
}) : null]
|
|
446
|
-
}) });
|
|
447
|
-
}
|
|
448
|
-
function triggerOfKind(kind) {
|
|
449
|
-
if (kind.startsWith("piece:")) {
|
|
450
|
-
const rest = kind.slice(6);
|
|
451
|
-
const colon = rest.indexOf(":");
|
|
452
|
-
if (colon > 0) return {
|
|
453
|
-
pieceName: rest.slice(0, colon),
|
|
454
|
-
kind: "trigger",
|
|
455
|
-
name: rest.slice(colon + 1)
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
return {
|
|
459
|
-
pieceName: CORE_PIECE,
|
|
460
|
-
kind: "trigger",
|
|
461
|
-
name: kind
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
/** A workflow's steps in the order a run reaches them, coloured by a run. */
|
|
465
|
-
function workflowLinks(workflow, latest) {
|
|
466
|
-
const records = new Map((latest?.steps ?? []).map((record) => [record.stepKey, record]));
|
|
467
|
-
return graphLayout(workflow).nodes.map(({ step, port }) => {
|
|
468
|
-
const record = records.get(step.key);
|
|
469
|
-
return {
|
|
470
|
-
id: step.id,
|
|
471
|
-
block: stepBlock(step),
|
|
472
|
-
label: step.name || step.key,
|
|
473
|
-
status: record?.status,
|
|
474
|
-
tip: /* @__PURE__ */ jsx(StepTip, {
|
|
475
|
-
step,
|
|
476
|
-
port,
|
|
477
|
-
record,
|
|
478
|
-
ran: Boolean(latest)
|
|
479
|
-
})
|
|
480
|
-
};
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
/** A run's own chain: the trigger, then every step it recorded. */
|
|
484
|
-
function runLinks(run, trigger) {
|
|
485
|
-
return [{
|
|
486
|
-
id: "trigger",
|
|
487
|
-
block: trigger ?? triggerOfKind(run.triggerKind),
|
|
488
|
-
label: "Trigger",
|
|
489
|
-
status: "SUCCEEDED"
|
|
490
|
-
}, ...run.steps.map((step) => ({
|
|
491
|
-
id: step.stepId + step.stepKey,
|
|
492
|
-
block: {
|
|
493
|
-
pieceName: step.pieceName,
|
|
494
|
-
kind: "action",
|
|
495
|
-
name: step.blockName
|
|
496
|
-
},
|
|
497
|
-
label: step.stepKey,
|
|
498
|
-
status: step.status
|
|
499
|
-
}))];
|
|
500
|
-
}
|
|
501
|
-
const STRIP_LENGTH = 14;
|
|
502
|
-
const TICK = {
|
|
503
|
-
ok: "bg-wf-ok",
|
|
504
|
-
fail: "bg-wf-fail",
|
|
505
|
-
warn: "bg-wf-warn",
|
|
506
|
-
run: "bg-wf-run animate-pulse",
|
|
507
|
-
idle: "bg-foreground/25"
|
|
508
|
-
};
|
|
509
|
-
/** Recent runs as ticks, oldest to newest, padded so strips line up. */
|
|
510
|
-
function RunStrip(props) {
|
|
511
|
-
const recent = props.runs.slice(0, STRIP_LENGTH).reverse();
|
|
512
|
-
const padding = STRIP_LENGTH - recent.length;
|
|
513
|
-
return /* @__PURE__ */ jsx(TipProvider, { children: /* @__PURE__ */ jsxs("span", {
|
|
514
|
-
className: `flex h-5 gap-[3px] ${props.centered ? "items-center" : "items-end"}`,
|
|
515
|
-
"aria-label": recent.length === 0 ? "No runs yet" : `Last ${recent.length} runs: ${recent.map((run) => run.status.toLowerCase()).join(", ")}`,
|
|
516
|
-
children: [Array.from({ length: padding }, (_, index) => /* @__PURE__ */ jsx("span", {
|
|
517
|
-
"aria-hidden": true,
|
|
518
|
-
className: "h-1.5 w-1.5 rounded-full bg-foreground/10"
|
|
519
|
-
}, `pad-${index}`)), recent.map((run) => /* @__PURE__ */ jsx(Tip, {
|
|
520
|
-
content: `${statusLabel(run.status)}, ${formatAbsolute(run.startedAt)}`,
|
|
521
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
522
|
-
"aria-hidden": true,
|
|
523
|
-
className: `h-5 w-1.5 rounded-full ${TICK[toneOf(RUN_TONE, run.status)]}`
|
|
524
|
-
})
|
|
525
|
-
}, run.id))]
|
|
526
|
-
}) });
|
|
527
|
-
}
|
|
528
|
-
//#endregion
|
|
529
|
-
//#region editors/workflow-studio/components/Waitpoints.tsx
|
|
530
|
-
const PieceMarkdown = lazy(() => import("./PieceMarkdown-CUSdTMH4.mjs"));
|
|
531
|
-
const WAITING_POLL_MS = 3e4;
|
|
532
|
-
function isOpenApproval(waitpoint) {
|
|
533
|
-
return waitpoint.status === "PENDING" && waitpoint.kind === "approval";
|
|
534
|
-
}
|
|
535
|
-
function waitDescription(waitpoint, stepName) {
|
|
536
|
-
if (waitpoint.kind === "delay") return waitpoint.resumeAt ? `${stepName} is waiting until ${formatAbsolute(waitpoint.resumeAt)}` : `${stepName} is waiting for its delay`;
|
|
537
|
-
return `${stepName} is waiting for a webhook callback${waitpoint.expiresAt ? `, until ${formatAbsolute(waitpoint.expiresAt)}` : ""}`;
|
|
538
|
-
}
|
|
539
|
-
function cancelFailure(result) {
|
|
540
|
-
if (!result) return "The run was not found";
|
|
541
|
-
if (result.status === "CANCELLED") return null;
|
|
542
|
-
return result.error ?? `The run is ${result.status}`;
|
|
543
|
-
}
|
|
544
|
-
function countPendingApprovals(runs, limit) {
|
|
545
|
-
const byWorkflow = /* @__PURE__ */ new Map();
|
|
546
|
-
let total = 0;
|
|
547
|
-
for (const run of runs ?? []) {
|
|
548
|
-
const open = (run.waitpoints ?? []).filter(isOpenApproval).length;
|
|
549
|
-
if (open === 0) continue;
|
|
550
|
-
total += open;
|
|
551
|
-
byWorkflow.set(run.workflowId, (byWorkflow.get(run.workflowId) ?? 0) + open);
|
|
552
|
-
}
|
|
553
|
-
return {
|
|
554
|
-
total,
|
|
555
|
-
byWorkflow,
|
|
556
|
-
capped: (runs?.length ?? 0) >= limit
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
function approvalCountText(count, capped) {
|
|
560
|
-
return capped ? `${count}+` : String(count);
|
|
561
|
-
}
|
|
562
|
-
function approvalCountLabel(count, capped) {
|
|
563
|
-
const noun = count === 1 && !capped ? "approval" : "approvals";
|
|
564
|
-
return `${approvalCountText(count, capped)} ${noun} waiting`;
|
|
565
|
-
}
|
|
566
|
-
function usePendingApprovals(driveId) {
|
|
567
|
-
return countPendingApprovals(useWaitingRunsQuery({
|
|
568
|
-
driveId,
|
|
569
|
-
first: 100
|
|
570
|
-
}, { pollMs: WAITING_POLL_MS }).data, 100);
|
|
571
|
-
}
|
|
572
|
-
function ApprovalBadge(props) {
|
|
573
|
-
if (props.count === 0) return null;
|
|
574
|
-
const label = approvalCountLabel(props.count, props.capped);
|
|
575
|
-
const className = `inline-flex h-5 shrink-0 items-center gap-1 rounded-full bg-wf-warn/12 px-1.5 text-[11px] font-medium tabular-nums text-wf-warn ${props.className ?? ""}`;
|
|
576
|
-
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Icon, {
|
|
577
|
-
name: "clock",
|
|
578
|
-
className: "h-3 w-3"
|
|
579
|
-
}), approvalCountText(props.count, props.capped)] });
|
|
580
|
-
return props.onClick ? /* @__PURE__ */ jsx("button", {
|
|
581
|
-
type: "button",
|
|
582
|
-
title: label,
|
|
583
|
-
"aria-label": label,
|
|
584
|
-
className: `${className} hover:bg-wf-warn/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,
|
|
585
|
-
onClick: (event) => {
|
|
586
|
-
event.stopPropagation();
|
|
587
|
-
props.onClick();
|
|
588
|
-
},
|
|
589
|
-
children: content
|
|
590
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
591
|
-
role: "img",
|
|
592
|
-
title: label,
|
|
593
|
-
"aria-label": label,
|
|
594
|
-
className,
|
|
595
|
-
children: content
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
function reasonRequired(waitpoint, approved) {
|
|
599
|
-
const policy = waitpoint.approval?.reasonRequiredOn ?? "none";
|
|
600
|
-
return policy === "both" || policy === "reject" && !approved;
|
|
601
|
-
}
|
|
602
|
-
function errorText(error) {
|
|
603
|
-
return error instanceof Error ? error.message : String(error);
|
|
604
|
-
}
|
|
605
|
-
function ApprovalCard(props) {
|
|
606
|
-
const { waitpoint } = props;
|
|
607
|
-
const { resolveWaitpoint } = useRuntimeActions();
|
|
608
|
-
const reasonId = useId();
|
|
609
|
-
const [reason, setReason] = useState("");
|
|
610
|
-
const [busy, setBusy] = useState(null);
|
|
611
|
-
const [error, setError] = useState(null);
|
|
612
|
-
const approval = waitpoint.approval;
|
|
613
|
-
const stepName = props.stepName ?? waitpoint.stepKey;
|
|
614
|
-
const policy = approval?.reasonRequiredOn ?? "none";
|
|
615
|
-
const expiresIn = waitpoint.expiresAt ? formatUntil(waitpoint.expiresAt) : null;
|
|
616
|
-
const decide = (approved) => {
|
|
617
|
-
const trimmed = reason.trim();
|
|
618
|
-
if (reasonRequired(waitpoint, approved) && !trimmed) {
|
|
619
|
-
setError(`Give a reason to ${approved ? "approve" : "disapprove"} this request.`);
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
setBusy(approved);
|
|
623
|
-
setError(null);
|
|
624
|
-
resolveWaitpoint(waitpoint, approved, trimmed || void 0).then(() => props.onResolved?.()).catch((resolveError) => setError(errorText(resolveError))).finally(() => setBusy(null));
|
|
625
|
-
};
|
|
626
|
-
return /* @__PURE__ */ jsxs("section", {
|
|
627
|
-
"aria-label": `Approval for ${stepName}`,
|
|
628
|
-
className: "overflow-hidden rounded-xl border border-solid border-foreground/10 bg-card",
|
|
629
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
630
|
-
className: "flex items-start gap-3 px-4 py-3.5",
|
|
631
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
632
|
-
"aria-hidden": true,
|
|
633
|
-
className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-wf-warn/12 text-wf-warn",
|
|
634
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
635
|
-
name: "clock",
|
|
636
|
-
className: "h-3.5 w-3.5"
|
|
637
|
-
})
|
|
638
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
639
|
-
className: "min-w-0 grow space-y-3",
|
|
640
|
-
children: [
|
|
641
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
|
|
642
|
-
className: "text-[13px] font-semibold text-foreground",
|
|
643
|
-
children: approval?.title || `Waiting at ${stepName}`
|
|
644
|
-
}), /* @__PURE__ */ jsxs("p", {
|
|
645
|
-
className: "mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-muted-foreground",
|
|
646
|
-
children: [
|
|
647
|
-
props.meta,
|
|
648
|
-
/* @__PURE__ */ jsxs("span", {
|
|
649
|
-
title: formatAbsolute(waitpoint.createdAt),
|
|
650
|
-
children: ["Asked ", formatWhen(waitpoint.createdAt)]
|
|
651
|
-
}),
|
|
652
|
-
waitpoint.expiresAt ? /* @__PURE__ */ jsx("span", {
|
|
653
|
-
title: formatAbsolute(waitpoint.expiresAt),
|
|
654
|
-
className: expiresIn ? void 0 : "text-wf-warn",
|
|
655
|
-
children: expiresIn ? `Expires ${expiresIn}` : "Expired"
|
|
656
|
-
}) : null
|
|
657
|
-
]
|
|
658
|
-
})] }),
|
|
659
|
-
approval?.body ? /* @__PURE__ */ jsx(Suspense, {
|
|
660
|
-
fallback: /* @__PURE__ */ jsx("p", {
|
|
661
|
-
className: "whitespace-pre-wrap text-[13px] text-foreground",
|
|
662
|
-
children: approval.body
|
|
663
|
-
}),
|
|
664
|
-
children: /* @__PURE__ */ jsx(PieceMarkdown, {
|
|
665
|
-
text: approval.body,
|
|
666
|
-
className: "max-w-prose text-[13px] text-foreground"
|
|
667
|
-
})
|
|
668
|
-
}) : null,
|
|
669
|
-
approval && approval.approvers.length > 0 ? /* @__PURE__ */ jsxs("p", {
|
|
670
|
-
className: "text-xs text-muted-foreground",
|
|
671
|
-
title: approval.approvers.join("\n"),
|
|
672
|
-
children: [
|
|
673
|
-
"Only ",
|
|
674
|
-
approval.approvers.length,
|
|
675
|
-
" listed",
|
|
676
|
-
" ",
|
|
677
|
-
approval.approvers.length === 1 ? "approver" : "approvers",
|
|
678
|
-
" can decide."
|
|
679
|
-
]
|
|
680
|
-
}) : null
|
|
681
|
-
]
|
|
682
|
-
})]
|
|
683
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
684
|
-
className: "border-t border-solid border-border bg-muted/40 px-4 py-3",
|
|
685
|
-
children: [
|
|
686
|
-
/* @__PURE__ */ jsxs("label", {
|
|
687
|
-
htmlFor: reasonId,
|
|
688
|
-
className: "mb-1.5 flex items-baseline gap-1.5 text-[13px] font-medium text-foreground",
|
|
689
|
-
children: ["Reason", /* @__PURE__ */ jsx("span", {
|
|
690
|
-
className: "text-xs font-normal text-muted-foreground",
|
|
691
|
-
children: policy === "none" ? "Optional" : policy === "reject" ? "Required to disapprove" : "Required"
|
|
692
|
-
})]
|
|
693
|
-
}),
|
|
694
|
-
/* @__PURE__ */ jsx("textarea", {
|
|
695
|
-
id: reasonId,
|
|
696
|
-
className: `${textAreaClass} min-h-16 resize-y`,
|
|
697
|
-
rows: 2,
|
|
698
|
-
value: reason,
|
|
699
|
-
onChange: (event) => setReason(event.target.value)
|
|
700
|
-
}),
|
|
701
|
-
/* @__PURE__ */ jsxs("div", {
|
|
702
|
-
className: "mt-3 flex flex-wrap items-center justify-end gap-2",
|
|
703
|
-
children: [
|
|
704
|
-
error ? /* @__PURE__ */ jsx("span", {
|
|
705
|
-
role: "alert",
|
|
706
|
-
className: "mr-auto text-xs text-wf-fail",
|
|
707
|
-
children: error
|
|
708
|
-
}) : null,
|
|
709
|
-
/* @__PURE__ */ jsxs(Button, {
|
|
710
|
-
variant: "destructive",
|
|
711
|
-
disabled: busy !== null,
|
|
712
|
-
onClick: () => decide(false),
|
|
713
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
714
|
-
name: "close",
|
|
715
|
-
className: "h-3.5 w-3.5"
|
|
716
|
-
}), busy === false ? "Disapproving…" : approval?.rejectLabel || "Disapprove"]
|
|
717
|
-
}),
|
|
718
|
-
/* @__PURE__ */ jsxs(Button, {
|
|
719
|
-
variant: "primary",
|
|
720
|
-
disabled: busy !== null,
|
|
721
|
-
onClick: () => decide(true),
|
|
722
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
723
|
-
name: "check",
|
|
724
|
-
className: "h-3.5 w-3.5"
|
|
725
|
-
}), busy === true ? "Approving…" : approval?.approveLabel || "Approve"]
|
|
726
|
-
})
|
|
727
|
-
]
|
|
728
|
-
})
|
|
729
|
-
]
|
|
730
|
-
})]
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
function RunWaitpoints(props) {
|
|
734
|
-
const open = props.waitpoints.filter((waitpoint) => waitpoint.status === "PENDING");
|
|
735
|
-
if (open.length === 0) return null;
|
|
736
|
-
return /* @__PURE__ */ jsx("div", {
|
|
737
|
-
className: "space-y-2",
|
|
738
|
-
children: open.map((waitpoint) => waitpoint.kind === "approval" ? /* @__PURE__ */ jsx(ApprovalCard, {
|
|
739
|
-
waitpoint,
|
|
740
|
-
stepName: props.names.get(waitpoint.stepKey),
|
|
741
|
-
onResolved: props.onChanged
|
|
742
|
-
}, waitpoint.id) : /* @__PURE__ */ jsxs("p", {
|
|
743
|
-
className: "flex items-center gap-2 rounded-md bg-wf-warn/10 px-3 py-2 text-[13px] text-wf-warn",
|
|
744
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
745
|
-
name: "clock",
|
|
746
|
-
className: "h-3.5 w-3.5"
|
|
747
|
-
}), waitDescription(waitpoint, props.names.get(waitpoint.stepKey) ?? waitpoint.stepKey)]
|
|
748
|
-
}, waitpoint.id))
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
function CancelRunButton(props) {
|
|
752
|
-
const { cancelRun } = useRuntimeActions();
|
|
753
|
-
const [cancelling, setCancelling] = useState(false);
|
|
754
|
-
const [error, setError] = useState(null);
|
|
755
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Button, {
|
|
756
|
-
variant: "danger",
|
|
757
|
-
disabled: cancelling,
|
|
758
|
-
onClick: () => {
|
|
759
|
-
setCancelling(true);
|
|
760
|
-
setError(null);
|
|
761
|
-
cancelRun(props.run.id).then((result) => setError(cancelFailure(result))).catch((cancelError) => setError(errorText(cancelError))).finally(() => {
|
|
762
|
-
setCancelling(false);
|
|
763
|
-
props.onChanged();
|
|
764
|
-
});
|
|
765
|
-
},
|
|
766
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
767
|
-
name: "close",
|
|
768
|
-
className: "h-3.5 w-3.5"
|
|
769
|
-
}), cancelling ? "Cancelling…" : "Cancel run"]
|
|
770
|
-
}), error ? /* @__PURE__ */ jsx("span", {
|
|
771
|
-
className: "text-wf-fail",
|
|
772
|
-
children: error
|
|
773
|
-
}) : null] });
|
|
774
|
-
}
|
|
775
|
-
function WaitingApprovals(props) {
|
|
776
|
-
const query = useWaitingRunsQuery({
|
|
777
|
-
driveId: props.driveId,
|
|
778
|
-
workflowId: props.workflowId,
|
|
779
|
-
first: 100
|
|
780
|
-
}, { pollMs: WAITING_POLL_MS });
|
|
781
|
-
const entries = (query.data ?? []).flatMap((run) => (run.waitpoints ?? []).filter(isOpenApproval).map((waitpoint) => ({
|
|
782
|
-
run,
|
|
783
|
-
waitpoint
|
|
784
|
-
})));
|
|
785
|
-
const capped = (query.data?.length ?? 0) >= 100;
|
|
786
|
-
const sectionRef = useRef(null);
|
|
787
|
-
const handled = useRef(0);
|
|
788
|
-
const shown = entries.length > 0;
|
|
789
|
-
useEffect(() => {
|
|
790
|
-
const request = props.focusRequest ?? 0;
|
|
791
|
-
if (!shown || request === handled.current) return;
|
|
792
|
-
handled.current = request;
|
|
793
|
-
sectionRef.current?.scrollIntoView({
|
|
794
|
-
behavior: "smooth",
|
|
795
|
-
block: "start"
|
|
796
|
-
});
|
|
797
|
-
sectionRef.current?.focus({ preventScroll: true });
|
|
798
|
-
}, [props.focusRequest, shown]);
|
|
799
|
-
if (!shown) return null;
|
|
800
|
-
return /* @__PURE__ */ jsxs("section", {
|
|
801
|
-
ref: sectionRef,
|
|
802
|
-
tabIndex: -1,
|
|
803
|
-
"aria-label": "Waiting for approval",
|
|
804
|
-
className: "mb-8 scroll-mt-4 focus:outline-none",
|
|
805
|
-
children: [/* @__PURE__ */ jsxs("h2", {
|
|
806
|
-
className: "mb-4 flex items-center gap-2 text-[15px] font-semibold text-foreground",
|
|
807
|
-
children: ["Waiting for approval", /* @__PURE__ */ jsx(ApprovalBadge, {
|
|
808
|
-
count: entries.length,
|
|
809
|
-
capped
|
|
810
|
-
})]
|
|
811
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
812
|
-
className: "space-y-3",
|
|
813
|
-
children: entries.map(({ run, waitpoint }) => {
|
|
814
|
-
const names = props.stepNames.get(run.workflowId);
|
|
815
|
-
return /* @__PURE__ */ jsx(ApprovalCard, {
|
|
816
|
-
waitpoint,
|
|
817
|
-
stepName: names?.get(waitpoint.stepKey),
|
|
818
|
-
onResolved: props.onChanged,
|
|
819
|
-
meta: /* @__PURE__ */ jsxs(Fragment$1, { children: [props.showWorkflow ? /* @__PURE__ */ jsx("span", {
|
|
820
|
-
className: "font-medium text-foreground",
|
|
821
|
-
children: run.workflowName
|
|
822
|
-
}) : null, /* @__PURE__ */ jsxs("span", {
|
|
823
|
-
title: formatAbsolute(run.startedAt),
|
|
824
|
-
children: [
|
|
825
|
-
"Run ",
|
|
826
|
-
/* @__PURE__ */ jsx("span", {
|
|
827
|
-
className: "font-mono",
|
|
828
|
-
children: run.id.slice(0, 8)
|
|
829
|
-
}),
|
|
830
|
-
" ",
|
|
831
|
-
"started ",
|
|
832
|
-
formatWhen(run.startedAt)
|
|
833
|
-
]
|
|
834
|
-
})] })
|
|
835
|
-
}, waitpoint.id);
|
|
836
|
-
})
|
|
837
|
-
})]
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
//#endregion
|
|
841
|
-
//#region editors/workflow-studio/components/RunsTable.tsx
|
|
842
|
-
const STATUS_FILTERS = ["ALL", ...RUN_STATUSES];
|
|
843
|
-
/** The runs table's query params. */
|
|
844
|
-
const RUNS_PARAMS = {
|
|
845
|
-
status: "runs.status",
|
|
846
|
-
query: "runs.q",
|
|
847
|
-
workflow: "runs.workflow",
|
|
848
|
-
trigger: "runs.trigger"
|
|
849
|
-
};
|
|
850
|
-
const DETAIL_POLL_MS = 5e3;
|
|
851
|
-
const CONTROL = "h-8 rounded-md border border-solid border-border bg-card px-2.5 text-[13px] text-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring";
|
|
852
|
-
function stringify(value) {
|
|
853
|
-
if (value === void 0) return "";
|
|
854
|
-
try {
|
|
855
|
-
return JSON.stringify(value, null, 2);
|
|
856
|
-
} catch {
|
|
857
|
-
return String(value);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
function TimelineBar(props) {
|
|
861
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
862
|
-
className: "ml-auto flex shrink-0 items-center gap-2",
|
|
863
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
864
|
-
"aria-hidden": true,
|
|
865
|
-
className: "relative hidden h-1.5 w-40 overflow-hidden rounded-full bg-muted sm:block",
|
|
866
|
-
children: props.span ? /* @__PURE__ */ jsx("span", {
|
|
867
|
-
className: `absolute inset-y-0 rounded-full ${TONE_DOT[props.tone]}`,
|
|
868
|
-
style: {
|
|
869
|
-
left: `${props.span.offset * 100}%`,
|
|
870
|
-
width: `max(${props.span.width * 100}%, 4px)`
|
|
871
|
-
}
|
|
872
|
-
}) : null
|
|
873
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
874
|
-
className: "w-14 text-right text-[11px] tabular-nums text-muted-foreground",
|
|
875
|
-
children: props.span ? formatMs(props.span.ms) : "–"
|
|
876
|
-
})]
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
function StepRow(props) {
|
|
880
|
-
const { step } = props;
|
|
881
|
-
const meta = blockMeta({
|
|
882
|
-
pieceName: step.pieceName,
|
|
883
|
-
kind: "action",
|
|
884
|
-
name: step.blockName
|
|
885
|
-
});
|
|
886
|
-
const [open, setOpen] = useState(false);
|
|
887
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
888
|
-
role: "listitem",
|
|
889
|
-
className: "border-t border-solid border-border",
|
|
890
|
-
children: [/* @__PURE__ */ jsxs("button", {
|
|
891
|
-
type: "button",
|
|
892
|
-
"aria-expanded": open,
|
|
893
|
-
className: "flex w-full items-center gap-3 px-3 py-2 text-left text-[13px] hover:bg-accent/60 focus-visible:bg-accent/60 focus-visible:outline-none",
|
|
894
|
-
onClick: () => setOpen((value) => !value),
|
|
895
|
-
children: [
|
|
896
|
-
/* @__PURE__ */ jsx(Icon, {
|
|
897
|
-
name: "chevron",
|
|
898
|
-
className: `h-3.5 w-3.5 text-muted-foreground transition-transform ${open ? "rotate-90" : ""}`
|
|
899
|
-
}),
|
|
900
|
-
/* @__PURE__ */ jsx(StatusText, {
|
|
901
|
-
tone: toneOf(STEP_TONE, step.status),
|
|
902
|
-
status: step.status,
|
|
903
|
-
className: "w-24 shrink-0 text-xs"
|
|
904
|
-
}),
|
|
905
|
-
/* @__PURE__ */ jsx("span", {
|
|
906
|
-
className: "shrink-0 font-medium text-foreground",
|
|
907
|
-
title: `Key: ${step.stepKey}`,
|
|
908
|
-
children: props.name ?? step.stepKey
|
|
909
|
-
}),
|
|
910
|
-
/* @__PURE__ */ jsxs("span", {
|
|
911
|
-
className: "flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",
|
|
912
|
-
children: [meta.logoUrl ? /* @__PURE__ */ jsx("img", {
|
|
913
|
-
src: meta.logoUrl,
|
|
914
|
-
alt: "",
|
|
915
|
-
title: meta.subtitle,
|
|
916
|
-
className: "h-3.5 w-3.5"
|
|
917
|
-
}) : null, /* @__PURE__ */ jsx("span", {
|
|
918
|
-
className: "truncate",
|
|
919
|
-
children: meta.logoUrl ? meta.displayName : `${meta.subtitle}: ${meta.displayName}`
|
|
920
|
-
})]
|
|
921
|
-
}),
|
|
922
|
-
step.port && step.port !== "next" ? /* @__PURE__ */ jsxs("span", {
|
|
923
|
-
className: "shrink-0 rounded bg-muted px-1.5 text-[11px] text-muted-foreground",
|
|
924
|
-
children: ["took ", step.port]
|
|
925
|
-
}) : null,
|
|
926
|
-
/* @__PURE__ */ jsx(TimelineBar, {
|
|
927
|
-
span: props.span,
|
|
928
|
-
tone: toneOf(STEP_TONE, step.status)
|
|
929
|
-
})
|
|
930
|
-
]
|
|
931
|
-
}), open ? /* @__PURE__ */ jsxs("div", {
|
|
932
|
-
className: "space-y-2 pb-3 pl-10 pr-3",
|
|
933
|
-
children: [step.error ? /* @__PURE__ */ jsx(StepError, { error: step.error }) : null, step.status === "SKIPPED" ? /* @__PURE__ */ jsx("p", {
|
|
934
|
-
className: "text-xs text-muted-foreground",
|
|
935
|
-
children: "The run never reached this step."
|
|
936
|
-
}) : props.dataError ? /* @__PURE__ */ jsxs("p", {
|
|
937
|
-
className: "text-xs text-wf-warn",
|
|
938
|
-
children: ["Couldn't load what this step received and produced.", /* @__PURE__ */ jsx("span", {
|
|
939
|
-
className: "mt-0.5 block opacity-80",
|
|
940
|
-
children: props.dataError
|
|
941
|
-
})]
|
|
942
|
-
}) : props.dataPending ? /* @__PURE__ */ jsx("p", {
|
|
943
|
-
className: "text-xs text-muted-foreground",
|
|
944
|
-
children: "Loading step data…"
|
|
945
|
-
}) : /* @__PURE__ */ jsxs("div", {
|
|
946
|
-
className: "grid items-start gap-2 md:grid-cols-2",
|
|
947
|
-
children: [/* @__PURE__ */ jsx(DataViewer, {
|
|
948
|
-
label: "Received",
|
|
949
|
-
value: step.input
|
|
950
|
-
}), /* @__PURE__ */ jsx(DataViewer, {
|
|
951
|
-
label: "Produced",
|
|
952
|
-
value: step.output,
|
|
953
|
-
root: `steps.${step.stepKey}.output`,
|
|
954
|
-
emptyText: step.status === "FAILED" ? "Nothing, the step failed" : void 0
|
|
955
|
-
})]
|
|
956
|
-
})]
|
|
957
|
-
}) : null]
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
const TRIGGER_LABEL = {
|
|
961
|
-
manual: "Manual",
|
|
962
|
-
schedule: "Schedule",
|
|
963
|
-
webhook: "Webhook",
|
|
964
|
-
"document-event": "Document change",
|
|
965
|
-
piece: "Piece trigger",
|
|
966
|
-
rerun: "Rerun"
|
|
967
|
-
};
|
|
968
|
-
function triggerLabel(kind) {
|
|
969
|
-
if (kind.startsWith("piece:")) {
|
|
970
|
-
const trigger = triggerOfKind(kind);
|
|
971
|
-
return describeTrigger({
|
|
972
|
-
pieceName: trigger.pieceName,
|
|
973
|
-
triggerName: trigger.name,
|
|
974
|
-
config: null
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
return TRIGGER_LABEL[kind] ?? formatTrigger(kind);
|
|
978
|
-
}
|
|
979
|
-
function describeRunError(error, names) {
|
|
980
|
-
return error.replace(/^Step "([^"]+)" failed: /, (whole, key) => {
|
|
981
|
-
const name = names.get(key);
|
|
982
|
-
return name ? `${name} failed: ` : whole;
|
|
983
|
-
});
|
|
984
|
-
}
|
|
985
|
-
function TriggerRow(props) {
|
|
986
|
-
const { run } = props;
|
|
987
|
-
const [open, setOpen] = useState(false);
|
|
988
|
-
const payload = stringify(run.triggerPayload);
|
|
989
|
-
const hasPayload = payload !== "" && payload !== "null" && payload !== "{}";
|
|
990
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
991
|
-
role: "listitem",
|
|
992
|
-
children: [/* @__PURE__ */ jsxs("button", {
|
|
993
|
-
type: "button",
|
|
994
|
-
"aria-expanded": hasPayload ? open : void 0,
|
|
995
|
-
disabled: !hasPayload,
|
|
996
|
-
className: "flex w-full items-center gap-3 px-3 py-2 text-left text-[13px] enabled:hover:bg-accent/60 focus-visible:bg-accent/60 focus-visible:outline-none",
|
|
997
|
-
onClick: () => setOpen((value) => !value),
|
|
998
|
-
children: [
|
|
999
|
-
/* @__PURE__ */ jsx(Icon, {
|
|
1000
|
-
name: "chevron",
|
|
1001
|
-
className: `h-3.5 w-3.5 text-muted-foreground transition-transform ${open ? "rotate-90" : ""} ${hasPayload ? "" : "invisible"}`
|
|
1002
|
-
}),
|
|
1003
|
-
/* @__PURE__ */ jsx(StatusText, {
|
|
1004
|
-
tone: "ok",
|
|
1005
|
-
status: "FIRED",
|
|
1006
|
-
className: "w-24 shrink-0 text-xs"
|
|
1007
|
-
}),
|
|
1008
|
-
/* @__PURE__ */ jsx("span", {
|
|
1009
|
-
className: "shrink-0 font-medium text-foreground",
|
|
1010
|
-
children: "Trigger"
|
|
1011
|
-
}),
|
|
1012
|
-
/* @__PURE__ */ jsx("span", {
|
|
1013
|
-
className: "truncate text-xs text-muted-foreground",
|
|
1014
|
-
children: triggerLabel(run.triggerKind)
|
|
1015
|
-
}),
|
|
1016
|
-
!hasPayload ? /* @__PURE__ */ jsx("span", {
|
|
1017
|
-
className: "shrink-0 text-[11px] text-muted-foreground",
|
|
1018
|
-
children: "No payload"
|
|
1019
|
-
}) : null,
|
|
1020
|
-
/* @__PURE__ */ jsxs("span", {
|
|
1021
|
-
className: "ml-auto flex shrink-0 items-center gap-2",
|
|
1022
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
1023
|
-
"aria-hidden": true,
|
|
1024
|
-
className: "relative hidden h-1.5 w-40 sm:block",
|
|
1025
|
-
children: /* @__PURE__ */ jsx("span", { className: "absolute inset-y-0 left-0 w-1 rounded-full bg-wf-ok" })
|
|
1026
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
1027
|
-
className: "w-14 text-right text-[11px] tabular-nums text-muted-foreground",
|
|
1028
|
-
children: new Date(run.startedAt).toLocaleTimeString([], {
|
|
1029
|
-
hour: "2-digit",
|
|
1030
|
-
minute: "2-digit",
|
|
1031
|
-
second: "2-digit",
|
|
1032
|
-
hour12: false
|
|
1033
|
-
})
|
|
1034
|
-
})]
|
|
1035
|
-
})
|
|
1036
|
-
]
|
|
1037
|
-
}), open ? /* @__PURE__ */ jsx("div", {
|
|
1038
|
-
className: "pb-3 pl-10 pr-3",
|
|
1039
|
-
children: /* @__PURE__ */ jsx(DataViewer, {
|
|
1040
|
-
label: "Payload",
|
|
1041
|
-
value: run.triggerPayload,
|
|
1042
|
-
root: "trigger.payload"
|
|
1043
|
-
})
|
|
1044
|
-
}) : null]
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
function RunDetail(props) {
|
|
1048
|
-
const { names } = props;
|
|
1049
|
-
const { rerunRun } = useRuntimeActions();
|
|
1050
|
-
const full = useRunQuery(props.run.id, { pollMs: DETAIL_POLL_MS });
|
|
1051
|
-
const run = full.data ?? props.run;
|
|
1052
|
-
const dataPending = full.data === void 0 && full.status === "pending";
|
|
1053
|
-
const dataError = full.status === "error" ? full.error instanceof Error ? full.error.message : String(full.error) : null;
|
|
1054
|
-
const timeline = runTimeline(run);
|
|
1055
|
-
const [rerunning, setRerunning] = useState(false);
|
|
1056
|
-
const [rerunError, setRerunError] = useState(null);
|
|
1057
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1058
|
-
className: "space-y-3 bg-muted/40 px-4 py-4",
|
|
1059
|
-
children: [
|
|
1060
|
-
run.error ? /* @__PURE__ */ jsx("p", {
|
|
1061
|
-
className: "rounded-md bg-wf-fail/10 px-3 py-2 text-[13px] text-wf-fail",
|
|
1062
|
-
children: describeRunError(run.error, names)
|
|
1063
|
-
}) : null,
|
|
1064
|
-
run.waitpoints ? /* @__PURE__ */ jsx(RunWaitpoints, {
|
|
1065
|
-
waitpoints: run.waitpoints,
|
|
1066
|
-
names,
|
|
1067
|
-
onChanged: props.onChanged
|
|
1068
|
-
}) : null,
|
|
1069
|
-
run.warningNotes.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
1070
|
-
"aria-label": "Run warnings",
|
|
1071
|
-
className: "space-y-1 rounded-md bg-wf-warn/10 px-3 py-2 text-[13px] text-wf-warn",
|
|
1072
|
-
children: run.warningNotes.map((note) => /* @__PURE__ */ jsx("li", { children: note }, note))
|
|
1073
|
-
}) : null,
|
|
1074
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1075
|
-
className: "flex flex-wrap items-center gap-x-5 gap-y-1 text-xs text-muted-foreground",
|
|
1076
|
-
children: [
|
|
1077
|
-
/* @__PURE__ */ jsxs("span", { children: ["Run ", /* @__PURE__ */ jsx("span", {
|
|
1078
|
-
className: "font-mono",
|
|
1079
|
-
children: run.id.slice(0, 8)
|
|
1080
|
-
})] }),
|
|
1081
|
-
/* @__PURE__ */ jsxs("span", { children: ["Started ", formatAbsolute(run.startedAt)] }),
|
|
1082
|
-
run.rerunOf ? /* @__PURE__ */ jsxs("span", { children: ["Resumes ", /* @__PURE__ */ jsx("span", {
|
|
1083
|
-
className: "font-mono",
|
|
1084
|
-
children: run.rerunOf.slice(0, 8)
|
|
1085
|
-
})] }) : null,
|
|
1086
|
-
canRerun(run) ? /* @__PURE__ */ jsxs(Button, {
|
|
1087
|
-
className: "ml-auto",
|
|
1088
|
-
disabled: rerunning,
|
|
1089
|
-
onClick: () => {
|
|
1090
|
-
setRerunning(true);
|
|
1091
|
-
setRerunError(null);
|
|
1092
|
-
rerunRun(run.id).then((result) => setRerunError(result.error)).catch((error) => setRerunError(error instanceof Error ? error.message : String(error))).finally(() => {
|
|
1093
|
-
setRerunning(false);
|
|
1094
|
-
props.onChanged();
|
|
1095
|
-
});
|
|
1096
|
-
},
|
|
1097
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
1098
|
-
name: "retry",
|
|
1099
|
-
className: "h-3.5 w-3.5"
|
|
1100
|
-
}), rerunning ? "Rerunning…" : "Rerun from failed step"]
|
|
1101
|
-
}) : null,
|
|
1102
|
-
rerunError ? /* @__PURE__ */ jsx("span", {
|
|
1103
|
-
className: "text-wf-fail",
|
|
1104
|
-
children: rerunError
|
|
1105
|
-
}) : null,
|
|
1106
|
-
run.status === "WAITING" ? /* @__PURE__ */ jsx("span", {
|
|
1107
|
-
className: "ml-auto flex items-center gap-2",
|
|
1108
|
-
children: /* @__PURE__ */ jsx(CancelRunButton, {
|
|
1109
|
-
run,
|
|
1110
|
-
onChanged: props.onChanged
|
|
1111
|
-
})
|
|
1112
|
-
}) : null
|
|
1113
|
-
]
|
|
1114
|
-
}),
|
|
1115
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1116
|
-
role: "list",
|
|
1117
|
-
"aria-label": "Steps of this run",
|
|
1118
|
-
className: "overflow-hidden rounded-md border border-solid border-border bg-card",
|
|
1119
|
-
children: [
|
|
1120
|
-
/* @__PURE__ */ jsx(TriggerRow, { run }),
|
|
1121
|
-
run.steps.map((step) => /* @__PURE__ */ jsx(StepRow, {
|
|
1122
|
-
step,
|
|
1123
|
-
name: names.get(step.stepKey),
|
|
1124
|
-
span: timeline.get(step.stepId),
|
|
1125
|
-
dataPending,
|
|
1126
|
-
dataError
|
|
1127
|
-
}, step.stepId + step.stepKey)),
|
|
1128
|
-
run.steps.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
1129
|
-
className: "border-t border-solid border-border px-3 py-2 pl-10 text-xs text-muted-foreground",
|
|
1130
|
-
children: "No steps ran."
|
|
1131
|
-
}) : null
|
|
1132
|
-
]
|
|
1133
|
-
})
|
|
1134
|
-
]
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
function SortHeader(props) {
|
|
1138
|
-
return /* @__PURE__ */ jsx("th", {
|
|
1139
|
-
scope: "col",
|
|
1140
|
-
className: props.className,
|
|
1141
|
-
children: /* @__PURE__ */ jsxs("button", {
|
|
1142
|
-
type: "button",
|
|
1143
|
-
className: `flex items-center gap-1 hover:text-foreground ${props.active ? "text-foreground" : ""}`,
|
|
1144
|
-
onClick: props.onClick,
|
|
1145
|
-
children: [props.label, /* @__PURE__ */ jsx("span", {
|
|
1146
|
-
"aria-hidden": true,
|
|
1147
|
-
className: props.active ? "" : "opacity-0",
|
|
1148
|
-
children: props.descending ? "↓" : "↑"
|
|
1149
|
-
})]
|
|
1150
|
-
})
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
function RunsTable(props) {
|
|
1154
|
-
const [query, setQuery] = useSearchParamDraft(RUNS_PARAMS.query);
|
|
1155
|
-
const [status, setStatusParam] = useSearchParam(RUNS_PARAMS.status, "ALL", STATUS_FILTERS);
|
|
1156
|
-
const setStatus = (value) => setStatusParam(value, { replace: true });
|
|
1157
|
-
const [workflow, setWorkflowParam] = useSearchParam(RUNS_PARAMS.workflow, "ALL");
|
|
1158
|
-
const setWorkflow = (value) => setWorkflowParam(value, { replace: true });
|
|
1159
|
-
const [trigger, setTriggerParam] = useSearchParam(RUNS_PARAMS.trigger, "ALL");
|
|
1160
|
-
const setTrigger = (value) => setTriggerParam(value, { replace: true });
|
|
1161
|
-
const setParams = useSetSearchParams();
|
|
1162
|
-
const [sort, setSort] = useState("startedAt");
|
|
1163
|
-
const [descending, setDescending] = useState(true);
|
|
1164
|
-
const [expanded, setExpanded] = useState(null);
|
|
1165
|
-
const documents = useWorkflowDocumentsInSelectedDrive() ?? [];
|
|
1166
|
-
const triggerBlocks = new Map(documents.map((document) => {
|
|
1167
|
-
const trigger = document.state.global.trigger;
|
|
1168
|
-
return [document.header.id, trigger ? triggerBlock(trigger) : void 0];
|
|
1169
|
-
}));
|
|
1170
|
-
const stepNames = new Map(documents.map((document) => [document.header.id, new Map(document.state.global.steps.map((step) => [step.key, step.name || step.key]))]));
|
|
1171
|
-
usePieceLogos();
|
|
1172
|
-
const workflowOptions = useMemo(() => [...new Map(props.runs.map((run) => [run.workflowId, run.workflowName]))].map(([id, name]) => ({
|
|
1173
|
-
id,
|
|
1174
|
-
name
|
|
1175
|
-
})).sort((a, b) => a.name.localeCompare(b.name)), [props.runs]);
|
|
1176
|
-
const triggerOptions = useMemo(() => [...new Set(props.runs.map((run) => run.triggerKind))].sort(), [props.runs]);
|
|
1177
|
-
const scoped = useMemo(() => {
|
|
1178
|
-
const needle = query.trim().toLowerCase();
|
|
1179
|
-
return props.runs.filter((run) => {
|
|
1180
|
-
if (workflow !== "ALL" && run.workflowId !== workflow) return false;
|
|
1181
|
-
if (trigger !== "ALL" && run.triggerKind !== trigger) return false;
|
|
1182
|
-
if (!needle) return true;
|
|
1183
|
-
return run.workflowName.toLowerCase().includes(needle) || run.id.toLowerCase().includes(needle) || (run.error?.toLowerCase().includes(needle) ?? false) || run.steps.some((step) => step.stepKey.toLowerCase().includes(needle));
|
|
1184
|
-
});
|
|
1185
|
-
}, [
|
|
1186
|
-
props.runs,
|
|
1187
|
-
query,
|
|
1188
|
-
workflow,
|
|
1189
|
-
trigger
|
|
1190
|
-
]);
|
|
1191
|
-
const counts = useMemo(() => ({
|
|
1192
|
-
ALL: scoped.length,
|
|
1193
|
-
RUNNING: scoped.filter((run) => run.status === "RUNNING").length,
|
|
1194
|
-
WAITING: scoped.filter((run) => run.status === "WAITING").length,
|
|
1195
|
-
SUCCEEDED: scoped.filter((run) => run.status === "SUCCEEDED").length,
|
|
1196
|
-
FAILED: scoped.filter((run) => run.status === "FAILED").length
|
|
1197
|
-
}), [scoped]);
|
|
1198
|
-
const visible = useMemo(() => {
|
|
1199
|
-
const rows = scoped.filter((run) => status === "ALL" || run.status === status);
|
|
1200
|
-
const direction = descending ? -1 : 1;
|
|
1201
|
-
return [...rows].sort((a, b) => {
|
|
1202
|
-
if (sort === "duration") return ((durationMs(a.startedAt, a.endedAt) ?? Infinity) - (durationMs(b.startedAt, b.endedAt) ?? Infinity)) * direction;
|
|
1203
|
-
return (new Date(a.startedAt).getTime() - new Date(b.startedAt).getTime()) * direction;
|
|
1204
|
-
});
|
|
1205
|
-
}, [
|
|
1206
|
-
scoped,
|
|
1207
|
-
status,
|
|
1208
|
-
sort,
|
|
1209
|
-
descending
|
|
1210
|
-
]);
|
|
1211
|
-
const filtered = query.trim() || workflow !== "ALL" || trigger !== "ALL";
|
|
1212
|
-
const sortBy = (key) => {
|
|
1213
|
-
if (key === sort) {
|
|
1214
|
-
setDescending((value) => !value);
|
|
1215
|
-
return;
|
|
1216
|
-
}
|
|
1217
|
-
setSort(key);
|
|
1218
|
-
setDescending(true);
|
|
1219
|
-
};
|
|
1220
|
-
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
1221
|
-
className: "mb-3 flex flex-wrap items-center gap-2",
|
|
1222
|
-
children: [
|
|
1223
|
-
/* @__PURE__ */ jsx("div", {
|
|
1224
|
-
className: "flex h-8 items-center gap-0.5 rounded-md bg-muted p-0.5",
|
|
1225
|
-
children: STATUS_FILTERS.map((option) => /* @__PURE__ */ jsxs("button", {
|
|
1226
|
-
type: "button",
|
|
1227
|
-
"aria-pressed": status === option,
|
|
1228
|
-
className: `h-7 rounded px-2.5 text-[13px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${status === option ? "bg-card font-medium text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
|
|
1229
|
-
onClick: () => setStatus(option),
|
|
1230
|
-
children: [option === "ALL" ? "All" : statusLabel(option), /* @__PURE__ */ jsx("span", {
|
|
1231
|
-
className: "ml-1.5 tabular-nums text-muted-foreground",
|
|
1232
|
-
children: counts[option]
|
|
1233
|
-
})]
|
|
1234
|
-
}, option))
|
|
1235
|
-
}),
|
|
1236
|
-
/* @__PURE__ */ jsx("input", {
|
|
1237
|
-
type: "search",
|
|
1238
|
-
className: `${CONTROL} w-48`,
|
|
1239
|
-
placeholder: "Search runs",
|
|
1240
|
-
value: query,
|
|
1241
|
-
onChange: (event) => setQuery(event.target.value)
|
|
1242
|
-
}),
|
|
1243
|
-
props.showWorkflow && workflowOptions.length > 1 ? /* @__PURE__ */ jsx("div", {
|
|
1244
|
-
className: "w-44",
|
|
1245
|
-
children: /* @__PURE__ */ jsx(Select, {
|
|
1246
|
-
value: workflow,
|
|
1247
|
-
options: [{
|
|
1248
|
-
value: "ALL",
|
|
1249
|
-
label: "Every workflow"
|
|
1250
|
-
}, ...workflowOptions.map((option) => ({
|
|
1251
|
-
value: option.id,
|
|
1252
|
-
label: option.name
|
|
1253
|
-
}))],
|
|
1254
|
-
onChange: setWorkflow
|
|
1255
|
-
})
|
|
1256
|
-
}) : null,
|
|
1257
|
-
triggerOptions.length > 1 ? /* @__PURE__ */ jsx("div", {
|
|
1258
|
-
className: "w-40",
|
|
1259
|
-
children: /* @__PURE__ */ jsx(Select, {
|
|
1260
|
-
value: trigger,
|
|
1261
|
-
options: [{
|
|
1262
|
-
value: "ALL",
|
|
1263
|
-
label: "Every trigger"
|
|
1264
|
-
}, ...triggerOptions.map((option) => ({
|
|
1265
|
-
value: option,
|
|
1266
|
-
label: triggerLabel(option)
|
|
1267
|
-
}))],
|
|
1268
|
-
onChange: setTrigger
|
|
1269
|
-
})
|
|
1270
|
-
}) : null,
|
|
1271
|
-
filtered ? /* @__PURE__ */ jsx("button", {
|
|
1272
|
-
type: "button",
|
|
1273
|
-
className: "text-[13px] text-muted-foreground underline underline-offset-2 hover:text-foreground",
|
|
1274
|
-
onClick: () => {
|
|
1275
|
-
setParams({
|
|
1276
|
-
[RUNS_PARAMS.query]: void 0,
|
|
1277
|
-
[RUNS_PARAMS.workflow]: void 0,
|
|
1278
|
-
[RUNS_PARAMS.trigger]: void 0
|
|
1279
|
-
}, { replace: true });
|
|
1280
|
-
},
|
|
1281
|
-
children: "Clear filters"
|
|
1282
|
-
}) : null,
|
|
1283
|
-
/* @__PURE__ */ jsxs("span", {
|
|
1284
|
-
className: "ml-auto text-xs tabular-nums text-muted-foreground",
|
|
1285
|
-
children: [
|
|
1286
|
-
visible.length,
|
|
1287
|
-
" of ",
|
|
1288
|
-
props.runs.length,
|
|
1289
|
-
" runs"
|
|
1290
|
-
]
|
|
1291
|
-
})
|
|
1292
|
-
]
|
|
1293
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
1294
|
-
className: "overflow-x-auto rounded-lg border border-solid border-border bg-card",
|
|
1295
|
-
children: /* @__PURE__ */ jsxs("table", {
|
|
1296
|
-
className: "w-full border-collapse text-left",
|
|
1297
|
-
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
|
|
1298
|
-
className: "border-b border-solid border-border text-xs font-medium text-muted-foreground",
|
|
1299
|
-
children: [
|
|
1300
|
-
/* @__PURE__ */ jsx("th", {
|
|
1301
|
-
scope: "col",
|
|
1302
|
-
className: "px-3 py-2.5 font-medium",
|
|
1303
|
-
children: "Status"
|
|
1304
|
-
}),
|
|
1305
|
-
props.showWorkflow ? /* @__PURE__ */ jsx("th", {
|
|
1306
|
-
scope: "col",
|
|
1307
|
-
className: "px-3 py-2.5 font-medium",
|
|
1308
|
-
children: "Workflow"
|
|
1309
|
-
}) : null,
|
|
1310
|
-
/* @__PURE__ */ jsx("th", {
|
|
1311
|
-
scope: "col",
|
|
1312
|
-
className: "px-3 py-2.5 font-medium",
|
|
1313
|
-
children: "Trigger"
|
|
1314
|
-
}),
|
|
1315
|
-
/* @__PURE__ */ jsx(SortHeader, {
|
|
1316
|
-
label: "Started",
|
|
1317
|
-
className: "px-3 py-2.5 font-medium",
|
|
1318
|
-
active: sort === "startedAt",
|
|
1319
|
-
descending,
|
|
1320
|
-
onClick: () => sortBy("startedAt")
|
|
1321
|
-
}),
|
|
1322
|
-
/* @__PURE__ */ jsx(SortHeader, {
|
|
1323
|
-
label: "Duration",
|
|
1324
|
-
className: "px-3 py-2.5 font-medium",
|
|
1325
|
-
active: sort === "duration",
|
|
1326
|
-
descending,
|
|
1327
|
-
onClick: () => sortBy("duration")
|
|
1328
|
-
}),
|
|
1329
|
-
/* @__PURE__ */ jsx("th", {
|
|
1330
|
-
scope: "col",
|
|
1331
|
-
className: "px-3 py-2.5 font-medium",
|
|
1332
|
-
children: "Steps"
|
|
1333
|
-
}),
|
|
1334
|
-
/* @__PURE__ */ jsx("th", {
|
|
1335
|
-
scope: "col",
|
|
1336
|
-
className: "w-8 px-3 py-2",
|
|
1337
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
1338
|
-
className: "sr-only",
|
|
1339
|
-
children: "Details"
|
|
1340
|
-
})
|
|
1341
|
-
})
|
|
1342
|
-
]
|
|
1343
|
-
}) }), /* @__PURE__ */ jsx("tbody", { children: visible.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
|
|
1344
|
-
colSpan: props.showWorkflow ? 7 : 6,
|
|
1345
|
-
className: "px-3 py-8 text-center text-[13px] text-muted-foreground",
|
|
1346
|
-
children: "No runs match these filters."
|
|
1347
|
-
}) }) : visible.map((run) => {
|
|
1348
|
-
const open = expanded === run.id;
|
|
1349
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("tr", {
|
|
1350
|
-
className: `cursor-pointer border-b border-solid border-border text-[13px] last:border-b-0 ${open ? "bg-muted/40" : "hover:bg-accent/60"}`,
|
|
1351
|
-
onClick: () => setExpanded(open ? null : run.id),
|
|
1352
|
-
children: [
|
|
1353
|
-
/* @__PURE__ */ jsx("td", {
|
|
1354
|
-
className: "px-3 py-2.5",
|
|
1355
|
-
children: /* @__PURE__ */ jsx(StatusText, {
|
|
1356
|
-
tone: runTone(run),
|
|
1357
|
-
status: run.status,
|
|
1358
|
-
label: runStatusLabel(run)
|
|
1359
|
-
})
|
|
1360
|
-
}),
|
|
1361
|
-
props.showWorkflow ? /* @__PURE__ */ jsx("td", {
|
|
1362
|
-
className: "max-w-48 truncate px-3 py-2.5 font-medium text-foreground",
|
|
1363
|
-
children: run.workflowName
|
|
1364
|
-
}) : null,
|
|
1365
|
-
/* @__PURE__ */ jsxs("td", {
|
|
1366
|
-
className: "px-3 py-2.5 text-muted-foreground",
|
|
1367
|
-
children: [triggerLabel(run.triggerKind), /* @__PURE__ */ jsxs("span", {
|
|
1368
|
-
className: "ml-1.5 text-xs text-muted-foreground/70",
|
|
1369
|
-
children: ["v", run.workflowVersion]
|
|
1370
|
-
})]
|
|
1371
|
-
}),
|
|
1372
|
-
/* @__PURE__ */ jsx("td", {
|
|
1373
|
-
className: "whitespace-nowrap px-3 py-2.5 tabular-nums text-muted-foreground",
|
|
1374
|
-
title: formatAbsolute(run.startedAt),
|
|
1375
|
-
children: formatWhen(run.startedAt)
|
|
1376
|
-
}),
|
|
1377
|
-
/* @__PURE__ */ jsx("td", {
|
|
1378
|
-
className: "whitespace-nowrap px-3 py-2.5 tabular-nums text-muted-foreground",
|
|
1379
|
-
children: formatDuration(run.startedAt, run.endedAt)
|
|
1380
|
-
}),
|
|
1381
|
-
/* @__PURE__ */ jsx("td", {
|
|
1382
|
-
className: "px-3 py-2",
|
|
1383
|
-
children: /* @__PURE__ */ jsx(MiniChain, { links: runLinks(run, triggerBlocks.get(run.workflowId)) })
|
|
1384
|
-
}),
|
|
1385
|
-
/* @__PURE__ */ jsx("td", {
|
|
1386
|
-
className: "px-3 py-2.5",
|
|
1387
|
-
children: /* @__PURE__ */ jsx("button", {
|
|
1388
|
-
type: "button",
|
|
1389
|
-
"aria-expanded": open,
|
|
1390
|
-
"aria-label": `${open ? "Hide" : "Show"} steps of the run started ${formatAbsolute(run.startedAt)}`,
|
|
1391
|
-
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1392
|
-
onClick: (event) => {
|
|
1393
|
-
event.stopPropagation();
|
|
1394
|
-
setExpanded(open ? null : run.id);
|
|
1395
|
-
},
|
|
1396
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
1397
|
-
name: "chevron",
|
|
1398
|
-
className: `h-3.5 w-3.5 transition-transform ${open ? "rotate-90" : ""}`
|
|
1399
|
-
})
|
|
1400
|
-
})
|
|
1401
|
-
})
|
|
1402
|
-
]
|
|
1403
|
-
}), open ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
|
|
1404
|
-
colSpan: props.showWorkflow ? 7 : 6,
|
|
1405
|
-
className: "border-b border-solid border-border p-0",
|
|
1406
|
-
children: /* @__PURE__ */ jsx(RunDetail, {
|
|
1407
|
-
run,
|
|
1408
|
-
names: stepNames.get(run.workflowId) ?? /* @__PURE__ */ new Map(),
|
|
1409
|
-
onChanged: props.onChanged
|
|
1410
|
-
})
|
|
1411
|
-
}) }) : null] }, run.id);
|
|
1412
|
-
}) })]
|
|
1413
|
-
})
|
|
1414
|
-
})] });
|
|
1415
|
-
}
|
|
1416
|
-
//#endregion
|
|
1417
|
-
//#region editors/workflow-studio/components/RunsView.tsx
|
|
1418
|
-
function RunsView(props) {
|
|
1419
|
-
const [firing, setFiring] = useState(false);
|
|
1420
|
-
const [fireError, setFireError] = useState(null);
|
|
1421
|
-
const [asking, setAsking] = useState(false);
|
|
1422
|
-
const { runs } = props;
|
|
1423
|
-
const inputs = props.fireInputs ?? [];
|
|
1424
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1425
|
-
className: "w-full",
|
|
1426
|
-
children: [
|
|
1427
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1428
|
-
className: "mb-4 flex items-center gap-3",
|
|
1429
|
-
children: [
|
|
1430
|
-
/* @__PURE__ */ jsx("h2", {
|
|
1431
|
-
className: "text-[15px] font-semibold text-foreground",
|
|
1432
|
-
children: props.title
|
|
1433
|
-
}),
|
|
1434
|
-
/* @__PURE__ */ jsx("span", { className: "grow" }),
|
|
1435
|
-
props.onFire ? /* @__PURE__ */ jsxs(Button, {
|
|
1436
|
-
variant: "primary",
|
|
1437
|
-
disabled: firing,
|
|
1438
|
-
onClick: () => {
|
|
1439
|
-
if (inputs.length > 0) {
|
|
1440
|
-
setFireError(null);
|
|
1441
|
-
setAsking(true);
|
|
1442
|
-
return;
|
|
1443
|
-
}
|
|
1444
|
-
setFiring(true);
|
|
1445
|
-
setFireError(null);
|
|
1446
|
-
props.onFire().then((fireResultError) => setFireError(fireResultError)).catch((fireCallError) => setFireError(fireCallError instanceof Error ? fireCallError.message : String(fireCallError))).finally(() => {
|
|
1447
|
-
setFiring(false);
|
|
1448
|
-
props.reload();
|
|
1449
|
-
});
|
|
1450
|
-
},
|
|
1451
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
1452
|
-
name: "play",
|
|
1453
|
-
className: "h-3.5 w-3.5"
|
|
1454
|
-
}), firing ? "Running…" : "Run now"]
|
|
1455
|
-
}) : null
|
|
1456
|
-
]
|
|
1457
|
-
}),
|
|
1458
|
-
asking && props.onFire && inputs.length > 0 ? /* @__PURE__ */ jsx(RunDialog, {
|
|
1459
|
-
inputs,
|
|
1460
|
-
onCancel: () => setAsking(false),
|
|
1461
|
-
onFire: (payload) => props.onFire(payload).finally(() => props.reload())
|
|
1462
|
-
}) : null,
|
|
1463
|
-
fireError ? /* @__PURE__ */ jsx("p", {
|
|
1464
|
-
className: "mb-3 rounded-md bg-wf-fail/10 px-3 py-2 text-[13px] text-wf-fail",
|
|
1465
|
-
children: fireError
|
|
1466
|
-
}) : null,
|
|
1467
|
-
props.error ? /* @__PURE__ */ jsxs("p", {
|
|
1468
|
-
className: "rounded-md bg-wf-warn/10 px-3 py-2 text-[13px] text-wf-warn",
|
|
1469
|
-
children: ["Runs can't be listed because the workflow runtime is unreachable.", /* @__PURE__ */ jsx("span", {
|
|
1470
|
-
className: "mt-0.5 block text-xs opacity-80",
|
|
1471
|
-
children: props.error
|
|
1472
|
-
})]
|
|
1473
|
-
}) : runs === null ? /* @__PURE__ */ jsx("p", {
|
|
1474
|
-
className: "text-[13px] text-muted-foreground",
|
|
1475
|
-
children: "Loading runs…"
|
|
1476
|
-
}) : runs.length === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
1477
|
-
className: "rounded-lg border border-dashed border-border px-4 py-10 text-center",
|
|
1478
|
-
children: [/* @__PURE__ */ jsx("p", {
|
|
1479
|
-
className: "text-[13px] font-medium text-foreground",
|
|
1480
|
-
children: "No runs yet"
|
|
1481
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
1482
|
-
className: "mt-1 text-xs text-muted-foreground",
|
|
1483
|
-
children: props.onFire ? "Use Run now to record the first one." : "Runs appear here once the trigger fires."
|
|
1484
|
-
})]
|
|
1485
|
-
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(RunsTable, {
|
|
1486
|
-
runs,
|
|
1487
|
-
showWorkflow: props.showWorkflow,
|
|
1488
|
-
onChanged: props.reload
|
|
1489
|
-
}), props.hasMore && props.onLoadMore ? /* @__PURE__ */ jsx("div", {
|
|
1490
|
-
className: "mt-3 flex justify-center",
|
|
1491
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
1492
|
-
disabled: props.loadingMore,
|
|
1493
|
-
onClick: () => props.onLoadMore(),
|
|
1494
|
-
children: props.loadingMore ? "Loading…" : "Load older runs"
|
|
1495
|
-
})
|
|
1496
|
-
}) : null] })
|
|
1497
|
-
]
|
|
1498
|
-
});
|
|
1499
|
-
}
|
|
1500
|
-
//#endregion
|
|
1501
|
-
//#region editors/workflow-studio/components/workflow-order.ts
|
|
1502
|
-
const DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
1503
|
-
const HOME_FOLDER = /^([0-9A-Za-z]+) · (.*)$/s;
|
|
1504
|
-
function compareKeys(a, b) {
|
|
1505
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
1506
|
-
}
|
|
1507
|
-
function midpoint(a, b) {
|
|
1508
|
-
if (b !== null) {
|
|
1509
|
-
let n = 0;
|
|
1510
|
-
while ((a[n] ?? "0") === b[n]) n++;
|
|
1511
|
-
if (n > 0) return b.slice(0, n) + midpoint(a.slice(n), b.slice(n));
|
|
1512
|
-
}
|
|
1513
|
-
const digitA = a ? DIGITS.indexOf(a[0]) : 0;
|
|
1514
|
-
const digitB = b !== null ? DIGITS.indexOf(b[0]) : 62;
|
|
1515
|
-
if (digitB - digitA > 1) return DIGITS[Math.round((digitA + digitB) / 2)];
|
|
1516
|
-
if (b !== null && b.length > 1) return b.slice(0, 1);
|
|
1517
|
-
return DIGITS[digitA] + midpoint(a.slice(1), null);
|
|
1518
|
-
}
|
|
1519
|
-
/** A key that sorts after `before` and before `after`. */
|
|
1520
|
-
function keyBetween(before, after) {
|
|
1521
|
-
return midpoint(before ?? "", after ?? null);
|
|
1522
|
-
}
|
|
1523
|
-
/** `count` ascending keys, evenly spread. */
|
|
1524
|
-
function spreadKeys(count) {
|
|
1525
|
-
let width = 1;
|
|
1526
|
-
while (62 ** width <= count) width++;
|
|
1527
|
-
const span = 62 ** width;
|
|
1528
|
-
return Array.from({ length: count }, (_, i) => {
|
|
1529
|
-
let value = Math.floor((i + 1) * span / (count + 1));
|
|
1530
|
-
let key = "";
|
|
1531
|
-
for (let d = 0; d < width; d++) {
|
|
1532
|
-
key = DIGITS[value % 62] + key;
|
|
1533
|
-
value = Math.floor(value / 62);
|
|
1534
|
-
}
|
|
1535
|
-
return key.replace(/0+$/, "");
|
|
1536
|
-
});
|
|
1537
|
-
}
|
|
1538
|
-
function homeFolderName(key, name) {
|
|
1539
|
-
return `${key} · ${name || "Workflow"}`;
|
|
1540
|
-
}
|
|
1541
|
-
function orderWorkflows(workflows, nodes) {
|
|
1542
|
-
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
1543
|
-
const childCount = /* @__PURE__ */ new Map();
|
|
1544
|
-
for (const node of nodes) if (node.parentFolder) childCount.set(node.parentFolder, (childCount.get(node.parentFolder) ?? 0) + 1);
|
|
1545
|
-
return workflows.map((node) => {
|
|
1546
|
-
const parent = node.parentFolder ? byId.get(node.parentFolder) : void 0;
|
|
1547
|
-
if (parent?.kind !== "folder" || parent.parentFolder || childCount.get(parent.id) !== 1) return { node };
|
|
1548
|
-
const match = HOME_FOLDER.exec(parent.name);
|
|
1549
|
-
return match ? {
|
|
1550
|
-
node,
|
|
1551
|
-
folder: parent,
|
|
1552
|
-
key: match[1]
|
|
1553
|
-
} : { node };
|
|
1554
|
-
}).sort((a, b) => {
|
|
1555
|
-
if (a.key === void 0 || b.key === void 0) {
|
|
1556
|
-
if (a.key !== b.key) return a.key === void 0 ? -1 : 1;
|
|
1557
|
-
} else {
|
|
1558
|
-
const byKey = compareKeys(a.key, b.key);
|
|
1559
|
-
if (byKey !== 0) return byKey;
|
|
1560
|
-
}
|
|
1561
|
-
return compareKeys(a.node.id, b.node.id);
|
|
1562
|
-
});
|
|
1563
|
-
}
|
|
1564
|
-
/** The key for a new workflow, after every other one. */
|
|
1565
|
-
function nextKey(ordered) {
|
|
1566
|
-
return keyBetween(ordered.at(-1)?.key, null);
|
|
1567
|
-
}
|
|
1568
|
-
/** The node to delete to remove a workflow: its home folder, if it has one. */
|
|
1569
|
-
function deletionTarget(workflowId, nodes) {
|
|
1570
|
-
const node = nodes.find((n) => n.id === workflowId);
|
|
1571
|
-
if (node?.kind !== "file") return node;
|
|
1572
|
-
return orderWorkflows([node], nodes)[0].folder ?? node;
|
|
1573
|
-
}
|
|
1574
|
-
function folderTail(item, names) {
|
|
1575
|
-
const name = names.get(item.node.id) || item.node.name;
|
|
1576
|
-
return item.folder ? HOME_FOLDER.exec(item.folder.name)?.[2] ?? name : name;
|
|
1577
|
-
}
|
|
1578
|
-
function reorderActions(ordered, from, to, names = /* @__PURE__ */ new Map()) {
|
|
1579
|
-
if (from === to || !ordered[from]) return [];
|
|
1580
|
-
const next = [...ordered];
|
|
1581
|
-
const [moved] = next.splice(from, 1);
|
|
1582
|
-
next.splice(to, 0, moved);
|
|
1583
|
-
const before = to > 0 ? next[to - 1] : void 0;
|
|
1584
|
-
const after = to < next.length - 1 ? next[to + 1] : void 0;
|
|
1585
|
-
if (moved.folder && (!before || before.key !== void 0) && (!after || after.key !== void 0) && (!before || !after || compareKeys(before.key, after.key) < 0)) {
|
|
1586
|
-
const key = keyBetween(before?.key, after?.key);
|
|
1587
|
-
return [updateNode({
|
|
1588
|
-
id: moved.folder.id,
|
|
1589
|
-
name: homeFolderName(key, folderTail(moved, names))
|
|
1590
|
-
})];
|
|
1591
|
-
}
|
|
1592
|
-
const keys = spreadKeys(next.length);
|
|
1593
|
-
return next.flatMap((item, i) => {
|
|
1594
|
-
const name = homeFolderName(keys[i], folderTail(item, names));
|
|
1595
|
-
if (item.folder) return item.folder.name === name ? [] : [updateNode({
|
|
1596
|
-
id: item.folder.id,
|
|
1597
|
-
name
|
|
1598
|
-
})];
|
|
1599
|
-
const folderId = generateId();
|
|
1600
|
-
return [addFolder$1({
|
|
1601
|
-
id: folderId,
|
|
1602
|
-
name,
|
|
1603
|
-
parentFolder: null
|
|
1604
|
-
}), moveNode({
|
|
1605
|
-
srcFolder: item.node.id,
|
|
1606
|
-
targetParentFolder: folderId
|
|
1607
|
-
})];
|
|
1608
|
-
});
|
|
1609
|
-
}
|
|
1610
|
-
//#endregion
|
|
1611
|
-
//#region editors/workflow-studio/components/WorkflowMenu.tsx
|
|
1612
|
-
/** Deletes a workflow with its home folder, reading the drive's nodes now. */
|
|
1613
|
-
async function deleteWorkflow(workflowId) {
|
|
1614
|
-
const store = getPHStore();
|
|
1615
|
-
const driveId = store?.selectedDriveId;
|
|
1616
|
-
if (!driveId) throw new Error("No drive is selected");
|
|
1617
|
-
const nodes = store?.drives?.find((drive) => drive.header.id === driveId)?.state.global.nodes ?? [];
|
|
1618
|
-
await deleteNode(driveId, deletionTarget(workflowId, nodes)?.id ?? workflowId);
|
|
1619
|
-
}
|
|
1620
|
-
function DeleteWorkflowDialog(props) {
|
|
1621
|
-
const [typed, setTyped] = useState("");
|
|
1622
|
-
const [error, setError] = useState(null);
|
|
1623
|
-
const [deleting, setDeleting] = useState(false);
|
|
1624
|
-
const inputId = useId();
|
|
1625
|
-
const cancelRef = useRef(null);
|
|
1626
|
-
const matches = typed === props.name;
|
|
1627
|
-
return /* @__PURE__ */ jsx(Modal, {
|
|
1628
|
-
open: true,
|
|
1629
|
-
title: "Delete workflow",
|
|
1630
|
-
onOpenChange: (open) => {
|
|
1631
|
-
if (!open) props.onCancel();
|
|
1632
|
-
},
|
|
1633
|
-
contentProps: {
|
|
1634
|
-
className: "w-[28rem] max-w-[92vw] rounded-xl border border-solid border-foreground/10",
|
|
1635
|
-
role: "alertdialog",
|
|
1636
|
-
"aria-label": "Delete workflow",
|
|
1637
|
-
onOpenAutoFocus: (event) => {
|
|
1638
|
-
event.preventDefault();
|
|
1639
|
-
cancelRef.current?.focus();
|
|
1640
|
-
}
|
|
1641
|
-
},
|
|
1642
|
-
children: /* @__PURE__ */ jsxs("form", {
|
|
1643
|
-
className: "flex flex-col gap-4 p-6",
|
|
1644
|
-
onSubmit: (event) => {
|
|
1645
|
-
event.preventDefault();
|
|
1646
|
-
if (!matches || deleting) return;
|
|
1647
|
-
setDeleting(true);
|
|
1648
|
-
props.onConfirm().catch((cause) => {
|
|
1649
|
-
setDeleting(false);
|
|
1650
|
-
setError(cause instanceof Error ? cause.message : String(cause));
|
|
1651
|
-
});
|
|
1652
|
-
},
|
|
1653
|
-
children: [
|
|
1654
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
|
|
1655
|
-
className: "text-[15px] font-semibold text-foreground",
|
|
1656
|
-
children: "Delete workflow"
|
|
1657
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
1658
|
-
className: "mt-1 text-[13px] text-muted-foreground",
|
|
1659
|
-
children: "This removes the workflow from the drive and can't be undone. To archive it instead, use Archive."
|
|
1660
|
-
})] }),
|
|
1661
|
-
/* @__PURE__ */ jsxs("label", {
|
|
1662
|
-
htmlFor: inputId,
|
|
1663
|
-
className: "flex flex-col gap-1.5",
|
|
1664
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
1665
|
-
className: "text-[13px] text-foreground",
|
|
1666
|
-
children: [
|
|
1667
|
-
"Type ",
|
|
1668
|
-
/* @__PURE__ */ jsx("strong", {
|
|
1669
|
-
className: "font-semibold",
|
|
1670
|
-
children: props.name
|
|
1671
|
-
}),
|
|
1672
|
-
" to confirm"
|
|
1673
|
-
]
|
|
1674
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
1675
|
-
id: inputId,
|
|
1676
|
-
className: textInputClass,
|
|
1677
|
-
value: typed,
|
|
1678
|
-
spellCheck: false,
|
|
1679
|
-
autoComplete: "off",
|
|
1680
|
-
onChange: (event) => setTyped(event.target.value)
|
|
1681
|
-
})]
|
|
1682
|
-
}),
|
|
1683
|
-
error ? /* @__PURE__ */ jsx("p", {
|
|
1684
|
-
className: "text-xs text-wf-fail",
|
|
1685
|
-
children: error
|
|
1686
|
-
}) : null,
|
|
1687
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1688
|
-
className: "flex justify-end gap-2",
|
|
1689
|
-
children: [/* @__PURE__ */ jsx(Button, {
|
|
1690
|
-
ref: cancelRef,
|
|
1691
|
-
onClick: props.onCancel,
|
|
1692
|
-
children: "Cancel"
|
|
1693
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
1694
|
-
type: "submit",
|
|
1695
|
-
variant: "destructive",
|
|
1696
|
-
disabled: !matches || deleting,
|
|
1697
|
-
children: deleting ? "Deleting…" : "Delete workflow"
|
|
1698
|
-
})]
|
|
1699
|
-
})
|
|
1700
|
-
]
|
|
1701
|
-
})
|
|
1702
|
-
});
|
|
1703
|
-
}
|
|
1704
|
-
function MenuItem(props) {
|
|
1705
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
1706
|
-
type: "button",
|
|
1707
|
-
role: "menuitem",
|
|
1708
|
-
className: `flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[13px] hover:bg-accent focus-visible:bg-accent focus-visible:outline-none ${props.danger ? "text-wf-fail" : "text-foreground"}`,
|
|
1709
|
-
onClick: props.onSelect,
|
|
1710
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
1711
|
-
name: props.icon,
|
|
1712
|
-
className: "h-3.5 w-3.5"
|
|
1713
|
-
}), props.label]
|
|
1714
|
-
});
|
|
1715
|
-
}
|
|
1716
|
-
function WorkflowMenu(props) {
|
|
1717
|
-
const [open, setOpen] = useState(false);
|
|
1718
|
-
const [confirming, setConfirming] = useState(false);
|
|
1719
|
-
const [, dispatch] = useDispatch(props.document);
|
|
1720
|
-
const ref = useRef(null);
|
|
1721
|
-
const state = props.document.state.global;
|
|
1722
|
-
const name = state.name || props.nodeName || "Untitled workflow";
|
|
1723
|
-
const archived = state.status === "ARCHIVED";
|
|
1724
|
-
useEffect(() => {
|
|
1725
|
-
if (!open) return;
|
|
1726
|
-
const close = (event) => {
|
|
1727
|
-
if (!ref.current?.contains(event.target)) setOpen(false);
|
|
1728
|
-
};
|
|
1729
|
-
const escape = (event) => {
|
|
1730
|
-
if (event.key === "Escape") setOpen(false);
|
|
1731
|
-
};
|
|
1732
|
-
window.addEventListener("mousedown", close);
|
|
1733
|
-
window.addEventListener("keydown", escape);
|
|
1734
|
-
return () => {
|
|
1735
|
-
window.removeEventListener("mousedown", close);
|
|
1736
|
-
window.removeEventListener("keydown", escape);
|
|
1737
|
-
};
|
|
1738
|
-
}, [open]);
|
|
1739
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1740
|
-
ref,
|
|
1741
|
-
className: "relative",
|
|
1742
|
-
children: [
|
|
1743
|
-
/* @__PURE__ */ jsx("button", {
|
|
1744
|
-
type: "button",
|
|
1745
|
-
"aria-label": `More actions for ${name}`,
|
|
1746
|
-
"aria-haspopup": "menu",
|
|
1747
|
-
"aria-expanded": open,
|
|
1748
|
-
className: `flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${props.subtle && !open ? "opacity-0 group-hover:opacity-100" : ""}`,
|
|
1749
|
-
onClick: (event) => {
|
|
1750
|
-
event.stopPropagation();
|
|
1751
|
-
setOpen((value) => !value);
|
|
1752
|
-
},
|
|
1753
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
1754
|
-
name: "more",
|
|
1755
|
-
className: "h-4 w-4"
|
|
1756
|
-
})
|
|
1757
|
-
}),
|
|
1758
|
-
open ? /* @__PURE__ */ jsxs("div", {
|
|
1759
|
-
role: "menu",
|
|
1760
|
-
className: "absolute right-0 top-full z-50 mt-1 w-44 rounded-md border border-solid border-foreground/10 bg-card p-1 shadow-lg",
|
|
1761
|
-
children: [/* @__PURE__ */ jsx(MenuItem, {
|
|
1762
|
-
label: archived ? "Restore" : "Archive",
|
|
1763
|
-
icon: archived ? "retry" : "archive",
|
|
1764
|
-
onSelect: () => {
|
|
1765
|
-
setOpen(false);
|
|
1766
|
-
const status = archived ? state.published ? "DISABLED" : "DRAFT" : "ARCHIVED";
|
|
1767
|
-
dispatch(actions.setWorkflowStatus({ status }));
|
|
1768
|
-
}
|
|
1769
|
-
}), /* @__PURE__ */ jsx(MenuItem, {
|
|
1770
|
-
label: "Delete…",
|
|
1771
|
-
icon: "trash",
|
|
1772
|
-
danger: true,
|
|
1773
|
-
onSelect: () => {
|
|
1774
|
-
setOpen(false);
|
|
1775
|
-
setConfirming(true);
|
|
1776
|
-
}
|
|
1777
|
-
})]
|
|
1778
|
-
}) : null,
|
|
1779
|
-
confirming ? /* @__PURE__ */ jsx(DeleteWorkflowDialog, {
|
|
1780
|
-
name,
|
|
1781
|
-
onCancel: () => setConfirming(false),
|
|
1782
|
-
onConfirm: async () => {
|
|
1783
|
-
await deleteWorkflow(props.document.header.id);
|
|
1784
|
-
setConfirming(false);
|
|
1785
|
-
props.onDeleted?.();
|
|
1786
|
-
}
|
|
1787
|
-
}) : null
|
|
1788
|
-
]
|
|
1789
|
-
});
|
|
1790
|
-
}
|
|
1791
|
-
//#endregion
|
|
1792
|
-
//#region editors/workflow-studio/components/Sidebar.tsx
|
|
1793
|
-
const WORKFLOW_TYPE$2 = "powerhouse/workflow";
|
|
1794
|
-
function documentName(document, fallback) {
|
|
1795
|
-
return (document?.state?.global)?.name || fallback || "(unnamed)";
|
|
1796
|
-
}
|
|
1797
|
-
function documentStatus(document) {
|
|
1798
|
-
const state = document?.state?.global;
|
|
1799
|
-
return {
|
|
1800
|
-
status: state?.status,
|
|
1801
|
-
published: Boolean(state?.published)
|
|
1802
|
-
};
|
|
1803
|
-
}
|
|
1804
|
-
function Row(props) {
|
|
1805
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1806
|
-
className: `group mx-2 flex items-center rounded-md ${props.active ? "bg-accent" : "hover:bg-accent/60"}`,
|
|
1807
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
1808
|
-
type: "button",
|
|
1809
|
-
"aria-current": props.active ? "true" : void 0,
|
|
1810
|
-
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"}`,
|
|
1811
|
-
onClick: props.onClick,
|
|
1812
|
-
onKeyDown: props.onKeyDown,
|
|
1813
|
-
"aria-keyshortcuts": props.keyShortcuts,
|
|
1814
|
-
children: props.children
|
|
1815
|
-
}), props.trailing]
|
|
1816
|
-
});
|
|
1817
|
-
}
|
|
1818
|
-
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";
|
|
1819
|
-
const DELETE_ACTION = `${ROW_ACTION} hover:text-wf-fail`;
|
|
1820
|
-
function DeleteButton(props) {
|
|
1821
|
-
const [confirming, setConfirming] = useState(false);
|
|
1822
|
-
const isWorkflow = props.node.documentType === WORKFLOW_TYPE$2;
|
|
1823
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
1824
|
-
type: "button",
|
|
1825
|
-
title: "Delete",
|
|
1826
|
-
"aria-label": `Delete ${props.label}`,
|
|
1827
|
-
className: DELETE_ACTION,
|
|
1828
|
-
onClick: () => isWorkflow ? setConfirming(true) : showDeleteNodeModal(props.node),
|
|
1829
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
1830
|
-
name: "trash",
|
|
1831
|
-
className: "h-3.5 w-3.5"
|
|
1832
|
-
})
|
|
1833
|
-
}), confirming ? /* @__PURE__ */ jsx(DeleteWorkflowDialog, {
|
|
1834
|
-
name: props.label,
|
|
1835
|
-
onCancel: () => setConfirming(false),
|
|
1836
|
-
onConfirm: async () => {
|
|
1837
|
-
await deleteWorkflow(props.node.id);
|
|
1838
|
-
setConfirming(false);
|
|
1839
|
-
}
|
|
1840
|
-
}) : null] });
|
|
1841
|
-
}
|
|
1842
|
-
function NodeRow(props) {
|
|
1843
|
-
const { node } = props;
|
|
1844
|
-
const { data: document, error } = useDocumentSafe(node.id);
|
|
1845
|
-
useEffect(() => {
|
|
1846
|
-
if (error !== void 0) console.error(`Failed to load document ${node.id}:`, error);
|
|
1847
|
-
}, [error, node.id]);
|
|
1848
|
-
if (error !== void 0) return /* @__PURE__ */ jsxs(Row, {
|
|
1849
|
-
active: props.active,
|
|
1850
|
-
onClick: props.onOpen,
|
|
1851
|
-
onKeyDown: props.onKeyDown,
|
|
1852
|
-
keyShortcuts: props.keyShortcuts,
|
|
1853
|
-
trailing: /* @__PURE__ */ jsx("span", {
|
|
1854
|
-
className: "mr-1.5 flex shrink-0 items-center",
|
|
1855
|
-
children: /* @__PURE__ */ jsx(DeleteButton, {
|
|
1856
|
-
node,
|
|
1857
|
-
label: node.name || node.id
|
|
1858
|
-
})
|
|
1859
|
-
}),
|
|
1860
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
1861
|
-
className: "shrink-0 text-xs text-wf-fail",
|
|
1862
|
-
title: `Could not load ${node.id}: ${errorMessage(error)}`,
|
|
1863
|
-
"aria-hidden": true,
|
|
1864
|
-
children: "⚠"
|
|
1865
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
1866
|
-
className: "min-w-0 truncate text-wf-fail",
|
|
1867
|
-
children: node.name || "(unnamed)"
|
|
1868
|
-
})]
|
|
1869
|
-
});
|
|
1870
|
-
const { status, published } = documentStatus(document);
|
|
1871
|
-
const isWorkflow = node.documentType === WORKFLOW_TYPE$2;
|
|
1872
|
-
const { tone, label, hollow } = isWorkflow ? workflowHealth(status, props.lastRunStatus, published) : {
|
|
1873
|
-
tone: toneOf(CONNECTION_TONE, status),
|
|
1874
|
-
label: status,
|
|
1875
|
-
hollow: void 0
|
|
1876
|
-
};
|
|
1877
|
-
return /* @__PURE__ */ jsxs(Row, {
|
|
1878
|
-
active: props.active,
|
|
1879
|
-
onClick: props.onOpen,
|
|
1880
|
-
onKeyDown: props.onKeyDown,
|
|
1881
|
-
keyShortcuts: props.keyShortcuts,
|
|
1882
|
-
trailing: /* @__PURE__ */ jsxs("span", {
|
|
1883
|
-
className: "mr-1.5 flex shrink-0 items-center",
|
|
1884
|
-
children: [
|
|
1885
|
-
/* @__PURE__ */ jsx(ApprovalBadge, {
|
|
1886
|
-
count: props.approvals ?? 0,
|
|
1887
|
-
capped: props.approvalsCapped ?? false,
|
|
1888
|
-
onClick: props.onShowApprovals,
|
|
1889
|
-
className: "mr-0.5"
|
|
1890
|
-
}),
|
|
1891
|
-
props.onEdit ? /* @__PURE__ */ jsx("button", {
|
|
1892
|
-
type: "button",
|
|
1893
|
-
title: "Open in editor",
|
|
1894
|
-
"aria-label": `Open ${documentName(document, node.name)} in the editor`,
|
|
1895
|
-
className: ROW_ACTION,
|
|
1896
|
-
onClick: props.onEdit,
|
|
1897
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
1898
|
-
name: "pencil",
|
|
1899
|
-
className: "h-3.5 w-3.5"
|
|
1900
|
-
})
|
|
1901
|
-
}) : null,
|
|
1902
|
-
isWorkflow && document ? /* @__PURE__ */ jsx(WorkflowMenu, {
|
|
1903
|
-
subtle: true,
|
|
1904
|
-
document,
|
|
1905
|
-
nodeName: node.name
|
|
1906
|
-
}) : /* @__PURE__ */ jsx(DeleteButton, {
|
|
1907
|
-
node,
|
|
1908
|
-
label: documentName(document, node.name)
|
|
1909
|
-
})
|
|
1910
|
-
]
|
|
1911
|
-
}),
|
|
1912
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
1913
|
-
title: label,
|
|
1914
|
-
className: "flex",
|
|
1915
|
-
children: /* @__PURE__ */ jsx(StatusDot, {
|
|
1916
|
-
tone,
|
|
1917
|
-
hollow
|
|
1918
|
-
})
|
|
1919
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
1920
|
-
className: "min-w-0 truncate",
|
|
1921
|
-
children: documentName(document, node.name)
|
|
1922
|
-
})]
|
|
1923
|
-
});
|
|
1924
|
-
}
|
|
1925
|
-
function DropLine(props) {
|
|
1926
|
-
return /* @__PURE__ */ jsx("span", {
|
|
1927
|
-
"aria-hidden": true,
|
|
1928
|
-
className: `pointer-events-none absolute inset-x-3 z-10 h-0.5 rounded-full bg-primary ${props.edge === "top" ? "-top-px" : "-bottom-px"}`
|
|
1929
|
-
});
|
|
1930
|
-
}
|
|
1931
|
-
function Section(props) {
|
|
1932
|
-
const { onReorder } = props;
|
|
1933
|
-
const headingId = useId();
|
|
1934
|
-
const [drag, setDrag] = useState(null);
|
|
1935
|
-
const count = props.nodes.length;
|
|
1936
|
-
const drop = (from, at) => {
|
|
1937
|
-
const to = at > from ? at - 1 : at;
|
|
1938
|
-
if (to !== from) onReorder?.(from, to);
|
|
1939
|
-
};
|
|
1940
|
-
const showLine = (at) => drag !== null && drag.at === at && at !== drag.from && at !== drag.from + 1;
|
|
1941
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1942
|
-
className: "mt-5",
|
|
1943
|
-
role: "group",
|
|
1944
|
-
"aria-labelledby": headingId,
|
|
1945
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
1946
|
-
className: "mb-1 flex items-center justify-between pl-4 pr-3",
|
|
1947
|
-
children: [/* @__PURE__ */ jsx("h3", {
|
|
1948
|
-
id: headingId,
|
|
1949
|
-
className: "text-xs font-medium text-muted-foreground",
|
|
1950
|
-
children: props.title
|
|
1951
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
1952
|
-
type: "button",
|
|
1953
|
-
disabled: props.creating,
|
|
1954
|
-
className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",
|
|
1955
|
-
title: props.addLabel,
|
|
1956
|
-
"aria-label": props.addLabel,
|
|
1957
|
-
onClick: props.onCreate,
|
|
1958
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
1959
|
-
name: "plus",
|
|
1960
|
-
className: "h-3.5 w-3.5"
|
|
1961
|
-
})
|
|
1962
|
-
})]
|
|
1963
|
-
}), props.nodes.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
1964
|
-
className: "px-4 py-1 text-xs text-muted-foreground",
|
|
1965
|
-
children: props.empty
|
|
1966
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
1967
|
-
className: "flex flex-col gap-0.5",
|
|
1968
|
-
children: props.nodes.map((node, i) => /* @__PURE__ */ jsxs("div", {
|
|
1969
|
-
className: `relative ${drag?.from === i ? "opacity-50" : ""}`,
|
|
1970
|
-
draggable: Boolean(onReorder),
|
|
1971
|
-
onDragStart: (event) => {
|
|
1972
|
-
event.dataTransfer.effectAllowed = "move";
|
|
1973
|
-
event.dataTransfer.setData("text/plain", node.id);
|
|
1974
|
-
setDrag({
|
|
1975
|
-
from: i,
|
|
1976
|
-
at: i
|
|
1977
|
-
});
|
|
1978
|
-
},
|
|
1979
|
-
onDragOver: (event) => {
|
|
1980
|
-
if (!drag) return;
|
|
1981
|
-
event.preventDefault();
|
|
1982
|
-
event.dataTransfer.dropEffect = "move";
|
|
1983
|
-
const box = event.currentTarget.getBoundingClientRect();
|
|
1984
|
-
const at = event.clientY < box.top + box.height / 2 ? i : i + 1;
|
|
1985
|
-
if (at !== drag.at) setDrag({
|
|
1986
|
-
...drag,
|
|
1987
|
-
at
|
|
1988
|
-
});
|
|
1989
|
-
},
|
|
1990
|
-
onDrop: (event) => {
|
|
1991
|
-
event.preventDefault();
|
|
1992
|
-
if (drag) drop(drag.from, drag.at);
|
|
1993
|
-
setDrag(null);
|
|
1994
|
-
},
|
|
1995
|
-
onDragEnd: () => setDrag(null),
|
|
1996
|
-
children: [
|
|
1997
|
-
showLine(i) ? /* @__PURE__ */ jsx(DropLine, { edge: "top" }) : null,
|
|
1998
|
-
/* @__PURE__ */ jsx(NodeRow, {
|
|
1999
|
-
node,
|
|
2000
|
-
lastRunStatus: props.lastRuns?.get(node.id),
|
|
2001
|
-
approvals: props.approvals?.byWorkflow.get(node.id),
|
|
2002
|
-
approvalsCapped: props.approvals?.capped,
|
|
2003
|
-
onShowApprovals: props.onShowApprovals ? () => props.onShowApprovals(node) : void 0,
|
|
2004
|
-
active: props.activeId === node.id,
|
|
2005
|
-
onOpen: () => props.onOpen(node),
|
|
2006
|
-
onEdit: props.onEdit ? () => props.onEdit(node) : void 0,
|
|
2007
|
-
keyShortcuts: onReorder ? "Alt+ArrowUp Alt+ArrowDown" : void 0,
|
|
2008
|
-
onKeyDown: onReorder ? (event) => {
|
|
2009
|
-
if (!event.altKey) return;
|
|
2010
|
-
if (event.key === "ArrowUp" && i > 0) {
|
|
2011
|
-
event.preventDefault();
|
|
2012
|
-
onReorder(i, i - 1);
|
|
2013
|
-
} else if (event.key === "ArrowDown" && i < count - 1) {
|
|
2014
|
-
event.preventDefault();
|
|
2015
|
-
onReorder(i, i + 1);
|
|
2016
|
-
}
|
|
2017
|
-
} : void 0
|
|
2018
|
-
}),
|
|
2019
|
-
i === count - 1 && showLine(count) ? /* @__PURE__ */ jsx(DropLine, { edge: "bottom" }) : null
|
|
2020
|
-
]
|
|
2021
|
-
}, node.id))
|
|
2022
|
-
})]
|
|
2023
|
-
});
|
|
2024
|
-
}
|
|
2025
|
-
function Sidebar(props) {
|
|
2026
|
-
return /* @__PURE__ */ jsxs("aside", {
|
|
2027
|
-
className: "max-h-56 w-full shrink-0 overflow-y-auto border-b border-solid border-border bg-muted/50 py-3 md:max-h-none md:w-60 md:border-r md:border-b-0",
|
|
2028
|
-
children: [
|
|
2029
|
-
/* @__PURE__ */ jsxs(Row, {
|
|
2030
|
-
active: props.allRunsActive,
|
|
2031
|
-
onClick: props.onShowAllRuns,
|
|
2032
|
-
trailing: /* @__PURE__ */ jsx(ApprovalBadge, {
|
|
2033
|
-
count: props.approvals.total,
|
|
2034
|
-
capped: props.approvals.capped,
|
|
2035
|
-
onClick: () => props.onShowApprovals(),
|
|
2036
|
-
className: "mr-2"
|
|
2037
|
-
}),
|
|
2038
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
2039
|
-
name: "list",
|
|
2040
|
-
className: "text-muted-foreground"
|
|
2041
|
-
}), /* @__PURE__ */ jsx("span", { children: "Overview" })]
|
|
2042
|
-
}),
|
|
2043
|
-
/* @__PURE__ */ jsx(Section, {
|
|
2044
|
-
title: "Workflows",
|
|
2045
|
-
addLabel: "New workflow",
|
|
2046
|
-
empty: "No workflows yet.",
|
|
2047
|
-
nodes: props.workflows,
|
|
2048
|
-
lastRuns: props.lastRuns,
|
|
2049
|
-
approvals: props.approvals,
|
|
2050
|
-
onShowApprovals: (node) => props.onShowApprovals(node.id),
|
|
2051
|
-
activeId: props.activeId,
|
|
2052
|
-
onOpen: props.onOpenWorkflow,
|
|
2053
|
-
onEdit: props.onEditWorkflow,
|
|
2054
|
-
onCreate: props.onCreateWorkflow,
|
|
2055
|
-
onReorder: props.onReorderWorkflow,
|
|
2056
|
-
creating: props.creating
|
|
2057
|
-
}),
|
|
2058
|
-
/* @__PURE__ */ jsx(Section, {
|
|
2059
|
-
title: "Connections",
|
|
2060
|
-
addLabel: "New connection",
|
|
2061
|
-
empty: "No connections yet.",
|
|
2062
|
-
nodes: props.connections,
|
|
2063
|
-
activeId: props.activeId,
|
|
2064
|
-
onOpen: props.onOpenConnection,
|
|
2065
|
-
onCreate: props.onCreateConnection,
|
|
2066
|
-
creating: props.creating
|
|
2067
|
-
})
|
|
2068
|
-
]
|
|
2069
|
-
});
|
|
2070
|
-
}
|
|
2071
|
-
//#endregion
|
|
2072
|
-
//#region editors/workflow-studio/components/use-item-selection.ts
|
|
2073
|
-
function readLegacyHash() {
|
|
2074
|
-
if (typeof window === "undefined") return void 0;
|
|
2075
|
-
return window.location.hash.replace(/^#/, "") || void 0;
|
|
2076
|
-
}
|
|
2077
|
-
/** The selected item, a setter, and `go`, which also opens or closes the item's
|
|
2078
|
-
* editor; each is one history entry, so back and forward walk the studio. */
|
|
2079
|
-
function useItemSelection(openEditorId) {
|
|
2080
|
-
const params = useSearchParams();
|
|
2081
|
-
const setParams = useSetSearchParams();
|
|
2082
|
-
const setSelectedNode = useSetSelectedNode();
|
|
2083
|
-
const selected = params["item"] || void 0;
|
|
2084
|
-
const select = useCallback((id, options) => {
|
|
2085
|
-
if (id === selected) return;
|
|
2086
|
-
setParams({ [ITEM_PARAM]: id }, options);
|
|
2087
|
-
}, [selected, setParams]);
|
|
2088
|
-
const go = useCallback((id, editor) => {
|
|
2089
|
-
if ((editor ?? null) === (openEditorId ?? null)) {
|
|
2090
|
-
select(id);
|
|
2091
|
-
return;
|
|
2092
|
-
}
|
|
2093
|
-
setSelectedNode(editor, { search: { [ITEM_PARAM]: id } });
|
|
2094
|
-
}, [
|
|
2095
|
-
openEditorId,
|
|
2096
|
-
select,
|
|
2097
|
-
setSelectedNode
|
|
2098
|
-
]);
|
|
2099
|
-
useEffect(() => {
|
|
2100
|
-
const legacy = readLegacyHash();
|
|
2101
|
-
if (legacy && !selected) setParams({ [ITEM_PARAM]: legacy }, { replace: true });
|
|
2102
|
-
}, []);
|
|
2103
|
-
return [
|
|
2104
|
-
selected,
|
|
2105
|
-
select,
|
|
2106
|
-
go
|
|
2107
|
-
];
|
|
2108
|
-
}
|
|
2109
|
-
//#endregion
|
|
2110
|
-
//#region editors/workflow-studio/components/useRuns.ts
|
|
2111
|
-
const POLL_MS = 5e3;
|
|
2112
|
-
function useRuns(scope, active = true) {
|
|
2113
|
-
const { workflowId, driveId, limit } = scope;
|
|
2114
|
-
const query = useRunPagesQuery({
|
|
2115
|
-
workflowId,
|
|
2116
|
-
driveId,
|
|
2117
|
-
limit
|
|
2118
|
-
}, {
|
|
2119
|
-
active,
|
|
2120
|
-
pollMs: POLL_MS
|
|
2121
|
-
});
|
|
2122
|
-
const { refetch, fetchNextPage } = query;
|
|
2123
|
-
return {
|
|
2124
|
-
runs: query.data ? runsOfPages(query.data.pages) : null,
|
|
2125
|
-
error: query.status === "error" ? query.error instanceof Error ? query.error.message : String(query.error) : null,
|
|
2126
|
-
reload: () => void refetch(),
|
|
2127
|
-
hasMore: query.hasNextPage,
|
|
2128
|
-
loadingMore: query.isFetchingNextPage,
|
|
2129
|
-
loadMore: () => void fetchNextPage()
|
|
2130
|
-
};
|
|
2131
|
-
}
|
|
2132
|
-
//#endregion
|
|
2133
|
-
//#region editors/workflow-studio/components/ScrollFade.tsx
|
|
2134
|
-
const FADE = 40;
|
|
2135
|
-
function fadeMask(start, end) {
|
|
2136
|
-
if (!start && !end) return void 0;
|
|
2137
|
-
return `linear-gradient(to right, ${start ? `transparent, black ${FADE}px` : "black"}, ${end ? `black calc(100% - ${FADE}px), transparent` : "black"})`;
|
|
2138
|
-
}
|
|
2139
|
-
function ScrollFade(props) {
|
|
2140
|
-
const ref = useRef(null);
|
|
2141
|
-
const [edges, setEdges] = useState({
|
|
2142
|
-
start: false,
|
|
2143
|
-
end: false
|
|
2144
|
-
});
|
|
2145
|
-
useEffect(() => {
|
|
2146
|
-
const element = ref.current;
|
|
2147
|
-
if (!element) return;
|
|
2148
|
-
const measure = () => {
|
|
2149
|
-
const start = element.scrollLeft > 1;
|
|
2150
|
-
const end = element.scrollLeft + element.clientWidth < element.scrollWidth - 1;
|
|
2151
|
-
setEdges((prev) => prev.start === start && prev.end === end ? prev : {
|
|
2152
|
-
start,
|
|
2153
|
-
end
|
|
2154
|
-
});
|
|
2155
|
-
};
|
|
2156
|
-
measure();
|
|
2157
|
-
const resize = new ResizeObserver(measure);
|
|
2158
|
-
resize.observe(element);
|
|
2159
|
-
if (element.firstElementChild) resize.observe(element.firstElementChild);
|
|
2160
|
-
element.addEventListener("scroll", measure, { passive: true });
|
|
2161
|
-
return () => {
|
|
2162
|
-
resize.disconnect();
|
|
2163
|
-
element.removeEventListener("scroll", measure);
|
|
2164
|
-
};
|
|
2165
|
-
}, []);
|
|
2166
|
-
const mask = fadeMask(edges.start, edges.end);
|
|
2167
|
-
return /* @__PURE__ */ jsx("span", {
|
|
2168
|
-
ref,
|
|
2169
|
-
className: `block ${props.clip ? "overflow-hidden" : "overflow-x-auto"} ${props.className ?? ""}`,
|
|
2170
|
-
style: {
|
|
2171
|
-
maskImage: mask,
|
|
2172
|
-
WebkitMaskImage: mask
|
|
2173
|
-
},
|
|
2174
|
-
children: props.children
|
|
2175
|
-
});
|
|
2176
|
-
}
|
|
2177
|
-
//#endregion
|
|
2178
|
-
//#region editors/workflow-studio/components/use-collapsed.ts
|
|
2179
|
-
const KEY = "workflow-studio:collapsed";
|
|
2180
|
-
function read() {
|
|
2181
|
-
try {
|
|
2182
|
-
const parsed = JSON.parse(localStorage.getItem(KEY) ?? "[]");
|
|
2183
|
-
return new Set(Array.isArray(parsed) ? parsed.filter((id) => typeof id === "string") : []);
|
|
2184
|
-
} catch {
|
|
2185
|
-
return /* @__PURE__ */ new Set();
|
|
2186
|
-
}
|
|
2187
|
-
}
|
|
2188
|
-
function write(ids) {
|
|
2189
|
-
try {
|
|
2190
|
-
localStorage.setItem(KEY, JSON.stringify([...ids]));
|
|
2191
|
-
} catch {}
|
|
2192
|
-
}
|
|
2193
|
-
function useCollapsed() {
|
|
2194
|
-
const [collapsed, setCollapsed] = useState(read);
|
|
2195
|
-
return {
|
|
2196
|
-
isCollapsed: (id) => collapsed.has(id),
|
|
2197
|
-
toggle: useCallback((id) => {
|
|
2198
|
-
setCollapsed((previous) => {
|
|
2199
|
-
const next = new Set(previous);
|
|
2200
|
-
if (!next.delete(id)) next.add(id);
|
|
2201
|
-
write(next);
|
|
2202
|
-
return next;
|
|
2203
|
-
});
|
|
2204
|
-
}, [])
|
|
2205
|
-
};
|
|
2206
|
-
}
|
|
2207
|
-
//#endregion
|
|
2208
|
-
//#region editors/workflow-studio/components/WorkflowGraph.tsx
|
|
2209
|
-
const STACK_GAP = 16;
|
|
2210
|
-
const MAX_STRETCH = 1.5;
|
|
2211
|
-
function fitGraph(base, cols, room) {
|
|
2212
|
-
if (!room || room.width <= 0 || cols === 0) return {
|
|
2213
|
-
g: base,
|
|
2214
|
-
stacked: false,
|
|
2215
|
-
perRow: Math.max(cols, 1)
|
|
2216
|
-
};
|
|
2217
|
-
const tailOf = (col) => base.label ? col / 2 : base.r;
|
|
2218
|
-
const span = (n, lead) => lead + (n - 1) * base.col + base.r + tailOf(base.col);
|
|
2219
|
-
const beside = room.width - room.pill;
|
|
2220
|
-
const stacked = span(cols, base.lead) > beside;
|
|
2221
|
-
const lead = stacked ? base.pillLogoX * 2 : base.lead;
|
|
2222
|
-
const space = stacked ? room.width : beside;
|
|
2223
|
-
const fits = Math.floor((space - lead - base.r - tailOf(base.col)) / base.col) + 1;
|
|
2224
|
-
const perRow = stacked ? Math.min(cols, Math.max(2, fits)) : cols;
|
|
2225
|
-
const fill = base.label ? (space - lead - base.r) / (perRow - .5) : perRow > 1 ? (space - lead - 2 * base.r) / (perRow - 1) : base.col;
|
|
2226
|
-
const col = Math.floor(Math.min(base.col * MAX_STRETCH, Math.max(base.col, fill)));
|
|
2227
|
-
return {
|
|
2228
|
-
g: {
|
|
2229
|
-
...base,
|
|
2230
|
-
col,
|
|
2231
|
-
lead
|
|
2232
|
-
},
|
|
2233
|
-
stacked,
|
|
2234
|
-
perRow
|
|
2235
|
-
};
|
|
2236
|
-
}
|
|
2237
|
-
const GEOMETRY = {
|
|
2238
|
-
sm: {
|
|
2239
|
-
r: 12,
|
|
2240
|
-
col: 144,
|
|
2241
|
-
lane: 80,
|
|
2242
|
-
lead: 40,
|
|
2243
|
-
top: 14,
|
|
2244
|
-
dip: 60,
|
|
2245
|
-
label: 34,
|
|
2246
|
-
subtitle: false,
|
|
2247
|
-
nameText: "text-xs leading-4",
|
|
2248
|
-
logo: 14,
|
|
2249
|
-
circle: "h-6 w-6",
|
|
2250
|
-
pill: "h-7 pl-1 pr-2.5 text-[12px]",
|
|
2251
|
-
pillLogo: "h-5 w-5",
|
|
2252
|
-
pillLogoX: 14,
|
|
2253
|
-
portText: "text-[10px]"
|
|
2254
|
-
},
|
|
2255
|
-
md: {
|
|
2256
|
-
r: 18,
|
|
2257
|
-
col: 168,
|
|
2258
|
-
lane: 112,
|
|
2259
|
-
lead: 48,
|
|
2260
|
-
top: 18,
|
|
2261
|
-
dip: 86,
|
|
2262
|
-
label: 54,
|
|
2263
|
-
subtitle: true,
|
|
2264
|
-
nameText: "text-[13px] leading-[18px]",
|
|
2265
|
-
logo: 20,
|
|
2266
|
-
circle: "h-9 w-9",
|
|
2267
|
-
pill: "h-9 pl-1.5 pr-3 text-[13px]",
|
|
2268
|
-
pillLogo: "h-6 w-6",
|
|
2269
|
-
pillLogoX: 18,
|
|
2270
|
-
portText: "text-[11px]"
|
|
2271
|
-
}
|
|
2272
|
-
};
|
|
2273
|
-
const RING$1 = {
|
|
2274
|
-
ok: "ring-wf-ok",
|
|
2275
|
-
fail: "ring-wf-fail",
|
|
2276
|
-
warn: "ring-wf-warn",
|
|
2277
|
-
run: "ring-wf-run",
|
|
2278
|
-
idle: "ring-foreground/15 dark:ring-foreground/30"
|
|
2279
|
-
};
|
|
2280
|
-
const STROKE = {
|
|
2281
|
-
ok: "text-wf-ok",
|
|
2282
|
-
fail: "text-wf-fail",
|
|
2283
|
-
warn: "text-wf-warn",
|
|
2284
|
-
run: "text-wf-run",
|
|
2285
|
-
idle: "text-foreground/15 dark:text-foreground/30"
|
|
2286
|
-
};
|
|
2287
|
-
const PORT_PILL = {
|
|
2288
|
-
true: "bg-wf-ok/10 text-wf-ok ring-wf-ok/30",
|
|
2289
|
-
false: "bg-foreground/5 text-muted-foreground ring-foreground/15",
|
|
2290
|
-
error: "bg-wf-fail/10 text-wf-fail ring-wf-fail/30"
|
|
2291
|
-
};
|
|
2292
|
-
function roundedPath(points, radius = 6) {
|
|
2293
|
-
let d = `M ${points[0][0]} ${points[0][1]}`;
|
|
2294
|
-
for (let i = 1; i < points.length - 1; i++) {
|
|
2295
|
-
const [px, py] = points[i - 1];
|
|
2296
|
-
const [x, y] = points[i];
|
|
2297
|
-
const [nx, ny] = points[i + 1];
|
|
2298
|
-
const r = Math.min(radius, Math.hypot(x - px, y - py) / 2, Math.hypot(nx - x, ny - y) / 2);
|
|
2299
|
-
const inX = x - Math.sign(x - px) * r;
|
|
2300
|
-
const inY = y - Math.sign(y - py) * r;
|
|
2301
|
-
const outX = x + Math.sign(nx - x) * r;
|
|
2302
|
-
const outY = y + Math.sign(ny - y) * r;
|
|
2303
|
-
d += ` L ${inX} ${inY} Q ${x} ${y} ${outX} ${outY}`;
|
|
2304
|
-
}
|
|
2305
|
-
const [lx, ly] = points[points.length - 1];
|
|
2306
|
-
return `${d} L ${lx} ${ly}`;
|
|
2307
|
-
}
|
|
2308
|
-
function simplify(route) {
|
|
2309
|
-
const points = [];
|
|
2310
|
-
for (const point of route) {
|
|
2311
|
-
const last = points.at(-1);
|
|
2312
|
-
if (last && last[0] === point[0] && last[1] === point[1]) continue;
|
|
2313
|
-
const prev = points.at(-2);
|
|
2314
|
-
if (prev && last && (prev[0] === last[0] && last[0] === point[0] || prev[1] === last[1] && last[1] === point[1])) points.pop();
|
|
2315
|
-
points.push(point);
|
|
2316
|
-
}
|
|
2317
|
-
return points;
|
|
2318
|
-
}
|
|
2319
|
-
function edgeRoute(g, source, target, trackY, stacked) {
|
|
2320
|
-
const dir = target.dir;
|
|
2321
|
-
const after = source ? source.x + dir * g.col / 2 : g.lead / 2;
|
|
2322
|
-
const fromAbove = !source && stacked;
|
|
2323
|
-
const x1 = source ? source.x + dir * g.r : fromAbove ? after : 0;
|
|
2324
|
-
const y1 = source ? source.y : fromAbove ? -16 : g.top;
|
|
2325
|
-
const x2 = target.x - dir * g.r;
|
|
2326
|
-
const y2 = target.y;
|
|
2327
|
-
const before = target.x - dir * g.col / 2;
|
|
2328
|
-
return {
|
|
2329
|
-
points: simplify([
|
|
2330
|
-
[x1, y1],
|
|
2331
|
-
[after, y1],
|
|
2332
|
-
[after, trackY],
|
|
2333
|
-
[before, trackY],
|
|
2334
|
-
[before, y2],
|
|
2335
|
-
[x2, y2]
|
|
2336
|
-
]),
|
|
2337
|
-
label: {
|
|
2338
|
-
x: ((trackY === y1 ? x1 : after) + (trackY === y2 ? x2 : before)) / 2,
|
|
2339
|
-
y: trackY
|
|
2340
|
-
}
|
|
2341
|
-
};
|
|
2342
|
-
}
|
|
2343
|
-
function wrapRoute(g, source, target, ends) {
|
|
2344
|
-
const turn = source.dir > 0 ? ends.right : ends.left;
|
|
2345
|
-
const x1 = source.x + source.dir * g.r;
|
|
2346
|
-
const before = target.x - target.dir * g.col / 2;
|
|
2347
|
-
const y = (target.row - source.row) % 2 === 1 ? target.y : target.y - g.lane / 2;
|
|
2348
|
-
return {
|
|
2349
|
-
points: simplify([
|
|
2350
|
-
[x1, source.y],
|
|
2351
|
-
[turn, source.y],
|
|
2352
|
-
[turn, y],
|
|
2353
|
-
[before, y],
|
|
2354
|
-
[before, target.y],
|
|
2355
|
-
[target.x - target.dir * g.r, target.y]
|
|
2356
|
-
]),
|
|
2357
|
-
label: {
|
|
2358
|
-
x: (x1 + turn) / 2,
|
|
2359
|
-
y: source.y
|
|
2360
|
-
}
|
|
2361
|
-
};
|
|
2362
|
-
}
|
|
2363
|
-
function Mark({ label, className, onOpen, children, ref, onClick, ...rest }) {
|
|
2364
|
-
return onOpen ? /* @__PURE__ */ jsx("button", {
|
|
2365
|
-
...rest,
|
|
2366
|
-
ref,
|
|
2367
|
-
type: "button",
|
|
2368
|
-
"aria-label": label,
|
|
2369
|
-
className: `${className} focus-visible:outline-none focus-visible:ring-[3px]`,
|
|
2370
|
-
onClick: (event) => {
|
|
2371
|
-
onClick?.(event);
|
|
2372
|
-
onOpen();
|
|
2373
|
-
},
|
|
2374
|
-
children
|
|
2375
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
2376
|
-
...rest,
|
|
2377
|
-
ref,
|
|
2378
|
-
onClick,
|
|
2379
|
-
className,
|
|
2380
|
-
children
|
|
2381
|
-
});
|
|
2382
|
-
}
|
|
2383
|
-
function WorkflowGraph(props) {
|
|
2384
|
-
const { state, latest } = props;
|
|
2385
|
-
const frame = useRef(null);
|
|
2386
|
-
const pill = useRef(null);
|
|
2387
|
-
const [room, setRoom] = useState(null);
|
|
2388
|
-
useLayoutEffect(() => {
|
|
2389
|
-
const element = frame.current;
|
|
2390
|
-
if (!props.fit || !element) return;
|
|
2391
|
-
const measure = () => {
|
|
2392
|
-
const next = {
|
|
2393
|
-
width: element.clientWidth,
|
|
2394
|
-
pill: pill.current?.offsetWidth ?? 0
|
|
2395
|
-
};
|
|
2396
|
-
setRoom((prev) => prev?.width === next.width && prev.pill === next.pill ? prev : next);
|
|
2397
|
-
};
|
|
2398
|
-
measure();
|
|
2399
|
-
const observer = new ResizeObserver(measure);
|
|
2400
|
-
observer.observe(element);
|
|
2401
|
-
if (pill.current) observer.observe(pill.current);
|
|
2402
|
-
return () => observer.disconnect();
|
|
2403
|
-
}, [props.fit]);
|
|
2404
|
-
const layout = graphLayout({
|
|
2405
|
-
triggerId: state.trigger?.id,
|
|
2406
|
-
steps: state.steps,
|
|
2407
|
-
edges: state.edges
|
|
2408
|
-
});
|
|
2409
|
-
const { g, stacked, perRow } = fitGraph(GEOMETRY[props.size ?? "sm"], layout.cols, props.fit ? room : null);
|
|
2410
|
-
const rowOf = (col) => Math.floor((col - 1) / perRow);
|
|
2411
|
-
const rows = Math.max(1, Math.ceil(layout.cols / perRow));
|
|
2412
|
-
const rowLanes = Array.from({ length: rows }, () => 1);
|
|
2413
|
-
for (const node of layout.nodes) {
|
|
2414
|
-
const row = rowOf(node.col);
|
|
2415
|
-
rowLanes[row] = Math.max(rowLanes[row], node.lane + 1);
|
|
2416
|
-
}
|
|
2417
|
-
const rowTop = [];
|
|
2418
|
-
for (let row = 0, y = g.top; row < rows; y += rowLanes[row] * g.lane, row++) rowTop.push(y);
|
|
2419
|
-
const spot = (col, lane) => {
|
|
2420
|
-
const row = rowOf(col);
|
|
2421
|
-
const slot = (col - 1) % perRow;
|
|
2422
|
-
const back = row % 2 === 1;
|
|
2423
|
-
return {
|
|
2424
|
-
x: g.lead + (back ? perRow - 1 - slot : slot) * g.col + g.r,
|
|
2425
|
-
y: rowTop[row] + lane * g.lane,
|
|
2426
|
-
row,
|
|
2427
|
-
dir: back ? -1 : 1
|
|
2428
|
-
};
|
|
2429
|
-
};
|
|
2430
|
-
const records = new Map((latest?.steps ?? []).map((record) => [record.stepKey, record]));
|
|
2431
|
-
const toneOfStep = (key) => {
|
|
2432
|
-
const status = records.get(key)?.status;
|
|
2433
|
-
return status ? toneOf(STEP_TONE, status) : "idle";
|
|
2434
|
-
};
|
|
2435
|
-
const at = new Map(layout.nodes.map((node) => [node.step.id, node]));
|
|
2436
|
-
const lastX = g.lead + (Math.min(perRow, layout.cols) - 1) * g.col + g.r;
|
|
2437
|
-
const width = layout.cols > 0 ? lastX + (g.label ? g.col / 2 : g.r) : 0;
|
|
2438
|
-
const ends = {
|
|
2439
|
-
left: g.lead / 2,
|
|
2440
|
-
right: lastX + g.col / 2
|
|
2441
|
-
};
|
|
2442
|
-
const trackY = (edge, row) => rowTop[row] + edge.track.lane * g.lane + (edge.track.under ? g.dip : 0);
|
|
2443
|
-
const routes = layout.edges.map((edge) => {
|
|
2444
|
-
const from = edge.from === "trigger" ? null : at.get(edge.from);
|
|
2445
|
-
const to = at.get(edge.to);
|
|
2446
|
-
const source = from ? spot(from.col, from.lane) : null;
|
|
2447
|
-
const target = spot(to.col, to.lane);
|
|
2448
|
-
const wraps = source !== null && source.row !== target.row;
|
|
2449
|
-
return {
|
|
2450
|
-
key: `${edge.from}-${edge.port}-${edge.to}`,
|
|
2451
|
-
edge,
|
|
2452
|
-
tone: toneOfStep(to.step.key),
|
|
2453
|
-
under: !wraps && edge.track.under,
|
|
2454
|
-
route: wraps ? wrapRoute(g, source, target, ends) : edgeRoute(g, source, target, trackY(edge, target.row), stacked)
|
|
2455
|
-
};
|
|
2456
|
-
});
|
|
2457
|
-
const dips = routes.filter((route) => route.under).map(({ route, edge }) => route.label.y + (PORT_PILL[edge.port] ? 10 : 4));
|
|
2458
|
-
const height = Math.max(...layout.nodes.map((node) => spot(node.col, node.lane).y + (g.label ? g.r + 6 + g.label : g.top)), ...dips);
|
|
2459
|
-
const labelBox = (x) => {
|
|
2460
|
-
let w = Math.min(g.col - 16, 2 * (width - x));
|
|
2461
|
-
let left = x - w / 2;
|
|
2462
|
-
if (stacked && left < -12) {
|
|
2463
|
-
left += Math.min(-12 - left, 16);
|
|
2464
|
-
if (left < -12) {
|
|
2465
|
-
w -= -12 - left;
|
|
2466
|
-
left = -12;
|
|
2467
|
-
}
|
|
2468
|
-
}
|
|
2469
|
-
return {
|
|
2470
|
-
left,
|
|
2471
|
-
width: w
|
|
2472
|
-
};
|
|
2473
|
-
};
|
|
2474
|
-
const trigger = state.trigger ? triggerBlock(state.trigger) : null;
|
|
2475
|
-
return /* @__PURE__ */ jsx(TipProvider, { children: /* @__PURE__ */ jsxs("div", {
|
|
2476
|
-
ref: frame,
|
|
2477
|
-
className: stacked ? "flex flex-col items-start" : "flex items-start",
|
|
2478
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
2479
|
-
ref: pill,
|
|
2480
|
-
className: "flex shrink-0",
|
|
2481
|
-
children: /* @__PURE__ */ jsx(Tip, {
|
|
2482
|
-
content: /* @__PURE__ */ jsx(TriggerTip, {
|
|
2483
|
-
trigger,
|
|
2484
|
-
latest
|
|
2485
|
-
}),
|
|
2486
|
-
children: /* @__PURE__ */ jsxs(Mark, {
|
|
2487
|
-
label: `Trigger: ${props.triggerText}`,
|
|
2488
|
-
onOpen: props.onOpen,
|
|
2489
|
-
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}`,
|
|
2490
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
2491
|
-
className: `flex items-center justify-center rounded-full dark:bg-white ${g.pillLogo}`,
|
|
2492
|
-
children: trigger ? /* @__PURE__ */ jsx(BlockLogo, {
|
|
2493
|
-
bare: true,
|
|
2494
|
-
block: trigger,
|
|
2495
|
-
size: g.logo - 2
|
|
2496
|
-
}) : null
|
|
2497
|
-
}), props.triggerText]
|
|
2498
|
-
})
|
|
2499
|
-
})
|
|
2500
|
-
}), layout.nodes.length > 0 ? /* @__PURE__ */ jsxs("ol", {
|
|
2501
|
-
className: `relative shrink-0 ${stacked ? "" : "-ml-px"}`,
|
|
2502
|
-
style: {
|
|
2503
|
-
width,
|
|
2504
|
-
height,
|
|
2505
|
-
marginTop: stacked ? STACK_GAP : 0
|
|
2506
|
-
},
|
|
2507
|
-
"aria-label": layout.nodes.map((node) => {
|
|
2508
|
-
const status = records.get(node.step.key)?.status;
|
|
2509
|
-
const label = node.step.name || node.step.key;
|
|
2510
|
-
return status ? `${label}: ${status.toLowerCase()}` : label;
|
|
2511
|
-
}).join(", "),
|
|
2512
|
-
children: [
|
|
2513
|
-
/* @__PURE__ */ jsx("svg", {
|
|
2514
|
-
"aria-hidden": true,
|
|
2515
|
-
className: "absolute inset-0 overflow-visible",
|
|
2516
|
-
width,
|
|
2517
|
-
height,
|
|
2518
|
-
children: routes.map(({ key, edge, route, tone }) => /* @__PURE__ */ jsx("path", {
|
|
2519
|
-
d: roundedPath(route.points),
|
|
2520
|
-
fill: "none",
|
|
2521
|
-
stroke: "currentColor",
|
|
2522
|
-
strokeWidth: 2,
|
|
2523
|
-
strokeDasharray: edge.port === "error" ? "3 3" : void 0,
|
|
2524
|
-
className: STROKE[tone]
|
|
2525
|
-
}, key))
|
|
2526
|
-
}),
|
|
2527
|
-
routes.map(({ key, edge, route }) => PORT_PILL[edge.port] ? /* @__PURE__ */ jsx("span", {
|
|
2528
|
-
"aria-hidden": true,
|
|
2529
|
-
className: "pointer-events-none absolute z-[1] -translate-x-1/2 -translate-y-1/2 rounded-full bg-card",
|
|
2530
|
-
style: {
|
|
2531
|
-
left: route.label.x,
|
|
2532
|
-
top: route.label.y
|
|
2533
|
-
},
|
|
2534
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
2535
|
-
className: `block rounded-full px-1.5 font-medium leading-4 ring-1 ring-inset ${g.portText} ${PORT_PILL[edge.port]}`,
|
|
2536
|
-
children: edge.port
|
|
2537
|
-
})
|
|
2538
|
-
}, key) : null),
|
|
2539
|
-
layout.nodes.map((node) => {
|
|
2540
|
-
const record = records.get(node.step.key);
|
|
2541
|
-
const skipped = record?.status === "SKIPPED";
|
|
2542
|
-
const name = node.step.name || node.step.key;
|
|
2543
|
-
const { x, y } = spot(node.col, node.lane);
|
|
2544
|
-
const tip = /* @__PURE__ */ jsx(StepTip, {
|
|
2545
|
-
step: node.step,
|
|
2546
|
-
port: node.port,
|
|
2547
|
-
record,
|
|
2548
|
-
ran: Boolean(latest)
|
|
2549
|
-
});
|
|
2550
|
-
return /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("span", {
|
|
2551
|
-
className: "absolute",
|
|
2552
|
-
style: {
|
|
2553
|
-
left: x - g.r,
|
|
2554
|
-
top: y - g.r
|
|
2555
|
-
},
|
|
2556
|
-
children: /* @__PURE__ */ jsx(Tip, {
|
|
2557
|
-
content: tip,
|
|
2558
|
-
children: /* @__PURE__ */ jsx(Mark, {
|
|
2559
|
-
label: `${name}: ${record ? record.status.toLowerCase() : "not run"}`,
|
|
2560
|
-
onOpen: props.onOpen,
|
|
2561
|
-
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)]}`}`,
|
|
2562
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
2563
|
-
className: skipped ? "flex opacity-40" : "flex",
|
|
2564
|
-
children: /* @__PURE__ */ jsx(BlockLogo, {
|
|
2565
|
-
bare: true,
|
|
2566
|
-
block: stepBlock(node.step),
|
|
2567
|
-
size: g.logo
|
|
2568
|
-
})
|
|
2569
|
-
})
|
|
2570
|
-
})
|
|
2571
|
-
})
|
|
2572
|
-
}), g.label ? /* @__PURE__ */ jsxs("span", {
|
|
2573
|
-
"aria-hidden": true,
|
|
2574
|
-
className: "pointer-events-none absolute flex flex-col items-center text-center",
|
|
2575
|
-
style: {
|
|
2576
|
-
...labelBox(x),
|
|
2577
|
-
top: y + g.r + 6
|
|
2578
|
-
},
|
|
2579
|
-
children: [/* @__PURE__ */ jsx(Tip, {
|
|
2580
|
-
content: tip,
|
|
2581
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
2582
|
-
className: `pointer-events-auto line-clamp-2 max-w-full font-medium text-foreground [overflow-wrap:anywhere] ${g.nameText}`,
|
|
2583
|
-
children: name
|
|
2584
|
-
})
|
|
2585
|
-
}), g.subtitle ? /* @__PURE__ */ jsx("span", {
|
|
2586
|
-
className: "max-w-full truncate text-xs text-muted-foreground",
|
|
2587
|
-
children: blockMeta(stepBlock(node.step)).displayName
|
|
2588
|
-
}) : null]
|
|
2589
|
-
}) : null] }, node.step.id);
|
|
2590
|
-
})
|
|
2591
|
-
]
|
|
2592
|
-
}) : null]
|
|
2593
|
-
}) });
|
|
2594
|
-
}
|
|
2595
|
-
//#endregion
|
|
2596
|
-
//#region editors/workflow-studio/components/WorkflowBoard.tsx
|
|
2597
|
-
function CollapsedChain(props) {
|
|
2598
|
-
const trigger = props.state.trigger ? triggerBlock(props.state.trigger) : null;
|
|
2599
|
-
const links = workflowLinks({
|
|
2600
|
-
triggerId: props.state.trigger?.id,
|
|
2601
|
-
steps: props.state.steps,
|
|
2602
|
-
edges: props.state.edges
|
|
2603
|
-
}, props.latest);
|
|
2604
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
2605
|
-
className: "flex min-w-0 items-center",
|
|
2606
|
-
children: [/* @__PURE__ */ jsx(Tip, {
|
|
2607
|
-
content: /* @__PURE__ */ jsx(TriggerTip, {
|
|
2608
|
-
trigger,
|
|
2609
|
-
latest: props.latest,
|
|
2610
|
-
text: props.triggerText
|
|
2611
|
-
}),
|
|
2612
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
2613
|
-
className: "flex min-w-6 shrink-[100]",
|
|
2614
|
-
children: /* @__PURE__ */ jsxs("span", {
|
|
2615
|
-
className: `flex h-6 min-w-0 max-w-full items-center gap-1.5 overflow-hidden rounded-full bg-card px-0.5 text-[12px] font-medium text-foreground ring-[1.5px] @[26rem]:pr-2.5 ${props.latest ? "ring-wf-ok" : "ring-foreground/15 dark:ring-foreground/30"}`,
|
|
2616
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
2617
|
-
className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full dark:bg-white",
|
|
2618
|
-
children: trigger ? /* @__PURE__ */ jsx(BlockLogo, {
|
|
2619
|
-
bare: true,
|
|
2620
|
-
block: trigger,
|
|
2621
|
-
size: 12
|
|
2622
|
-
}) : null
|
|
2623
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
2624
|
-
className: "hidden truncate @[26rem]:inline",
|
|
2625
|
-
children: props.triggerText
|
|
2626
|
-
})]
|
|
2627
|
-
})
|
|
2628
|
-
})
|
|
2629
|
-
}), links.length > 0 ? /* @__PURE__ */ jsxs("span", {
|
|
2630
|
-
className: "hidden min-w-0 items-center @[26rem]:flex",
|
|
2631
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
2632
|
-
"aria-hidden": true,
|
|
2633
|
-
className: "h-0.5 w-3 shrink-0 bg-foreground/15 dark:bg-foreground/30"
|
|
2634
|
-
}), /* @__PURE__ */ jsx(ScrollFade, {
|
|
2635
|
-
clip: true,
|
|
2636
|
-
className: "-my-1 min-w-0 px-0.5 py-1",
|
|
2637
|
-
children: /* @__PURE__ */ jsx(MiniChain, { links })
|
|
2638
|
-
})]
|
|
2639
|
-
}) : null]
|
|
2640
|
-
});
|
|
2641
|
-
}
|
|
2642
|
-
function RowToggle(props) {
|
|
2643
|
-
const [, dispatch] = useDispatch(props.document);
|
|
2644
|
-
const state = props.document.state.global;
|
|
2645
|
-
return /* @__PURE__ */ jsx(StatusToggle, {
|
|
2646
|
-
tooltipSide: "left",
|
|
2647
|
-
published: Boolean(state.published),
|
|
2648
|
-
status: state.status,
|
|
2649
|
-
onChange: (status) => dispatch(actions.setWorkflowStatus({ status }))
|
|
2650
|
-
});
|
|
2651
|
-
}
|
|
2652
|
-
function summary(rows) {
|
|
2653
|
-
const count = `${rows.length} ${rows.length === 1 ? "workflow" : "workflows"}`;
|
|
2654
|
-
const failing = rows.filter((row) => row.runs[0]?.status === "FAILED").length;
|
|
2655
|
-
const parts = [count, `${rows.filter((row) => row.status === "ENABLED").length} enabled`];
|
|
2656
|
-
if (failing > 0) parts.push(`${failing} failed on the last run`);
|
|
2657
|
-
return parts.join(", ");
|
|
2658
|
-
}
|
|
2659
|
-
function WorkflowBoard(props) {
|
|
2660
|
-
const { approvals, onShowApprovals } = props;
|
|
2661
|
-
usePieceLogos();
|
|
2662
|
-
const { isCollapsed, toggle } = useCollapsed();
|
|
2663
|
-
const documents = useWorkflowDocumentsInSelectedDrive() ?? [];
|
|
2664
|
-
const runs = props.runs ?? [];
|
|
2665
|
-
const positions = new Map(props.order.map((id, i) => [id, i]));
|
|
2666
|
-
const position = (id) => positions.get(id) ?? positions.size;
|
|
2667
|
-
const rows = documents.map((document) => {
|
|
2668
|
-
const state = document.state.global;
|
|
2669
|
-
const workflowRuns = runs.filter((run) => run.workflowId === document.header.id);
|
|
2670
|
-
return {
|
|
2671
|
-
document,
|
|
2672
|
-
id: document.header.id,
|
|
2673
|
-
name: state.name || document.header.name || "Untitled workflow",
|
|
2674
|
-
description: state.description,
|
|
2675
|
-
status: state.status,
|
|
2676
|
-
trigger: describeTrigger(state.trigger),
|
|
2677
|
-
runs: workflowRuns
|
|
2678
|
-
};
|
|
2679
|
-
}).sort((a, b) => position(a.id) - position(b.id));
|
|
2680
|
-
return /* @__PURE__ */ jsxs("section", {
|
|
2681
|
-
className: "mb-10",
|
|
2682
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2683
|
-
className: "mb-4 flex flex-wrap items-end justify-between gap-3",
|
|
2684
|
-
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
|
|
2685
|
-
className: "text-2xl font-semibold tracking-tight text-foreground",
|
|
2686
|
-
children: "Workflows"
|
|
2687
|
-
}), /* @__PURE__ */ jsxs("p", {
|
|
2688
|
-
className: "mt-1 flex flex-wrap items-center gap-2 text-[13px] text-muted-foreground",
|
|
2689
|
-
children: [rows.length === 0 ? "Automations in this drive" : summary(rows), approvals && approvals.total > 0 ? /* @__PURE__ */ jsxs("button", {
|
|
2690
|
-
type: "button",
|
|
2691
|
-
className: "inline-flex items-center gap-1 rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs font-medium text-wf-warn hover:bg-wf-warn/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
2692
|
-
onClick: () => onShowApprovals?.(),
|
|
2693
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
2694
|
-
name: "clock",
|
|
2695
|
-
className: "h-3 w-3"
|
|
2696
|
-
}), approvalCountLabel(approvals.total, approvals.capped)]
|
|
2697
|
-
}) : null]
|
|
2698
|
-
})] }), /* @__PURE__ */ jsxs(Button, {
|
|
2699
|
-
variant: "primary",
|
|
2700
|
-
disabled: props.creating,
|
|
2701
|
-
onClick: props.onCreate,
|
|
2702
|
-
children: [/* @__PURE__ */ jsx(Icon, {
|
|
2703
|
-
name: "plus",
|
|
2704
|
-
className: "h-3.5 w-3.5"
|
|
2705
|
-
}), "New workflow"]
|
|
2706
|
-
})]
|
|
2707
|
-
}), rows.length === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
2708
|
-
className: "rounded-xl border border-dashed border-foreground/15 px-6 py-12 text-center",
|
|
2709
|
-
children: [/* @__PURE__ */ jsx("p", {
|
|
2710
|
-
className: "text-[15px] font-medium text-foreground",
|
|
2711
|
-
children: "No workflows yet"
|
|
2712
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
2713
|
-
className: "mx-auto mt-1 max-w-sm text-[13px] text-muted-foreground",
|
|
2714
|
-
children: "A workflow starts on a trigger, like a schedule or a webhook, and runs a chain of steps across your services."
|
|
2715
|
-
})]
|
|
2716
|
-
}) : /* @__PURE__ */ jsx(TipProvider, { children: /* @__PURE__ */ jsx("ul", {
|
|
2717
|
-
"aria-label": "Workflows",
|
|
2718
|
-
className: "rounded-xl border border-solid border-foreground/10 bg-card",
|
|
2719
|
-
children: rows.map((row) => {
|
|
2720
|
-
const latest = row.runs.at(0);
|
|
2721
|
-
const latestTone = toneOf(RUN_TONE, latest?.status);
|
|
2722
|
-
const health = workflowHealth(row.status, latest?.status, Boolean(row.document.state.global.published));
|
|
2723
|
-
const collapsed = isCollapsed(row.id);
|
|
2724
|
-
return /* @__PURE__ */ jsxs("li", {
|
|
2725
|
-
className: "group/row border-b border-solid border-foreground/10 first:rounded-t-xl last:rounded-b-xl last:border-b-0",
|
|
2726
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2727
|
-
className: `flex items-start transition-colors group-first/row:rounded-t-xl has-[[data-row-header]:hover]:bg-accent/40 has-[[data-row-header]:focus-visible]:bg-accent/40 ${collapsed ? "group-last/row:rounded-b-xl" : ""}`,
|
|
2728
|
-
children: [/* @__PURE__ */ jsxs("button", {
|
|
2729
|
-
type: "button",
|
|
2730
|
-
"data-row-header": true,
|
|
2731
|
-
"aria-expanded": !collapsed,
|
|
2732
|
-
"aria-label": `${collapsed ? "Expand" : "Collapse"} ${row.name}`,
|
|
2733
|
-
className: "group/header @container flex min-w-0 flex-1 cursor-pointer items-start gap-1 py-4 pl-2 pr-5 text-left focus-visible:outline-none",
|
|
2734
|
-
onClick: () => toggle(row.id),
|
|
2735
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
2736
|
-
"aria-hidden": true,
|
|
2737
|
-
className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors group-hover/header:bg-accent group-hover/header:text-foreground group-focus-visible/header:bg-accent group-focus-visible/header:text-foreground",
|
|
2738
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
2739
|
-
name: "chevron",
|
|
2740
|
-
className: `h-3.5 w-3.5 transition-transform ${collapsed ? "" : "rotate-90"}`
|
|
2741
|
-
})
|
|
2742
|
-
}), /* @__PURE__ */ jsxs("span", {
|
|
2743
|
-
className: `grid w-full grid-rows-[1.5rem] items-center gap-x-6 ${collapsed ? "grid-cols-[minmax(10rem,1fr)_minmax(0,2fr)] @[44rem]:grid-cols-[minmax(10rem,1fr)_minmax(0,2fr)_auto] @[60rem]:grid-cols-[minmax(10rem,1fr)_minmax(0,2fr)_minmax(0,10rem)_auto]" : "grid-cols-[minmax(0,1fr)_auto] md:grid-cols-[minmax(0,1fr)_minmax(0,10rem)_auto]"}`,
|
|
2744
|
-
children: [
|
|
2745
|
-
/* @__PURE__ */ jsxs("span", {
|
|
2746
|
-
className: "flex min-w-0 items-center gap-2",
|
|
2747
|
-
children: [
|
|
2748
|
-
/* @__PURE__ */ jsx(Tip, {
|
|
2749
|
-
content: health.label,
|
|
2750
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
2751
|
-
className: "flex",
|
|
2752
|
-
children: /* @__PURE__ */ jsx(StatusDot, {
|
|
2753
|
-
tone: health.tone,
|
|
2754
|
-
hollow: health.hollow
|
|
2755
|
-
})
|
|
2756
|
-
})
|
|
2757
|
-
}),
|
|
2758
|
-
/* @__PURE__ */ jsx("span", {
|
|
2759
|
-
className: "min-w-0 truncate text-[15px] font-semibold text-foreground",
|
|
2760
|
-
children: row.name
|
|
2761
|
-
}),
|
|
2762
|
-
row.status !== "ENABLED" ? /* @__PURE__ */ jsx("span", {
|
|
2763
|
-
className: "shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",
|
|
2764
|
-
children: statusLabel(row.status)
|
|
2765
|
-
}) : null
|
|
2766
|
-
]
|
|
2767
|
-
}),
|
|
2768
|
-
collapsed ? /* @__PURE__ */ jsx(CollapsedChain, {
|
|
2769
|
-
state: row.document.state.global,
|
|
2770
|
-
triggerText: row.trigger,
|
|
2771
|
-
latest
|
|
2772
|
-
}) : null,
|
|
2773
|
-
/* @__PURE__ */ jsx("span", {
|
|
2774
|
-
className: `hidden text-[13px] ${collapsed ? "@[60rem]:block" : "md:block"}`,
|
|
2775
|
-
children: latest ? /* @__PURE__ */ jsx(Tip, {
|
|
2776
|
-
content: formatAbsolute(latest.startedAt),
|
|
2777
|
-
children: /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
|
|
2778
|
-
className: `font-medium ${latestTone === "fail" ? "text-wf-fail" : latestTone === "ok" ? "text-wf-ok" : "text-foreground"}`,
|
|
2779
|
-
children: statusLabel(latest.status)
|
|
2780
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
2781
|
-
className: "ml-1.5 text-xs text-muted-foreground",
|
|
2782
|
-
children: formatWhen(latest.startedAt)
|
|
2783
|
-
})] })
|
|
2784
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
2785
|
-
className: "text-muted-foreground",
|
|
2786
|
-
children: "Not run yet"
|
|
2787
|
-
})
|
|
2788
|
-
}),
|
|
2789
|
-
collapsed ? /* @__PURE__ */ jsx("span", {
|
|
2790
|
-
className: "hidden @[44rem]:block",
|
|
2791
|
-
children: /* @__PURE__ */ jsx(RunStrip, {
|
|
2792
|
-
centered: true,
|
|
2793
|
-
runs: row.runs
|
|
2794
|
-
})
|
|
2795
|
-
}) : /* @__PURE__ */ jsx(RunStrip, {
|
|
2796
|
-
centered: true,
|
|
2797
|
-
runs: row.runs
|
|
2798
|
-
})
|
|
2799
|
-
]
|
|
2800
|
-
})]
|
|
2801
|
-
}), /* @__PURE__ */ jsxs("span", {
|
|
2802
|
-
className: "mt-4 flex h-6 shrink-0 items-center gap-1 pr-3",
|
|
2803
|
-
children: [
|
|
2804
|
-
/* @__PURE__ */ jsx(ApprovalBadge, {
|
|
2805
|
-
count: approvals?.byWorkflow.get(row.id) ?? 0,
|
|
2806
|
-
capped: approvals?.capped ?? false,
|
|
2807
|
-
onClick: onShowApprovals ? () => onShowApprovals(row.id) : void 0
|
|
2808
|
-
}),
|
|
2809
|
-
/* @__PURE__ */ jsx(RowToggle, { document: row.document }),
|
|
2810
|
-
/* @__PURE__ */ jsx(WorkflowMenu, { document: row.document })
|
|
2811
|
-
]
|
|
2812
|
-
})]
|
|
2813
|
-
}), collapsed ? null : /* @__PURE__ */ jsxs("button", {
|
|
2814
|
-
type: "button",
|
|
2815
|
-
"aria-label": `Open ${row.name}`,
|
|
2816
|
-
className: "group/content relative flex w-full cursor-pointer flex-col gap-3 pb-4 pl-9 pr-5 pt-1 text-left transition-colors hover:bg-accent/50 focus-visible:bg-accent/50 focus-visible:outline-none group-last/row:rounded-b-xl",
|
|
2817
|
-
onClick: () => props.onOpen(row.id),
|
|
2818
|
-
children: [
|
|
2819
|
-
/* @__PURE__ */ jsxs("span", {
|
|
2820
|
-
"aria-hidden": true,
|
|
2821
|
-
className: "pointer-events-none absolute right-4 top-2.5 z-10 flex items-center gap-1 rounded-md bg-card px-1.5 py-0.5 text-xs font-medium text-muted-foreground opacity-0 shadow-sm transition-opacity group-hover/content:opacity-100 group-focus-visible/content:opacity-100",
|
|
2822
|
-
children: ["Open workflow", /* @__PURE__ */ jsx(Icon, {
|
|
2823
|
-
name: "arrowRight",
|
|
2824
|
-
className: "h-3.5 w-3.5"
|
|
2825
|
-
})]
|
|
2826
|
-
}),
|
|
2827
|
-
row.description ? /* @__PURE__ */ jsx("span", {
|
|
2828
|
-
className: "max-w-prose pl-4 text-[13px] leading-5 text-muted-foreground",
|
|
2829
|
-
children: row.description
|
|
2830
|
-
}) : null,
|
|
2831
|
-
/* @__PURE__ */ jsx(ScrollFade, {
|
|
2832
|
-
className: "max-w-full py-1 pl-4 pr-1",
|
|
2833
|
-
children: /* @__PURE__ */ jsx(WorkflowGraph, {
|
|
2834
|
-
fit: true,
|
|
2835
|
-
state: row.document.state.global,
|
|
2836
|
-
triggerText: row.trigger,
|
|
2837
|
-
latest
|
|
2838
|
-
})
|
|
2839
|
-
})
|
|
2840
|
-
]
|
|
2841
|
-
})]
|
|
2842
|
-
}, row.id);
|
|
2843
|
-
})
|
|
2844
|
-
}) })]
|
|
2845
|
-
});
|
|
2846
|
-
}
|
|
2847
|
-
//#endregion
|
|
2848
|
-
//#region editors/workflow-studio/components/WorkflowSteps.tsx
|
|
2849
|
-
const RAIL = {
|
|
2850
|
-
ok: "bg-wf-ok",
|
|
2851
|
-
fail: "bg-wf-fail",
|
|
2852
|
-
warn: "bg-wf-warn",
|
|
2853
|
-
run: "bg-wf-run",
|
|
2854
|
-
idle: "bg-border"
|
|
2855
|
-
};
|
|
2856
|
-
const RING = {
|
|
2857
|
-
ok: "ring-wf-ok",
|
|
2858
|
-
fail: "ring-wf-fail",
|
|
2859
|
-
warn: "ring-wf-warn",
|
|
2860
|
-
run: "ring-wf-run",
|
|
2861
|
-
idle: "ring-border"
|
|
2862
|
-
};
|
|
2863
|
-
function TrackStop(props) {
|
|
2864
|
-
const { stop } = props;
|
|
2865
|
-
const tone = stop.status ? toneOf(STEP_TONE, stop.status) : "idle";
|
|
2866
|
-
return /* @__PURE__ */ jsxs("li", {
|
|
2867
|
-
className: "relative flex w-40 shrink-0 flex-col items-center",
|
|
2868
|
-
children: [
|
|
2869
|
-
/* @__PURE__ */ jsx("span", {
|
|
2870
|
-
"aria-hidden": true,
|
|
2871
|
-
className: `absolute left-0 top-[19px] h-0.5 w-1/2 ${props.first ? "invisible" : RAIL[props.inbound]}`
|
|
2872
|
-
}),
|
|
2873
|
-
/* @__PURE__ */ jsx("span", {
|
|
2874
|
-
"aria-hidden": true,
|
|
2875
|
-
className: `absolute right-0 top-[19px] h-0.5 w-1/2 ${props.last ? "invisible" : RAIL[props.outbound]}`
|
|
2876
|
-
}),
|
|
2877
|
-
stop.port ? /* @__PURE__ */ jsx("span", {
|
|
2878
|
-
className: "absolute -left-4 top-0 rounded bg-background px-1 text-[11px] text-muted-foreground",
|
|
2879
|
-
children: stop.port
|
|
2880
|
-
}) : null,
|
|
2881
|
-
/* @__PURE__ */ jsx("button", {
|
|
2882
|
-
type: "button",
|
|
2883
|
-
title: stop.status ? `${stop.title}: ${stop.status.toLowerCase()}` : stop.title,
|
|
2884
|
-
"aria-label": `${stop.title}: ${stop.status ? stop.status.toLowerCase() : "not run"}`,
|
|
2885
|
-
className: `relative z-10 flex h-10 w-10 items-center justify-center rounded-full bg-card ring-2 transition-shadow dark:bg-white hover:ring-4 focus-visible:outline-none focus-visible:ring-4 ${RING[tone]}`,
|
|
2886
|
-
onClick: props.onClick,
|
|
2887
|
-
children: /* @__PURE__ */ jsx(BlockLogo, {
|
|
2888
|
-
bare: true,
|
|
2889
|
-
block: stop.block,
|
|
2890
|
-
size: 20
|
|
2891
|
-
})
|
|
2892
|
-
}),
|
|
2893
|
-
/* @__PURE__ */ jsx("span", {
|
|
2894
|
-
className: "mt-2 max-w-full truncate px-2 text-[13px] font-medium text-foreground",
|
|
2895
|
-
children: stop.title
|
|
2896
|
-
}),
|
|
2897
|
-
/* @__PURE__ */ jsx("span", {
|
|
2898
|
-
className: "max-w-full truncate px-2 text-xs text-muted-foreground",
|
|
2899
|
-
title: stop.subtitle,
|
|
2900
|
-
children: stop.subtitle
|
|
2901
|
-
})
|
|
2902
|
-
]
|
|
2903
|
-
});
|
|
2904
|
-
}
|
|
2905
|
-
function WorkflowSteps(props) {
|
|
2906
|
-
const { state } = props;
|
|
2907
|
-
usePieceLogos();
|
|
2908
|
-
const outline = stepOutline({
|
|
2909
|
-
triggerId: state.trigger?.id,
|
|
2910
|
-
steps: state.steps,
|
|
2911
|
-
edges: state.edges
|
|
2912
|
-
});
|
|
2913
|
-
const statusByKey = new Map((props.latestRun?.steps ?? []).map((step) => [step.stepKey, step.status]));
|
|
2914
|
-
const stopFor = (step, port) => {
|
|
2915
|
-
const block = stepBlock(step);
|
|
2916
|
-
const meta = blockMeta(block);
|
|
2917
|
-
return {
|
|
2918
|
-
id: step.id,
|
|
2919
|
-
title: step.name || step.key,
|
|
2920
|
-
subtitle: meta.displayName,
|
|
2921
|
-
block,
|
|
2922
|
-
status: statusByKey.get(step.key),
|
|
2923
|
-
port
|
|
2924
|
-
};
|
|
2925
|
-
};
|
|
2926
|
-
if (!state.trigger && state.steps.length === 0) return /* @__PURE__ */ jsx("section", {
|
|
2927
|
-
className: "mt-8 border-t border-solid border-border pt-6",
|
|
2928
|
-
children: /* @__PURE__ */ jsxs("p", {
|
|
2929
|
-
className: "text-[13px] text-muted-foreground",
|
|
2930
|
-
children: [
|
|
2931
|
-
"This workflow has no trigger or steps yet.",
|
|
2932
|
-
" ",
|
|
2933
|
-
/* @__PURE__ */ jsx("button", {
|
|
2934
|
-
type: "button",
|
|
2935
|
-
className: "font-medium text-foreground underline underline-offset-2",
|
|
2936
|
-
onClick: props.onOpenEditor,
|
|
2937
|
-
children: "Open the editor"
|
|
2938
|
-
}),
|
|
2939
|
-
" ",
|
|
2940
|
-
"to build it."
|
|
2941
|
-
]
|
|
2942
|
-
})
|
|
2943
|
-
});
|
|
2944
|
-
return /* @__PURE__ */ jsxs("section", {
|
|
2945
|
-
className: "mt-8 border-t border-solid border-border pt-6",
|
|
2946
|
-
children: [
|
|
2947
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2948
|
-
className: "mb-4 flex items-baseline gap-2",
|
|
2949
|
-
children: [/* @__PURE__ */ jsx("h3", {
|
|
2950
|
-
className: "text-[13px] font-medium text-foreground",
|
|
2951
|
-
children: "Steps"
|
|
2952
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
2953
|
-
className: "text-xs text-muted-foreground",
|
|
2954
|
-
children: props.latestRun ? "Coloured by the latest run" : "Not run yet"
|
|
2955
|
-
})]
|
|
2956
|
-
}),
|
|
2957
|
-
!state.trigger ? /* @__PURE__ */ jsx("p", {
|
|
2958
|
-
className: "mb-3 text-xs text-wf-warn",
|
|
2959
|
-
children: "No trigger set, so this workflow never starts on its own."
|
|
2960
|
-
}) : null,
|
|
2961
|
-
/* @__PURE__ */ jsx(ScrollFade, {
|
|
2962
|
-
className: "-mx-1 px-1 py-1.5",
|
|
2963
|
-
children: /* @__PURE__ */ jsx(WorkflowGraph, {
|
|
2964
|
-
state,
|
|
2965
|
-
triggerText: describeTrigger(state.trigger),
|
|
2966
|
-
latest: props.latestRun,
|
|
2967
|
-
onOpen: props.onOpenEditor,
|
|
2968
|
-
size: "md",
|
|
2969
|
-
fit: true
|
|
2970
|
-
})
|
|
2971
|
-
}),
|
|
2972
|
-
outline.orphans.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
2973
|
-
className: "mt-5",
|
|
2974
|
-
children: [/* @__PURE__ */ jsx("p", {
|
|
2975
|
-
className: "mb-3 text-xs text-muted-foreground",
|
|
2976
|
-
children: "Not connected to the trigger, so runs never reach these:"
|
|
2977
|
-
}), /* @__PURE__ */ jsx("ol", {
|
|
2978
|
-
className: "-mx-6 flex overflow-x-auto px-6 py-1.5 opacity-60",
|
|
2979
|
-
children: outline.orphans.map((step) => /* @__PURE__ */ jsx(TrackStop, {
|
|
2980
|
-
stop: stopFor(step, null),
|
|
2981
|
-
first: true,
|
|
2982
|
-
last: true,
|
|
2983
|
-
inbound: "idle",
|
|
2984
|
-
outbound: "idle",
|
|
2985
|
-
onClick: props.onOpenEditor
|
|
2986
|
-
}, step.id))
|
|
2987
|
-
})]
|
|
2988
|
-
}) : null
|
|
2989
|
-
]
|
|
2990
|
-
});
|
|
2991
|
-
}
|
|
2992
|
-
//#endregion
|
|
2993
|
-
//#region editors/workflow-studio/components/WorkflowHeader.tsx
|
|
2994
|
-
const WORKFLOW_TYPE$1 = "powerhouse/workflow";
|
|
2995
|
-
function WorkflowHeader(props) {
|
|
2996
|
-
const workflowId = props.node.id;
|
|
2997
|
-
const { data: document, error, reload } = useDocumentSafe(workflowId);
|
|
2998
|
-
const [, dispatch] = useDispatch(document);
|
|
2999
|
-
if (error !== void 0) return /* @__PURE__ */ jsx(DocumentLoadError, {
|
|
3000
|
-
title: "This workflow could not be loaded",
|
|
3001
|
-
documentId: workflowId,
|
|
3002
|
-
error,
|
|
3003
|
-
onRetry: () => {
|
|
3004
|
-
reload();
|
|
3005
|
-
}
|
|
3006
|
-
});
|
|
3007
|
-
if (document?.header.documentType !== WORKFLOW_TYPE$1) return null;
|
|
3008
|
-
const workflow = document;
|
|
3009
|
-
const state = workflow.state.global;
|
|
3010
|
-
const stats = runStats(props.runs ?? []);
|
|
3011
|
-
const lastTone = toneOf(RUN_TONE, stats.lastRun?.status);
|
|
3012
|
-
return /* @__PURE__ */ jsxs("header", {
|
|
3013
|
-
className: "mb-8",
|
|
3014
|
-
children: [
|
|
3015
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3016
|
-
className: "flex flex-wrap items-start gap-3",
|
|
3017
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
3018
|
-
className: "min-w-0 grow",
|
|
3019
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
3020
|
-
className: "flex items-center gap-2.5",
|
|
3021
|
-
children: [
|
|
3022
|
-
/* @__PURE__ */ jsx("h2", {
|
|
3023
|
-
className: "min-w-0 truncate text-xl font-semibold tracking-tight text-foreground",
|
|
3024
|
-
children: state.name || props.node.name || "Untitled workflow"
|
|
3025
|
-
}),
|
|
3026
|
-
/* @__PURE__ */ jsx(PublishState, { model: state }),
|
|
3027
|
-
state.status === "ARCHIVED" ? /* @__PURE__ */ jsx("span", {
|
|
3028
|
-
className: "rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",
|
|
3029
|
-
children: "Archived"
|
|
3030
|
-
}) : null
|
|
3031
|
-
]
|
|
3032
|
-
}), state.description ? /* @__PURE__ */ jsx("p", {
|
|
3033
|
-
className: "mt-1 max-w-prose text-[13px] text-muted-foreground",
|
|
3034
|
-
children: state.description
|
|
3035
|
-
}) : null]
|
|
3036
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
3037
|
-
className: "flex items-center gap-2",
|
|
3038
|
-
children: [
|
|
3039
|
-
/* @__PURE__ */ jsx(StatusToggle, {
|
|
3040
|
-
published: Boolean(state.published),
|
|
3041
|
-
status: state.status,
|
|
3042
|
-
onChange: (status) => dispatch(actions.setWorkflowStatus({ status }))
|
|
3043
|
-
}),
|
|
3044
|
-
/* @__PURE__ */ jsx(Button, {
|
|
3045
|
-
variant: "primary",
|
|
3046
|
-
onClick: props.onEdit,
|
|
3047
|
-
children: "Edit workflow"
|
|
3048
|
-
}),
|
|
3049
|
-
/* @__PURE__ */ jsx(WorkflowMenu, {
|
|
3050
|
-
document: workflow,
|
|
3051
|
-
nodeName: props.node.name,
|
|
3052
|
-
onDeleted: props.onDeleted
|
|
3053
|
-
})
|
|
3054
|
-
]
|
|
3055
|
-
})]
|
|
3056
|
-
}),
|
|
3057
|
-
/* @__PURE__ */ jsxs("dl", {
|
|
3058
|
-
className: "mt-5 flex flex-wrap gap-x-10 gap-y-3",
|
|
3059
|
-
children: [
|
|
3060
|
-
/* @__PURE__ */ jsx(Fact, {
|
|
3061
|
-
label: "Starts",
|
|
3062
|
-
children: state.trigger ? describeTrigger(state.trigger) : /* @__PURE__ */ jsx("span", {
|
|
3063
|
-
className: "text-wf-warn",
|
|
3064
|
-
children: "Never: no trigger"
|
|
3065
|
-
})
|
|
3066
|
-
}),
|
|
3067
|
-
/* @__PURE__ */ jsx(Fact, {
|
|
3068
|
-
label: "Last run",
|
|
3069
|
-
title: stats.lastRun ? formatAbsolute(stats.lastRun.startedAt) : void 0,
|
|
3070
|
-
children: stats.lastRun ? /* @__PURE__ */ jsxs("span", {
|
|
3071
|
-
className: `inline-flex items-center gap-1.5 ${TONE_TEXT[lastTone]}`,
|
|
3072
|
-
children: [/* @__PURE__ */ jsx(StatusDot, { tone: lastTone }), formatWhen(stats.lastRun.startedAt)]
|
|
3073
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
3074
|
-
className: "text-muted-foreground",
|
|
3075
|
-
children: "Never"
|
|
3076
|
-
})
|
|
3077
|
-
}),
|
|
3078
|
-
/* @__PURE__ */ jsx(Fact, {
|
|
3079
|
-
label: "Recent runs",
|
|
3080
|
-
children: stats.total > 0 ? /* @__PURE__ */ jsx(RunStrip, {
|
|
3081
|
-
centered: true,
|
|
3082
|
-
runs: props.runs ?? []
|
|
3083
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
3084
|
-
className: "text-muted-foreground",
|
|
3085
|
-
children: "None yet"
|
|
3086
|
-
})
|
|
3087
|
-
}),
|
|
3088
|
-
/* @__PURE__ */ jsx(Fact, {
|
|
3089
|
-
label: "Success rate",
|
|
3090
|
-
children: stats.successRate === null ? /* @__PURE__ */ jsx("span", {
|
|
3091
|
-
className: "text-muted-foreground",
|
|
3092
|
-
children: "No finished runs"
|
|
3093
|
-
}) : `${stats.successRate}%`
|
|
3094
|
-
}),
|
|
3095
|
-
/* @__PURE__ */ jsxs(Fact, {
|
|
3096
|
-
label: "Version",
|
|
3097
|
-
children: ["v", state.version]
|
|
3098
|
-
})
|
|
3099
|
-
]
|
|
3100
|
-
}),
|
|
3101
|
-
/* @__PURE__ */ jsx(WorkflowSteps, {
|
|
3102
|
-
state,
|
|
3103
|
-
latestRun: stats.lastRun,
|
|
3104
|
-
onOpenEditor: props.onEdit
|
|
3105
|
-
})
|
|
3106
|
-
]
|
|
3107
|
-
});
|
|
3108
|
-
}
|
|
3109
|
-
//#endregion
|
|
3110
|
-
//#region editors/workflow-studio/components/WorkflowStudio.tsx
|
|
3111
|
-
const WORKFLOW_TYPE = "powerhouse/workflow";
|
|
3112
|
-
const CONNECTION_TYPE = "powerhouse/connection";
|
|
3113
|
-
function WorkflowStudio(props) {
|
|
3114
|
-
return /* @__PURE__ */ jsx(WorkflowRuntimeProvider, { children: /* @__PURE__ */ jsx(Studio, { children: props.children }) });
|
|
3115
|
-
}
|
|
3116
|
-
function Studio(props) {
|
|
3117
|
-
const { fireWorkflow } = useRuntimeActions();
|
|
3118
|
-
const [drive, dispatchDrive] = useSelectedDrive();
|
|
3119
|
-
const nodes = useNodesInSelectedDrive() ?? [];
|
|
3120
|
-
const fileNodes = useFileNodesInSelectedDrive() ?? [];
|
|
3121
|
-
const workflowDocuments = useWorkflowDocumentsInSelectedDrive() ?? [];
|
|
3122
|
-
const selectedNode = useSelectedNode();
|
|
3123
|
-
const selectedNodeId = selectedNode?.id;
|
|
3124
|
-
const toast = usePHToast();
|
|
3125
|
-
const [selectedId, select, go] = useItemSelection(selectedNodeId);
|
|
3126
|
-
const [creating, setCreating] = useState(false);
|
|
3127
|
-
const driveId = drive.header.id;
|
|
3128
|
-
const orderedWorkflows = orderWorkflows(fileNodes.filter((node) => node.documentType === WORKFLOW_TYPE), nodes);
|
|
3129
|
-
const workflows = orderedWorkflows.map((item) => item.node);
|
|
3130
|
-
const connections = fileNodes.filter((node) => node.documentType === CONNECTION_TYPE);
|
|
3131
|
-
const editorOpen = Boolean(props.children && selectedNodeId);
|
|
3132
|
-
const create = (documentType, baseName, count) => {
|
|
3133
|
-
if (creating) return;
|
|
3134
|
-
setCreating(true);
|
|
3135
|
-
const name = `${baseName} ${count + 1}`;
|
|
3136
|
-
(documentType === WORKFLOW_TYPE ? addFolder(driveId, homeFolderName(nextKey(orderedWorkflows), name)).then((folder) => addDocument(driveId, name, documentType, folder.id).catch(async (error) => {
|
|
3137
|
-
await deleteNode(driveId, folder.id).catch(() => void 0);
|
|
3138
|
-
throw error;
|
|
3139
|
-
})) : addDocument(driveId, name, documentType)).then((node) => go(node.id, node.id)).catch((error) => {
|
|
3140
|
-
toast?.(error instanceof Error ? error.message : `Failed to create ${baseName}`, { type: "error" });
|
|
3141
|
-
}).finally(() => setCreating(false));
|
|
3142
|
-
};
|
|
3143
|
-
const reorder = (from, to) => {
|
|
3144
|
-
const names = new Map(workflowDocuments.map((doc) => [doc.header.id, doc.state.global.name]));
|
|
3145
|
-
const actions = reorderActions(orderedWorkflows, from, to, names);
|
|
3146
|
-
if (actions.length === 0) return;
|
|
3147
|
-
dispatchDrive(actions, (errors) => toast?.(errors[0]?.message ?? "Failed to reorder workflows", { type: "error" }));
|
|
3148
|
-
};
|
|
3149
|
-
const showRuns = (node) => go(node?.id);
|
|
3150
|
-
const liveTarget = workflows.find((node) => node.id === selectedId) ?? null;
|
|
3151
|
-
const connectionSelected = connections.some((node) => node.id === selectedId);
|
|
3152
|
-
const wasEditing = useRef(editorOpen);
|
|
3153
|
-
useEffect(() => {
|
|
3154
|
-
if (wasEditing.current && !editorOpen && connectionSelected) select(void 0, { replace: true });
|
|
3155
|
-
wasEditing.current = editorOpen;
|
|
3156
|
-
}, [
|
|
3157
|
-
editorOpen,
|
|
3158
|
-
connectionSelected,
|
|
3159
|
-
select
|
|
3160
|
-
]);
|
|
3161
|
-
const selectionExists = fileNodes.some((node) => node.id === selectedId);
|
|
3162
|
-
useEffect(() => {
|
|
3163
|
-
if (selectedId && fileNodes.length > 0 && !selectionExists) select(void 0, { replace: true });
|
|
3164
|
-
}, [
|
|
3165
|
-
fileNodes.length,
|
|
3166
|
-
select,
|
|
3167
|
-
selectedId,
|
|
3168
|
-
selectionExists
|
|
3169
|
-
]);
|
|
3170
|
-
const focusedWorkflow = liveTarget;
|
|
3171
|
-
const driveFeed = useRuns({ driveId });
|
|
3172
|
-
const approvals = usePendingApprovals(driveId);
|
|
3173
|
-
const [waitingFocus, setWaitingFocus] = useState(0);
|
|
3174
|
-
const showApprovals = (workflowId) => {
|
|
3175
|
-
go(workflowId);
|
|
3176
|
-
setWaitingFocus((request) => request + 1);
|
|
3177
|
-
};
|
|
3178
|
-
const workflowFeed = useRuns({ workflowId: focusedWorkflow?.id }, Boolean(focusedWorkflow));
|
|
3179
|
-
const feed = focusedWorkflow ? workflowFeed : driveFeed;
|
|
3180
|
-
const { runs, error: runsError, reload: reloadRuns } = feed;
|
|
3181
|
-
const lastRuns = /* @__PURE__ */ new Map();
|
|
3182
|
-
for (const run of driveFeed.runs ?? []) if (!lastRuns.has(run.workflowId)) lastRuns.set(run.workflowId, run.status);
|
|
3183
|
-
const stepNames = new Map(workflowDocuments.map((document) => [document.header.id, new Map(document.state.global.steps.map((step) => [step.key, step.name || step.key]))]));
|
|
3184
|
-
const { data: targetDocument } = useDocumentSafe(liveTarget?.id ?? null);
|
|
3185
|
-
const targetTrigger = targetDocument?.header.documentType === WORKFLOW_TYPE ? targetDocument.state.global.trigger : null;
|
|
3186
|
-
const manualTrigger = Boolean(targetTrigger && sameBlock(triggerBlock(targetTrigger), MANUAL_TRIGGER));
|
|
3187
|
-
const published = targetDocument?.header.documentType === WORKFLOW_TYPE ? targetDocument.state.global.published : null;
|
|
3188
|
-
const firedTrigger = published ? published.trigger : targetTrigger;
|
|
3189
|
-
const fireInputs = useMemo(() => firedTrigger && sameBlock(triggerBlock(firedTrigger), MANUAL_TRIGGER) ? parseManualInputs(firedTrigger.config) : [], [firedTrigger]);
|
|
3190
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3191
|
-
className: "flex h-full min-h-0 flex-col md:flex-row",
|
|
3192
|
-
children: [/* @__PURE__ */ jsx(Sidebar, {
|
|
3193
|
-
workflows,
|
|
3194
|
-
connections,
|
|
3195
|
-
lastRuns,
|
|
3196
|
-
approvals,
|
|
3197
|
-
onShowApprovals: showApprovals,
|
|
3198
|
-
activeId: selectedId,
|
|
3199
|
-
allRunsActive: !selectedId,
|
|
3200
|
-
creating,
|
|
3201
|
-
onReorderWorkflow: reorder,
|
|
3202
|
-
onShowAllRuns: () => showRuns(null),
|
|
3203
|
-
onOpenWorkflow: (node) => showRuns(node),
|
|
3204
|
-
onEditWorkflow: (node) => go(node.id, node.id),
|
|
3205
|
-
onOpenConnection: (node) => go(node.id, node.id),
|
|
3206
|
-
onCreateWorkflow: () => create(WORKFLOW_TYPE, "Workflow", workflows.length),
|
|
3207
|
-
onCreateConnection: () => create(CONNECTION_TYPE, "Connection", connections.length)
|
|
3208
|
-
}), /* @__PURE__ */ jsx("main", {
|
|
3209
|
-
className: "relative min-h-0 min-w-0 flex-1 overflow-y-auto",
|
|
3210
|
-
children: editorOpen ? /* @__PURE__ */ jsx("div", {
|
|
3211
|
-
className: "flex h-full min-h-0 flex-col",
|
|
3212
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
3213
|
-
className: "flex min-h-0 flex-1 flex-col [&>#document-editor-container]:min-h-0",
|
|
3214
|
-
children: /* @__PURE__ */ jsx(DocumentErrorBoundary, {
|
|
3215
|
-
documentId: selectedNodeId,
|
|
3216
|
-
label: selectedNode?.name,
|
|
3217
|
-
onDismiss: () => go(selectedId),
|
|
3218
|
-
children: props.children
|
|
3219
|
-
}, selectedNodeId)
|
|
3220
|
-
})
|
|
3221
|
-
}) : /* @__PURE__ */ jsxs("div", {
|
|
3222
|
-
className: "mx-auto w-full max-w-6xl px-4 py-6 md:px-8 md:py-10",
|
|
3223
|
-
children: [
|
|
3224
|
-
liveTarget ? /* @__PURE__ */ jsx(WorkflowHeader, {
|
|
3225
|
-
node: liveTarget,
|
|
3226
|
-
runs,
|
|
3227
|
-
onEdit: () => go(liveTarget.id, liveTarget.id),
|
|
3228
|
-
onDeleted: () => select(void 0, { replace: true })
|
|
3229
|
-
}, liveTarget.id) : /* @__PURE__ */ jsx(WorkflowBoard, {
|
|
3230
|
-
runs,
|
|
3231
|
-
order: workflows.map((node) => node.id),
|
|
3232
|
-
creating,
|
|
3233
|
-
onOpen: (workflowId) => go(workflowId),
|
|
3234
|
-
approvals,
|
|
3235
|
-
onShowApprovals: showApprovals,
|
|
3236
|
-
onCreate: () => create(WORKFLOW_TYPE, "Workflow", workflows.length)
|
|
3237
|
-
}),
|
|
3238
|
-
/* @__PURE__ */ jsx(WaitingApprovals, {
|
|
3239
|
-
driveId: liveTarget ? void 0 : driveId,
|
|
3240
|
-
workflowId: liveTarget?.id,
|
|
3241
|
-
showWorkflow: liveTarget === null,
|
|
3242
|
-
stepNames,
|
|
3243
|
-
onChanged: reloadRuns,
|
|
3244
|
-
focusRequest: waitingFocus
|
|
3245
|
-
}),
|
|
3246
|
-
/* @__PURE__ */ jsx(RunsView, {
|
|
3247
|
-
title: liveTarget ? "Runs" : "Recent runs",
|
|
3248
|
-
runs,
|
|
3249
|
-
error: runsError,
|
|
3250
|
-
reload: reloadRuns,
|
|
3251
|
-
showWorkflow: liveTarget === null,
|
|
3252
|
-
hasMore: feed.hasMore,
|
|
3253
|
-
loadingMore: feed.loadingMore,
|
|
3254
|
-
onLoadMore: feed.loadMore,
|
|
3255
|
-
onFire: liveTarget && manualTrigger ? (payload) => fireWorkflow(liveTarget.id, payload).then((result) => result.error) : void 0,
|
|
3256
|
-
fireInputs
|
|
3257
|
-
})
|
|
3258
|
-
]
|
|
3259
|
-
})
|
|
3260
|
-
})]
|
|
3261
|
-
});
|
|
3262
|
-
}
|
|
3263
|
-
//#endregion
|
|
3264
|
-
//#region editors/workflow-studio/config.ts
|
|
3265
|
-
const editorConfig = {
|
|
3266
|
-
isDragAndDropEnabled: true,
|
|
3267
|
-
allowedDocumentTypes: ["powerhouse/workflow", "powerhouse/connection"]
|
|
3268
|
-
};
|
|
3269
|
-
//#endregion
|
|
3270
|
-
//#region editors/workflow-studio/editor.tsx
|
|
3271
|
-
/**
|
|
3272
|
-
* WARNING: DO NOT EDIT
|
|
3273
|
-
* This file is auto-generated and updated by codegen
|
|
3274
|
-
*/
|
|
3275
|
-
/** Editor component for the app */
|
|
3276
|
-
function Editor(props) {
|
|
3277
|
-
useSetPHAppConfig(editorConfig);
|
|
3278
|
-
return /* @__PURE__ */ jsx("div", {
|
|
3279
|
-
className: "h-full min-h-0 bg-background",
|
|
3280
|
-
children: /* @__PURE__ */ jsx(WorkflowStudio, { children: props.children })
|
|
3281
|
-
});
|
|
3282
|
-
}
|
|
3283
|
-
//#endregion
|
|
3284
|
-
export { Editor as default };
|
|
3285
|
-
|
|
3286
|
-
//# sourceMappingURL=editor-B4ZwM3pR.mjs.map
|