@burdenoff/microfe-planmagnet 2026.1014.1 → 2026.1031.1

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.
@@ -1,25 +1,26 @@
1
1
  import { AssigneeSelect as e, WORK_ITEM_PRIORITIES as t, WORK_ITEM_STATUSES as n, enumLabel as r } from "../controls/WorkItemControls.js";
2
2
  import { ProjectSelect as i } from "../controls/Pickers.js";
3
- import { ACTION_TYPES as a, ACTION_TYPE_LABEL as o, AUTOMATION_TEMPLATE_MAX_LENGTH as s, CHANNEL_POSTING_BLOCKED_MESSAGE as c, CHANNEL_POSTING_OPTION_REASON as l, CONDITION_FIELDS as u, CONDITION_OPERATORS as d, CONDITION_OPERATOR_LABEL as f, NO_WORK_ITEM_TRIGGER_TYPES as p, POST_COMMENT_MAX_RENDERED_LENGTH as m, TEMPLATE_PLACEHOLDER_INFO as h, TRIGGER_TYPES as g, TRIGGER_TYPE_LABEL as _, WORK_ITEM_ACTION_TYPES as v, parseScheduleDays as y, renderTemplatePreview as b, templatePlaceholdersForTrigger as x, templateSampleValues as S, triggerHint as C, triggerOptionSuffix as w } from "./automationRuleTypes.js";
4
- import { Plus as T, X as E } from "lucide-react";
5
- import { jsx as D, jsxs as O } from "react/jsx-runtime";
6
- import { Button as k, Checkbox as A, Input as j, Textarea as M } from "@burdenoff/fe-libs/ui";
3
+ import { ACTION_TYPES as a, ACTION_TYPE_LABEL as o, AUTOMATION_TEMPLATE_MAX_LENGTH as s, CHANNEL_POSTING_BLOCKED_MESSAGE as c, CHANNEL_POSTING_OPTION_REASON as l, CONDITION_FIELDS as u, CONDITION_OPERATORS as d, CONDITION_OPERATOR_LABEL as f, NO_WORK_ITEM_TRIGGER_TYPES as p, POST_COMMENT_MAX_RENDERED_LENGTH as m, TEMPLATE_PLACEHOLDER_INFO as h, TRIGGER_TYPES as g, TRIGGER_TYPE_LABEL as _, WORK_ITEM_ACTION_TYPES as v, parseScheduleDays as y, renderTemplatePreview as b, templatePlaceholdersForTrigger as x, templateSampleValues as S, triggerHint as C, triggerOptionSuffix as w, triggerSaveBlockReason as T } from "./automationRuleTypes.js";
4
+ import { WorkflowSelect as E } from "./WorkflowSelect.js";
5
+ import { Plus as D, X as O } from "lucide-react";
6
+ import { jsx as k, jsxs as A } from "react/jsx-runtime";
7
+ import { Button as j, Checkbox as M, Input as N, Textarea as P } from "@burdenoff/fe-libs/ui";
7
8
  //#region src/planmagnet/automation/AutomationRuleFields.tsx
