@aglyn/plugins-workflows 1.0.0-beta.179 → 1.0.0-beta.181
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/package.json +12 -11
- package/src/lib/components/automation-trigger-conditions.component.d.ts +43 -0
- package/src/lib/components/automation-trigger-conditions.component.js +189 -0
- package/src/lib/components/automation-trigger-conditions.component.js.map +1 -0
- package/src/lib/components/host-actions-card.component.js +27 -176
- package/src/lib/components/host-actions-card.component.js.map +1 -1
- package/src/lib/components/org-automation-editor.component.d.ts +51 -0
- package/src/lib/components/org-automation-editor.component.js +310 -0
- package/src/lib/components/org-automation-editor.component.js.map +1 -0
- package/src/lib/components/org-automations-card.component.d.ts +28 -0
- package/src/lib/components/org-automations-card.component.js +373 -0
- package/src/lib/components/org-automations-card.component.js.map +1 -0
- package/src/lib/components/org-site-automation-list.component.d.ts +43 -0
- package/src/lib/components/org-site-automation-list.component.js +289 -0
- package/src/lib/components/org-site-automation-list.component.js.map +1 -0
- package/src/lib/components/site-org-automations-panel.component.d.ts +22 -0
- package/src/lib/components/site-org-automations-panel.component.js +201 -0
- package/src/lib/components/site-org-automations-panel.component.js.map +1 -0
- package/src/lib/components/use-org-automation-step-pickers.d.ts +20 -0
- package/src/lib/components/use-org-automation-step-pickers.js +108 -0
- package/src/lib/components/use-org-automation-step-pickers.js.map +1 -0
- package/src/lib/components/use-org-automations-api.d.ts +16 -0
- package/src/lib/components/use-org-automations-api.js +55 -0
- package/src/lib/components/use-org-automations-api.js.map +1 -0
- package/src/lib/components/workflows-console-page.js +63 -1
- package/src/lib/components/workflows-console-page.js.map +1 -1
- package/src/lib/components/workflows-console-sections.d.ts +19 -1
- package/src/lib/components/workflows-console-sections.js +37 -2
- package/src/lib/components/workflows-console-sections.js.map +1 -1
- package/src/lib/components/workflows-org-mount.d.ts +52 -0
- package/src/lib/components/workflows-org-mount.js +49 -0
- package/src/lib/components/workflows-org-mount.js.map +1 -0
- package/src/lib/engine/flow-enrollments.d.ts +26 -10
- package/src/lib/engine/flow-enrollments.js +14 -7
- package/src/lib/engine/flow-enrollments.js.map +1 -1
- package/src/lib/engine/run-event-actions.d.ts +57 -4
- package/src/lib/engine/run-event-actions.js +119 -19
- package/src/lib/engine/run-event-actions.js.map +1 -1
- package/src/lib/engine/run-org-automations.d.ts +75 -0
- package/src/lib/engine/run-org-automations.js +154 -0
- package/src/lib/engine/run-org-automations.js.map +1 -0
- package/src/lib/model/org-automations.d.ts +232 -0
- package/src/lib/model/org-automations.js +423 -0
- package/src/lib/model/org-automations.js.map +1 -0
- package/src/lib/plugin.js +26 -1
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/org-automations-routes.d.ts +88 -0
- package/src/lib/server/org-automations-routes.js +474 -0
- package/src/lib/server/org-automations-routes.js.map +1 -0
- package/src/lib/server-console.d.ts +2 -1
- package/src/lib/server-console.js +12 -2
- package/src/lib/server-console.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-workflows",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.181",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,16 +25,17 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-ui-next": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-ui-snackstack": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-util-email": "1.0.0-beta.
|
|
34
|
-
"@aglyn/shared-util-
|
|
35
|
-
"@aglyn/
|
|
36
|
-
"@aglyn/tenant-
|
|
37
|
-
"@aglyn/tenant-
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.181",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.0.0-beta.181",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.181",
|
|
31
|
+
"@aglyn/shared-ui-next": "1.0.0-beta.181",
|
|
32
|
+
"@aglyn/shared-ui-snackstack": "1.0.0-beta.181",
|
|
33
|
+
"@aglyn/shared-util-email": "1.0.0-beta.181",
|
|
34
|
+
"@aglyn/shared-util-http": "1.0.0-beta.181",
|
|
35
|
+
"@aglyn/shared-util-timestamp": "1.0.0-beta.181",
|
|
36
|
+
"@aglyn/tenant-data-admin": "1.0.0-beta.181",
|
|
37
|
+
"@aglyn/tenant-feature-instance": "1.0.0-beta.181",
|
|
38
|
+
"@aglyn/tenant-runtime": "1.0.0-beta.181",
|
|
38
39
|
"@swc/helpers": "0.5.23"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type HostActionTrigger, type HostActionTriggerCondition, type TriggerCombinator, type TriggerConditionOp } from '@aglyn/aglyn';
|
|
2
|
+
/**
|
|
3
|
+
* ONE TRIGGER-CONDITION EDITOR FOR EVERY AUTOMATION THAT HAS A TRIGGER.
|
|
4
|
+
*
|
|
5
|
+
* The structured payload conditions (AGL-557), chainable with AND/OR
|
|
6
|
+
* (AGL-565): the no-code sibling of the filter expression — "only when
|
|
7
|
+
* `subscribe` is not empty". A site action and an org automation (AGL-3302)
|
|
8
|
+
* take the same clauses and are judged by the same evaluator, so they are
|
|
9
|
+
* edited by the same rows.
|
|
10
|
+
*/
|
|
11
|
+
/** One editable condition row; a lone row with an empty op means "always run". */
|
|
12
|
+
export interface ConditionRowDraft {
|
|
13
|
+
op: '' | TriggerConditionOp;
|
|
14
|
+
field: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const EMPTY_CONDITION_ROW: ConditionRowDraft;
|
|
18
|
+
/**
|
|
19
|
+
* A stored trigger's clauses as editor rows. A legacy single-condition trigger
|
|
20
|
+
* normalizes to one row, and a trigger with none opens on the lone "always"
|
|
21
|
+
* row.
|
|
22
|
+
*/
|
|
23
|
+
export declare function conditionRowsFromTrigger(trigger: Pick<HostActionTrigger, 'condition' | 'conditions'> | null | undefined): ConditionRowDraft[];
|
|
24
|
+
/**
|
|
25
|
+
* The rows as the stored clause list, or nothing when every row says
|
|
26
|
+
* "always". Blank fields are kept, so the validator names what is missing.
|
|
27
|
+
*/
|
|
28
|
+
export declare function conditionsFromRows(rows: readonly ConditionRowDraft[], combinator: TriggerCombinator): {
|
|
29
|
+
conditions?: HostActionTriggerCondition[];
|
|
30
|
+
combinator?: TriggerCombinator;
|
|
31
|
+
};
|
|
32
|
+
export interface TriggerConditionRowsProps {
|
|
33
|
+
rows: readonly ConditionRowDraft[];
|
|
34
|
+
combinator: TriggerCombinator;
|
|
35
|
+
/** Replaces the rows, from the rows as they stand. */
|
|
36
|
+
onRowsChange: (update: (previous: ConditionRowDraft[]) => ConditionRowDraft[]) => void;
|
|
37
|
+
onCombinatorChange: (combinator: TriggerCombinator) => void;
|
|
38
|
+
}
|
|
39
|
+
/** The condition rows, "Add condition", and the AND/OR choice once there are two. */
|
|
40
|
+
export declare function TriggerConditionRows({ rows, combinator, onRowsChange, onCombinatorChange, }: TriggerConditionRowsProps): import("react").JSX.Element;
|
|
41
|
+
export declare namespace TriggerConditionRows {
|
|
42
|
+
var displayName: string;
|
|
43
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
+
import { ACTION_MAX_CONDITIONS, normalizeTriggerConditions } from "@aglyn/aglyn";
|
|
20
|
+
import { Button, IconButton, MenuItem, Stack, TextField, Typography } from "@mui/material";
|
|
21
|
+
import { placeholderState } from "./automation-step-fields.component.js";
|
|
22
|
+
export const EMPTY_CONDITION_ROW = {
|
|
23
|
+
op: '',
|
|
24
|
+
field: '',
|
|
25
|
+
value: ''
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A stored trigger's clauses as editor rows. A legacy single-condition trigger
|
|
29
|
+
* normalizes to one row, and a trigger with none opens on the lone "always"
|
|
30
|
+
* row.
|
|
31
|
+
*/ export function conditionRowsFromTrigger(trigger) {
|
|
32
|
+
const rows = normalizeTriggerConditions(trigger).map((condition)=>{
|
|
33
|
+
var _condition_op, _condition_field, _condition_value;
|
|
34
|
+
return {
|
|
35
|
+
op: (_condition_op = condition.op) != null ? _condition_op : '',
|
|
36
|
+
field: (_condition_field = condition.field) != null ? _condition_field : '',
|
|
37
|
+
value: (_condition_value = condition.value) != null ? _condition_value : ''
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
return rows.length ? rows : [
|
|
41
|
+
EMPTY_CONDITION_ROW
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The rows as the stored clause list, or nothing when every row says
|
|
46
|
+
* "always". Blank fields are kept, so the validator names what is missing.
|
|
47
|
+
*/ export function conditionsFromRows(rows, combinator) {
|
|
48
|
+
if (!rows.some((row)=>row.op)) return {};
|
|
49
|
+
return {
|
|
50
|
+
conditions: rows.filter((row)=>row.op).map((row)=>_extends({
|
|
51
|
+
field: row.field.trim(),
|
|
52
|
+
op: row.op
|
|
53
|
+
}, row.op !== 'notEmpty' ? {
|
|
54
|
+
value: row.value.trim()
|
|
55
|
+
} : {})),
|
|
56
|
+
combinator
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** The condition rows, "Add condition", and the AND/OR choice once there are two. */ export function TriggerConditionRows({ rows, combinator, onRowsChange, onCombinatorChange }) {
|
|
60
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
61
|
+
children: [
|
|
62
|
+
rows.map((row, index)=>/*#__PURE__*/ _jsxs(Stack, {
|
|
63
|
+
direction: "row",
|
|
64
|
+
spacing: 1,
|
|
65
|
+
sx: {
|
|
66
|
+
alignItems: 'center'
|
|
67
|
+
},
|
|
68
|
+
children: [
|
|
69
|
+
index > 0 ? /*#__PURE__*/ _jsx(Typography, {
|
|
70
|
+
variant: "caption",
|
|
71
|
+
color: "text.secondary",
|
|
72
|
+
children: combinator === 'or' ? 'or' : 'and'
|
|
73
|
+
}) : null,
|
|
74
|
+
/*#__PURE__*/ _jsxs(TextField, {
|
|
75
|
+
select: true,
|
|
76
|
+
label: index === 0 ? 'Only run when' : 'Condition',
|
|
77
|
+
value: row.op,
|
|
78
|
+
onChange: (event)=>onRowsChange((previous)=>previous.map((previousRow, index2)=>index2 === index ? _extends({}, previousRow, {
|
|
79
|
+
op: event.target.value
|
|
80
|
+
}) : previousRow)),
|
|
81
|
+
size: "small",
|
|
82
|
+
sx: {
|
|
83
|
+
minWidth: 180
|
|
84
|
+
},
|
|
85
|
+
children: [
|
|
86
|
+
rows.length === 1 ? /*#__PURE__*/ _jsx(MenuItem, {
|
|
87
|
+
value: "",
|
|
88
|
+
children: 'Always (no condition)'
|
|
89
|
+
}) : null,
|
|
90
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
91
|
+
value: "notEmpty",
|
|
92
|
+
children: 'A field is not empty'
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
95
|
+
value: "equals",
|
|
96
|
+
children: 'A field equals…'
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
99
|
+
value: "contains",
|
|
100
|
+
children: 'A field contains…'
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
}),
|
|
104
|
+
row.op ? /*#__PURE__*/ _jsx(TextField, {
|
|
105
|
+
label: "Field",
|
|
106
|
+
placeholder: "subscribe",
|
|
107
|
+
value: row.field,
|
|
108
|
+
onChange: (event)=>onRowsChange((previous)=>previous.map((previousRow, index2)=>index2 === index ? _extends({}, previousRow, {
|
|
109
|
+
field: event.target.value
|
|
110
|
+
}) : previousRow)),
|
|
111
|
+
size: "small",
|
|
112
|
+
sx: {
|
|
113
|
+
flex: 1
|
|
114
|
+
}
|
|
115
|
+
}) : null,
|
|
116
|
+
row.op === 'equals' || row.op === 'contains' ? /*#__PURE__*/ _jsx(TextField, _extends({
|
|
117
|
+
label: "Value",
|
|
118
|
+
placeholder: "Yes"
|
|
119
|
+
}, placeholderState(row.value, 'Replace the placeholder with the value to match'), {
|
|
120
|
+
value: row.value,
|
|
121
|
+
onChange: (event)=>onRowsChange((previous)=>previous.map((previousRow, index2)=>index2 === index ? _extends({}, previousRow, {
|
|
122
|
+
value: event.target.value
|
|
123
|
+
}) : previousRow)),
|
|
124
|
+
size: "small",
|
|
125
|
+
sx: {
|
|
126
|
+
flex: 1
|
|
127
|
+
}
|
|
128
|
+
})) : null,
|
|
129
|
+
rows.length > 1 ? /*#__PURE__*/ _jsx(IconButton, {
|
|
130
|
+
size: "small",
|
|
131
|
+
"aria-label": "remove condition",
|
|
132
|
+
onClick: ()=>onRowsChange((previous)=>previous.length > 1 ? previous.filter((_, index2)=>index2 !== index) : [
|
|
133
|
+
EMPTY_CONDITION_ROW
|
|
134
|
+
]),
|
|
135
|
+
children: '×'
|
|
136
|
+
}) : null
|
|
137
|
+
]
|
|
138
|
+
}, index)),
|
|
139
|
+
rows.every((row)=>row.op) ? /*#__PURE__*/ _jsxs(Stack, {
|
|
140
|
+
direction: "row",
|
|
141
|
+
spacing: 1,
|
|
142
|
+
sx: {
|
|
143
|
+
alignItems: 'center'
|
|
144
|
+
},
|
|
145
|
+
children: [
|
|
146
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
147
|
+
size: "small",
|
|
148
|
+
disabled: rows.length >= ACTION_MAX_CONDITIONS,
|
|
149
|
+
onClick: ()=>onRowsChange((previous)=>[
|
|
150
|
+
...previous,
|
|
151
|
+
// New rows start on the simplest operator so the field input
|
|
152
|
+
// is immediately visible.
|
|
153
|
+
{
|
|
154
|
+
op: 'notEmpty',
|
|
155
|
+
field: '',
|
|
156
|
+
value: ''
|
|
157
|
+
}
|
|
158
|
+
]),
|
|
159
|
+
children: 'Add condition'
|
|
160
|
+
}),
|
|
161
|
+
rows.length >= 2 ? // AND/OR combinator (AGL-565); applies to every row.
|
|
162
|
+
/*#__PURE__*/ _jsxs(TextField, {
|
|
163
|
+
select: true,
|
|
164
|
+
label: "Match",
|
|
165
|
+
value: combinator,
|
|
166
|
+
onChange: (event)=>onCombinatorChange(event.target.value),
|
|
167
|
+
size: "small",
|
|
168
|
+
sx: {
|
|
169
|
+
minWidth: 220
|
|
170
|
+
},
|
|
171
|
+
children: [
|
|
172
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
173
|
+
value: "and",
|
|
174
|
+
children: 'All conditions match (AND)'
|
|
175
|
+
}),
|
|
176
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
177
|
+
value: "or",
|
|
178
|
+
children: 'Any condition matches (OR)'
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
}) : null
|
|
182
|
+
]
|
|
183
|
+
}) : null
|
|
184
|
+
]
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
TriggerConditionRows.displayName = 'TriggerConditionRows';
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=automation-trigger-conditions.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/components/automation-trigger-conditions.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n ACTION_MAX_CONDITIONS,\n type HostActionTrigger,\n type HostActionTriggerCondition,\n normalizeTriggerConditions,\n type TriggerCombinator,\n type TriggerConditionOp,\n} from '@aglyn/aglyn'\nimport {\n Button,\n IconButton,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { placeholderState } from './automation-step-fields.component'\n\n/**\n * ONE TRIGGER-CONDITION EDITOR FOR EVERY AUTOMATION THAT HAS A TRIGGER.\n *\n * The structured payload conditions (AGL-557), chainable with AND/OR\n * (AGL-565): the no-code sibling of the filter expression — \"only when\n * `subscribe` is not empty\". A site action and an org automation (AGL-3302)\n * take the same clauses and are judged by the same evaluator, so they are\n * edited by the same rows.\n */\n\n/** One editable condition row; a lone row with an empty op means \"always run\". */\nexport interface ConditionRowDraft {\n op: '' | TriggerConditionOp\n field: string\n value: string\n}\n\nexport const EMPTY_CONDITION_ROW: ConditionRowDraft = {\n op: '',\n field: '',\n value: '',\n}\n\n/**\n * A stored trigger's clauses as editor rows. A legacy single-condition trigger\n * normalizes to one row, and a trigger with none opens on the lone \"always\"\n * row.\n */\nexport function conditionRowsFromTrigger(\n trigger:\n | Pick<HostActionTrigger, 'condition' | 'conditions'>\n | null\n | undefined,\n): ConditionRowDraft[] {\n const rows = normalizeTriggerConditions(trigger).map(\n (condition): ConditionRowDraft => ({\n op: condition.op ?? '',\n field: condition.field ?? '',\n value: condition.value ?? '',\n }),\n )\n return rows.length ? rows : [EMPTY_CONDITION_ROW]\n}\n\n/**\n * The rows as the stored clause list, or nothing when every row says\n * \"always\". Blank fields are kept, so the validator names what is missing.\n */\nexport function conditionsFromRows(\n rows: readonly ConditionRowDraft[],\n combinator: TriggerCombinator,\n): { conditions?: HostActionTriggerCondition[]; combinator?: TriggerCombinator } {\n if (!rows.some((row) => row.op)) return {}\n return {\n conditions: rows\n .filter((row) => row.op)\n .map((row) => ({\n field: row.field.trim(),\n op: row.op as TriggerConditionOp,\n ...(row.op !== 'notEmpty' ? { value: row.value.trim() } : {}),\n })),\n combinator,\n }\n}\n\nexport interface TriggerConditionRowsProps {\n rows: readonly ConditionRowDraft[]\n combinator: TriggerCombinator\n /** Replaces the rows, from the rows as they stand. */\n onRowsChange: (\n update: (previous: ConditionRowDraft[]) => ConditionRowDraft[],\n ) => void\n onCombinatorChange: (combinator: TriggerCombinator) => void\n}\n\n/** The condition rows, \"Add condition\", and the AND/OR choice once there are two. */\nexport function TriggerConditionRows({\n rows,\n combinator,\n onRowsChange,\n onCombinatorChange,\n}: TriggerConditionRowsProps) {\n return (\n <>\n {rows.map((row, index) => (\n <Stack\n key={index}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n {index > 0 ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {combinator === 'or' ? 'or' : 'and'}\n </Typography>\n ) : null}\n <TextField\n select\n label={index === 0 ? 'Only run when' : 'Condition'}\n value={row.op}\n onChange={(event) =>\n onRowsChange((previous) =>\n previous.map((previousRow, index2) =>\n index2 === index\n ? {\n ...previousRow,\n op: event.target.value as ConditionRowDraft['op'],\n }\n : previousRow,\n ),\n )\n }\n size=\"small\"\n sx={{ minWidth: 180 }}\n >\n {/* \"Always\" only exists while this is the sole row —\n multi-row chains clear by removing rows instead. */}\n {rows.length === 1 ? (\n <MenuItem value=\"\">{'Always (no condition)'}</MenuItem>\n ) : null}\n <MenuItem value=\"notEmpty\">{'A field is not empty'}</MenuItem>\n <MenuItem value=\"equals\">{'A field equals…'}</MenuItem>\n <MenuItem value=\"contains\">{'A field contains…'}</MenuItem>\n </TextField>\n {row.op ? (\n <TextField\n label=\"Field\"\n placeholder=\"subscribe\"\n value={row.field}\n onChange={(event) =>\n onRowsChange((previous) =>\n previous.map((previousRow, index2) =>\n index2 === index\n ? { ...previousRow, field: event.target.value }\n : previousRow,\n ),\n )\n }\n size=\"small\"\n sx={{ flex: 1 }}\n />\n ) : null}\n {row.op === 'equals' || row.op === 'contains' ? (\n <TextField\n label=\"Value\"\n placeholder=\"Yes\"\n {...placeholderState(\n row.value,\n 'Replace the placeholder with the value to match',\n )}\n value={row.value}\n onChange={(event) =>\n onRowsChange((previous) =>\n previous.map((previousRow, index2) =>\n index2 === index\n ? { ...previousRow, value: event.target.value }\n : previousRow,\n ),\n )\n }\n size=\"small\"\n sx={{ flex: 1 }}\n />\n ) : null}\n {rows.length > 1 ? (\n <IconButton\n size=\"small\"\n aria-label=\"remove condition\"\n onClick={() =>\n onRowsChange((previous) =>\n previous.length > 1\n ? previous.filter((_, index2) => index2 !== index)\n : [EMPTY_CONDITION_ROW],\n )\n }\n >\n {'×'}\n </IconButton>\n ) : null}\n </Stack>\n ))}\n {rows.every((row) => row.op) ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Button\n size=\"small\"\n disabled={rows.length >= ACTION_MAX_CONDITIONS}\n onClick={() =>\n onRowsChange((previous) => [\n ...previous,\n // New rows start on the simplest operator so the field input\n // is immediately visible.\n { op: 'notEmpty', field: '', value: '' },\n ])\n }\n >\n {'Add condition'}\n </Button>\n {rows.length >= 2 ? (\n // AND/OR combinator (AGL-565); applies to every row.\n <TextField\n select\n label=\"Match\"\n value={combinator}\n onChange={(event) =>\n onCombinatorChange(event.target.value as TriggerCombinator)\n }\n size=\"small\"\n sx={{ minWidth: 220 }}\n >\n <MenuItem value=\"and\">{'All conditions match (AND)'}</MenuItem>\n <MenuItem value=\"or\">{'Any condition matches (OR)'}</MenuItem>\n </TextField>\n ) : null}\n </Stack>\n ) : null}\n </>\n )\n}\nTriggerConditionRows.displayName = 'TriggerConditionRows'\n"],"names":["ACTION_MAX_CONDITIONS","normalizeTriggerConditions","Button","IconButton","MenuItem","Stack","TextField","Typography","placeholderState","EMPTY_CONDITION_ROW","op","field","value","conditionRowsFromTrigger","trigger","rows","map","condition","length","conditionsFromRows","combinator","some","row","conditions","filter","trim","TriggerConditionRows","onRowsChange","onCombinatorChange","index","direction","spacing","sx","alignItems","variant","color","select","label","onChange","event","previous","previousRow","index2","target","size","minWidth","placeholder","flex","aria-label","onClick","_","every","disabled","displayName"],"mappings":"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"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/ 'use client';
|
|
17
17
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
18
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
-
import {
|
|
19
|
+
import { ACTION_MAX_STEPS, checkEntitlement, createResourceUid, CRM_ACTION_RECIPES, ELEMENT_SCOPED_SITE_EVENTS, HOST_ACTION_STEP_LABELS, HOST_EVENT_TYPES, hostActionDocument, hostActionRecipeId, hostEventLabel, hostEventPayloadHint, isSiteEventType, pluginDocsHelp, SITE_EVENT_TYPES, validateHostAction } from "@aglyn/aglyn";
|
|
20
20
|
import { automationPlaceholders, describeAutomationPlaceholder } from "@aglyn/aglyn/app-utils/automation-placeholders";
|
|
21
21
|
import { useConsoleWidgetSlot } from "@aglyn/aglyn/app-utils/console-widget-slot-context";
|
|
22
22
|
import { CardDisplay, useConfirmationContext } from "@aglyn/shared-ui-jsx";
|
|
@@ -24,11 +24,12 @@ import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.
|
|
|
24
24
|
import { TABLE_PAGE_SIZE_DEFAULT } from "@aglyn/shared-ui-jsx/const/table-pagination";
|
|
25
25
|
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
26
26
|
import { Timestamp } from "@aglyn/shared-util-timestamp";
|
|
27
|
-
import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle,
|
|
27
|
+
import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, ListItemText, Menu, MenuItem, Stack, Switch, TextField, Typography } from "@mui/material";
|
|
28
28
|
import { collection, doc, setDoc, updateDoc } from "firebase/firestore";
|
|
29
29
|
import { useCallback, useMemo, useRef, useState } from "react";
|
|
30
30
|
import { ceilingedWindow, collectionCeiling, useFirestore, useFirestoreCollection, useHostResourceApi, writeGuardedBySeed } from "@aglyn/tenant-feature-instance";
|
|
31
|
-
import { AutomationStepFields, defaultStep
|
|
31
|
+
import { AutomationStepFields, defaultStep } from "./automation-step-fields.component.js";
|
|
32
|
+
import { conditionRowsFromTrigger, conditionsFromRows, EMPTY_CONDITION_ROW, TriggerConditionRows } from "./automation-trigger-conditions.component.js";
|
|
32
33
|
import HostRunHistoryCard from "./host-run-history-card.component.js";
|
|
33
34
|
import { EDITOR_OPTION_CEILING, useAutomationStepPickers } from "./use-automation-step-pickers.js";
|
|
34
35
|
const CUSTOM_EVENT_VALUE = '__custom__';
|
|
@@ -42,11 +43,6 @@ const CUSTOM_EVENT_VALUE = '__custom__';
|
|
|
42
43
|
* `ACTIONS_MAX_PER_HOST` is 500, so the ceiling really can bite and the probe
|
|
43
44
|
* beside it is what says when it has.
|
|
44
45
|
*/ const ACTION_CEILING = 100;
|
|
45
|
-
const EMPTY_CONDITION_ROW = {
|
|
46
|
-
op: '',
|
|
47
|
-
field: '',
|
|
48
|
-
value: ''
|
|
49
|
-
};
|
|
50
46
|
/** Every Actions step, as the builder's "Do" picker offers it. */ const ACTION_STEP_KINDS = Object.entries(HOST_ACTION_STEP_LABELS).map(([value, label])=>({
|
|
51
47
|
value,
|
|
52
48
|
label
|
|
@@ -65,14 +61,6 @@ const EMPTY_CONDITION_ROW = {
|
|
|
65
61
|
var _ref, _action_name, _ref1, _ref2, _ref3, _action_steps, _ref4;
|
|
66
62
|
var _action_trigger, _action_trigger1, _action_trigger2, _action_trigger3, _action_trigger4, _action_trigger5, _action_trigger6, _action_trigger7, _action_trigger8, _action_trigger9, _action_trigger10, _action_trigger11, _action_trigger12;
|
|
67
63
|
const builtIn = HOST_EVENT_TYPES.includes((_action_trigger = action.trigger) == null ? void 0 : _action_trigger.event) || isSiteEventType(String((_ref = (_action_trigger1 = action.trigger) == null ? void 0 : _action_trigger1.event) != null ? _ref : ''));
|
|
68
|
-
const rows = normalizeTriggerConditions(action.trigger).map((condition)=>{
|
|
69
|
-
var _condition_op, _condition_field, _condition_value;
|
|
70
|
-
return {
|
|
71
|
-
op: (_condition_op = condition.op) != null ? _condition_op : '',
|
|
72
|
-
field: (_condition_field = condition.field) != null ? _condition_field : '',
|
|
73
|
-
value: (_condition_value = condition.value) != null ? _condition_value : ''
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
64
|
return {
|
|
77
65
|
id,
|
|
78
66
|
name: (_action_name = action.name) != null ? _action_name : '',
|
|
@@ -91,9 +79,7 @@ const EMPTY_CONDITION_ROW = {
|
|
|
91
79
|
steps: (_action_steps = action.steps) != null ? _action_steps : [],
|
|
92
80
|
enabled: action.enabled !== false,
|
|
93
81
|
customEvent: builtIn ? '' : (_ref4 = (_action_trigger11 = action.trigger) == null ? void 0 : _action_trigger11.event) != null ? _ref4 : '',
|
|
94
|
-
conditionRows:
|
|
95
|
-
EMPTY_CONDITION_ROW
|
|
96
|
-
],
|
|
82
|
+
conditionRows: conditionRowsFromTrigger(action.trigger),
|
|
97
83
|
conditionCombinator: ((_action_trigger12 = action.trigger) == null ? void 0 : _action_trigger12.combinator) === 'or' ? 'or' : 'and',
|
|
98
84
|
// A recipe stamps what it builds, and a stored action carries what it
|
|
99
85
|
// was saved with — one reader for both doors, unknown kept unknown.
|
|
@@ -107,7 +93,7 @@ const EMPTY_CONDITION_ROW = {
|
|
|
107
93
|
* event, dataset append). Runs server-side via runEventActions; paid
|
|
108
94
|
* feature (`actions` flag, Pro+, `actionRunsPerMonth` metered).
|
|
109
95
|
*/ export function HostActionsCard(props) {
|
|
110
|
-
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _hostEventPayloadHint, _ref6, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19,
|
|
96
|
+
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _hostEventPayloadHint, _ref6, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _runsFor_name;
|
|
111
97
|
var _CRM_ACTION_RECIPES_find;
|
|
112
98
|
const { hostId, org } = props;
|
|
113
99
|
// Org-shared data root (AGL-237). Null until the org lookup settles
|
|
@@ -408,15 +394,7 @@ const EMPTY_CONDITION_ROW = {
|
|
|
408
394
|
cooldownMinutes: Number(draft.trigger.cooldownMinutes)
|
|
409
395
|
} : {}, draft.trigger.everyTime === true ? {
|
|
410
396
|
everyTime: true
|
|
411
|
-
} : {}, draft.conditionRows.
|
|
412
|
-
conditions: draft.conditionRows.filter((row)=>row.op).map((row)=>_extends({
|
|
413
|
-
field: row.field.trim(),
|
|
414
|
-
op: row.op
|
|
415
|
-
}, row.op !== 'notEmpty' ? {
|
|
416
|
-
value: row.value.trim()
|
|
417
|
-
} : {})),
|
|
418
|
-
combinator: draft.conditionCombinator
|
|
419
|
-
} : {}),
|
|
397
|
+
} : {}, conditionsFromRows(draft.conditionRows, draft.conditionCombinator)),
|
|
420
398
|
steps: draft.steps,
|
|
421
399
|
enabled: draft.enabled !== false
|
|
422
400
|
}, draft.recipe !== undefined ? {
|
|
@@ -833,152 +811,25 @@ const EMPTY_CONDITION_ROW = {
|
|
|
833
811
|
})
|
|
834
812
|
]
|
|
835
813
|
}),
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
index > 0 ? /*#__PURE__*/ _jsx(Typography, {
|
|
846
|
-
variant: "caption",
|
|
847
|
-
color: "text.secondary",
|
|
848
|
-
children: (draft == null ? void 0 : draft.conditionCombinator) === 'or' ? 'or' : 'and'
|
|
849
|
-
}) : null,
|
|
850
|
-
/*#__PURE__*/ _jsxs(TextField, {
|
|
851
|
-
select: true,
|
|
852
|
-
label: index === 0 ? 'Only run when' : 'Condition',
|
|
853
|
-
value: row.op,
|
|
854
|
-
onChange: (event)=>patch((previous)=>_extends({}, previous, {
|
|
855
|
-
conditionRows: previous.conditionRows.map((previousRow, index2)=>index2 === index ? _extends({}, previousRow, {
|
|
856
|
-
op: event.target.value
|
|
857
|
-
}) : previousRow)
|
|
858
|
-
})),
|
|
859
|
-
size: "small",
|
|
860
|
-
sx: {
|
|
861
|
-
minWidth: 180
|
|
862
|
-
},
|
|
863
|
-
children: [
|
|
864
|
-
((_ref = draft == null ? void 0 : draft.conditionRows.length) != null ? _ref : 0) === 1 ? /*#__PURE__*/ _jsx(MenuItem, {
|
|
865
|
-
value: "",
|
|
866
|
-
children: 'Always (no condition)'
|
|
867
|
-
}) : null,
|
|
868
|
-
/*#__PURE__*/ _jsx(MenuItem, {
|
|
869
|
-
value: "notEmpty",
|
|
870
|
-
children: 'A field is not empty'
|
|
871
|
-
}),
|
|
872
|
-
/*#__PURE__*/ _jsx(MenuItem, {
|
|
873
|
-
value: "equals",
|
|
874
|
-
children: 'A field equals…'
|
|
875
|
-
}),
|
|
876
|
-
/*#__PURE__*/ _jsx(MenuItem, {
|
|
877
|
-
value: "contains",
|
|
878
|
-
children: 'A field contains…'
|
|
879
|
-
})
|
|
880
|
-
]
|
|
881
|
-
}),
|
|
882
|
-
row.op ? /*#__PURE__*/ _jsx(TextField, {
|
|
883
|
-
label: "Field",
|
|
884
|
-
placeholder: "subscribe",
|
|
885
|
-
value: row.field,
|
|
886
|
-
onChange: (event)=>patch((previous)=>_extends({}, previous, {
|
|
887
|
-
conditionRows: previous.conditionRows.map((previousRow, index2)=>index2 === index ? _extends({}, previousRow, {
|
|
888
|
-
field: event.target.value
|
|
889
|
-
}) : previousRow)
|
|
890
|
-
})),
|
|
891
|
-
size: "small",
|
|
892
|
-
sx: {
|
|
893
|
-
flex: 1
|
|
894
|
-
}
|
|
895
|
-
}) : null,
|
|
896
|
-
row.op === 'equals' || row.op === 'contains' ? /*#__PURE__*/ _jsx(TextField, _extends({
|
|
897
|
-
label: "Value",
|
|
898
|
-
placeholder: "Yes"
|
|
899
|
-
}, placeholderState(row.value, 'Replace the placeholder with the value to match'), {
|
|
900
|
-
value: row.value,
|
|
901
|
-
onChange: (event)=>patch((previous)=>_extends({}, previous, {
|
|
902
|
-
conditionRows: previous.conditionRows.map((previousRow, index2)=>index2 === index ? _extends({}, previousRow, {
|
|
903
|
-
value: event.target.value
|
|
904
|
-
}) : previousRow)
|
|
905
|
-
})),
|
|
906
|
-
size: "small",
|
|
907
|
-
sx: {
|
|
908
|
-
flex: 1
|
|
909
|
-
}
|
|
910
|
-
})) : null,
|
|
911
|
-
((_ref1 = draft == null ? void 0 : draft.conditionRows.length) != null ? _ref1 : 0) > 1 ? /*#__PURE__*/ _jsx(IconButton, {
|
|
912
|
-
size: "small",
|
|
913
|
-
"aria-label": "remove condition",
|
|
914
|
-
onClick: ()=>patch((previous)=>_extends({}, previous, {
|
|
915
|
-
conditionRows: previous.conditionRows.length > 1 ? previous.conditionRows.filter((_, index2)=>index2 !== index) : [
|
|
916
|
-
EMPTY_CONDITION_ROW
|
|
917
|
-
]
|
|
918
|
-
})),
|
|
919
|
-
children: '×'
|
|
920
|
-
}) : null
|
|
921
|
-
]
|
|
922
|
-
}, index);
|
|
814
|
+
/*#__PURE__*/ _jsx(TriggerConditionRows, {
|
|
815
|
+
rows: (_ref7 = draft == null ? void 0 : draft.conditionRows) != null ? _ref7 : [],
|
|
816
|
+
combinator: (_ref8 = draft == null ? void 0 : draft.conditionCombinator) != null ? _ref8 : 'and',
|
|
817
|
+
onRowsChange: (update)=>patch((previous)=>_extends({}, previous, {
|
|
818
|
+
conditionRows: update(previous.conditionRows)
|
|
819
|
+
})),
|
|
820
|
+
onCombinatorChange: (combinator)=>patch((previous)=>_extends({}, previous, {
|
|
821
|
+
conditionCombinator: combinator
|
|
822
|
+
}))
|
|
923
823
|
}),
|
|
924
|
-
(draft == null ? void 0 : draft.
|
|
925
|
-
direction: "row",
|
|
926
|
-
spacing: 1,
|
|
927
|
-
sx: {
|
|
928
|
-
alignItems: 'center'
|
|
929
|
-
},
|
|
930
|
-
children: [
|
|
931
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
932
|
-
size: "small",
|
|
933
|
-
disabled: ((_ref8 = draft == null ? void 0 : draft.conditionRows.length) != null ? _ref8 : 0) >= ACTION_MAX_CONDITIONS,
|
|
934
|
-
onClick: ()=>patch((previous)=>_extends({}, previous, {
|
|
935
|
-
conditionRows: [
|
|
936
|
-
...previous.conditionRows,
|
|
937
|
-
// New rows start on the simplest operator so the
|
|
938
|
-
// field input is immediately visible.
|
|
939
|
-
{
|
|
940
|
-
op: 'notEmpty',
|
|
941
|
-
field: '',
|
|
942
|
-
value: ''
|
|
943
|
-
}
|
|
944
|
-
]
|
|
945
|
-
})),
|
|
946
|
-
children: 'Add condition'
|
|
947
|
-
}),
|
|
948
|
-
((_ref9 = draft == null ? void 0 : draft.conditionRows.length) != null ? _ref9 : 0) >= 2 ? // AND/OR combinator (AGL-565); applies to every row.
|
|
949
|
-
/*#__PURE__*/ _jsxs(TextField, {
|
|
950
|
-
select: true,
|
|
951
|
-
label: "Match",
|
|
952
|
-
value: (_ref10 = draft == null ? void 0 : draft.conditionCombinator) != null ? _ref10 : 'and',
|
|
953
|
-
onChange: (event)=>patch((previous)=>_extends({}, previous, {
|
|
954
|
-
conditionCombinator: event.target.value
|
|
955
|
-
})),
|
|
956
|
-
size: "small",
|
|
957
|
-
sx: {
|
|
958
|
-
minWidth: 220
|
|
959
|
-
},
|
|
960
|
-
children: [
|
|
961
|
-
/*#__PURE__*/ _jsx(MenuItem, {
|
|
962
|
-
value: "and",
|
|
963
|
-
children: 'All conditions match (AND)'
|
|
964
|
-
}),
|
|
965
|
-
/*#__PURE__*/ _jsx(MenuItem, {
|
|
966
|
-
value: "or",
|
|
967
|
-
children: 'Any condition matches (OR)'
|
|
968
|
-
})
|
|
969
|
-
]
|
|
970
|
-
}) : null
|
|
971
|
-
]
|
|
972
|
-
}) : null,
|
|
973
|
-
isSiteEventType((_ref11 = draft == null ? void 0 : draft.trigger.event) != null ? _ref11 : '') ? // Site-event config (AGL-256): what/where the trigger watches.
|
|
824
|
+
isSiteEventType((_ref9 = draft == null ? void 0 : draft.trigger.event) != null ? _ref9 : '') ? // Site-event config (AGL-256): what/where the trigger watches.
|
|
974
825
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
975
826
|
direction: "row",
|
|
976
827
|
spacing: 1,
|
|
977
828
|
children: [
|
|
978
|
-
ELEMENT_SCOPED_SITE_EVENTS.includes((
|
|
829
|
+
ELEMENT_SCOPED_SITE_EVENTS.includes((_ref10 = draft == null ? void 0 : draft.trigger.event) != null ? _ref10 : '') ? /*#__PURE__*/ _jsx(TextField, {
|
|
979
830
|
label: "CSS selector",
|
|
980
831
|
placeholder: "#pricing-table",
|
|
981
|
-
value: (
|
|
832
|
+
value: (_ref11 = draft == null ? void 0 : draft.trigger.selector) != null ? _ref11 : '',
|
|
982
833
|
onChange: (event)=>patch((previous)=>_extends({}, previous, {
|
|
983
834
|
trigger: _extends({}, previous.trigger, {
|
|
984
835
|
selector: event.target.value
|
|
@@ -992,10 +843,10 @@ const EMPTY_CONDITION_ROW = {
|
|
|
992
843
|
[
|
|
993
844
|
'scrollDepth',
|
|
994
845
|
'timeOnPage'
|
|
995
|
-
].includes((
|
|
846
|
+
].includes((_ref12 = draft == null ? void 0 : draft.trigger.event) != null ? _ref12 : '') ? /*#__PURE__*/ _jsx(TextField, {
|
|
996
847
|
type: "number",
|
|
997
848
|
label: (draft == null ? void 0 : draft.trigger.event) === 'scrollDepth' ? 'Scroll %' : 'Seconds',
|
|
998
|
-
value: (
|
|
849
|
+
value: (_ref13 = draft == null ? void 0 : draft.trigger.threshold) != null ? _ref13 : '',
|
|
999
850
|
onChange: (event)=>patch((previous)=>_extends({}, previous, {
|
|
1000
851
|
trigger: _extends({}, previous.trigger, {
|
|
1001
852
|
threshold: Number(event.target.value)
|
|
@@ -1009,7 +860,7 @@ const EMPTY_CONDITION_ROW = {
|
|
|
1009
860
|
/*#__PURE__*/ _jsx(TextField, {
|
|
1010
861
|
label: "Only on pages (optional)",
|
|
1011
862
|
placeholder: "/pricing or /blog/*",
|
|
1012
|
-
value: (
|
|
863
|
+
value: (_ref14 = draft == null ? void 0 : draft.trigger.pathPattern) != null ? _ref14 : '',
|
|
1013
864
|
onChange: (event)=>patch((previous)=>_extends({}, previous, {
|
|
1014
865
|
trigger: _extends({}, previous.trigger, {
|
|
1015
866
|
pathPattern: event.target.value
|
|
@@ -1071,7 +922,7 @@ const EMPTY_CONDITION_ROW = {
|
|
|
1071
922
|
sx: {
|
|
1072
923
|
width: 150
|
|
1073
924
|
},
|
|
1074
|
-
value: (
|
|
925
|
+
value: (_ref15 = draft == null ? void 0 : draft.trigger.cooldownMinutes) != null ? _ref15 : 60,
|
|
1075
926
|
onChange: (event)=>patch((previous)=>_extends({}, previous, {
|
|
1076
927
|
trigger: _extends({}, previous.trigger, {
|
|
1077
928
|
cooldownMinutes: Number(event.target.value)
|
|
@@ -1085,7 +936,7 @@ const EMPTY_CONDITION_ROW = {
|
|
|
1085
936
|
color: "text.secondary",
|
|
1086
937
|
children: 'Steps (run in order)'
|
|
1087
938
|
}),
|
|
1088
|
-
((
|
|
939
|
+
((_ref16 = draft == null ? void 0 : draft.steps) != null ? _ref16 : []).map((step, index)=>/*#__PURE__*/ _jsx(AutomationStepFields, {
|
|
1089
940
|
step: step,
|
|
1090
941
|
index: index,
|
|
1091
942
|
kind: step.type,
|
|
@@ -1101,7 +952,7 @@ const EMPTY_CONDITION_ROW = {
|
|
|
1101
952
|
sx: {
|
|
1102
953
|
alignSelf: 'flex-start'
|
|
1103
954
|
},
|
|
1104
|
-
disabled: ((
|
|
955
|
+
disabled: ((_ref17 = draft == null ? void 0 : draft.steps.length) != null ? _ref17 : 0) >= ACTION_MAX_STEPS,
|
|
1105
956
|
onClick: ()=>patch((previous)=>_extends({}, previous, {
|
|
1106
957
|
steps: [
|
|
1107
958
|
...previous.steps,
|
|
@@ -1136,7 +987,7 @@ const EMPTY_CONDITION_ROW = {
|
|
|
1136
987
|
fullWidth: true,
|
|
1137
988
|
children: [
|
|
1138
989
|
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
1139
|
-
children: (
|
|
990
|
+
children: (_ref18 = formPickFor == null ? void 0 : formPickFor.title) != null ? _ref18 : ''
|
|
1140
991
|
}),
|
|
1141
992
|
/*#__PURE__*/ _jsxs(DialogContent, {
|
|
1142
993
|
sx: {
|
|
@@ -1199,7 +1050,7 @@ const EMPTY_CONDITION_ROW = {
|
|
|
1199
1050
|
fullWidth: true,
|
|
1200
1051
|
children: [
|
|
1201
1052
|
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
1202
|
-
children: `Runs — ${(
|
|
1053
|
+
children: `Runs — ${(_ref19 = runsFor == null ? void 0 : runsFor.name) != null ? _ref19 : ''}`
|
|
1203
1054
|
}),
|
|
1204
1055
|
/*#__PURE__*/ _jsx(DialogContent, {
|
|
1205
1056
|
children: runsFor ? /*#__PURE__*/ _jsx(HostRunHistoryCard, {
|