@panneau/actions 5.0.0-alpha.4 → 5.0.0-alpha.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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 { usePlugins } from "@panneau/core";
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({ adapter, children, onResult, onNavigate = navigateTo, onDownload = openDownload, clientActions, pollInterval = 2e3, locales }) {
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 = usePlugins();
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
- const [runs, setRuns] = useState([]);
41
- const notified = useRef(/* @__PURE__ */ new Set());
42
- const finish = async (resource, target, result) => {
43
- await onResult?.(result, {
44
- resource,
45
- target
46
- });
47
- const content = describeResult(result, target.action.label, intl);
48
- const hasDetails = (result.results ?? []).length > 0;
49
- const download = result.download ?? null;
50
- if (download !== null) onDownload(download);
51
- toasts.show({
52
- ...content,
53
- ...hasDetails ? { action: {
54
- label: intl.formatMessage(messages.details),
55
- onAction: () => setDetails({
56
- label: target.action.label,
57
- result
58
- })
59
- } } : download !== null ? { action: {
60
- label: intl.formatMessage(messages.download),
61
- onAction: () => onDownload(download)
62
- } } : {}
63
- });
64
- const redirect = result.redirect ?? null;
65
- if (redirect !== null) onNavigate(redirect);
66
- };
67
- const follow = (resource_0, target_0, run) => {
68
- setRuns((current) => [...current.filter((entry) => entry.run.id !== run.id), {
69
- run,
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
- const run_1 = (resource_3, target_3) => {
110
- const { action } = target_3;
111
- if (action.kind === "link") {
112
- const to = getLinkTarget(target_3);
113
- if (to === null) return Promise.reject(/* @__PURE__ */ new Error(`The action "${action.id}" has no URL or route.`));
114
- onNavigate(to);
115
- return Promise.resolve({
116
- status: "navigated",
117
- to
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
- if (action.kind === "client") {
121
- const name = action.component ?? "";
122
- const Handler = (clientActions !== void 0 && Object.hasOwn(clientActions, name) ? clientActions[name] : void 0) ?? plugins.actions.get(name);
123
- if (Handler === void 0) return Promise.reject(/* @__PURE__ */ new Error(`No handler for the client action "${action.id}" (${name}).`));
124
- return new Promise((resolve) => setClient({
125
- resource: resource_3,
126
- target: target_3,
127
- resolve,
128
- Handler
129
- }));
130
- }
131
- if ((action.fields ?? []).length > 0) return new Promise((resolve_0) => setParameters({
132
- resource: resource_3,
133
- target: target_3,
134
- resolve: resolve_0
135
- }));
136
- return execute(resource_3, target_3);
137
- };
138
- const cancelRun = async (id) => {
139
- if (adapter.cancelActionRun === void 0) throw new Error("The adapter cannot cancel runs.");
140
- await adapter.cancelActionRun(id);
141
- const updated = await adapter.getActionRun(id);
142
- setRuns((current_0) => current_0.map((entry_1) => entry_1.run.id === id ? {
143
- ...entry_1,
144
- run: updated
145
- } : entry_1));
146
- const entry_2 = runs.find((candidate) => candidate.run.id === id);
147
- if (entry_2 !== void 0 && isFinished(updated.status)) await ended({
148
- ...entry_2,
149
- run: updated
150
- });
151
- };
152
- const dismissRun = (id_0) => setRuns((current_1) => current_1.filter((entry_3) => entry_3.run.id !== id_0));
153
- const onRunEnded = useEffectEvent((entry_4) => ended(entry_4));
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
- runs,
182
- adapter,
183
- pollInterval
184
- ]);
185
- const value = {
186
- adapter,
187
- run: run_1,
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
- onCancel: () => {
207
- setParameters(null);
208
- parameters.resolve(false);
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
- }) : null,
211
- client !== null && ClientHandler !== void 0 ? /* @__PURE__ */ jsx(ClientHandler, {
212
- action: client.target.action,
213
- resource: client.resource,
214
- target: client.target,
215
- onDone: (result_0) => {
216
- setClient(null);
217
- if (result_0 === void 0) {
218
- client.resolve({
219
- status: "done",
220
- result: {}
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
- return;
346
+ } catch {
347
+ if (!stopped) setRuns(_temp3);
223
348
  }
224
- finish(client.resource, client.target, result_0).then(() => client.resolve({
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: result_0
227
- }));
228
- },
229
- onCancel: () => {
230
- setClient(null);
231
- client.resolve(false);
436
+ result: {}
437
+ });
438
+ return;
232
439
  }
233
- }) : null,
234
- details !== null ? /* @__PURE__ */ jsx(ResultsDialog, {
235
- label: details.label,
236
- result: details.result,
237
- onClose: () => setDetails(null)
238
- }) : null
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 };