8
- var N = "rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60", P = `mt-1 w-full ${N}`, F = "text-foreground";
9
- function I({ value: e, triggerType: t, onChange: n }) {
9
+ var F = "rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60", I = `mt-1 w-full ${F}`, L = "text-foreground";
10
+ function R({ value: e, triggerType: t, onChange: n }) {
10
11
  let r = x(t), i = b(e, S(t), m), a = (t) => n(`${e}{{${t}}}`);
11
- return /* @__PURE__ */ O("div", {
12
+ return /* @__PURE__ */ A("div", {
12
13
  className: "space-y-2",
13
14
  children: [
14
- /* @__PURE__ */ O("div", { children: [/* @__PURE__ */ D(M, {
15
+ /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(P, {
15
16
  "aria-label": "Comment template",
16
17
  "data-testid": "automation-template",
17
- className: `min-h-[72px] w-full ${F}`,
18
+ className: `min-h-[72px] w-full ${L}`,
18
19
  maxLength: s,
19
20
  placeholder: "e.g. Automatically moved to {{toStatus}} by {{actor}}",
20
21
  value: e,
21
22
  onChange: (e) => n(e.target.value)
22
- }), /* @__PURE__ */ O("p", {
23
+ }), /* @__PURE__ */ A("p", {
23
24
  className: "mt-1 text-xs text-muted-foreground",
24
25
  children: [
25
26
  e.length,
@@ -28,13 +29,13 @@ function I({ value: e, triggerType: t, onChange: n }) {
28
29
  " characters"
29
30
  ]
30
31
  })] }),
31
- /* @__PURE__ */ O("div", { children: [/* @__PURE__ */ D("p", {
32
+ /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("p", {
32
33
  className: "text-xs font-medium text-muted-foreground",
33
34
  children: "Insert a placeholder"
34
- }), /* @__PURE__ */ D("div", {
35
+ }), /* @__PURE__ */ k("div", {
35
36
  "data-testid": "automation-placeholders",
36
37
  className: "mt-1 flex flex-wrap gap-1.5",
37
- children: r.map((e) => /* @__PURE__ */ D("button", {
38
+ children: r.map((e) => /* @__PURE__ */ k("button", {
38
39
  type: "button",
39
40
  onClick: () => a(e),
40
41
  title: `Insert {{${e}}} — ${h[e]?.label ?? e}`,
@@ -42,15 +43,15 @@ function I({ value: e, triggerType: t, onChange: n }) {
42
43
  children: `{{${e}}}`
43
44
  }, e))
44
45
  })] }),
45
- /* @__PURE__ */ O("div", {
46
+ /* @__PURE__ */ A("div", {
46
47
  "data-testid": "automation-template-preview",
47
48
  className: "rounded-md border border-dashed border-input p-2 text-xs",
48
- children: [/* @__PURE__ */ D("p", {
49
+ children: [/* @__PURE__ */ k("p", {
49
50
  className: "font-medium text-foreground",
50
51
  children: "Preview"
51
- }), /* @__PURE__ */ D("p", {
52
+ }), /* @__PURE__ */ k("p", {
52
53
  className: "mt-0.5 whitespace-pre-wrap text-muted-foreground",
53
- children: i || /* @__PURE__ */ D("span", {
54
+ children: i || /* @__PURE__ */ k("span", {
54
55
  className: "italic",
55
56
  children: "Nothing to show yet — write a template above."
56
57
  })
@@ -59,86 +60,90 @@ function I({ value: e, triggerType: t, onChange: n }) {
59
60
  ]
60
61
  });
61
62
  }
62
- function L({ action: i, triggerType: a, onChange: o }) {
63
+ function z({ action: i, triggerType: a, onChange: o }) {
63
64
  switch (i.type) {
64
- case "ASSIGN_TO_USER": return /* @__PURE__ */ D(e, {
65
+ case "ASSIGN_TO_USER": return /* @__PURE__ */ k(e, {
65
66
  value: i.value,
66
67
  onChange: o
67
68
  });
68
- case "SET_STATUS": return /* @__PURE__ */ O("select", {
69
- className: `${N} w-full`,
69
+ case "SET_STATUS": return /* @__PURE__ */ A("select", {
70
+ className: `${F} w-full`,
70
71
  value: i.value,
71
72
  onChange: (e) => o(e.target.value),
72
- children: [/* @__PURE__ */ D("option", {
73
+ children: [/* @__PURE__ */ k("option", {
73
74
  value: "",
74
75
  children: "Choose a status"
75
- }), n.map((e) => /* @__PURE__ */ D("option", {
76
+ }), n.map((e) => /* @__PURE__ */ k("option", {
76
77
  value: e,
77
78
  children: r(e)
78
79
  }, e))]
79
80
  });
80
- case "SET_PRIORITY": return /* @__PURE__ */ O("select", {
81
- className: `${N} w-full`,
81
+ case "SET_PRIORITY": return /* @__PURE__ */ A("select", {
82
+ className: `${F} w-full`,
82
83
  value: i.value,
83
84
  onChange: (e) => o(e.target.value),
84
- children: [/* @__PURE__ */ D("option", {
85
+ children: [/* @__PURE__ */ k("option", {
85
86
  value: "",
86
87
  children: "Choose a priority"
87
- }), t.map((e) => /* @__PURE__ */ D("option", {
88
+ }), t.map((e) => /* @__PURE__ */ k("option", {
88
89
  value: e,
89
90
  children: r(e)
90
91
  }, e))]
91
92
  });
92
- case "POST_COMMENT": return /* @__PURE__ */ D(I, {
93
+ case "POST_COMMENT": return /* @__PURE__ */ k(R, {
93
94
  value: i.value,
94
95
  triggerType: a,
95
96
  onChange: o
96
97
  });
97
- case "POST_TO_CHANNEL": return /* @__PURE__ */ O("div", {
98
+ case "RUN_WORKFLOW": return /* @__PURE__ */ k(E, {
99
+ value: i.value,
100
+ onChange: o
101
+ });
102
+ case "POST_TO_CHANNEL": return /* @__PURE__ */ A("div", {
98
103
  className: "space-y-1",
99
- children: [/* @__PURE__ */ D(j, {
104
+ children: [/* @__PURE__ */ k(N, {
100
105
  "aria-label": "Channel message template (read-only — not available yet)",
101
- className: F,
106
+ className: L,
102
107
  value: i.value,
103
108
  disabled: !0,
104
109
  readOnly: !0
105
- }), /* @__PURE__ */ D("p", {
110
+ }), /* @__PURE__ */ k("p", {
106
111
  className: "text-xs text-destructive",
107
112
  children: c
108
113
  })]
109
114
  });
110
- default: return /* @__PURE__ */ D(j, {
115
+ default: return /* @__PURE__ */ k(N, {
111
116
  "aria-label": "Label",
112
- className: F,
117
+ className: L,
113
118
  placeholder: "e.g. needs-review",
114
119
  value: i.value,
115
120
  onChange: (e) => o(e.target.value)
116
121
  });
117
122
  }
118
123
  }
119
- function R({ actions: e, triggerType: t, onChange: n }) {
124
+ function B({ actions: e, triggerType: t, onChange: n }) {
120
125
  let r = p.has(t), i = (t, r) => n(e.map((e, n) => n === t ? {
121
126
  ...e,
122
127
  ...r
123
128
  } : e)), s = (t) => n(e.filter((e, n) => n !== t));
124
- return /* @__PURE__ */ O("div", {
129
+ return /* @__PURE__ */ A("div", {
125
130
  className: "space-y-2",
126
131
  children: [
127
- r && /* @__PURE__ */ D("p", {
132
+ r && /* @__PURE__ */ k("p", {
128
133
  className: "text-xs text-muted-foreground",
129
- children: "This trigger has no target work item, so none of the actions below can run for it. Remove any left over from before this restriction existed, or switch to a different trigger."
134
+ children: "This trigger has no target work item, so only \"Run a workflow\" can run for it. Remove any work item action left over from before, or switch to a different trigger."
130
135
  }),
131
136
  e.map((e, n) => {
132
137
  let c = a.includes(e.type), u = c ? a : [e.type, ...a], d = r && v.has(e.type);
133
- return /* @__PURE__ */ O("div", {
138
+ return /* @__PURE__ */ A("div", {
134
139
  className: "space-y-1",
135
- children: [/* @__PURE__ */ O("div", {
140
+ children: [/* @__PURE__ */ A("div", {
136
141
  className: "flex items-start gap-2",
137
142
  children: [
138
- /* @__PURE__ */ D("select", {
143
+ /* @__PURE__ */ k("select", {
139
144
  "aria-label": "Action type",
140
145
  "data-testid": "automation-action-type",
141
- className: `${N} w-40 shrink-0`,
146
+ className: `${F} w-40 shrink-0`,
142
147
  value: e.type,
143
148
  disabled: d,
144
149
  onChange: (t) => i(n, {
@@ -146,108 +151,106 @@ function R({ actions: e, triggerType: t, onChange: n }) {
146
151
  value: t.target.value === e.type ? e.value : ""
147
152
  }),
148
153
  children: u.map((t) => {
149
- let n = t === "POST_TO_CHANNEL" && !0, r = c || t !== e.type ? o[t] ?? t : t;
150
- return /* @__PURE__ */ D("option", {
154
+ let n = t === "POST_TO_CHANNEL" && !0, i = r && v.has(t), a = n || i, s = c || t !== e.type ? o[t] ?? t : t;
155
+ return /* @__PURE__ */ k("option", {
151
156
  value: t,
152
- disabled: n,
153
- children: n ? `${r} — ${l}` : r
157
+ disabled: a,
158
+ children: n ? `${s} — ${l}` : i ? `${s} — needs a work item` : s
154
159
  }, t);
155
160
  })
156
161
  }),
157
- /* @__PURE__ */ D("div", {
162
+ /* @__PURE__ */ k("div", {
158
163
  className: "min-w-0 flex-1",
159
- children: /* @__PURE__ */ D(L, {
164
+ children: /* @__PURE__ */ k(z, {
160
165
  action: e,
161
166
  triggerType: t,
162
167
  onChange: (e) => i(n, { value: e })
163
168
  })
164
169
  }),
165
- /* @__PURE__ */ D(k, {
170
+ /* @__PURE__ */ k(j, {
166
171
  type: "button",
167
172
  size: "sm",
168
173
  variant: "ghost",
169
174
  "aria-label": "Remove action",
170
175
  onClick: () => s(n),
171
- children: /* @__PURE__ */ D(E, { className: "h-4 w-4" })
176
+ children: /* @__PURE__ */ k(O, { className: "h-4 w-4" })
172
177
  })
173
178
  ]
174
- }), !c && /* @__PURE__ */ D("p", {
179
+ }), !c && /* @__PURE__ */ k("p", {
175
180
  className: "text-xs text-muted-foreground",
176
181
  children: "This action type is not run by the engine yet; the rule keeps it but never dispatches it."
177
182
  })]
178
183
  }, n);
179
184
  }),
180
- /* @__PURE__ */ O(k, {
185
+ /* @__PURE__ */ A(j, {
181
186
  type: "button",
182
187
  size: "sm",
183
188
  variant: "outline",
184
189
  onClick: () => n([...e, {
185
- type: "ASSIGN_TO_USER",
190
+ type: r ? "RUN_WORKFLOW" : "ASSIGN_TO_USER",
186
191
  value: ""
187
192
  }]),
188
- disabled: r,
189
- title: r ? "This trigger has no target work item — no action can be added." : void 0,
190
193
  "data-testid": "automation-add-action",
191
- children: [/* @__PURE__ */ D(T, { className: "mr-1 h-4 w-4" }), "Add action"]
194
+ children: [/* @__PURE__ */ k(D, { className: "mr-1 h-4 w-4" }), "Add action"]
192
195
  }),
193
- e.length === 0 && !r && /* @__PURE__ */ D("p", {
196
+ e.length === 0 && /* @__PURE__ */ k("p", {
194
197
  className: "text-xs text-muted-foreground",
195
198
  children: "A rule with no actions still records that it ran, but changes nothing."
196
199
  })
197
200
  ]
198
201
  });
199
202
  }
200
- function z({ conditions: e, onChange: t }) {
203
+ function V({ conditions: e, onChange: t }) {
201
204
  let n = (n, r) => t(e.map((e, t) => t === n ? {
202
205
  ...e,
203
206
  ...r
204
207
  } : e)), r = (n) => t(e.filter((e, t) => t !== n));
205
- return /* @__PURE__ */ O("div", {
208
+ return /* @__PURE__ */ A("div", {
206
209
  className: "space-y-2",
207
210
  children: [
208
- e.map((e, t) => /* @__PURE__ */ O("div", {
211
+ e.map((e, t) => /* @__PURE__ */ A("div", {
209
212
  className: "flex items-start gap-2",
210
213
  children: [
211
- /* @__PURE__ */ D(j, {
214
+ /* @__PURE__ */ k(N, {
212
215
  "aria-label": "Condition field",
213
216
  list: "automation-condition-fields",
214
- className: `w-36 shrink-0 ${F}`,
217
+ className: `w-36 shrink-0 ${L}`,
215
218
  placeholder: "field",
216
219
  value: e.field,
217
220
  onChange: (e) => n(t, { field: e.target.value })
218
221
  }),
219
- /* @__PURE__ */ D("select", {
222
+ /* @__PURE__ */ k("select", {
220
223
  "aria-label": "Condition operator",
221
- className: `${N} w-32 shrink-0`,
224
+ className: `${F} w-32 shrink-0`,
222
225
  value: e.operator,
223
226
  onChange: (e) => n(t, { operator: e.target.value }),
224
- children: d.map((e) => /* @__PURE__ */ D("option", {
227
+ children: d.map((e) => /* @__PURE__ */ k("option", {
225
228
  value: e,
226
229
  children: f[e]
227
230
  }, e))
228
231
  }),
229
- e.operator !== "exists" && /* @__PURE__ */ D(j, {
232
+ e.operator !== "exists" && /* @__PURE__ */ k(N, {
230
233
  "aria-label": "Condition value",
231
- className: `min-w-0 flex-1 ${F}`,
234
+ className: `min-w-0 flex-1 ${L}`,
232
235
  placeholder: e.operator === "in" || e.operator === "notIn" ? "comma, separated, values" : "value",
233
236
  value: e.value,
234
237
  onChange: (e) => n(t, { value: e.target.value })
235
238
  }),
236
- /* @__PURE__ */ D(k, {
239
+ /* @__PURE__ */ k(j, {
237
240
  type: "button",
238
241
  size: "sm",
239
242
  variant: "ghost",
240
243
  "aria-label": "Remove condition",
241
244
  onClick: () => r(t),
242
- children: /* @__PURE__ */ D(E, { className: "h-4 w-4" })
245
+ children: /* @__PURE__ */ k(O, { className: "h-4 w-4" })
243
246
  })
244
247
  ]
245
248
  }, t)),
246
- /* @__PURE__ */ D("datalist", {
249
+ /* @__PURE__ */ k("datalist", {
247
250
  id: "automation-condition-fields",
248
- children: u.map((e) => /* @__PURE__ */ D("option", { value: e }, e))
251
+ children: u.map((e) => /* @__PURE__ */ k("option", { value: e }, e))
249
252
  }),
250
- /* @__PURE__ */ O(k, {
253
+ /* @__PURE__ */ A(j, {
251
254
  type: "button",
252
255
  size: "sm",
253
256
  variant: "outline",
@@ -257,84 +260,84 @@ function z({ conditions: e, onChange: t }) {
257
260
  value: ""
258
261
  }]),
259
262
  "data-testid": "automation-add-condition",
260
- children: [/* @__PURE__ */ D(T, { className: "mr-1 h-4 w-4" }), "Add condition"]
263
+ children: [/* @__PURE__ */ k(D, { className: "mr-1 h-4 w-4" }), "Add condition"]
261
264
  }),
262
- e.length === 0 && /* @__PURE__ */ D("p", {
265
+ e.length === 0 && /* @__PURE__ */ k("p", {
263
266
  className: "text-xs text-muted-foreground",
264
267
  children: "No conditions: the rule matches every event."
265
268
  })
266
269
  ]
267
270
  });
268
271
  }
269
- function B({ statuses: e, days: t, onStatusesChange: i, onDaysChange: a }) {
272
+ function H({ statuses: e, days: t, onStatusesChange: i, onDaysChange: a }) {
270
273
  let o = (t) => i(e.includes(t) ? e.filter((e) => e !== t) : [...e, t]), s = y(t);
271
- return /* @__PURE__ */ O("div", {
274
+ return /* @__PURE__ */ A("div", {
272
275
  className: "space-y-3",
273
276
  children: [
274
- /* @__PURE__ */ O("div", { children: [
275
- /* @__PURE__ */ D("p", {
277
+ /* @__PURE__ */ A("div", { children: [
278
+ /* @__PURE__ */ k("p", {
276
279
  className: "text-sm font-medium",
277
280
  children: "Statuses"
278
281
  }),
279
- /* @__PURE__ */ D("div", {
282
+ /* @__PURE__ */ k("div", {
280
283
  "data-testid": "automation-schedule-statuses",
281
284
  role: "group",
282
285
  "aria-label": "Statuses to watch",
283
286
  className: "mt-1 flex flex-wrap gap-2",
284
- children: n.map((t) => /* @__PURE__ */ O("label", {
287
+ children: n.map((t) => /* @__PURE__ */ A("label", {
285
288
  className: "flex items-center gap-1.5 rounded-md border border-input px-2 py-1 text-sm",
286
- children: [/* @__PURE__ */ D(A, {
289
+ children: [/* @__PURE__ */ k(M, {
287
290
  checked: e.includes(t),
288
291
  onCheckedChange: () => o(t),
289
292
  "aria-label": r(t)
290
293
  }), r(t)]
291
294
  }, t))
292
295
  }),
293
- e.length === 0 && /* @__PURE__ */ D("p", {
296
+ e.length === 0 && /* @__PURE__ */ k("p", {
294
297
  className: "mt-1 text-xs text-destructive",
295
298
  children: "Choose at least one status."
296
299
  })
297
300
  ] }),
298
- /* @__PURE__ */ O("div", { children: [
299
- /* @__PURE__ */ D("label", {
301
+ /* @__PURE__ */ A("div", { children: [
302
+ /* @__PURE__ */ k("label", {
300
303
  htmlFor: "automation-schedule-days",
301
304
  className: "text-sm font-medium",
302
305
  children: "Not updated for (days)"
303
306
  }),
304
- /* @__PURE__ */ D(j, {
307
+ /* @__PURE__ */ k(N, {
305
308
  id: "automation-schedule-days",
306
309
  "data-testid": "automation-schedule-days",
307
310
  inputMode: "numeric",
308
311
  pattern: "[0-9]*",
309
- className: `mt-1 w-28 ${F}`,
312
+ className: `mt-1 w-28 ${L}`,
310
313
  value: t,
311
314
  onChange: (e) => a(e.target.value),
312
315
  placeholder: "e.g. 7"
313
316
  }),
314
- t !== "" && s === null && /* @__PURE__ */ D("p", {
317
+ t !== "" && s === null && /* @__PURE__ */ k("p", {
315
318
  className: "mt-1 text-xs text-destructive",
316
319
  children: "Enter a whole number of days, 1 or more."
317
320
  })
318
321
  ] }),
319
- /* @__PURE__ */ D("p", {
322
+ /* @__PURE__ */ k("p", {
320
323
  className: "text-xs text-muted-foreground",
321
324
  children: "Runs once a day against every work item matching these statuses and staleness window, and acts on each matching item at most once per day."
322
325
  })
323
326
  ]
324
327
  });
325
328
  }
326
- function V({ form: e, onChange: t, projectLocked: n = !1 }) {
329
+ function U({ form: e, onChange: t, projectLocked: n = !1 }) {
327
330
  let r = C(e.triggerType), a = e.triggerType === "SCHEDULE";
328
- return /* @__PURE__ */ O("div", {
331
+ return /* @__PURE__ */ A("div", {
329
332
  className: "space-y-4",
330
333
  children: [
331
- /* @__PURE__ */ O("div", { children: [/* @__PURE__ */ D("label", {
334
+ /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("label", {
332
335
  htmlFor: "automation-name",
333
336
  className: "text-sm font-medium",
334
337
  children: "Name"
335
- }), /* @__PURE__ */ D(j, {
338
+ }), /* @__PURE__ */ k(N, {
336
339
  id: "automation-name",
337
- className: `mt-1 ${F}`,
340
+ className: `mt-1 ${L}`,
338
341
  value: e.name,
339
342
  onChange: (n) => t({
340
343
  ...e,
@@ -342,11 +345,11 @@ function V({ form: e, onChange: t, projectLocked: n = !1 }) {
342
345
  }),
343
346
  placeholder: "e.g. Assign new bugs to triage"
344
347
  })] }),
345
- /* @__PURE__ */ O("div", { children: [/* @__PURE__ */ D("label", {
348
+ /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("label", {
346
349
  htmlFor: "automation-description",
347
350
  className: "text-sm font-medium",
348
351
  children: "Description"
349
- }), /* @__PURE__ */ D("textarea", {
352
+ }), /* @__PURE__ */ k("textarea", {
350
353
  id: "automation-description",
351
354
  className: "mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[72px]",
352
355
  value: e.description,
@@ -356,18 +359,18 @@ function V({ form: e, onChange: t, projectLocked: n = !1 }) {
356
359
  }),
357
360
  placeholder: "What this rule is for"
358
361
  })] }),
359
- /* @__PURE__ */ O("div", {
362
+ /* @__PURE__ */ A("div", {
360
363
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
361
- children: [/* @__PURE__ */ O("div", { children: [/* @__PURE__ */ D("label", {
364
+ children: [/* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("label", {
362
365
  htmlFor: "automation-project",
363
366
  className: "text-sm font-medium",
364
367
  children: "Project"
365
- }), n ? /* @__PURE__ */ D("p", {
368
+ }), n ? /* @__PURE__ */ k("p", {
366
369
  className: "mt-1 text-sm text-muted-foreground",
367
370
  children: "A rule's project cannot be changed after it is created."
368
- }) : /* @__PURE__ */ D("div", {
371
+ }) : /* @__PURE__ */ k("div", {
369
372
  className: "mt-1",
370
- children: /* @__PURE__ */ D(i, {
373
+ children: /* @__PURE__ */ k(i, {
371
374
  id: "automation-project",
372
375
  value: e.projectId,
373
376
  onChange: (n) => t({
@@ -375,42 +378,42 @@ function V({ form: e, onChange: t, projectLocked: n = !1 }) {
375
378
  projectId: n
376
379
  })
377
380
  })
378
- })] }), /* @__PURE__ */ O("div", { children: [
379
- /* @__PURE__ */ D("label", {
381
+ })] }), /* @__PURE__ */ A("div", { children: [
382
+ /* @__PURE__ */ k("label", {
380
383
  htmlFor: "automation-trigger",
381
384
  className: "text-sm font-medium",
382
385
  children: "Trigger"
383
386
  }),
384
- /* @__PURE__ */ D("select", {
387
+ /* @__PURE__ */ k("select", {
385
388
  id: "automation-trigger",
386
- className: P,
389
+ className: I,
387
390
  value: e.triggerType,
388
391
  onChange: (n) => t({
389
392
  ...e,
390
393
  triggerType: n.target.value
391
394
  }),
392
- children: g.map((e) => /* @__PURE__ */ O("option", {
395
+ children: g.map((e) => /* @__PURE__ */ A("option", {
393
396
  value: e,
394
397
  children: [_[e], w(e)]
395
398
  }, e))
396
399
  }),
397
- r && /* @__PURE__ */ D("p", {
400
+ r && /* @__PURE__ */ k("p", {
398
401
  "data-testid": "automation-trigger-hint",
399
- className: `mt-1 text-xs ${p.has(e.triggerType) ? "text-destructive" : "text-muted-foreground"}`,
402
+ className: `mt-1 text-xs ${T(e.triggerType, e.actions) ? "text-destructive" : "text-muted-foreground"}`,
400
403
  children: r
401
404
  })
402
405
  ] })]
403
406
  }),
404
- /* @__PURE__ */ O("div", { children: [
405
- /* @__PURE__ */ D("p", {
407
+ /* @__PURE__ */ A("div", { children: [
408
+ /* @__PURE__ */ k("p", {
406
409
  className: "text-sm font-medium",
407
410
  children: a ? "Schedule conditions" : "Conditions"
408
411
  }),
409
- /* @__PURE__ */ D("p", {
412
+ /* @__PURE__ */ k("p", {
410
413
  className: "mb-2 text-xs text-muted-foreground",
411
414
  children: a ? "Which work items this schedule watches." : "All conditions must match. Leave empty to match every event."
412
415
  }),
413
- a ? /* @__PURE__ */ D(B, {
416
+ a ? /* @__PURE__ */ k(H, {
414
417
  statuses: e.scheduleStatuses,
415
418
  days: e.scheduleNotUpdatedForDays,
416
419
  onStatusesChange: (n) => t({
@@ -421,7 +424,7 @@ function V({ form: e, onChange: t, projectLocked: n = !1 }) {
421
424
  ...e,
422
425
  scheduleNotUpdatedForDays: n
423
426
  })
424
- }) : /* @__PURE__ */ D(z, {
427
+ }) : /* @__PURE__ */ k(V, {
425
428
  conditions: e.conditions,
426
429
  onChange: (n) => t({
427
430
  ...e,
@@ -429,16 +432,16 @@ function V({ form: e, onChange: t, projectLocked: n = !1 }) {
429
432
  })
430
433
  })
431
434
  ] }),
432
- /* @__PURE__ */ O("div", { children: [
433
- /* @__PURE__ */ D("p", {
435
+ /* @__PURE__ */ A("div", { children: [
436
+ /* @__PURE__ */ k("p", {
434
437
  className: "text-sm font-medium",
435
438
  children: "Actions"
436
439
  }),
437
- /* @__PURE__ */ D("p", {
440
+ /* @__PURE__ */ k("p", {
438
441
  className: "mb-2 text-xs text-muted-foreground",
439
442
  children: "Run in order when the conditions match."
440
443
  }),
441
- /* @__PURE__ */ D(R, {
444
+ /* @__PURE__ */ k(B, {
442
445
  actions: e.actions,
443
446
  triggerType: e.triggerType,
444
447
  onChange: (n) => t({
@@ -451,4 +454,4 @@ function V({ form: e, onChange: t, projectLocked: n = !1 }) {
451
454
  });
452
455
  }
453
456
  //#endregion
454
- export { V as AutomationRuleFields };
457
+ export { U as AutomationRuleFields };
@@ -0,0 +1,5 @@
1
+ export declare function WorkflowSelect({ value, onChange, }: {
2
+ value: string;
3
+ onChange: (workflowDefinitionId: string) => void;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=WorkflowSelect.d.ts.map
@@ -0,0 +1,74 @@
1
+ import { gql as e } from "@apollo/client";
2
+ import { useQuery as t } from "@apollo/client/react";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ //#region src/planmagnet/automation/WorkflowSelect.tsx
5
+ var i = e`
6
+ query AutomationRunnableWorkflows($input: ListWorkflowDefinitionsInput!) {
7
+ workflowDefinitions(input: $input) {
8
+ items {
9
+ id
10
+ name
11
+ workflowKey
12
+ version
13
+ }
14
+ total
15
+ hasMore
16
+ }
17
+ }
18
+ `, a = 100, o = "w-full rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60";
19
+ function s({ value: e, onChange: s }) {
20
+ let { data: c, loading: l, error: u } = t(i, {
21
+ variables: { input: {
22
+ status: "ACTIVE",
23
+ limit: a,
24
+ offset: 0
25
+ } },
26
+ fetchPolicy: "cache-and-network"
27
+ }), d = c?.workflowDefinitions.items ?? [], f = e === "" || d.some((t) => t.id === e);
28
+ return /* @__PURE__ */ r("div", {
29
+ className: "space-y-1",
30
+ children: [/* @__PURE__ */ r("select", {
31
+ "aria-label": "Workflow",
32
+ "data-testid": "automation-workflow-select",
33
+ className: o,
34
+ value: e,
35
+ onChange: (e) => s(e.target.value),
36
+ children: [
37
+ /* @__PURE__ */ n("option", {
38
+ value: "",
39
+ children: l && !c ? "Loading workflows…" : u ? "Workflows could not be loaded" : d.length === 0 ? "No active workflows yet" : "Choose a workflow"
40
+ }),
41
+ !f && c && /* @__PURE__ */ n("option", {
42
+ value: e,
43
+ children: "Unavailable workflow (no longer active)"
44
+ }),
45
+ d.map((e) => /* @__PURE__ */ n("option", {
46
+ value: e.id,
47
+ children: `${e.name} (v${e.version})`
48
+ }, e.id)),
49
+ c?.workflowDefinitions.hasMore && /* @__PURE__ */ n("option", {
50
+ value: "",
51
+ disabled: !0,
52
+ children: `Only the first ${a} active workflows are listed`
53
+ })
54
+ ]
55
+ }), u ? /* @__PURE__ */ r("p", {
56
+ role: "alert",
57
+ className: "text-xs text-destructive",
58
+ children: ["The workflow list could not be loaded: ", u.message]
59
+ }) : /* @__PURE__ */ r("p", {
60
+ className: "text-xs text-muted-foreground",
61
+ children: [
62
+ "Starts a run of this workflow with the PlanMagnet event as its trigger data. The workflow needs a \"Trigger manually\" or \"When called by another workflow\" start node.",
63
+ " ",
64
+ /* @__PURE__ */ n("a", {
65
+ href: "/workflows",
66
+ className: "text-primary underline underline-offset-2",
67
+ children: "Build and activate workflows"
68
+ })
69
+ ]
70
+ })]
71
+ });
72
+ }
73
+ //#endregion
74
+ export { s as WorkflowSelect };