@panneau/actions 5.0.0-alpha.3 → 5.0.0-alpha.32
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/README.md +4 -2
- package/dist/ActionRunnerProvider.d.ts +8 -2
- package/dist/ActionRunnerProvider.d.ts.map +1 -1
- package/dist/ActionRunnerProvider.js +449 -197
- package/dist/ActionRunnerProvider.js.map +1 -1
- package/dist/ActionRuns.d.ts.map +1 -1
- package/dist/ActionRuns.js +52 -38
- package/dist/ActionRuns.js.map +1 -1
- package/dist/ParametersDialog.d.ts +1 -1
- package/dist/ParametersDialog.d.ts.map +1 -1
- package/dist/ParametersDialog.js +99 -79
- package/dist/ParametersDialog.js.map +1 -1
- package/dist/ResultsDialog.js +1 -1
- package/dist/ResultsDialog.js.map +1 -1
- package/dist/context.d.ts +6 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/describe.d.ts +35 -4
- package/dist/describe.d.ts.map +1 -1
- package/dist/describe.js +89 -7
- package/dist/describe.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js.map +1 -1
- package/dist/request.d.ts +1 -1
- package/dist/request.js.map +1 -1
- package/dist/useActionRunner.d.ts +2 -2
- package/dist/useActionRunner.js.map +1 -1
- package/package.json +10 -10
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { messages } from "./messages.js";
|
|
2
2
|
import { ParametersDialog } from "./ParametersDialog.js";
|
|
3
|
-
import { buildActionRequest, getLinkTarget, isFinished } from "./request.js";
|
|
4
|
-
import { describeResult } from "./describe.js";
|
|
3
|
+
import { buildActionRequest, getLinkTarget, getResultCounts, isFinished } from "./request.js";
|
|
4
|
+
import { describeResult, describeSubject, getChangedItems, getItemTitle, isInUse } from "./describe.js";
|
|
5
5
|
import { ResultsDialog } from "./ResultsDialog.js";
|
|
6
6
|
import { ActionRunnerContext } from "./context.js";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
7
8
|
import { useEffect, useEffectEvent, useRef, useState } from "react";
|
|
8
|
-
import {
|
|
9
|
+
import { usePanneau } from "@panneau/core";
|
|
10
|
+
import { getActionLabel } from "@panneau/intl";
|
|
9
11
|
import { usePanneauIntl, useToast } from "@panneau/ui";
|
|
10
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
13
|
//#region src/ActionRunnerProvider.tsx
|
|
@@ -30,214 +32,464 @@ function openDownload(download) {
|
|
|
30
32
|
* redirects and opens downloads. Put it inside `PanneauRoot`, and above the router of an app, so
|
|
31
33
|
* that runs are followed from page to page. `useActionRunner(resource)` runs an action.
|
|
32
34
|
*/
|
|
33
|
-
function ActionRunnerProvider(
|
|
35
|
+
function ActionRunnerProvider(t0) {
|
|
36
|
+
const $ = c(72);
|
|
37
|
+
const { adapter, children, onResult, onNavigate: t1, onDownload: t2, onShowItems, clientActions, pollInterval: t3, locales } = t0;
|
|
38
|
+
const onNavigate = t1 === void 0 ? navigateTo : t1;
|
|
39
|
+
const onDownload = t2 === void 0 ? openDownload : t2;
|
|
40
|
+
const pollInterval = t3 === void 0 ? 2e3 : t3;
|
|
34
41
|
const intl = usePanneauIntl();
|
|
35
42
|
const toasts = useToast();
|
|
36
|
-
const plugins =
|
|
43
|
+
const { definition, plugins } = usePanneau();
|
|
37
44
|
const [parameters, setParameters] = useState(null);
|
|
38
45
|
const [client, setClient] = useState(null);
|
|
39
46
|
const [details, setDetails] = useState(null);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
resource: resource_0,
|
|
71
|
-
target: target_0
|
|
72
|
-
}]);
|
|
73
|
-
toasts.show({
|
|
74
|
-
title: intl.formatMessage(messages.queued, { action: target_0.action.label }),
|
|
75
|
-
description: intl.formatMessage(messages.queuedDescription),
|
|
76
|
-
tone: "info"
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
const ended = async (entry_0) => {
|
|
80
|
-
const { run: run_0, resource: resource_1, target: target_1 } = entry_0;
|
|
81
|
-
if (notified.current.has(run_0.id)) return;
|
|
82
|
-
notified.current.add(run_0.id);
|
|
83
|
-
if (run_0.result !== void 0) await finish(resource_1, target_1, run_0.result);
|
|
84
|
-
else if (run_0.status === "cancelled") toasts.show({ title: intl.formatMessage(messages.cancelled, { action: target_1.action.label }) });
|
|
85
|
-
else if (run_0.status === "failed") toasts.show({
|
|
86
|
-
title: intl.formatMessage(messages.failed, { action: target_1.action.label }),
|
|
87
|
-
tone: "danger"
|
|
88
|
-
});
|
|
89
|
-
else toasts.show({
|
|
90
|
-
title: intl.formatMessage(messages.done, { action: target_1.action.label }),
|
|
91
|
-
tone: "success"
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
const execute = async (resource_2, target_2, values = {}) => {
|
|
95
|
-
const response = await adapter.runAction(resource_2, target_2.action.id, buildActionRequest(target_2, values));
|
|
96
|
-
if (response.run !== void 0) {
|
|
97
|
-
follow(resource_2, target_2, response.run);
|
|
98
|
-
return {
|
|
99
|
-
status: "queued",
|
|
100
|
-
run: response.run
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
await finish(resource_2, target_2, response.result);
|
|
104
|
-
return {
|
|
105
|
-
status: "done",
|
|
106
|
-
result: response.result
|
|
47
|
+
let t4;
|
|
48
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
49
|
+
t4 = [];
|
|
50
|
+
$[0] = t4;
|
|
51
|
+
} else t4 = $[0];
|
|
52
|
+
const [runs, setRuns] = useState(t4);
|
|
53
|
+
let t5;
|
|
54
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
55
|
+
t5 = /* @__PURE__ */ new Set();
|
|
56
|
+
$[1] = t5;
|
|
57
|
+
} else t5 = $[1];
|
|
58
|
+
const notified = useRef(t5);
|
|
59
|
+
const watchers = useRef(0);
|
|
60
|
+
let t6;
|
|
61
|
+
if ($[2] !== definition?.resources || $[3] !== intl) {
|
|
62
|
+
t6 = (resource, target, t7) => {
|
|
63
|
+
const count = t7 === void 0 ? null : t7;
|
|
64
|
+
return describeSubject(target, definition?.resources.find((candidate) => candidate.id === resource), intl, count);
|
|
65
|
+
};
|
|
66
|
+
$[2] = definition?.resources;
|
|
67
|
+
$[3] = intl;
|
|
68
|
+
$[4] = t6;
|
|
69
|
+
} else t6 = $[4];
|
|
70
|
+
const subjectOf = t6;
|
|
71
|
+
let t7;
|
|
72
|
+
if ($[5] !== definition?.resources || $[6] !== intl) {
|
|
73
|
+
t7 = (resource_0, target_0) => {
|
|
74
|
+
if (target_0.item === void 0) return null;
|
|
75
|
+
const itemTitle = definition?.resources.find((candidate_0) => candidate_0.id === resource_0)?.itemTitle;
|
|
76
|
+
return getItemTitle(target_0.item, itemTitle, intl.locale);
|
|
107
77
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
78
|
+
$[5] = definition?.resources;
|
|
79
|
+
$[6] = intl;
|
|
80
|
+
$[7] = t7;
|
|
81
|
+
} else t7 = $[7];
|
|
82
|
+
const itemTitleOf = t7;
|
|
83
|
+
const toastKey = _temp;
|
|
84
|
+
let finish;
|
|
85
|
+
let follow;
|
|
86
|
+
if ($[8] !== adapter || $[9] !== definition?.resources || $[10] !== intl || $[11] !== itemTitleOf || $[12] !== onDownload || $[13] !== onNavigate || $[14] !== onResult || $[15] !== onShowItems || $[16] !== subjectOf || $[17] !== toasts) {
|
|
87
|
+
finish = async (resource_2, target_2, result, t8) => {
|
|
88
|
+
const { queued: t9 } = t8 === void 0 ? {} : t8;
|
|
89
|
+
const queued = t9 === void 0 ? false : t9;
|
|
90
|
+
await onResult?.(result, {
|
|
91
|
+
resource: resource_2,
|
|
92
|
+
target: target_2
|
|
118
93
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
useEffect(() => {
|
|
155
|
-
const active = runs.filter((entry_5) => !isFinished(entry_5.run.status));
|
|
156
|
-
if (active.length === 0) return;
|
|
157
|
-
let stopped = false;
|
|
158
|
-
const timer = setTimeout(() => {
|
|
159
|
-
Promise.all(active.map(async (entry_6) => {
|
|
160
|
-
try {
|
|
161
|
-
const next = await adapter.getActionRun(entry_6.run.id);
|
|
162
|
-
if (stopped) return;
|
|
163
|
-
setRuns((current_3) => current_3.map((candidate_0) => candidate_0.run.id === next.id ? {
|
|
164
|
-
...candidate_0,
|
|
165
|
-
run: next
|
|
166
|
-
} : candidate_0));
|
|
167
|
-
if (isFinished(next.status)) await onRunEnded({
|
|
168
|
-
...entry_6,
|
|
169
|
-
run: next
|
|
170
|
-
});
|
|
171
|
-
} catch {
|
|
172
|
-
if (!stopped) setRuns((current_2) => [...current_2]);
|
|
173
|
-
}
|
|
174
|
-
}));
|
|
175
|
-
}, pollInterval);
|
|
176
|
-
return () => {
|
|
177
|
-
stopped = true;
|
|
178
|
-
clearTimeout(timer);
|
|
94
|
+
const counts = getResultCounts(result);
|
|
95
|
+
const itemTitle_0 = itemTitleOf(resource_2, target_2);
|
|
96
|
+
const content = describeResult(result, getActionLabel(target_2.action, intl), intl, subjectOf(resource_2, target_2, counts.succeeded), itemTitle_0);
|
|
97
|
+
const entries = result.results ?? [];
|
|
98
|
+
const hasDetails = entries.length > 0 && !(entries.length === 1 && entries[0] !== void 0 && isInUse(entries[0]) && itemTitle_0 !== null);
|
|
99
|
+
const download = result.download ?? null;
|
|
100
|
+
if (download !== null) onDownload(download);
|
|
101
|
+
const redirect = result.redirect ?? null;
|
|
102
|
+
const saysMore = (result.message ?? "") !== "" || hasDetails || download !== null;
|
|
103
|
+
if (queued && watchers.current > 0 && !saysMore) {
|
|
104
|
+
if (redirect !== null) onNavigate(redirect);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const undo = !queued ? result.undo ?? null : null;
|
|
108
|
+
const changed = onShowItems !== void 0 && redirect === null ? getChangedItems(target_2, result) : null;
|
|
109
|
+
toasts.show({
|
|
110
|
+
...content,
|
|
111
|
+
...undo !== null ? { action: {
|
|
112
|
+
label: intl.formatMessage(messages.undo),
|
|
113
|
+
onAction: () => void runUndo(resource_2, target_2, undo)
|
|
114
|
+
} } : hasDetails ? { action: {
|
|
115
|
+
label: intl.formatMessage(messages.details),
|
|
116
|
+
onAction: () => setDetails({
|
|
117
|
+
label: getActionLabel(target_2.action, intl),
|
|
118
|
+
result
|
|
119
|
+
})
|
|
120
|
+
} } : download !== null ? { action: {
|
|
121
|
+
label: intl.formatMessage(messages.download),
|
|
122
|
+
onAction: () => onDownload(download)
|
|
123
|
+
} } : changed !== null ? { action: {
|
|
124
|
+
label: intl.formatMessage(messages.showChanged),
|
|
125
|
+
onAction: () => onShowItems?.(resource_2, changed)
|
|
126
|
+
} } : {}
|
|
127
|
+
}, { key: toastKey(resource_2, target_2) });
|
|
128
|
+
if (redirect !== null) onNavigate(redirect);
|
|
179
129
|
};
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
runs,
|
|
189
|
-
cancelRun,
|
|
190
|
-
dismissRun
|
|
191
|
-
};
|
|
192
|
-
const ClientHandler = client?.Handler;
|
|
193
|
-
return /* @__PURE__ */ jsxs(ActionRunnerContext, {
|
|
194
|
-
value,
|
|
195
|
-
children: [
|
|
196
|
-
children,
|
|
197
|
-
parameters !== null ? /* @__PURE__ */ jsx(ParametersDialog, {
|
|
198
|
-
action: parameters.target.action,
|
|
199
|
-
count: parameters.target.count,
|
|
200
|
-
locales,
|
|
201
|
-
onSubmit: (values_0) => execute(parameters.resource, parameters.target, values_0),
|
|
202
|
-
onDone: (outcome) => {
|
|
203
|
-
setParameters(null);
|
|
204
|
-
parameters.resolve(outcome);
|
|
130
|
+
const runUndo = async (resource_3, target_3, undo_0) => {
|
|
131
|
+
const label = getActionLabel(target_3.action, intl);
|
|
132
|
+
const key = { key: toastKey(resource_3, target_3) };
|
|
133
|
+
const undoTarget = {
|
|
134
|
+
action: definition?.resources.find((candidate_1) => candidate_1.id === resource_3)?.actions?.find((action) => action.id === undo_0.action) ?? {
|
|
135
|
+
id: undo_0.action,
|
|
136
|
+
kind: "server",
|
|
137
|
+
scope: ["selection"]
|
|
205
138
|
},
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
139
|
+
scope: "selection",
|
|
140
|
+
selection: { ids: undo_0.items },
|
|
141
|
+
count: undo_0.items.length
|
|
142
|
+
};
|
|
143
|
+
await adapter.runAction(resource_3, undo_0.action, {
|
|
144
|
+
selection: { ids: undo_0.items },
|
|
145
|
+
values: undo_0.params ?? {}
|
|
146
|
+
}).then(async (response) => {
|
|
147
|
+
if (response.run !== void 0) {
|
|
148
|
+
follow(resource_3, undoTarget, response.run);
|
|
149
|
+
return;
|
|
209
150
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
151
|
+
await onResult?.(response.result, {
|
|
152
|
+
resource: resource_3,
|
|
153
|
+
target: undoTarget
|
|
154
|
+
});
|
|
155
|
+
const subject = subjectOf(resource_3, target_3, undo_0.items.length);
|
|
156
|
+
toasts.show({ title: subject !== null ? intl.formatMessage(messages.undoneFor, {
|
|
157
|
+
action: label,
|
|
158
|
+
subject
|
|
159
|
+
}) : intl.formatMessage(messages.undone, { action: label }) }, key);
|
|
160
|
+
}).catch((error) => {
|
|
161
|
+
toasts.show({
|
|
162
|
+
title: intl.formatMessage(messages.undoFailed, { action: label }),
|
|
163
|
+
...error instanceof Error && error.message !== "" ? { description: error.message } : {},
|
|
164
|
+
tone: "danger"
|
|
165
|
+
}, key);
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
follow = (resource_4, target_4, run) => {
|
|
169
|
+
setRuns((current) => [...current.filter((entry) => entry.run.id !== run.id), {
|
|
170
|
+
run,
|
|
171
|
+
resource: resource_4,
|
|
172
|
+
target: target_4
|
|
173
|
+
}]);
|
|
174
|
+
};
|
|
175
|
+
$[8] = adapter;
|
|
176
|
+
$[9] = definition?.resources;
|
|
177
|
+
$[10] = intl;
|
|
178
|
+
$[11] = itemTitleOf;
|
|
179
|
+
$[12] = onDownload;
|
|
180
|
+
$[13] = onNavigate;
|
|
181
|
+
$[14] = onResult;
|
|
182
|
+
$[15] = onShowItems;
|
|
183
|
+
$[16] = subjectOf;
|
|
184
|
+
$[17] = toasts;
|
|
185
|
+
$[18] = finish;
|
|
186
|
+
$[19] = follow;
|
|
187
|
+
} else {
|
|
188
|
+
finish = $[18];
|
|
189
|
+
follow = $[19];
|
|
190
|
+
}
|
|
191
|
+
let t8;
|
|
192
|
+
if ($[20] !== finish || $[21] !== intl || $[22] !== subjectOf || $[23] !== toasts) {
|
|
193
|
+
t8 = async (entry_0) => {
|
|
194
|
+
const { run: run_0, resource: resource_5, target: target_5 } = entry_0;
|
|
195
|
+
if (notified.current.has(run_0.id)) return;
|
|
196
|
+
notified.current.add(run_0.id);
|
|
197
|
+
if (run_0.result !== void 0) {
|
|
198
|
+
await finish(resource_5, target_5, run_0.result, { queued: true });
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const action_0 = getActionLabel(target_5.action, intl);
|
|
202
|
+
const subject_0 = subjectOf(resource_5, target_5);
|
|
203
|
+
const key_0 = { key: toastKey(resource_5, target_5) };
|
|
204
|
+
if (run_0.status === "cancelled") toasts.show({ title: subject_0 !== null ? intl.formatMessage(messages.cancelledFor, {
|
|
205
|
+
action: action_0,
|
|
206
|
+
subject: subject_0
|
|
207
|
+
}) : intl.formatMessage(messages.cancelled, { action: action_0 }) }, key_0);
|
|
208
|
+
else if (run_0.status === "failed") toasts.show({
|
|
209
|
+
title: subject_0 !== null ? intl.formatMessage(messages.failedFor, {
|
|
210
|
+
action: action_0,
|
|
211
|
+
subject: subject_0
|
|
212
|
+
}) : intl.formatMessage(messages.failed, { action: action_0 }),
|
|
213
|
+
tone: "danger"
|
|
214
|
+
}, key_0);
|
|
215
|
+
else if (watchers.current === 0) toasts.show({
|
|
216
|
+
title: subject_0 !== null ? intl.formatMessage(messages.doneFor, {
|
|
217
|
+
action: action_0,
|
|
218
|
+
subject: subject_0
|
|
219
|
+
}) : intl.formatMessage(messages.done, { action: action_0 }),
|
|
220
|
+
tone: "success"
|
|
221
|
+
}, key_0);
|
|
222
|
+
};
|
|
223
|
+
$[20] = finish;
|
|
224
|
+
$[21] = intl;
|
|
225
|
+
$[22] = subjectOf;
|
|
226
|
+
$[23] = toasts;
|
|
227
|
+
$[24] = t8;
|
|
228
|
+
} else t8 = $[24];
|
|
229
|
+
const ended = t8;
|
|
230
|
+
let t9;
|
|
231
|
+
if ($[25] !== adapter || $[26] !== finish || $[27] !== follow) {
|
|
232
|
+
t9 = async (resource_6, target_6, t10) => {
|
|
233
|
+
const values = t10 === void 0 ? {} : t10;
|
|
234
|
+
const response_0 = await adapter.runAction(resource_6, target_6.action.id, buildActionRequest(target_6, values));
|
|
235
|
+
if (response_0.run !== void 0) {
|
|
236
|
+
follow(resource_6, target_6, response_0.run);
|
|
237
|
+
return {
|
|
238
|
+
status: "queued",
|
|
239
|
+
run: response_0.run
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
await finish(resource_6, target_6, response_0.result);
|
|
243
|
+
return {
|
|
244
|
+
status: "done",
|
|
245
|
+
result: response_0.result
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
$[25] = adapter;
|
|
249
|
+
$[26] = finish;
|
|
250
|
+
$[27] = follow;
|
|
251
|
+
$[28] = t9;
|
|
252
|
+
} else t9 = $[28];
|
|
253
|
+
const execute = t9;
|
|
254
|
+
let t10;
|
|
255
|
+
if ($[29] !== clientActions || $[30] !== execute || $[31] !== onNavigate || $[32] !== plugins) {
|
|
256
|
+
t10 = (resource_7, target_7) => {
|
|
257
|
+
const { action: action_1 } = target_7;
|
|
258
|
+
if (action_1.kind === "link") {
|
|
259
|
+
const to = getLinkTarget(target_7);
|
|
260
|
+
if (to === null) return Promise.reject(/* @__PURE__ */ new Error(`The action "${action_1.id}" has no URL or route.`));
|
|
261
|
+
onNavigate(to);
|
|
262
|
+
return Promise.resolve({
|
|
263
|
+
status: "navigated",
|
|
264
|
+
to
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
if (action_1.kind === "client") {
|
|
268
|
+
const name = action_1.component ?? "";
|
|
269
|
+
const Handler = (clientActions !== void 0 && Object.hasOwn(clientActions, name) ? clientActions[name] : void 0) ?? plugins.actions.get(name);
|
|
270
|
+
if (Handler === void 0) return Promise.reject(/* @__PURE__ */ new Error(`No handler for the client action "${action_1.id}" (${name}).`));
|
|
271
|
+
return new Promise((resolve) => setClient({
|
|
272
|
+
resource: resource_7,
|
|
273
|
+
target: target_7,
|
|
274
|
+
resolve,
|
|
275
|
+
Handler
|
|
276
|
+
}));
|
|
277
|
+
}
|
|
278
|
+
if ((action_1.fields ?? []).length > 0) return new Promise((resolve_0) => setParameters({
|
|
279
|
+
resource: resource_7,
|
|
280
|
+
target: target_7,
|
|
281
|
+
resolve: resolve_0
|
|
282
|
+
}));
|
|
283
|
+
return execute(resource_7, target_7);
|
|
284
|
+
};
|
|
285
|
+
$[29] = clientActions;
|
|
286
|
+
$[30] = execute;
|
|
287
|
+
$[31] = onNavigate;
|
|
288
|
+
$[32] = plugins;
|
|
289
|
+
$[33] = t10;
|
|
290
|
+
} else t10 = $[33];
|
|
291
|
+
const run_1 = t10;
|
|
292
|
+
let t11;
|
|
293
|
+
if ($[34] !== adapter || $[35] !== ended || $[36] !== runs) {
|
|
294
|
+
t11 = async (id) => {
|
|
295
|
+
if (adapter.cancelActionRun === void 0) throw new Error("The adapter cannot cancel runs.");
|
|
296
|
+
await adapter.cancelActionRun(id);
|
|
297
|
+
const updated = await adapter.getActionRun(id);
|
|
298
|
+
setRuns((current_0) => current_0.map((entry_1) => entry_1.run.id === id ? {
|
|
299
|
+
...entry_1,
|
|
300
|
+
run: updated
|
|
301
|
+
} : entry_1));
|
|
302
|
+
const entry_2 = runs.find((candidate_2) => candidate_2.run.id === id);
|
|
303
|
+
if (entry_2 !== void 0 && isFinished(updated.status)) await ended({
|
|
304
|
+
...entry_2,
|
|
305
|
+
run: updated
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
$[34] = adapter;
|
|
309
|
+
$[35] = ended;
|
|
310
|
+
$[36] = runs;
|
|
311
|
+
$[37] = t11;
|
|
312
|
+
} else t11 = $[37];
|
|
313
|
+
const cancelRun = t11;
|
|
314
|
+
let t12;
|
|
315
|
+
if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
|
|
316
|
+
t12 = (id_0) => setRuns((current_1) => current_1.filter((entry_3) => entry_3.run.id !== id_0));
|
|
317
|
+
$[38] = t12;
|
|
318
|
+
} else t12 = $[38];
|
|
319
|
+
const dismissRun = t12;
|
|
320
|
+
let t13;
|
|
321
|
+
if ($[39] !== ended) {
|
|
322
|
+
t13 = (entry_4) => ended(entry_4);
|
|
323
|
+
$[39] = ended;
|
|
324
|
+
$[40] = t13;
|
|
325
|
+
} else t13 = $[40];
|
|
326
|
+
const onRunEnded = useEffectEvent(t13);
|
|
327
|
+
let t14;
|
|
328
|
+
if ($[41] !== adapter || $[42] !== onRunEnded || $[43] !== pollInterval || $[44] !== runs) {
|
|
329
|
+
t14 = () => {
|
|
330
|
+
const active = runs.filter(_temp2);
|
|
331
|
+
if (active.length === 0) return;
|
|
332
|
+
let stopped = false;
|
|
333
|
+
const timer = setTimeout(() => {
|
|
334
|
+
Promise.all(active.map(async (entry_6) => {
|
|
335
|
+
try {
|
|
336
|
+
const next = await adapter.getActionRun(entry_6.run.id);
|
|
337
|
+
if (stopped) return;
|
|
338
|
+
setRuns((current_3) => current_3.map((candidate_3) => candidate_3.run.id === next.id ? {
|
|
339
|
+
...candidate_3,
|
|
340
|
+
run: next
|
|
341
|
+
} : candidate_3));
|
|
342
|
+
if (isFinished(next.status)) await onRunEnded({
|
|
343
|
+
...entry_6,
|
|
344
|
+
run: next
|
|
221
345
|
});
|
|
222
|
-
|
|
346
|
+
} catch {
|
|
347
|
+
if (!stopped) setRuns(_temp3);
|
|
223
348
|
}
|
|
224
|
-
|
|
349
|
+
}));
|
|
350
|
+
}, pollInterval);
|
|
351
|
+
return () => {
|
|
352
|
+
stopped = true;
|
|
353
|
+
clearTimeout(timer);
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
$[41] = adapter;
|
|
357
|
+
$[42] = onRunEnded;
|
|
358
|
+
$[43] = pollInterval;
|
|
359
|
+
$[44] = runs;
|
|
360
|
+
$[45] = t14;
|
|
361
|
+
} else t14 = $[45];
|
|
362
|
+
let t15;
|
|
363
|
+
if ($[46] !== adapter || $[47] !== pollInterval || $[48] !== runs) {
|
|
364
|
+
t15 = [
|
|
365
|
+
runs,
|
|
366
|
+
adapter,
|
|
367
|
+
pollInterval
|
|
368
|
+
];
|
|
369
|
+
$[46] = adapter;
|
|
370
|
+
$[47] = pollInterval;
|
|
371
|
+
$[48] = runs;
|
|
372
|
+
$[49] = t15;
|
|
373
|
+
} else t15 = $[49];
|
|
374
|
+
useEffect(t14, t15);
|
|
375
|
+
let t16;
|
|
376
|
+
if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
|
|
377
|
+
t16 = () => {
|
|
378
|
+
watchers.current = watchers.current + 1;
|
|
379
|
+
return () => {
|
|
380
|
+
watchers.current = watchers.current - 1;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
$[50] = t16;
|
|
384
|
+
} else t16 = $[50];
|
|
385
|
+
const watchRuns = t16;
|
|
386
|
+
let t17;
|
|
387
|
+
if ($[51] !== adapter || $[52] !== cancelRun || $[53] !== run_1 || $[54] !== runs) {
|
|
388
|
+
t17 = {
|
|
389
|
+
adapter,
|
|
390
|
+
run: run_1,
|
|
391
|
+
runs,
|
|
392
|
+
cancelRun,
|
|
393
|
+
dismissRun,
|
|
394
|
+
watchRuns
|
|
395
|
+
};
|
|
396
|
+
$[51] = adapter;
|
|
397
|
+
$[52] = cancelRun;
|
|
398
|
+
$[53] = run_1;
|
|
399
|
+
$[54] = runs;
|
|
400
|
+
$[55] = t17;
|
|
401
|
+
} else t17 = $[55];
|
|
402
|
+
const value = t17;
|
|
403
|
+
const ClientHandler = client?.Handler;
|
|
404
|
+
let t18;
|
|
405
|
+
if ($[56] !== execute || $[57] !== locales || $[58] !== parameters) {
|
|
406
|
+
t18 = parameters !== null ? /* @__PURE__ */ jsx(ParametersDialog, {
|
|
407
|
+
action: parameters.target.action,
|
|
408
|
+
count: parameters.target.count,
|
|
409
|
+
locales,
|
|
410
|
+
onSubmit: (values_0) => execute(parameters.resource, parameters.target, values_0),
|
|
411
|
+
onDone: (outcome) => {
|
|
412
|
+
setParameters(null);
|
|
413
|
+
parameters.resolve(outcome);
|
|
414
|
+
},
|
|
415
|
+
onCancel: () => {
|
|
416
|
+
setParameters(null);
|
|
417
|
+
parameters.resolve(false);
|
|
418
|
+
}
|
|
419
|
+
}) : null;
|
|
420
|
+
$[56] = execute;
|
|
421
|
+
$[57] = locales;
|
|
422
|
+
$[58] = parameters;
|
|
423
|
+
$[59] = t18;
|
|
424
|
+
} else t18 = $[59];
|
|
425
|
+
let t19;
|
|
426
|
+
if ($[60] !== ClientHandler || $[61] !== client || $[62] !== finish) {
|
|
427
|
+
t19 = client !== null && ClientHandler !== void 0 ? /* @__PURE__ */ jsx(ClientHandler, {
|
|
428
|
+
action: client.target.action,
|
|
429
|
+
resource: client.resource,
|
|
430
|
+
target: client.target,
|
|
431
|
+
onDone: (result_0) => {
|
|
432
|
+
setClient(null);
|
|
433
|
+
if (result_0 === void 0) {
|
|
434
|
+
client.resolve({
|
|
225
435
|
status: "done",
|
|
226
|
-
result:
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
onCancel: () => {
|
|
230
|
-
setClient(null);
|
|
231
|
-
client.resolve(false);
|
|
436
|
+
result: {}
|
|
437
|
+
});
|
|
438
|
+
return;
|
|
232
439
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
440
|
+
finish(client.resource, client.target, result_0).then(() => client.resolve({
|
|
441
|
+
status: "done",
|
|
442
|
+
result: result_0
|
|
443
|
+
}));
|
|
444
|
+
},
|
|
445
|
+
onCancel: () => {
|
|
446
|
+
setClient(null);
|
|
447
|
+
client.resolve(false);
|
|
448
|
+
}
|
|
449
|
+
}) : null;
|
|
450
|
+
$[60] = ClientHandler;
|
|
451
|
+
$[61] = client;
|
|
452
|
+
$[62] = finish;
|
|
453
|
+
$[63] = t19;
|
|
454
|
+
} else t19 = $[63];
|
|
455
|
+
let t20;
|
|
456
|
+
if ($[64] !== details) {
|
|
457
|
+
t20 = details !== null ? /* @__PURE__ */ jsx(ResultsDialog, {
|
|
458
|
+
label: details.label,
|
|
459
|
+
result: details.result,
|
|
460
|
+
onClose: () => setDetails(null)
|
|
461
|
+
}) : null;
|
|
462
|
+
$[64] = details;
|
|
463
|
+
$[65] = t20;
|
|
464
|
+
} else t20 = $[65];
|
|
465
|
+
let t21;
|
|
466
|
+
if ($[66] !== children || $[67] !== t18 || $[68] !== t19 || $[69] !== t20 || $[70] !== value) {
|
|
467
|
+
t21 = /* @__PURE__ */ jsxs(ActionRunnerContext, {
|
|
468
|
+
value,
|
|
469
|
+
children: [
|
|
470
|
+
children,
|
|
471
|
+
t18,
|
|
472
|
+
t19,
|
|
473
|
+
t20
|
|
474
|
+
]
|
|
475
|
+
});
|
|
476
|
+
$[66] = children;
|
|
477
|
+
$[67] = t18;
|
|
478
|
+
$[68] = t19;
|
|
479
|
+
$[69] = t20;
|
|
480
|
+
$[70] = value;
|
|
481
|
+
$[71] = t21;
|
|
482
|
+
} else t21 = $[71];
|
|
483
|
+
return t21;
|
|
484
|
+
}
|
|
485
|
+
function _temp3(current_2) {
|
|
486
|
+
return [...current_2];
|
|
487
|
+
}
|
|
488
|
+
function _temp2(entry_5) {
|
|
489
|
+
return !isFinished(entry_5.run.status);
|
|
490
|
+
}
|
|
491
|
+
function _temp(resource_1, target_1) {
|
|
492
|
+
return `panneau-action:${resource_1}:${target_1.action.id}:${target_1.item?.id ?? "selection"}`;
|
|
241
493
|
}
|
|
242
494
|
//#endregion
|
|
243
495
|
export { ActionRunnerProvider };
|