@conduction/nextcloud-vue 2.56.0-beta.74 → 2.56.0-beta.75
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/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue.js +1 -1
- package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue2.js +12 -1
- package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue2.js.map +1 -1
- package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue3.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue.js +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js +10 -8
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js.map +1 -1
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js +95 -88
- package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue.js +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js +86 -8
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js +137 -121
- package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue.js +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue2.js +56 -4
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue3.js +166 -70
- package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue.js +9 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue2.js +123 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue2.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue3.js +268 -0
- package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue3.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue.js +9 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue2.js +49 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue2.js.map +1 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue3.js +41 -0
- package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue3.js.map +1 -0
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +116 -8
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js +110 -58
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js +78 -1
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js +44 -3
- package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +90 -75
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +46 -22
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
- package/dist/esm/composables/indexSources.js +24 -4
- package/dist/esm/composables/indexSources.js.map +1 -1
- package/dist/esm/composables/useFlowStore.js +75 -4
- package/dist/esm/composables/useFlowStore.js.map +1 -1
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue.js +1 -1
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue2.js +17 -0
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue2.js.map +1 -1
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue3.js +9 -1
- package/dist/esm/dialogs/CnFlowEdgeEditModal.vue3.js.map +1 -1
- package/dist/esm/dialogs/CnFlowEditModal.vue.js +1 -1
- package/dist/esm/dialogs/CnFlowEditModal.vue2.js +15 -0
- package/dist/esm/dialogs/CnFlowEditModal.vue2.js.map +1 -1
- package/dist/esm/dialogs/CnFlowEditModal.vue3.js +13 -3
- package/dist/esm/dialogs/CnFlowEditModal.vue3.js.map +1 -1
- package/dist/esm/dialogs/CnFlowStepPickerModal.vue.js +1 -1
- package/dist/esm/dialogs/CnFlowStepPickerModal.vue2.js +13 -1
- package/dist/esm/dialogs/CnFlowStepPickerModal.vue2.js.map +1 -1
- package/dist/esm/dialogs/CnFlowStepPickerModal.vue3.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/l10n/en.json.js +40 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +39 -1
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +566 -337
- package/dist/esm/utils/dialogWidths.js +6 -4
- package/dist/esm/utils/dialogWidths.js.map +1 -1
- package/dist/esm/utils/flowCondition.js +177 -0
- package/dist/esm/utils/flowCondition.js.map +1 -0
- package/dist/esm/utils/flowRunStatus.js +64 -1
- package/dist/esm/utils/flowRunStatus.js.map +1 -1
- package/dist/esm/utils/flowStepList.js +385 -0
- package/dist/esm/utils/flowStepList.js.map +1 -0
- package/dist/nextcloud-vue.cjs.js +12543 -10668
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +566 -337
- package/l10n/en.json +40 -1
- package/l10n/nl.json +39 -1
- package/package.json +1 -1
- package/src/components/CnBuildiqEditButton/CnBuildiqEditButton.vue +12 -1
- package/src/components/CnCellRenderer/CnCellRenderer.vue +8 -0
- package/src/components/CnFlowDetail/CnFlowDetail.vue +110 -12
- package/src/components/CnFlowDetail/CnFlowDryRunResult.vue +163 -5
- package/src/components/CnFlowDetail/CnFlowStepList.vue +408 -0
- package/src/components/CnFlowDetail/CnFlowViewSwitch.vue +117 -0
- package/src/components/CnFlowDetail/index.js +2 -0
- package/src/components/CnFlowsPage/CnFlowBoard.vue +182 -25
- package/src/components/CnFlowsPage/CnFlowEditorPage.vue +101 -3
- package/src/components/CnIndexPage/CnIndexPage.vue +29 -0
- package/src/components/index.js +1 -1
- package/src/composables/indexSources.js +24 -4
- package/src/composables/useFlowStore.js +75 -4
- package/src/css/index-page.css +4 -0
- package/src/dialogs/CnFlowEdgeEditModal.vue +28 -0
- package/src/dialogs/CnFlowEditModal.vue +26 -6
- package/src/dialogs/CnFlowStepPickerModal.vue +13 -1
- package/src/index.js +2 -0
- package/src/utils/dialogWidths.js +6 -4
- package/src/utils/flowCondition.js +173 -0
- package/src/utils/flowRunStatus.js +63 -0
- package/src/utils/flowStepList.js +381 -0
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
// SPDX-License-Identifier: EUPL-1.2
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The dialog widths of the screens canon (section 5 of UNIFORM-canon.md), by
|
|
6
|
+
* role. `browse` is the search-and-pick dialog with a filter column beside its
|
|
7
|
+
* results (learniq/LqOpenLesmateriaal). No other width is reachable through the
|
|
8
|
+
* `width` prop of a `Cn*` dialog.
|
|
8
9
|
*
|
|
9
|
-
* @spec openspec/changes/screens-dialog-parity/specs/dialog-system/spec.md#requirement-a-dialog-takes-one-of-
|
|
10
|
+
* @spec openspec/changes/screens-dialog-parity/specs/dialog-system/spec.md#requirement-a-dialog-takes-one-of-four-widths
|
|
10
11
|
* @type {Readonly<Record<string, number>>}
|
|
11
12
|
*/
|
|
12
13
|
const DIALOG_WIDTHS = Object.freeze({
|
|
13
14
|
confirm: 560,
|
|
14
15
|
form: 640,
|
|
15
16
|
wizard: 720,
|
|
17
|
+
browse: 1120,
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialogWidths.js","sources":["../../../src/utils/dialogWidths.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\n/**\n * The
|
|
1
|
+
{"version":3,"file":"dialogWidths.js","sources":["../../../src/utils/dialogWidths.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\n/**\n * The dialog widths of the screens canon (section 5 of UNIFORM-canon.md), by\n * role. `browse` is the search-and-pick dialog with a filter column beside its\n * results (learniq/LqOpenLesmateriaal). No other width is reachable through the\n * `width` prop of a `Cn*` dialog.\n *\n * @spec openspec/changes/screens-dialog-parity/specs/dialog-system/spec.md#requirement-a-dialog-takes-one-of-four-widths\n * @type {Readonly<Record<string, number>>}\n */\nexport const DIALOG_WIDTHS = Object.freeze({\n\tconfirm: 560,\n\tform: 640,\n\twizard: 720,\n\tbrowse: 1120,\n})\n\n/**\n * Resolve a width role to its role name and pixel width. An unknown or empty\n * `width` falls back to the component's default role, and an unknown default\n * falls back to `form`.\n *\n * @param {string} [width] The `width` prop value.\n * @param {string} [defaultWidth] The component's default role.\n * @return {{role: string, px: number}} The role name and its width in px.\n */\nexport function resolveDialogWidth(width, defaultWidth) {\n\tconst role = [width, defaultWidth].find((candidate) => Object.hasOwn(DIALOG_WIDTHS, candidate)) || 'form'\n\treturn { role, px: DIALOG_WIDTHS[role] }\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;AAC3C,CAAC,OAAO,EAAE,GAAG;AACb,CAAC,IAAI,EAAE,GAAG;AACV,CAAC,MAAM,EAAE,GAAG;AACZ,CAAC,MAAM,EAAE,IAAI;AACb,CAAC,EAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE;AACxD,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,IAAI,OAAM;AAC1G,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE;AACzC;;;;"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { translate } from '@nextcloud/l10n';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
5
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Readable text for the JSONLogic that routes a flow.
|
|
11
|
+
*
|
|
12
|
+
* The engine evaluates a condition on one of a node's `exits`, and an edge
|
|
13
|
+
* names its exit in `fromExit`; `condition` on the edge itself is read as well
|
|
14
|
+
* because documents carry it. The JSONLogic stays where it is: this module only
|
|
15
|
+
* says it in words.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {unknown} value A candidate condition.
|
|
20
|
+
* @return {boolean} Whether it is a non-empty JSONLogic object.
|
|
21
|
+
*/
|
|
22
|
+
function isLogic(value) {
|
|
23
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length > 0
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {unknown} operand A `{ var }` operand or a plain value.
|
|
28
|
+
* @return {string|null} The field it reads, without the item's `json.` prefix, or null.
|
|
29
|
+
*/
|
|
30
|
+
function fieldOf(operand) {
|
|
31
|
+
if (operand === null || typeof operand !== 'object' || !('var' in operand)) {
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
const path = Array.isArray(operand.var) ? operand.var[0] : operand.var;
|
|
35
|
+
|
|
36
|
+
return String(path ?? '').replace(/^json\./, '')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {unknown} value A literal operand.
|
|
41
|
+
* @return {string} It as text.
|
|
42
|
+
*/
|
|
43
|
+
function literal(value) {
|
|
44
|
+
return Array.isArray(value) ? value.map(literal).join(', ') : String(value ?? '')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const comparisons = {
|
|
48
|
+
'==': (parts) => translate('nextcloud-vue', '{field} is {value}', parts),
|
|
49
|
+
'===': (parts) => translate('nextcloud-vue', '{field} is {value}', parts),
|
|
50
|
+
'!=': (parts) => translate('nextcloud-vue', '{field} is not {value}', parts),
|
|
51
|
+
'!==': (parts) => translate('nextcloud-vue', '{field} is not {value}', parts),
|
|
52
|
+
'>': (parts) => translate('nextcloud-vue', '{field} is more than {value}', parts),
|
|
53
|
+
'>=': (parts) => translate('nextcloud-vue', '{field} is at least {value}', parts),
|
|
54
|
+
'<': (parts) => translate('nextcloud-vue', '{field} is less than {value}', parts),
|
|
55
|
+
'<=': (parts) => translate('nextcloud-vue', '{field} is at most {value}', parts),
|
|
56
|
+
in: (parts) => translate('nextcloud-vue', '{field} is one of {value}', parts),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const presence = {
|
|
60
|
+
'!!': (field) => translate('nextcloud-vue', '{field} is filled in', { field }),
|
|
61
|
+
'!': (field) => translate('nextcloud-vue', '{field} is empty', { field }),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} op A comparison operator.
|
|
66
|
+
* @param {Array} args Its operands.
|
|
67
|
+
* @return {string|null} The sentence, or null when neither side is a plain field and value.
|
|
68
|
+
*/
|
|
69
|
+
function compare(op, args) {
|
|
70
|
+
const field = fieldOf(args[0]);
|
|
71
|
+
if (field === null || fieldOf(args[1]) !== null) {
|
|
72
|
+
return null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return comparisons[op]({ field, value: literal(args[1]) })
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} op `and` or `or`.
|
|
80
|
+
* @param {Array} args The joined conditions.
|
|
81
|
+
* @return {string|null} The sentence, or null when one part has no words.
|
|
82
|
+
*/
|
|
83
|
+
function join(op, args) {
|
|
84
|
+
const parts = args.map((part) => {
|
|
85
|
+
const text = sentence(part);
|
|
86
|
+
const nested = isLogic(part) && ('and' in part || 'or' in part) && args.length > 1;
|
|
87
|
+
return text !== null && nested ? `(${text})` : text
|
|
88
|
+
});
|
|
89
|
+
if (parts.length === 0 || parts.includes(null)) {
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return parts.join(op === 'and' ? ` ${translate('nextcloud-vue', 'and')} ` : ` ${translate('nextcloud-vue', 'or')} `)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {unknown} logic A JSONLogic expression.
|
|
98
|
+
* @return {string|null} It in words, or null when it has none.
|
|
99
|
+
*/
|
|
100
|
+
function sentence(logic) {
|
|
101
|
+
if (!isLogic(logic)) {
|
|
102
|
+
return null
|
|
103
|
+
}
|
|
104
|
+
const [op] = Object.keys(logic);
|
|
105
|
+
const args = [].concat(logic[op]);
|
|
106
|
+
if (op === 'and' || op === 'or') {
|
|
107
|
+
return join(op, args)
|
|
108
|
+
}
|
|
109
|
+
if (comparisons[op]) {
|
|
110
|
+
return compare(op, args)
|
|
111
|
+
}
|
|
112
|
+
const field = presence[op] ? fieldOf(args[0]) : null;
|
|
113
|
+
|
|
114
|
+
return field === null ? null : presence[op](field)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A JSONLogic condition in words.
|
|
119
|
+
*
|
|
120
|
+
* @param {object|null} logic The condition.
|
|
121
|
+
* @return {string} The sentence, a fixed line when it cannot be put in words, or '' without a condition.
|
|
122
|
+
*/
|
|
123
|
+
function flowConditionText(logic) {
|
|
124
|
+
if (!isLogic(logic)) {
|
|
125
|
+
return ''
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return sentence(logic) ?? translate('nextcloud-vue', 'A custom condition')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @param {object} edge The stored edge.
|
|
133
|
+
* @param {object|null} source The node the edge leaves.
|
|
134
|
+
* @return {object|null} The exit the edge leaves through, if the node declares it.
|
|
135
|
+
*/
|
|
136
|
+
function exitOf(edge, source) {
|
|
137
|
+
const exits = Array.isArray(source?.exits) ? source.exits : [];
|
|
138
|
+
|
|
139
|
+
return exits.find((exit) => exit && exit.id === edge?.fromExit) || null
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The JSONLogic that decides whether a line is taken.
|
|
144
|
+
*
|
|
145
|
+
* @param {object} edge The stored edge.
|
|
146
|
+
* @param {object|null} source The node the edge leaves.
|
|
147
|
+
* @return {object|null} The condition, or null.
|
|
148
|
+
*/
|
|
149
|
+
function flowEdgeCondition(edge, source) {
|
|
150
|
+
if (isLogic(edge?.condition)) {
|
|
151
|
+
return edge.condition
|
|
152
|
+
}
|
|
153
|
+
const exit = exitOf(edge, source);
|
|
154
|
+
|
|
155
|
+
return isLogic(exit?.condition) ? exit.condition : null
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* When a line is taken, in words: its condition, or "Otherwise" on the exit
|
|
160
|
+
* without a condition beside exits that have one.
|
|
161
|
+
*
|
|
162
|
+
* @param {object} edge The stored edge.
|
|
163
|
+
* @param {object|null} source The node the edge leaves.
|
|
164
|
+
* @return {string} The text, or '' for a line that is simply followed.
|
|
165
|
+
*/
|
|
166
|
+
function flowEdgeConditionText(edge, source) {
|
|
167
|
+
const logic = flowEdgeCondition(edge, source);
|
|
168
|
+
if (logic !== null) {
|
|
169
|
+
return flowConditionText(logic)
|
|
170
|
+
}
|
|
171
|
+
const branches = exitOf(edge, source) !== null && source.exits.some((exit) => isLogic(exit?.condition));
|
|
172
|
+
|
|
173
|
+
return branches ? translate('nextcloud-vue', 'Otherwise') : ''
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export { flowConditionText, flowEdgeCondition, flowEdgeConditionText };
|
|
177
|
+
//# sourceMappingURL=flowCondition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowCondition.js","sources":["../../../src/utils/flowCondition.js"],"sourcesContent":["/**\n * SPDX-License-Identifier: EUPL-1.2\n * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>\n */\n\nimport { translate as t } from '@nextcloud/l10n'\n\n/**\n * Readable text for the JSONLogic that routes a flow.\n *\n * The engine evaluates a condition on one of a node's `exits`, and an edge\n * names its exit in `fromExit`; `condition` on the edge itself is read as well\n * because documents carry it. The JSONLogic stays where it is: this module only\n * says it in words.\n */\n\n/**\n * @param {unknown} value A candidate condition.\n * @return {boolean} Whether it is a non-empty JSONLogic object.\n */\nfunction isLogic(value) {\n\treturn value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length > 0\n}\n\n/**\n * @param {unknown} operand A `{ var }` operand or a plain value.\n * @return {string|null} The field it reads, without the item's `json.` prefix, or null.\n */\nfunction fieldOf(operand) {\n\tif (operand === null || typeof operand !== 'object' || !('var' in operand)) {\n\t\treturn null\n\t}\n\tconst path = Array.isArray(operand.var) ? operand.var[0] : operand.var\n\n\treturn String(path ?? '').replace(/^json\\./, '')\n}\n\n/**\n * @param {unknown} value A literal operand.\n * @return {string} It as text.\n */\nfunction literal(value) {\n\treturn Array.isArray(value) ? value.map(literal).join(', ') : String(value ?? '')\n}\n\nconst comparisons = {\n\t'==': (parts) => t('nextcloud-vue', '{field} is {value}', parts),\n\t'===': (parts) => t('nextcloud-vue', '{field} is {value}', parts),\n\t'!=': (parts) => t('nextcloud-vue', '{field} is not {value}', parts),\n\t'!==': (parts) => t('nextcloud-vue', '{field} is not {value}', parts),\n\t'>': (parts) => t('nextcloud-vue', '{field} is more than {value}', parts),\n\t'>=': (parts) => t('nextcloud-vue', '{field} is at least {value}', parts),\n\t'<': (parts) => t('nextcloud-vue', '{field} is less than {value}', parts),\n\t'<=': (parts) => t('nextcloud-vue', '{field} is at most {value}', parts),\n\tin: (parts) => t('nextcloud-vue', '{field} is one of {value}', parts),\n}\n\nconst presence = {\n\t'!!': (field) => t('nextcloud-vue', '{field} is filled in', { field }),\n\t'!': (field) => t('nextcloud-vue', '{field} is empty', { field }),\n}\n\n/**\n * @param {string} op A comparison operator.\n * @param {Array} args Its operands.\n * @return {string|null} The sentence, or null when neither side is a plain field and value.\n */\nfunction compare(op, args) {\n\tconst field = fieldOf(args[0])\n\tif (field === null || fieldOf(args[1]) !== null) {\n\t\treturn null\n\t}\n\n\treturn comparisons[op]({ field, value: literal(args[1]) })\n}\n\n/**\n * @param {string} op `and` or `or`.\n * @param {Array} args The joined conditions.\n * @return {string|null} The sentence, or null when one part has no words.\n */\nfunction join(op, args) {\n\tconst parts = args.map((part) => {\n\t\tconst text = sentence(part)\n\t\tconst nested = isLogic(part) && ('and' in part || 'or' in part) && args.length > 1\n\t\treturn text !== null && nested ? `(${text})` : text\n\t})\n\tif (parts.length === 0 || parts.includes(null)) {\n\t\treturn null\n\t}\n\n\treturn parts.join(op === 'and' ? ` ${t('nextcloud-vue', 'and')} ` : ` ${t('nextcloud-vue', 'or')} `)\n}\n\n/**\n * @param {unknown} logic A JSONLogic expression.\n * @return {string|null} It in words, or null when it has none.\n */\nfunction sentence(logic) {\n\tif (!isLogic(logic)) {\n\t\treturn null\n\t}\n\tconst [op] = Object.keys(logic)\n\tconst args = [].concat(logic[op])\n\tif (op === 'and' || op === 'or') {\n\t\treturn join(op, args)\n\t}\n\tif (comparisons[op]) {\n\t\treturn compare(op, args)\n\t}\n\tconst field = presence[op] ? fieldOf(args[0]) : null\n\n\treturn field === null ? null : presence[op](field)\n}\n\n/**\n * A JSONLogic condition in words.\n *\n * @param {object|null} logic The condition.\n * @return {string} The sentence, a fixed line when it cannot be put in words, or '' without a condition.\n */\nexport function flowConditionText(logic) {\n\tif (!isLogic(logic)) {\n\t\treturn ''\n\t}\n\n\treturn sentence(logic) ?? t('nextcloud-vue', 'A custom condition')\n}\n\n/**\n * @param {object} edge The stored edge.\n * @param {object|null} source The node the edge leaves.\n * @return {object|null} The exit the edge leaves through, if the node declares it.\n */\nfunction exitOf(edge, source) {\n\tconst exits = Array.isArray(source?.exits) ? source.exits : []\n\n\treturn exits.find((exit) => exit && exit.id === edge?.fromExit) || null\n}\n\n/**\n * The JSONLogic that decides whether a line is taken.\n *\n * @param {object} edge The stored edge.\n * @param {object|null} source The node the edge leaves.\n * @return {object|null} The condition, or null.\n */\nexport function flowEdgeCondition(edge, source) {\n\tif (isLogic(edge?.condition)) {\n\t\treturn edge.condition\n\t}\n\tconst exit = exitOf(edge, source)\n\n\treturn isLogic(exit?.condition) ? exit.condition : null\n}\n\n/**\n * When a line is taken, in words: its condition, or \"Otherwise\" on the exit\n * without a condition beside exits that have one.\n *\n * @param {object} edge The stored edge.\n * @param {object|null} source The node the edge leaves.\n * @return {string} The text, or '' for a line that is simply followed.\n */\nexport function flowEdgeConditionText(edge, source) {\n\tconst logic = flowEdgeCondition(edge, source)\n\tif (logic !== null) {\n\t\treturn flowConditionText(logic)\n\t}\n\tconst branches = exitOf(edge, source) !== null && source.exits.some((exit) => isLogic(exit?.condition))\n\n\treturn branches ? t('nextcloud-vue', 'Otherwise') : ''\n}\n"],"names":["t"],"m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M,EAAE;AAChD,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE;AAC/B,EAAE,OAAO,IAAI,CAAC,SAAS;AACvB,EAAE;AACF,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAC;AAClC;AACA,CAAC,OAAO,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,GAAG,IAAI;AACxD,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE;AACpD,CAAC,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAC;AAC9C,CAAC,IAAI,KAAK,KAAK,IAAI,EAAE;AACrB,EAAE,OAAO,iBAAiB,CAAC,KAAK,CAAC;AACjC,EAAE;AACF,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,EAAC;AACxG;AACA,CAAC,OAAO,QAAQ,GAAGA,SAAC,CAAC,eAAe,EAAE,WAAW,CAAC,GAAG,EAAE;AACvD;;;;"}
|
|
@@ -33,5 +33,68 @@ function flowRunStatuses() {
|
|
|
33
33
|
*/
|
|
34
34
|
const FLOW_RUN_ERROR_STATUSES = ['failed', 'dead_letter'];
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The engine statuses a run waits in for a person or a time.
|
|
38
|
+
*/
|
|
39
|
+
const FLOW_RUN_WAITING_STATUSES = ['suspended', 'awaiting_consent'];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The objects a run works with, each under its role.
|
|
43
|
+
*
|
|
44
|
+
* `subjects` is what the run declared; a run that declared none still has the
|
|
45
|
+
* object its trigger fired on.
|
|
46
|
+
*
|
|
47
|
+
* @param {object} run A run.
|
|
48
|
+
* @return {Array<{role: string, uuid: string}>} The subjects.
|
|
49
|
+
*/
|
|
50
|
+
function flowRunSubjects(run) {
|
|
51
|
+
const declared = Object.entries(run?.subjects || {}).map(([role, subject]) => ({ role, uuid: String(subject?.uuid ?? '') }));
|
|
52
|
+
if (declared.length > 0) {
|
|
53
|
+
return declared
|
|
54
|
+
}
|
|
55
|
+
const uuid = run?.subjectUuid ?? run?.subject?.uuid;
|
|
56
|
+
|
|
57
|
+
return uuid ? [{ role: '', uuid: String(uuid) }] : []
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The tile over the distinct subjects of some runs.
|
|
62
|
+
*
|
|
63
|
+
* @param {Array<object>} runs The runs.
|
|
64
|
+
* @return {object} The tile: how many objects, and under which roles.
|
|
65
|
+
*/
|
|
66
|
+
function subjectsCounter(runs) {
|
|
67
|
+
const subjects = runs.flatMap(flowRunSubjects);
|
|
68
|
+
const roles = [...new Set(subjects.map((subject) => subject.role).filter(Boolean))];
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
id: 'subjects',
|
|
72
|
+
label: translate('nextcloud-vue', 'Subjects'),
|
|
73
|
+
count: new Set(subjects.map((subject) => subject.uuid)).size,
|
|
74
|
+
note: roles.join(', '),
|
|
75
|
+
variant: 'default',
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The counters above a run history (board OrFlowRuns).
|
|
81
|
+
*
|
|
82
|
+
* @param {Array<object>} runs The runs in the list.
|
|
83
|
+
* @return {Array<{id: string, label: string, count: number, note: string, variant: string}>} The tiles.
|
|
84
|
+
*/
|
|
85
|
+
function flowRunCounters(runs) {
|
|
86
|
+
const counted = (statuses) => runs.filter((run) => statuses.includes(run.status)).length;
|
|
87
|
+
const finished = counted(['completed']);
|
|
88
|
+
const share = runs.length > 0 ? `${Math.round((finished / runs.length) * 100)}%` : '';
|
|
89
|
+
|
|
90
|
+
return [
|
|
91
|
+
{ id: 'runs', label: translate('nextcloud-vue', 'Runs'), count: runs.length, note: '', variant: 'default' },
|
|
92
|
+
{ id: 'finished', label: translate('nextcloud-vue', 'Finished'), count: finished, note: share, variant: 'success' },
|
|
93
|
+
{ id: 'failed', label: translate('nextcloud-vue', 'Failed'), count: counted(FLOW_RUN_ERROR_STATUSES), note: '', variant: 'error' },
|
|
94
|
+
{ id: 'waiting', label: translate('nextcloud-vue', 'Waiting'), count: counted(FLOW_RUN_WAITING_STATUSES), note: '', variant: 'warning' },
|
|
95
|
+
subjectsCounter(runs),
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { FLOW_RUN_ERROR_STATUSES, flowRunCounters, flowRunStatuses, flowRunSubjects };
|
|
37
100
|
//# sourceMappingURL=flowRunStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowRunStatus.js","sources":["../../../src/utils/flowRunStatus.js"],"sourcesContent":["/**\n * SPDX-License-Identifier: EUPL-1.2\n * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>\n */\n\nimport { translate as t } from '@nextcloud/l10n'\n\n/**\n * The run statuses a flow list distinguishes, as label and pill colour.\n *\n * The engine's own vocabulary (`FlowRun::STATUS_*`). A status the engine\n * adds later falls through to its raw value with the neutral colour rather\n * than disappearing.\n *\n * @return {Record<string, {label: string, variant: string}>} By engine status.\n */\nexport function flowRunStatuses() {\n\treturn {\n\t\tcompleted: { label: t('nextcloud-vue', 'Finished'), variant: 'success' },\n\t\tfailed: { label: t('nextcloud-vue', 'Failed'), variant: 'error' },\n\t\tdead_letter: { label: t('nextcloud-vue', 'Failed'), variant: 'error' },\n\t\tstopped: { label: t('nextcloud-vue', 'Stopped early'), variant: 'warning' },\n\t\tqueued: { label: t('nextcloud-vue', 'Queued'), variant: 'info' },\n\t\trunning: { label: t('nextcloud-vue', 'Running'), variant: 'info' },\n\t\tsuspended: { label: t('nextcloud-vue', 'Waiting'), variant: 'info' },\n\t\tawaiting_consent: { label: t('nextcloud-vue', 'Awaiting consent'), variant: 'warning' },\n\t}\n}\n\n/**\n * The engine statuses a \"with errors\" filter counts as an error.\n */\nexport const FLOW_RUN_ERROR_STATUSES = ['failed', 'dead_letter']\n"],"names":["t"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,GAAG;AAClC,CAAC,OAAO;AACR,EAAE,SAAS,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;AAC1E,EAAE,MAAM,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;AACnE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;AACxE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,eAAe,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;AAC7E,EAAE,MAAM,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;AAClE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;AACpE,EAAE,SAAS,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;AACtE,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAEA,SAAC,CAAC,eAAe,EAAE,kBAAkB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;AACzF,EAAE;AACF,CAAC;AACD;AACA;AACA;AACA;AACY,MAAC,uBAAuB,GAAG,CAAC,QAAQ,EAAE,aAAa;;;;"}
|
|
1
|
+
{"version":3,"file":"flowRunStatus.js","sources":["../../../src/utils/flowRunStatus.js"],"sourcesContent":["/**\n * SPDX-License-Identifier: EUPL-1.2\n * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>\n */\n\nimport { translate as t } from '@nextcloud/l10n'\n\n/**\n * The run statuses a flow list distinguishes, as label and pill colour.\n *\n * The engine's own vocabulary (`FlowRun::STATUS_*`). A status the engine\n * adds later falls through to its raw value with the neutral colour rather\n * than disappearing.\n *\n * @return {Record<string, {label: string, variant: string}>} By engine status.\n */\nexport function flowRunStatuses() {\n\treturn {\n\t\tcompleted: { label: t('nextcloud-vue', 'Finished'), variant: 'success' },\n\t\tfailed: { label: t('nextcloud-vue', 'Failed'), variant: 'error' },\n\t\tdead_letter: { label: t('nextcloud-vue', 'Failed'), variant: 'error' },\n\t\tstopped: { label: t('nextcloud-vue', 'Stopped early'), variant: 'warning' },\n\t\tqueued: { label: t('nextcloud-vue', 'Queued'), variant: 'info' },\n\t\trunning: { label: t('nextcloud-vue', 'Running'), variant: 'info' },\n\t\tsuspended: { label: t('nextcloud-vue', 'Waiting'), variant: 'info' },\n\t\tawaiting_consent: { label: t('nextcloud-vue', 'Awaiting consent'), variant: 'warning' },\n\t}\n}\n\n/**\n * The engine statuses a \"with errors\" filter counts as an error.\n */\nexport const FLOW_RUN_ERROR_STATUSES = ['failed', 'dead_letter']\n\n/**\n * The engine statuses a run waits in for a person or a time.\n */\nconst FLOW_RUN_WAITING_STATUSES = ['suspended', 'awaiting_consent']\n\n/**\n * The objects a run works with, each under its role.\n *\n * `subjects` is what the run declared; a run that declared none still has the\n * object its trigger fired on.\n *\n * @param {object} run A run.\n * @return {Array<{role: string, uuid: string}>} The subjects.\n */\nexport function flowRunSubjects(run) {\n\tconst declared = Object.entries(run?.subjects || {}).map(([role, subject]) => ({ role, uuid: String(subject?.uuid ?? '') }))\n\tif (declared.length > 0) {\n\t\treturn declared\n\t}\n\tconst uuid = run?.subjectUuid ?? run?.subject?.uuid\n\n\treturn uuid ? [{ role: '', uuid: String(uuid) }] : []\n}\n\n/**\n * The tile over the distinct subjects of some runs.\n *\n * @param {Array<object>} runs The runs.\n * @return {object} The tile: how many objects, and under which roles.\n */\nfunction subjectsCounter(runs) {\n\tconst subjects = runs.flatMap(flowRunSubjects)\n\tconst roles = [...new Set(subjects.map((subject) => subject.role).filter(Boolean))]\n\n\treturn {\n\t\tid: 'subjects',\n\t\tlabel: t('nextcloud-vue', 'Subjects'),\n\t\tcount: new Set(subjects.map((subject) => subject.uuid)).size,\n\t\tnote: roles.join(', '),\n\t\tvariant: 'default',\n\t}\n}\n\n/**\n * The counters above a run history (board OrFlowRuns).\n *\n * @param {Array<object>} runs The runs in the list.\n * @return {Array<{id: string, label: string, count: number, note: string, variant: string}>} The tiles.\n */\nexport function flowRunCounters(runs) {\n\tconst counted = (statuses) => runs.filter((run) => statuses.includes(run.status)).length\n\tconst finished = counted(['completed'])\n\tconst share = runs.length > 0 ? `${Math.round((finished / runs.length) * 100)}%` : ''\n\n\treturn [\n\t\t{ id: 'runs', label: t('nextcloud-vue', 'Runs'), count: runs.length, note: '', variant: 'default' },\n\t\t{ id: 'finished', label: t('nextcloud-vue', 'Finished'), count: finished, note: share, variant: 'success' },\n\t\t{ id: 'failed', label: t('nextcloud-vue', 'Failed'), count: counted(FLOW_RUN_ERROR_STATUSES), note: '', variant: 'error' },\n\t\t{ id: 'waiting', label: t('nextcloud-vue', 'Waiting'), count: counted(FLOW_RUN_WAITING_STATUSES), note: '', variant: 'warning' },\n\t\tsubjectsCounter(runs),\n\t]\n}\n"],"names":["t"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,GAAG;AAClC,CAAC,OAAO;AACR,EAAE,SAAS,EAAE,EAA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