@panneau/actions 5.0.0-alpha.17 → 5.0.0-alpha.19

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 CHANGED
@@ -63,12 +63,14 @@ function Pages() {
63
63
  - **`server` actions:**
64
64
  1. asks for the parameters (`fields`, in their `layout`) in a dialog, with the forms of `@panneau/forms`: client validation, then the `422` errors of the action endpoint on the fields;
65
65
  2. runs the action through the adapter, with the item or the selection (`ids`, or the list query with exceptions), or nothing for the resource;
66
- 3. shows the result in a toast: its `message`, the counts of what didn't succeed, and a "Details" button that lists those items with their message or reason;
66
+ 3. shows the result in a toast that names what it was done to (the item by the `itemTitle` of its resource, or the count of items): its `message`, the counts of what didn't succeed, and a "Details" button that lists those items with their message or reason. One toast per action and target: running it again replaces it ([decision 0062](../../docs/decisions/0062-toasts.md));
67
67
  4. calls `onResult` (refresh what it changed), opens the `download`, and goes to the `redirect`.
68
- - **Queued runs** (`202`): a toast says that the action runs in the background, the runner checks the run every `pollInterval` until it ends, then shows its result as above. `ActionRuns` lists the runs, with their progress, a button to cancel them (when the adapter has `cancelActionRun()`), and one to dismiss them once they have ended.
68
+ - **Queued runs** (`202`): no toast when they start (the runs button of the shell shows them), the runner checks the run every `pollInterval` until it ends, then shows its result as above, unless `ActionRuns` is on screen and the result says nothing more than its status. `ActionRuns` lists the runs, with their progress, a button to cancel them (when the adapter has `cancelActionRun()`), and one to dismiss them once they have ended.
69
69
  - **`link` actions** go to their `url` (with `{id}`) or `route`, through `onNavigate`.
70
70
  - **`client` actions** render the handler that their `component` names: one of `clientActions`, or of the plugins of `PanneauProvider` (`definePlugin({ actions: { 'share-dialog': ShareDialog } })`). It gets `ClientActionProps`, and ends with `onDone(result?)` or `onCancel()`.
71
71
 
72
+ **Undo** ([decision 0063](../../docs/decisions/0063-undo-instead-of-a-confirmation.md)). When a result has an `undo`, its toast has "Undo" for about 10 seconds: the runner runs that action of the resource on the items it lists, with its `params`, refreshes through `onResult`, and replaces the toast with a short one that says it was undone (or that it failed). The result of a queued run has no "Undo".
73
+
72
74
  **Dry runs.** `useActionPreview(resource)` is a list's `previewAction`. For an action that declares `dryRun`, on every item matching a query ("Select all N items"), it asks the backend what the action would do without running it (`"dryRun": true`), so that the list's confirmation says how many items will really be skipped: the list only knows the abilities of the current page. `previewAction(adapter, resource, target)` does the same outside of React.
73
75
 
74
76
  The function resolves with what happened (`{ status: 'done', result }`, `{ status: 'queued', run }` or `{ status: 'navigated', to }`), with `false` when the user cancelled the parameters (a list then keeps its selection), and rejects when the action failed (a list then shows it in a toast).
@@ -1 +1 @@
1
- {"version":3,"file":"ActionRunnerProvider.d.ts","sourceRoot":"","sources":["../src/ActionRunnerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAA+C,MAAM,OAAO,CAAC;AAIpF,OAAO,KAAK,EAAE,YAAY,EAAa,cAAc,EAAE,MAAM,mBAAmB,CAAC;AASjF,OAAO,KAAK,EACR,aAAa,EACb,cAAc,EAEd,mBAAmB,EAEnB,mBAAmB,EAEtB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,yBAAyB;IACtC,gFAAgF;IAChF,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC;IAC3E;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,KAAK,IAAI,CAAC;IACnD,gFAAgF;IAChF,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAChD,oFAAoF;IACpF,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC9D,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM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AO,EACP,QAAQ,EACR,QAAQ,EACR,UAAuB,EACvB,UAAyB,EACzB,aAAa,EACb,YAAmB,EACnB,OAAO,GACV,EAAE,yBAAyB,+BAsZ3B"}
@@ -1,12 +1,12 @@
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, getItemTitle, isInUse } from "./describe.js";
5
5
  import { ResultsDialog } from "./ResultsDialog.js";
6
6
  import { ActionRunnerContext } from "./context.js";
7
7
  import { c } from "react/compiler-runtime";
8
8
  import { useEffect, useEffectEvent, useRef, useState } from "react";
9
- import { usePlugins } from "@panneau/core";
9
+ import { usePanneau } from "@panneau/core";
10
10
  import { getActionLabel } from "@panneau/intl";
11
11
  import { usePanneauIntl, useToast } from "@panneau/ui";
12
12
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -33,14 +33,14 @@ function openDownload(download) {
33
33
  * that runs are followed from page to page. `useActionRunner(resource)` runs an action.
34
34
  */
35
35
  function ActionRunnerProvider(t0) {
36
- const $ = c(61);
36
+ const $ = c(71);
37
37
  const { adapter, children, onResult, onNavigate: t1, onDownload: t2, clientActions, pollInterval: t3, locales } = t0;
38
38
  const onNavigate = t1 === void 0 ? navigateTo : t1;
39
39
  const onDownload = t2 === void 0 ? openDownload : t2;
40
40
  const pollInterval = t3 === void 0 ? 2e3 : t3;
41
41
  const intl = usePanneauIntl();
42
42
  const toasts = useToast();
43
- const plugins = usePlugins();
43
+ const { definition, plugins } = usePanneau();
44
44
  const [parameters, setParameters] = useState(null);
45
45
  const [client, setClient] = useState(null);
46
46
  const [details, setDetails] = useState(null);
@@ -56,147 +56,236 @@ function ActionRunnerProvider(t0) {
56
56
  $[1] = t5;
57
57
  } else t5 = $[1];
58
58
  const notified = useRef(t5);
59
+ const watchers = useRef(0);
59
60
  let t6;
60
- if ($[2] !== intl || $[3] !== onDownload || $[4] !== onNavigate || $[5] !== onResult || $[6] !== toasts) {
61
- t6 = async (resource, target, result) => {
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);
77
+ };
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] !== subjectOf || $[16] !== 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;
62
90
  await onResult?.(result, {
63
- resource,
64
- target
91
+ resource: resource_2,
92
+ target: target_2
65
93
  });
66
- const content = describeResult(result, getActionLabel(target.action, intl), intl);
67
- const hasDetails = (result.results ?? []).length > 0;
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);
68
99
  const download = result.download ?? null;
69
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;
70
108
  toasts.show({
71
109
  ...content,
72
- ...hasDetails ? { action: {
110
+ ...undo !== null ? { action: {
111
+ label: intl.formatMessage(messages.undo),
112
+ onAction: () => void runUndo(resource_2, target_2, undo)
113
+ } } : hasDetails ? { action: {
73
114
  label: intl.formatMessage(messages.details),
74
115
  onAction: () => setDetails({
75
- label: getActionLabel(target.action, intl),
116
+ label: getActionLabel(target_2.action, intl),
76
117
  result
77
118
  })
78
119
  } } : download !== null ? { action: {
79
120
  label: intl.formatMessage(messages.download),
80
121
  onAction: () => onDownload(download)
81
122
  } } : {}
82
- });
83
- const redirect = result.redirect ?? null;
123
+ }, { key: toastKey(resource_2, target_2) });
84
124
  if (redirect !== null) onNavigate(redirect);
85
125
  };
86
- $[2] = intl;
87
- $[3] = onDownload;
88
- $[4] = onNavigate;
89
- $[5] = onResult;
90
- $[6] = toasts;
91
- $[7] = t6;
92
- } else t6 = $[7];
93
- const finish = t6;
94
- let t7;
95
- if ($[8] !== intl || $[9] !== toasts) {
96
- t7 = (resource_0, target_0, run) => {
126
+ const runUndo = async (resource_3, target_3, undo_0) => {
127
+ const label = getActionLabel(target_3.action, intl);
128
+ const key = { key: toastKey(resource_3, target_3) };
129
+ const undoTarget = {
130
+ action: definition?.resources.find((candidate_1) => candidate_1.id === resource_3)?.actions?.find((action) => action.id === undo_0.action) ?? {
131
+ id: undo_0.action,
132
+ kind: "server",
133
+ scope: ["selection"]
134
+ },
135
+ scope: "selection",
136
+ selection: { ids: undo_0.items },
137
+ count: undo_0.items.length
138
+ };
139
+ await adapter.runAction(resource_3, undo_0.action, {
140
+ selection: { ids: undo_0.items },
141
+ values: undo_0.params ?? {}
142
+ }).then(async (response) => {
143
+ if (response.run !== void 0) {
144
+ follow(resource_3, undoTarget, response.run);
145
+ return;
146
+ }
147
+ await onResult?.(response.result, {
148
+ resource: resource_3,
149
+ target: undoTarget
150
+ });
151
+ const subject = subjectOf(resource_3, target_3, undo_0.items.length);
152
+ toasts.show({ title: subject !== null ? intl.formatMessage(messages.undoneFor, {
153
+ action: label,
154
+ subject
155
+ }) : intl.formatMessage(messages.undone, { action: label }) }, key);
156
+ }).catch((error) => {
157
+ toasts.show({
158
+ title: intl.formatMessage(messages.undoFailed, { action: label }),
159
+ ...error instanceof Error && error.message !== "" ? { description: error.message } : {},
160
+ tone: "danger"
161
+ }, key);
162
+ });
163
+ };
164
+ follow = (resource_4, target_4, run) => {
97
165
  setRuns((current) => [...current.filter((entry) => entry.run.id !== run.id), {
98
166
  run,
99
- resource: resource_0,
100
- target: target_0
167
+ resource: resource_4,
168
+ target: target_4
101
169
  }]);
102
- toasts.show({
103
- title: intl.formatMessage(messages.queued, { action: getActionLabel(target_0.action, intl) }),
104
- description: intl.formatMessage(messages.queuedDescription),
105
- tone: "info"
106
- });
107
170
  };
108
- $[8] = intl;
109
- $[9] = toasts;
110
- $[10] = t7;
111
- } else t7 = $[10];
112
- const follow = t7;
171
+ $[8] = adapter;
172
+ $[9] = definition?.resources;
173
+ $[10] = intl;
174
+ $[11] = itemTitleOf;
175
+ $[12] = onDownload;
176
+ $[13] = onNavigate;
177
+ $[14] = onResult;
178
+ $[15] = subjectOf;
179
+ $[16] = toasts;
180
+ $[17] = finish;
181
+ $[18] = follow;
182
+ } else {
183
+ finish = $[17];
184
+ follow = $[18];
185
+ }
113
186
  let t8;
114
- if ($[11] !== finish || $[12] !== intl || $[13] !== toasts) {
187
+ if ($[19] !== finish || $[20] !== intl || $[21] !== subjectOf || $[22] !== toasts) {
115
188
  t8 = async (entry_0) => {
116
- const { run: run_0, resource: resource_1, target: target_1 } = entry_0;
189
+ const { run: run_0, resource: resource_5, target: target_5 } = entry_0;
117
190
  if (notified.current.has(run_0.id)) return;
118
191
  notified.current.add(run_0.id);
119
- if (run_0.result !== void 0) await finish(resource_1, target_1, run_0.result);
120
- else if (run_0.status === "cancelled") toasts.show({ title: intl.formatMessage(messages.cancelled, { action: getActionLabel(target_1.action, intl) }) });
192
+ if (run_0.result !== void 0) {
193
+ await finish(resource_5, target_5, run_0.result, { queued: true });
194
+ return;
195
+ }
196
+ const action_0 = getActionLabel(target_5.action, intl);
197
+ const subject_0 = subjectOf(resource_5, target_5);
198
+ const key_0 = { key: toastKey(resource_5, target_5) };
199
+ if (run_0.status === "cancelled") toasts.show({ title: subject_0 !== null ? intl.formatMessage(messages.cancelledFor, {
200
+ action: action_0,
201
+ subject: subject_0
202
+ }) : intl.formatMessage(messages.cancelled, { action: action_0 }) }, key_0);
121
203
  else if (run_0.status === "failed") toasts.show({
122
- title: intl.formatMessage(messages.failed, { action: getActionLabel(target_1.action, intl) }),
204
+ title: subject_0 !== null ? intl.formatMessage(messages.failedFor, {
205
+ action: action_0,
206
+ subject: subject_0
207
+ }) : intl.formatMessage(messages.failed, { action: action_0 }),
123
208
  tone: "danger"
124
- });
125
- else toasts.show({
126
- title: intl.formatMessage(messages.done, { action: getActionLabel(target_1.action, intl) }),
209
+ }, key_0);
210
+ else if (watchers.current === 0) toasts.show({
211
+ title: subject_0 !== null ? intl.formatMessage(messages.doneFor, {
212
+ action: action_0,
213
+ subject: subject_0
214
+ }) : intl.formatMessage(messages.done, { action: action_0 }),
127
215
  tone: "success"
128
- });
216
+ }, key_0);
129
217
  };
130
- $[11] = finish;
131
- $[12] = intl;
132
- $[13] = toasts;
133
- $[14] = t8;
134
- } else t8 = $[14];
218
+ $[19] = finish;
219
+ $[20] = intl;
220
+ $[21] = subjectOf;
221
+ $[22] = toasts;
222
+ $[23] = t8;
223
+ } else t8 = $[23];
135
224
  const ended = t8;
136
225
  let t9;
137
- if ($[15] !== adapter || $[16] !== finish || $[17] !== follow) {
138
- t9 = async (resource_2, target_2, t10) => {
226
+ if ($[24] !== adapter || $[25] !== finish || $[26] !== follow) {
227
+ t9 = async (resource_6, target_6, t10) => {
139
228
  const values = t10 === void 0 ? {} : t10;
140
- const response = await adapter.runAction(resource_2, target_2.action.id, buildActionRequest(target_2, values));
141
- if (response.run !== void 0) {
142
- follow(resource_2, target_2, response.run);
229
+ const response_0 = await adapter.runAction(resource_6, target_6.action.id, buildActionRequest(target_6, values));
230
+ if (response_0.run !== void 0) {
231
+ follow(resource_6, target_6, response_0.run);
143
232
  return {
144
233
  status: "queued",
145
- run: response.run
234
+ run: response_0.run
146
235
  };
147
236
  }
148
- await finish(resource_2, target_2, response.result);
237
+ await finish(resource_6, target_6, response_0.result);
149
238
  return {
150
239
  status: "done",
151
- result: response.result
240
+ result: response_0.result
152
241
  };
153
242
  };
154
- $[15] = adapter;
155
- $[16] = finish;
156
- $[17] = follow;
157
- $[18] = t9;
158
- } else t9 = $[18];
243
+ $[24] = adapter;
244
+ $[25] = finish;
245
+ $[26] = follow;
246
+ $[27] = t9;
247
+ } else t9 = $[27];
159
248
  const execute = t9;
160
249
  let t10;
161
- if ($[19] !== clientActions || $[20] !== execute || $[21] !== onNavigate || $[22] !== plugins) {
162
- t10 = (resource_3, target_3) => {
163
- const { action } = target_3;
164
- if (action.kind === "link") {
165
- const to = getLinkTarget(target_3);
166
- if (to === null) return Promise.reject(/* @__PURE__ */ new Error(`The action "${action.id}" has no URL or route.`));
250
+ if ($[28] !== clientActions || $[29] !== execute || $[30] !== onNavigate || $[31] !== plugins) {
251
+ t10 = (resource_7, target_7) => {
252
+ const { action: action_1 } = target_7;
253
+ if (action_1.kind === "link") {
254
+ const to = getLinkTarget(target_7);
255
+ if (to === null) return Promise.reject(/* @__PURE__ */ new Error(`The action "${action_1.id}" has no URL or route.`));
167
256
  onNavigate(to);
168
257
  return Promise.resolve({
169
258
  status: "navigated",
170
259
  to
171
260
  });
172
261
  }
173
- if (action.kind === "client") {
174
- const name = action.component ?? "";
262
+ if (action_1.kind === "client") {
263
+ const name = action_1.component ?? "";
175
264
  const Handler = (clientActions !== void 0 && Object.hasOwn(clientActions, name) ? clientActions[name] : void 0) ?? plugins.actions.get(name);
176
- if (Handler === void 0) return Promise.reject(/* @__PURE__ */ new Error(`No handler for the client action "${action.id}" (${name}).`));
265
+ if (Handler === void 0) return Promise.reject(/* @__PURE__ */ new Error(`No handler for the client action "${action_1.id}" (${name}).`));
177
266
  return new Promise((resolve) => setClient({
178
- resource: resource_3,
179
- target: target_3,
267
+ resource: resource_7,
268
+ target: target_7,
180
269
  resolve,
181
270
  Handler
182
271
  }));
183
272
  }
184
- if ((action.fields ?? []).length > 0) return new Promise((resolve_0) => setParameters({
185
- resource: resource_3,
186
- target: target_3,
273
+ if ((action_1.fields ?? []).length > 0) return new Promise((resolve_0) => setParameters({
274
+ resource: resource_7,
275
+ target: target_7,
187
276
  resolve: resolve_0
188
277
  }));
189
- return execute(resource_3, target_3);
278
+ return execute(resource_7, target_7);
190
279
  };
191
- $[19] = clientActions;
192
- $[20] = execute;
193
- $[21] = onNavigate;
194
- $[22] = plugins;
195
- $[23] = t10;
196
- } else t10 = $[23];
280
+ $[28] = clientActions;
281
+ $[29] = execute;
282
+ $[30] = onNavigate;
283
+ $[31] = plugins;
284
+ $[32] = t10;
285
+ } else t10 = $[32];
197
286
  const run_1 = t10;
198
287
  let t11;
199
- if ($[24] !== adapter || $[25] !== ended || $[26] !== runs) {
288
+ if ($[33] !== adapter || $[34] !== ended || $[35] !== runs) {
200
289
  t11 = async (id) => {
201
290
  if (adapter.cancelActionRun === void 0) throw new Error("The adapter cannot cancel runs.");
202
291
  await adapter.cancelActionRun(id);
@@ -205,35 +294,35 @@ function ActionRunnerProvider(t0) {
205
294
  ...entry_1,
206
295
  run: updated
207
296
  } : entry_1));
208
- const entry_2 = runs.find((candidate) => candidate.run.id === id);
297
+ const entry_2 = runs.find((candidate_2) => candidate_2.run.id === id);
209
298
  if (entry_2 !== void 0 && isFinished(updated.status)) await ended({
210
299
  ...entry_2,
211
300
  run: updated
212
301
  });
213
302
  };
214
- $[24] = adapter;
215
- $[25] = ended;
216
- $[26] = runs;
217
- $[27] = t11;
218
- } else t11 = $[27];
303
+ $[33] = adapter;
304
+ $[34] = ended;
305
+ $[35] = runs;
306
+ $[36] = t11;
307
+ } else t11 = $[36];
219
308
  const cancelRun = t11;
220
309
  let t12;
221
- if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
310
+ if ($[37] === Symbol.for("react.memo_cache_sentinel")) {
222
311
  t12 = (id_0) => setRuns((current_1) => current_1.filter((entry_3) => entry_3.run.id !== id_0));
223
- $[28] = t12;
224
- } else t12 = $[28];
312
+ $[37] = t12;
313
+ } else t12 = $[37];
225
314
  const dismissRun = t12;
226
315
  let t13;
227
- if ($[29] !== ended) {
316
+ if ($[38] !== ended) {
228
317
  t13 = (entry_4) => ended(entry_4);
229
- $[29] = ended;
230
- $[30] = t13;
231
- } else t13 = $[30];
318
+ $[38] = ended;
319
+ $[39] = t13;
320
+ } else t13 = $[39];
232
321
  const onRunEnded = useEffectEvent(t13);
233
322
  let t14;
234
- if ($[31] !== adapter || $[32] !== onRunEnded || $[33] !== pollInterval || $[34] !== runs) {
323
+ if ($[40] !== adapter || $[41] !== onRunEnded || $[42] !== pollInterval || $[43] !== runs) {
235
324
  t14 = () => {
236
- const active = runs.filter(_temp);
325
+ const active = runs.filter(_temp2);
237
326
  if (active.length === 0) return;
238
327
  let stopped = false;
239
328
  const timer = setTimeout(() => {
@@ -241,16 +330,16 @@ function ActionRunnerProvider(t0) {
241
330
  try {
242
331
  const next = await adapter.getActionRun(entry_6.run.id);
243
332
  if (stopped) return;
244
- setRuns((current_3) => current_3.map((candidate_0) => candidate_0.run.id === next.id ? {
245
- ...candidate_0,
333
+ setRuns((current_3) => current_3.map((candidate_3) => candidate_3.run.id === next.id ? {
334
+ ...candidate_3,
246
335
  run: next
247
- } : candidate_0));
336
+ } : candidate_3));
248
337
  if (isFinished(next.status)) await onRunEnded({
249
338
  ...entry_6,
250
339
  run: next
251
340
  });
252
341
  } catch {
253
- if (!stopped) setRuns(_temp2);
342
+ if (!stopped) setRuns(_temp3);
254
343
  }
255
344
  }));
256
345
  }, pollInterval);
@@ -259,45 +348,57 @@ function ActionRunnerProvider(t0) {
259
348
  clearTimeout(timer);
260
349
  };
261
350
  };
262
- $[31] = adapter;
263
- $[32] = onRunEnded;
264
- $[33] = pollInterval;
265
- $[34] = runs;
266
- $[35] = t14;
267
- } else t14 = $[35];
351
+ $[40] = adapter;
352
+ $[41] = onRunEnded;
353
+ $[42] = pollInterval;
354
+ $[43] = runs;
355
+ $[44] = t14;
356
+ } else t14 = $[44];
268
357
  let t15;
269
- if ($[36] !== adapter || $[37] !== pollInterval || $[38] !== runs) {
358
+ if ($[45] !== adapter || $[46] !== pollInterval || $[47] !== runs) {
270
359
  t15 = [
271
360
  runs,
272
361
  adapter,
273
362
  pollInterval
274
363
  ];
275
- $[36] = adapter;
276
- $[37] = pollInterval;
277
- $[38] = runs;
278
- $[39] = t15;
279
- } else t15 = $[39];
364
+ $[45] = adapter;
365
+ $[46] = pollInterval;
366
+ $[47] = runs;
367
+ $[48] = t15;
368
+ } else t15 = $[48];
280
369
  useEffect(t14, t15);
281
370
  let t16;
282
- if ($[40] !== adapter || $[41] !== cancelRun || $[42] !== run_1 || $[43] !== runs) {
283
- t16 = {
371
+ if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
372
+ t16 = () => {
373
+ watchers.current = watchers.current + 1;
374
+ return () => {
375
+ watchers.current = watchers.current - 1;
376
+ };
377
+ };
378
+ $[49] = t16;
379
+ } else t16 = $[49];
380
+ const watchRuns = t16;
381
+ let t17;
382
+ if ($[50] !== adapter || $[51] !== cancelRun || $[52] !== run_1 || $[53] !== runs) {
383
+ t17 = {
284
384
  adapter,
285
385
  run: run_1,
286
386
  runs,
287
387
  cancelRun,
288
- dismissRun
388
+ dismissRun,
389
+ watchRuns
289
390
  };
290
- $[40] = adapter;
291
- $[41] = cancelRun;
292
- $[42] = run_1;
293
- $[43] = runs;
294
- $[44] = t16;
295
- } else t16 = $[44];
296
- const value = t16;
391
+ $[50] = adapter;
392
+ $[51] = cancelRun;
393
+ $[52] = run_1;
394
+ $[53] = runs;
395
+ $[54] = t17;
396
+ } else t17 = $[54];
397
+ const value = t17;
297
398
  const ClientHandler = client?.Handler;
298
- let t17;
299
- if ($[45] !== execute || $[46] !== locales || $[47] !== parameters) {
300
- t17 = parameters !== null ? /* @__PURE__ */ jsx(ParametersDialog, {
399
+ let t18;
400
+ if ($[55] !== execute || $[56] !== locales || $[57] !== parameters) {
401
+ t18 = parameters !== null ? /* @__PURE__ */ jsx(ParametersDialog, {
301
402
  action: parameters.target.action,
302
403
  count: parameters.target.count,
303
404
  locales,
@@ -311,14 +412,14 @@ function ActionRunnerProvider(t0) {
311
412
  parameters.resolve(false);
312
413
  }
313
414
  }) : null;
314
- $[45] = execute;
315
- $[46] = locales;
316
- $[47] = parameters;
317
- $[48] = t17;
318
- } else t17 = $[48];
319
- let t18;
320
- if ($[49] !== ClientHandler || $[50] !== client || $[51] !== finish) {
321
- t18 = client !== null && ClientHandler !== void 0 ? /* @__PURE__ */ jsx(ClientHandler, {
415
+ $[55] = execute;
416
+ $[56] = locales;
417
+ $[57] = parameters;
418
+ $[58] = t18;
419
+ } else t18 = $[58];
420
+ let t19;
421
+ if ($[59] !== ClientHandler || $[60] !== client || $[61] !== finish) {
422
+ t19 = client !== null && ClientHandler !== void 0 ? /* @__PURE__ */ jsx(ClientHandler, {
322
423
  action: client.target.action,
323
424
  resource: client.resource,
324
425
  target: client.target,
@@ -341,47 +442,50 @@ function ActionRunnerProvider(t0) {
341
442
  client.resolve(false);
342
443
  }
343
444
  }) : null;
344
- $[49] = ClientHandler;
345
- $[50] = client;
346
- $[51] = finish;
347
- $[52] = t18;
348
- } else t18 = $[52];
349
- let t19;
350
- if ($[53] !== details) {
351
- t19 = details !== null ? /* @__PURE__ */ jsx(ResultsDialog, {
445
+ $[59] = ClientHandler;
446
+ $[60] = client;
447
+ $[61] = finish;
448
+ $[62] = t19;
449
+ } else t19 = $[62];
450
+ let t20;
451
+ if ($[63] !== details) {
452
+ t20 = details !== null ? /* @__PURE__ */ jsx(ResultsDialog, {
352
453
  label: details.label,
353
454
  result: details.result,
354
455
  onClose: () => setDetails(null)
355
456
  }) : null;
356
- $[53] = details;
357
- $[54] = t19;
358
- } else t19 = $[54];
359
- let t20;
360
- if ($[55] !== children || $[56] !== t17 || $[57] !== t18 || $[58] !== t19 || $[59] !== value) {
361
- t20 = /* @__PURE__ */ jsxs(ActionRunnerContext, {
457
+ $[63] = details;
458
+ $[64] = t20;
459
+ } else t20 = $[64];
460
+ let t21;
461
+ if ($[65] !== children || $[66] !== t18 || $[67] !== t19 || $[68] !== t20 || $[69] !== value) {
462
+ t21 = /* @__PURE__ */ jsxs(ActionRunnerContext, {
362
463
  value,
363
464
  children: [
364
465
  children,
365
- t17,
366
466
  t18,
367
- t19
467
+ t19,
468
+ t20
368
469
  ]
369
470
  });
370
- $[55] = children;
371
- $[56] = t17;
372
- $[57] = t18;
373
- $[58] = t19;
374
- $[59] = value;
375
- $[60] = t20;
376
- } else t20 = $[60];
377
- return t20;
471
+ $[65] = children;
472
+ $[66] = t18;
473
+ $[67] = t19;
474
+ $[68] = t20;
475
+ $[69] = value;
476
+ $[70] = t21;
477
+ } else t21 = $[70];
478
+ return t21;
378
479
  }
379
- function _temp2(current_2) {
480
+ function _temp3(current_2) {
380
481
  return [...current_2];
381
482
  }
382
- function _temp(entry_5) {
483
+ function _temp2(entry_5) {
383
484
  return !isFinished(entry_5.run.status);
384
485
  }
486
+ function _temp(resource_1, target_1) {
487
+ return `panneau-action:${resource_1}:${target_1.action.id}:${target_1.item?.id ?? "selection"}`;
488
+ }
385
489
  //#endregion
386
490
  export { ActionRunnerProvider };
387
491
 
@@ -1 +1 @@
1
- {"version":3,"file":"ActionRunnerProvider.js","names":["ReactNode","useEffect","useEffectEvent","useRef","useState","usePlugins","getActionLabel","ActionResult","ActionRun","RouteReference","usePanneauIntl","useToast","ParametersDialog","ResultsDialog","ActionRunnerContext","ActionRunnerContextValue","describeResult","messages","buildActionRequest","getLinkTarget","isFinished","ActionAdapter","ActionDownload","ActionOutcome","ActionResultContext","ActionTarget","ClientActionHandler","FollowedRun","ActionRunnerProviderProps","adapter","children","onResult","result","context","onNavigate","to","onDownload","download","clientActions","Readonly","Record","pollInterval","locales","Pending","resource","target","resolve","outcome","ClientPending","Handler","navigateTo","window","location","assign","console","warn","route","openDownload","link","document","createElement","href","url","filename","undefined","rel","hidden","body","append","click","remove","ActionRunnerProvider","t0","$","_c","t1","t2","t3","intl","toasts","plugins","parameters","setParameters","client","setClient","details","setDetails","t4","Symbol","for","runs","setRuns","t5","Set","notified","t6","content","action","hasDetails","results","length","show","label","formatMessage","onAction","redirect","finish","t7","resource_0","target_0","run","current","filter","entry","id","title","queued","description","queuedDescription","tone","follow","t8","entry_0","run_0","resource_1","target_1","has","add","status","cancelled","failed","done","ended","t9","resource_2","target_2","t10","values","response","runAction","execute","resource_3","target_3","kind","Promise","reject","Error","name","component","Object","hasOwn","actions","get","fields","resolve_0","run_1","t11","cancelActionRun","updated","getActionRun","current_0","map","entry_1","entry_2","find","candidate","cancelRun","t12","id_0","current_1","entry_3","dismissRun","t13","entry_4","onRunEnded","t14","active","_temp","stopped","timer","setTimeout","all","entry_6","next","current_3","candidate_0","_temp2","clearTimeout","t15","t16","value","ClientHandler","t17","count","values_0","t18","result_0","then","t19","t20","current_2","entry_5","_c"],"sources":["../src/ActionRunnerProvider.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useEffectEvent, useRef, useState } from 'react';\n\nimport { usePlugins } from '@panneau/core';\nimport { getActionLabel } from '@panneau/intl';\nimport type { ActionResult, ActionRun, RouteReference } from '@panneau/protocol';\nimport { usePanneauIntl, useToast } from '@panneau/ui';\n\nimport { ParametersDialog } from './ParametersDialog';\nimport { ResultsDialog } from './ResultsDialog';\nimport { ActionRunnerContext, type ActionRunnerContextValue } from './context';\nimport { describeResult } from './describe';\nimport { messages } from './messages';\nimport { buildActionRequest, getLinkTarget, isFinished } from './request';\nimport type {\n ActionAdapter,\n ActionDownload,\n ActionOutcome,\n ActionResultContext,\n ActionTarget,\n ClientActionHandler,\n FollowedRun,\n} from './types';\n\nexport interface ActionRunnerProviderProps {\n /** Runs the actions: a `DataAdapter`, or any object with its action methods. */\n adapter: ActionAdapter;\n children?: ReactNode;\n /**\n * Called with every result: of an action that finished at once, and of a queued run when it\n * finishes. Refresh what it changed here. With `@panneau/data/query`:\n * `invalidateActionResult(client, resource, result, target.selection)`.\n */\n onResult?: (result: ActionResult, context: ActionResultContext) => unknown;\n /**\n * Goes to the `redirect` of a result, or to the URL or route of a `link` action. Defaults to\n * `window.location.assign()` for URLs; routes need it.\n */\n onNavigate?: (to: string | RouteReference) => void;\n /** Opens the `download` of a result. Defaults to a link to its URL, clicked. */\n onDownload?: (download: ActionDownload) => void;\n /** Handlers of `client` actions by their `component`, over those of the plugins. */\n clientActions?: Readonly<Record<string, ClientActionHandler>>;\n /** Milliseconds between two checks of a queued run. Defaults to 2000. */\n pollInterval?: number;\n /** Locales of localized parameters. Defaults to the definition's. */\n locales?: readonly string[];\n}\n\ninterface Pending {\n resource: string;\n target: ActionTarget;\n resolve: (outcome: ActionOutcome | false) => void;\n}\n\ninterface ClientPending extends Pending {\n Handler: ClientActionHandler;\n}\n\nfunction navigateTo(to: string | RouteReference) {\n if (typeof to === 'string') {\n window.location.assign(to);\n } else {\n console.warn(\n `[panneau] An action goes to the route \"${to.route}\": give ActionRunnerProvider an onNavigate.`,\n );\n }\n}\n\nfunction openDownload(download: ActionDownload) {\n const link = document.createElement('a');\n link.href = download.url;\n if (download.filename !== undefined) {\n link.download = download.filename;\n }\n link.rel = 'noopener';\n link.hidden = true;\n document.body.append(link);\n link.click();\n link.remove();\n}\n\n/**\n * Runs the actions that lists and forms hand over ([decision 0023]): it asks for their parameters\n * in a dialog, runs them through the adapter, shows their result (a toast, and the items that\n * didn't succeed), follows queued runs until they end, refreshes through `onResult`, follows\n * redirects and opens downloads. Put it inside `PanneauRoot`, and above the router of an app, so\n * that runs are followed from page to page. `useActionRunner(resource)` runs an action.\n */\nexport function ActionRunnerProvider({\n adapter,\n children,\n onResult,\n onNavigate = navigateTo,\n onDownload = openDownload,\n clientActions,\n pollInterval = 2000,\n locales,\n}: ActionRunnerProviderProps) {\n const intl = usePanneauIntl();\n const toasts = useToast();\n const plugins = usePlugins();\n const [parameters, setParameters] = useState<Pending | null>(null);\n const [client, setClient] = useState<ClientPending | null>(null);\n const [details, setDetails] = useState<{ label: string; result: ActionResult } | null>(null);\n const [runs, setRuns] = useState<readonly FollowedRun[]>([]);\n // Runs whose end was already shown, so that a late poll doesn't show it twice.\n const notified = useRef(new Set<string>());\n\n const finish = async (resource: string, target: ActionTarget, result: ActionResult) => {\n await onResult?.(result, { resource, target });\n const content = describeResult(result, getActionLabel(target.action, intl), intl);\n const hasDetails = (result.results ?? []).length > 0;\n const download = result.download ?? null;\n if (download !== null) {\n onDownload(download);\n }\n toasts.show({\n ...content,\n ...(hasDetails\n ? {\n action: {\n label: intl.formatMessage(messages.details),\n onAction: () =>\n setDetails({ label: getActionLabel(target.action, intl), result }),\n },\n }\n : download !== null\n ? {\n action: {\n label: intl.formatMessage(messages.download),\n onAction: () => onDownload(download),\n },\n }\n : {}),\n });\n const redirect = result.redirect ?? null;\n if (redirect !== null) {\n onNavigate(redirect);\n }\n };\n\n const follow = (resource: string, target: ActionTarget, run: ActionRun) => {\n setRuns((current) => [\n ...current.filter((entry) => entry.run.id !== run.id),\n { run, resource, target },\n ]);\n toasts.show({\n title: intl.formatMessage(messages.queued, {\n action: getActionLabel(target.action, intl),\n }),\n description: intl.formatMessage(messages.queuedDescription),\n tone: 'info',\n });\n };\n\n const ended = async (entry: FollowedRun) => {\n const { run, resource, target } = entry;\n if (notified.current.has(run.id)) {\n return;\n }\n notified.current.add(run.id);\n if (run.result !== undefined) {\n await finish(resource, target, run.result);\n } else if (run.status === 'cancelled') {\n toasts.show({\n title: intl.formatMessage(messages.cancelled, {\n action: getActionLabel(target.action, intl),\n }),\n });\n } else if (run.status === 'failed') {\n toasts.show({\n title: intl.formatMessage(messages.failed, {\n action: getActionLabel(target.action, intl),\n }),\n tone: 'danger',\n });\n } else {\n toasts.show({\n title: intl.formatMessage(messages.done, {\n action: getActionLabel(target.action, intl),\n }),\n tone: 'success',\n });\n }\n };\n\n const execute = async (\n resource: string,\n target: ActionTarget,\n values: Record<string, unknown> = {},\n ): Promise<ActionOutcome> => {\n const response = await adapter.runAction(\n resource,\n target.action.id,\n buildActionRequest(target, values),\n );\n if (response.run !== undefined) {\n follow(resource, target, response.run);\n return { status: 'queued', run: response.run };\n }\n await finish(resource, target, response.result);\n return { status: 'done', result: response.result };\n };\n\n const run = (resource: string, target: ActionTarget): Promise<ActionOutcome | false> => {\n const { action } = target;\n if (action.kind === 'link') {\n const to = getLinkTarget(target);\n if (to === null) {\n return Promise.reject(new Error(`The action \"${action.id}\" has no URL or route.`));\n }\n onNavigate(to);\n return Promise.resolve({ status: 'navigated', to });\n }\n if (action.kind === 'client') {\n const name = action.component ?? '';\n const Handler =\n (clientActions !== undefined && Object.hasOwn(clientActions, name)\n ? clientActions[name]\n : undefined) ?? (plugins.actions.get(name) as ClientActionHandler | undefined);\n if (Handler === undefined) {\n return Promise.reject(\n new Error(`No handler for the client action \"${action.id}\" (${name}).`),\n );\n }\n return new Promise((resolve) => setClient({ resource, target, resolve, Handler }));\n }\n if ((action.fields ?? []).length > 0) {\n return new Promise((resolve) => setParameters({ resource, target, resolve }));\n }\n return execute(resource, target);\n };\n\n const cancelRun = async (id: string) => {\n if (adapter.cancelActionRun === undefined) {\n throw new Error('The adapter cannot cancel runs.');\n }\n await adapter.cancelActionRun(id);\n const updated = await adapter.getActionRun(id);\n setRuns((current) =>\n current.map((entry) => (entry.run.id === id ? { ...entry, run: updated } : entry)),\n );\n const entry = runs.find((candidate) => candidate.run.id === id);\n if (entry !== undefined && isFinished(updated.status)) {\n await ended({ ...entry, run: updated });\n }\n };\n\n const dismissRun = (id: string) =>\n setRuns((current) => current.filter((entry) => entry.run.id !== id));\n\n const onRunEnded = useEffectEvent((entry: FollowedRun) => ended(entry));\n\n // Checks the unfinished runs, one interval after the last change of the runs.\n useEffect(() => {\n const active = runs.filter((entry) => !isFinished(entry.run.status));\n if (active.length === 0) {\n return undefined;\n }\n let stopped = false;\n const timer = setTimeout(() => {\n void Promise.all(\n active.map(async (entry) => {\n try {\n const next = await adapter.getActionRun(entry.run.id);\n if (stopped) {\n return;\n }\n setRuns((current) =>\n current.map((candidate) =>\n candidate.run.id === next.id\n ? { ...candidate, run: next }\n : candidate,\n ),\n );\n if (isFinished(next.status)) {\n await onRunEnded({ ...entry, run: next });\n }\n } catch {\n // Checked again at the next interval.\n if (!stopped) {\n setRuns((current) => [...current]);\n }\n }\n }),\n );\n }, pollInterval);\n return () => {\n stopped = true;\n clearTimeout(timer);\n };\n }, [runs, adapter, pollInterval]);\n\n const value: ActionRunnerContextValue = { adapter, run, runs, cancelRun, dismissRun };\n\n const ClientHandler = client?.Handler;\n return (\n <ActionRunnerContext value={value}>\n {children}\n {parameters !== null ? (\n <ParametersDialog\n action={parameters.target.action}\n count={parameters.target.count}\n locales={locales}\n onSubmit={(values) => execute(parameters.resource, parameters.target, values)}\n onDone={(outcome) => {\n setParameters(null);\n parameters.resolve(outcome);\n }}\n onCancel={() => {\n setParameters(null);\n parameters.resolve(false);\n }}\n />\n ) : null}\n {client !== null && ClientHandler !== undefined ? (\n <ClientHandler\n action={client.target.action}\n resource={client.resource}\n target={client.target}\n onDone={(result) => {\n setClient(null);\n if (result === undefined) {\n client.resolve({ status: 'done', result: {} });\n return;\n }\n void finish(client.resource, client.target, result).then(() =>\n client.resolve({ status: 'done', result }),\n );\n }}\n onCancel={() => {\n setClient(null);\n client.resolve(false);\n }}\n />\n ) : null}\n {details !== null ? (\n <ResultsDialog\n label={details.label}\n result={details.result}\n onClose={() => setDetails(null)}\n />\n ) : null}\n </ActionRunnerContext>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA0DA,SAASkD,WAAWf,IAA6B;CAC7C,IAAI,OAAOA,OAAO,UACdgB,OAAOC,SAASC,OAAOlB,EAAE;MAEzBmB,QAAQC,KACJ,0CAA0CpB,GAAGqB,MAAK,4CACtD;AAER;AAEA,SAASC,aAAapB,UAA0B;CAC5C,MAAMqB,OAAOC,SAASC,cAAc,GAAG;CACvCF,KAAKG,OAAOxB,SAASyB;CACrB,IAAIzB,SAAS0B,aAAaC,KAAAA,GACtBN,KAAKrB,WAAWA,SAAS0B;CAE7BL,KAAKO,MAAM;CACXP,KAAKQ,SAAS;CACdP,SAASQ,KAAKC,OAAOV,IAAI;CACzBA,KAAKW,MAAM;CACXX,KAAKY,OAAO;AAChB;;;;;;;;AASA,SAAOC,qBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAA8B,MAAA,EAAA7C,SAAAC,UAAAC,UAAAG,YAAAyC,IAAAvC,YAAAwC,IAAAtC,eAAAG,cAAAoC,IAAAnC,YAAA8B;CAIjC,MAAAtC,aAAAyC,OAAAX,KAAAA,IAAAd,aAAAyB;CACA,MAAAvC,aAAAwC,OAAAZ,KAAAA,IAAAP,eAAAmB;CAEA,MAAAnC,eAAAoC,OAAAb,KAAAA,IAAA,MAAAa;CAGA,MAAAC,OAAapE,eAAe;CAC5B,MAAAqE,SAAepE,SAAS;CACxB,MAAAqE,UAAgB3E,WAAW;CAC3B,MAAA,CAAA4E,YAAAC,iBAAoC9E,SAAyB,IAAI;CACjE,MAAA,CAAA+E,QAAAC,aAA4BhF,SAA+B,IAAI;CAC/D,MAAA,CAAAiF,SAAAC,cAA8BlF,SAAyD,IAAI;CAAE,IAAAmF;CAAA,IAAAd,EAAA,OAAAe,OAAAC,IAAA,2BAAA,GAAA;EACpCF,KAAA,CAAA;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C,CAACrL,WAAW6F,QAAKH,IAAIkB,MAAO;AAAC"}
1
+ {"version":3,"file":"ActionRunnerProvider.js","names":["ReactNode","useEffect","useEffectEvent","useRef","useState","usePanneau","getActionLabel","ActionResult","ActionRun","RouteReference","usePanneauIntl","useToast","ParametersDialog","ResultsDialog","ActionRunnerContext","ActionRunnerContextValue","describeResult","describeSubject","getItemTitle","isInUse","messages","buildActionRequest","getLinkTarget","getResultCounts","isFinished","ActionAdapter","ActionDownload","ActionOutcome","ActionResultContext","ActionTarget","ClientActionHandler","FollowedRun","ActionRunnerProviderProps","adapter","children","onResult","result","context","onNavigate","to","onDownload","download","clientActions","Readonly","Record","pollInterval","locales","Pending","resource","target","resolve","outcome","ClientPending","Handler","navigateTo","window","location","assign","console","warn","route","openDownload","link","document","createElement","href","url","filename","undefined","rel","hidden","body","append","click","remove","ActionRunnerProvider","t0","$","_c","t1","t2","t3","intl","toasts","definition","plugins","parameters","setParameters","client","setClient","details","setDetails","t4","Symbol","for","runs","setRuns","t5","Set","notified","watchers","t6","resources","t7","count","find","candidate","id","subjectOf","resource_0","target_0","item","itemTitle","candidate_0","locale","itemTitleOf","toastKey","_temp","finish","follow","resource_2","target_2","t8","queued","t9","counts","itemTitle_0","content","action","succeeded","entries","results","hasDetails","length","redirect","saysMore","message","current","undo","show","label","formatMessage","onAction","runUndo","key","resource_3","target_3","undo_0","declared","candidate_1","actions","undoTarget","kind","scope","selection","ids","items","runAction","values","params","then","response","run","subject","title","undoneFor","undone","catch","error","undoFailed","Error","description","tone","resource_4","target_4","filter","entry","entry_0","run_0","resource_5","target_5","has","add","action_0","subject_0","key_0","status","cancelledFor","cancelled","failedFor","failed","doneFor","done","ended","resource_6","target_6","t10","response_0","execute","resource_7","target_7","action_1","Promise","reject","name","component","Object","hasOwn","get","fields","resolve_0","run_1","t11","cancelActionRun","updated","getActionRun","current_0","map","entry_1","entry_2","candidate_2","cancelRun","t12","id_0","current_1","entry_3","dismissRun","t13","entry_4","onRunEnded","t14","active","_temp2","stopped","timer","setTimeout","all","entry_6","next","current_3","candidate_3","_temp3","clearTimeout","t15","t16","watchRuns","t17","value","ClientHandler","t18","values_0","t19","result_0","t20","t21","current_2","entry_5","resource_1","target_1","_c"],"sources":["../src/ActionRunnerProvider.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useEffectEvent, useRef, useState } from 'react';\n\nimport { usePanneau } from '@panneau/core';\nimport { getActionLabel } from '@panneau/intl';\nimport type { ActionResult, ActionRun, RouteReference } from '@panneau/protocol';\nimport { usePanneauIntl, useToast } from '@panneau/ui';\n\nimport { ParametersDialog } from './ParametersDialog';\nimport { ResultsDialog } from './ResultsDialog';\nimport { ActionRunnerContext, type ActionRunnerContextValue } from './context';\nimport { describeResult, describeSubject, getItemTitle, isInUse } from './describe';\nimport { messages } from './messages';\nimport { buildActionRequest, getLinkTarget, getResultCounts, isFinished } from './request';\nimport type {\n ActionAdapter,\n ActionDownload,\n ActionOutcome,\n ActionResultContext,\n ActionTarget,\n ClientActionHandler,\n FollowedRun,\n} from './types';\n\nexport interface ActionRunnerProviderProps {\n /** Runs the actions: a `DataAdapter`, or any object with its action methods. */\n adapter: ActionAdapter;\n children?: ReactNode;\n /**\n * Called with every result: of an action that finished at once, and of a queued run when it\n * finishes. Refresh what it changed here. With `@panneau/data/query`:\n * `invalidateActionResult(client, resource, result, target.selection)`.\n */\n onResult?: (result: ActionResult, context: ActionResultContext) => unknown;\n /**\n * Goes to the `redirect` of a result, or to the URL or route of a `link` action. Defaults to\n * `window.location.assign()` for URLs; routes need it.\n */\n onNavigate?: (to: string | RouteReference) => void;\n /** Opens the `download` of a result. Defaults to a link to its URL, clicked. */\n onDownload?: (download: ActionDownload) => void;\n /** Handlers of `client` actions by their `component`, over those of the plugins. */\n clientActions?: Readonly<Record<string, ClientActionHandler>>;\n /** Milliseconds between two checks of a queued run. Defaults to 2000. */\n pollInterval?: number;\n /** Locales of localized parameters. Defaults to the definition's. */\n locales?: readonly string[];\n}\n\ninterface Pending {\n resource: string;\n target: ActionTarget;\n resolve: (outcome: ActionOutcome | false) => void;\n}\n\ninterface ClientPending extends Pending {\n Handler: ClientActionHandler;\n}\n\nfunction navigateTo(to: string | RouteReference) {\n if (typeof to === 'string') {\n window.location.assign(to);\n } else {\n console.warn(\n `[panneau] An action goes to the route \"${to.route}\": give ActionRunnerProvider an onNavigate.`,\n );\n }\n}\n\nfunction openDownload(download: ActionDownload) {\n const link = document.createElement('a');\n link.href = download.url;\n if (download.filename !== undefined) {\n link.download = download.filename;\n }\n link.rel = 'noopener';\n link.hidden = true;\n document.body.append(link);\n link.click();\n link.remove();\n}\n\n/**\n * Runs the actions that lists and forms hand over ([decision 0023]): it asks for their parameters\n * in a dialog, runs them through the adapter, shows their result (a toast, and the items that\n * didn't succeed), follows queued runs until they end, refreshes through `onResult`, follows\n * redirects and opens downloads. Put it inside `PanneauRoot`, and above the router of an app, so\n * that runs are followed from page to page. `useActionRunner(resource)` runs an action.\n */\nexport function ActionRunnerProvider({\n adapter,\n children,\n onResult,\n onNavigate = navigateTo,\n onDownload = openDownload,\n clientActions,\n pollInterval = 2000,\n locales,\n}: ActionRunnerProviderProps) {\n const intl = usePanneauIntl();\n const toasts = useToast();\n const { definition, plugins } = usePanneau();\n const [parameters, setParameters] = useState<Pending | null>(null);\n const [client, setClient] = useState<ClientPending | null>(null);\n const [details, setDetails] = useState<{ label: string; result: ActionResult } | null>(null);\n const [runs, setRuns] = useState<readonly FollowedRun[]>([]);\n // Runs whose end was already shown, so that a late poll doesn't show it twice.\n const notified = useRef(new Set<string>());\n // How many lists of runs are on screen (the popover of the runs): their user sees a run end.\n const watchers = useRef(0);\n\n /** What the action applied to, by the item's title or the count of items. */\n const subjectOf = (resource: string, target: ActionTarget, count: number | null = null) =>\n describeSubject(\n target,\n definition?.resources.find((candidate) => candidate.id === resource),\n intl,\n count,\n );\n\n /** The title of the item of an `item` action, to name it. */\n const itemTitleOf = (resource: string, target: ActionTarget) => {\n if (target.item === undefined) {\n return null;\n }\n const itemTitle = definition?.resources.find(\n (candidate) => candidate.id === resource,\n )?.itemTitle;\n return getItemTitle(target.item, itemTitle, intl.locale);\n };\n\n /** One toast per action and target: running it again replaces it. */\n const toastKey = (resource: string, target: ActionTarget) =>\n `panneau-action:${resource}:${target.action.id}:${target.item?.id ?? 'selection'}`;\n\n const finish = async (\n resource: string,\n target: ActionTarget,\n result: ActionResult,\n { queued = false }: { queued?: boolean } = {},\n ) => {\n await onResult?.(result, { resource, target });\n const counts = getResultCounts(result);\n const itemTitle = itemTitleOf(resource, target);\n const content = describeResult(\n result,\n getActionLabel(target.action, intl),\n intl,\n subjectOf(resource, target, counts.succeeded),\n itemTitle,\n );\n const entries = result.results ?? [];\n // The toast already names an item that is in use: its details would only repeat it.\n const hasDetails =\n entries.length > 0 &&\n !(\n entries.length === 1 &&\n entries[0] !== undefined &&\n isInUse(entries[0]) &&\n itemTitle !== null\n );\n const download = result.download ?? null;\n if (download !== null) {\n onDownload(download);\n }\n const redirect = result.redirect ?? null;\n // A queued run that ends in the open list of runs is seen there, unless its result says\n // more than its status: a message, items that didn't succeed, a download.\n const saysMore = (result.message ?? '') !== '' || hasDetails || download !== null;\n if (queued && watchers.current > 0 && !saysMore) {\n if (redirect !== null) {\n onNavigate(redirect);\n }\n return;\n }\n // \"Undo\" lives in the toast only (decision 0063): a queued run, which finished later, isn't\n // undone.\n const undo = !queued ? (result.undo ?? null) : null;\n toasts.show(\n {\n ...content,\n ...(undo !== null\n ? {\n action: {\n label: intl.formatMessage(messages.undo),\n onAction: () => void runUndo(resource, target, undo),\n },\n }\n : hasDetails\n ? {\n action: {\n label: intl.formatMessage(messages.details),\n onAction: () =>\n setDetails({\n label: getActionLabel(target.action, intl),\n result,\n }),\n },\n }\n : download !== null\n ? {\n action: {\n label: intl.formatMessage(messages.download),\n onAction: () => onDownload(download),\n },\n }\n : {}),\n },\n { key: toastKey(resource, target) },\n );\n if (redirect !== null) {\n onNavigate(redirect);\n }\n };\n\n /**\n * Runs the undo of a result: an action of the same resource, on the items it lists, as any\n * action. A short toast then says it was undone, in place of the first one.\n */\n const runUndo = async (\n resource: string,\n target: ActionTarget,\n undo: NonNullable<ActionResult['undo']>,\n ) => {\n const label = getActionLabel(target.action, intl);\n const key = { key: toastKey(resource, target) };\n const declared = definition?.resources\n .find((candidate) => candidate.id === resource)\n ?.actions?.find((action) => action.id === undo.action);\n const undoTarget: ActionTarget = {\n action: declared ?? { id: undo.action, kind: 'server', scope: ['selection'] },\n scope: 'selection',\n selection: { ids: undo.items },\n count: undo.items.length,\n };\n await adapter\n .runAction(resource, undo.action, {\n selection: { ids: undo.items },\n values: undo.params ?? {},\n })\n .then(async (response) => {\n if (response.run !== undefined) {\n follow(resource, undoTarget, response.run);\n return;\n }\n await onResult?.(response.result, { resource, target: undoTarget });\n const subject = subjectOf(resource, target, undo.items.length);\n toasts.show(\n {\n title:\n subject !== null\n ? intl.formatMessage(messages.undoneFor, {\n action: label,\n subject,\n })\n : intl.formatMessage(messages.undone, { action: label }),\n },\n key,\n );\n })\n .catch((error: unknown) => {\n toasts.show(\n {\n title: intl.formatMessage(messages.undoFailed, { action: label }),\n ...(error instanceof Error && error.message !== ''\n ? { description: error.message }\n : {}),\n tone: 'danger',\n },\n key,\n );\n });\n };\n\n // No toast when a run starts: the runs button of the shell shows it, and its popover follows\n // it. The toast comes when the run ends.\n const follow = (resource: string, target: ActionTarget, run: ActionRun) => {\n setRuns((current) => [\n ...current.filter((entry) => entry.run.id !== run.id),\n { run, resource, target },\n ]);\n };\n\n const ended = async (entry: FollowedRun) => {\n const { run, resource, target } = entry;\n if (notified.current.has(run.id)) {\n return;\n }\n notified.current.add(run.id);\n if (run.result !== undefined) {\n await finish(resource, target, run.result, { queued: true });\n return;\n }\n const action = getActionLabel(target.action, intl);\n const subject = subjectOf(resource, target);\n const key = { key: toastKey(resource, target) };\n if (run.status === 'cancelled') {\n toasts.show(\n {\n title:\n subject !== null\n ? intl.formatMessage(messages.cancelledFor, { action, subject })\n : intl.formatMessage(messages.cancelled, { action }),\n },\n key,\n );\n } else if (run.status === 'failed') {\n toasts.show(\n {\n title:\n subject !== null\n ? intl.formatMessage(messages.failedFor, { action, subject })\n : intl.formatMessage(messages.failed, { action }),\n tone: 'danger',\n },\n key,\n );\n } else if (watchers.current === 0) {\n toasts.show(\n {\n title:\n subject !== null\n ? intl.formatMessage(messages.doneFor, { action, subject })\n : intl.formatMessage(messages.done, { action }),\n tone: 'success',\n },\n key,\n );\n }\n };\n\n const execute = async (\n resource: string,\n target: ActionTarget,\n values: Record<string, unknown> = {},\n ): Promise<ActionOutcome> => {\n const response = await adapter.runAction(\n resource,\n target.action.id,\n buildActionRequest(target, values),\n );\n if (response.run !== undefined) {\n follow(resource, target, response.run);\n return { status: 'queued', run: response.run };\n }\n await finish(resource, target, response.result);\n return { status: 'done', result: response.result };\n };\n\n const run = (resource: string, target: ActionTarget): Promise<ActionOutcome | false> => {\n const { action } = target;\n if (action.kind === 'link') {\n const to = getLinkTarget(target);\n if (to === null) {\n return Promise.reject(new Error(`The action \"${action.id}\" has no URL or route.`));\n }\n onNavigate(to);\n return Promise.resolve({ status: 'navigated', to });\n }\n if (action.kind === 'client') {\n const name = action.component ?? '';\n const Handler =\n (clientActions !== undefined && Object.hasOwn(clientActions, name)\n ? clientActions[name]\n : undefined) ?? (plugins.actions.get(name) as ClientActionHandler | undefined);\n if (Handler === undefined) {\n return Promise.reject(\n new Error(`No handler for the client action \"${action.id}\" (${name}).`),\n );\n }\n return new Promise((resolve) => setClient({ resource, target, resolve, Handler }));\n }\n if ((action.fields ?? []).length > 0) {\n return new Promise((resolve) => setParameters({ resource, target, resolve }));\n }\n return execute(resource, target);\n };\n\n const cancelRun = async (id: string) => {\n if (adapter.cancelActionRun === undefined) {\n throw new Error('The adapter cannot cancel runs.');\n }\n await adapter.cancelActionRun(id);\n const updated = await adapter.getActionRun(id);\n setRuns((current) =>\n current.map((entry) => (entry.run.id === id ? { ...entry, run: updated } : entry)),\n );\n const entry = runs.find((candidate) => candidate.run.id === id);\n if (entry !== undefined && isFinished(updated.status)) {\n await ended({ ...entry, run: updated });\n }\n };\n\n const dismissRun = (id: string) =>\n setRuns((current) => current.filter((entry) => entry.run.id !== id));\n\n const onRunEnded = useEffectEvent((entry: FollowedRun) => ended(entry));\n\n // Checks the unfinished runs, one interval after the last change of the runs.\n useEffect(() => {\n const active = runs.filter((entry) => !isFinished(entry.run.status));\n if (active.length === 0) {\n return undefined;\n }\n let stopped = false;\n const timer = setTimeout(() => {\n void Promise.all(\n active.map(async (entry) => {\n try {\n const next = await adapter.getActionRun(entry.run.id);\n if (stopped) {\n return;\n }\n setRuns((current) =>\n current.map((candidate) =>\n candidate.run.id === next.id\n ? { ...candidate, run: next }\n : candidate,\n ),\n );\n if (isFinished(next.status)) {\n await onRunEnded({ ...entry, run: next });\n }\n } catch {\n // Checked again at the next interval.\n if (!stopped) {\n setRuns((current) => [...current]);\n }\n }\n }),\n );\n }, pollInterval);\n return () => {\n stopped = true;\n clearTimeout(timer);\n };\n }, [runs, adapter, pollInterval]);\n\n const watchRuns = () => {\n watchers.current += 1;\n return () => {\n watchers.current -= 1;\n };\n };\n\n const value: ActionRunnerContextValue = {\n adapter,\n run,\n runs,\n cancelRun,\n dismissRun,\n watchRuns,\n };\n\n const ClientHandler = client?.Handler;\n return (\n <ActionRunnerContext value={value}>\n {children}\n {parameters !== null ? (\n <ParametersDialog\n action={parameters.target.action}\n count={parameters.target.count}\n locales={locales}\n onSubmit={(values) => execute(parameters.resource, parameters.target, values)}\n onDone={(outcome) => {\n setParameters(null);\n parameters.resolve(outcome);\n }}\n onCancel={() => {\n setParameters(null);\n parameters.resolve(false);\n }}\n />\n ) : null}\n {client !== null && ClientHandler !== undefined ? (\n <ClientHandler\n action={client.target.action}\n resource={client.resource}\n target={client.target}\n onDone={(result) => {\n setClient(null);\n if (result === undefined) {\n client.resolve({ status: 'done', result: {} });\n return;\n }\n void finish(client.resource, client.target, result).then(() =>\n client.resolve({ status: 'done', result }),\n );\n }}\n onCancel={() => {\n setClient(null);\n client.resolve(false);\n }}\n />\n ) : null}\n {details !== null ? (\n <ResultsDialog\n label={details.label}\n result={details.result}\n onClose={() => setDetails(null)}\n />\n ) : null}\n </ActionRunnerContext>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA0DA,SAASsD,WAAWf,IAA6B;CAC7C,IAAI,OAAOA,OAAO,UACdgB,OAAOC,SAASC,OAAOlB,EAAE;MAEzBmB,QAAQC,KACJ,0CAA0CpB,GAAGqB,MAAK,4CACtD;AAER;AAEA,SAASC,aAAapB,UAA0B;CAC5C,MAAMqB,OAAOC,SAASC,cAAc,GAAG;CACvCF,KAAKG,OAAOxB,SAASyB;CACrB,IAAIzB,SAAS0B,aAAaC,KAAAA,GACtBN,KAAKrB,WAAWA,SAAS0B;CAE7BL,KAAKO,MAAM;CACXP,KAAKQ,SAAS;CACdP,SAASQ,KAAKC,OAAOV,IAAI;CACzBA,KAAKW,MAAM;CACXX,KAAKY,OAAO;AAChB;;;;;;;;AASA,SAAOC,qBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAA8B,MAAA,EAAA7C,SAAAC,UAAAC,UAAAG,YAAAyC,IAAAvC,YAAAwC,IAAAtC,eAAAG,cAAAoC,IAAAnC,YAAA8B;CAIjC,MAAAtC,aAAAyC,OAAAX,KAAAA,IAAAd,aAAAyB;CACA,MAAAvC,aAAAwC,OAAAZ,KAAAA,IAAAP,eAAAmB;CAEA,MAAAnC,eAAAoC,OAAAb,KAAAA,IAAA,MAAAa;CAGA,MAAAC,OAAaxE,eAAe;CAC5B,MAAAyE,SAAexE,SAAS;CACxB,MAAA,EAAAyE,YAAAC,YAAgChF,WAAW;CAC3C,MAAA,CAAAiF,YAAAC,iBAAoCnF,SAAyB,IAAI;CACjE,MAAA,CAAAoF,QAAAC,aAA4BrF,SAA+B,IAAI;CAC/D,MAAA,CAAAsF,SAAAC,cAA8BvF,SAAyD,IAAI;CAAE,IAAAwF;CAAA,IAA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AA9K,EAAA,MAAAgL;EAAAhL,EAAA,MAAA0K;EAAA1K,EAAA,MAAAiL;CAAA,OAAAA,MAAAjL,EAAA;CAAA,OA9CtBiL;AA8CsB;AA7ZvB,SAAAb,OAAAc,WAAA;CAAA,OAiV0C,CAAA,GAAItH,SAAO;AAAC;AAjVtD,SAAA+F,OAAAwB,SAAA;CAAA,OAuTuC,CAACxO,WAAWwJ,QAAKd,IAAIwB,MAAO;AAAC;AAvTpE,SAAArE,MAAA4I,YAAAC,UAAA;CAAA,OA4CC,kBAAkBlN,WAAQ,GAAIC,SAAM+E,OAAOrB,GAAG,GAAI1D,SAAM8D,MAASJ,MAAf;AAAgC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ActionRuns.d.ts","sourceRoot":"","sources":["../src/ActionRuns.tsx"],"names":[],"mappings":"AAsBA,MAAM,WAAW,eAAe;IAC5B,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,eAAe,sCA8EjF"}
1
+ {"version":3,"file":"ActionRuns.d.ts","sourceRoot":"","sources":["../src/ActionRuns.tsx"],"names":[],"mappings":"AAsBA,MAAM,WAAW,eAAe;IAC5B,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,eAAe,sCAgFjF"}
@@ -3,7 +3,7 @@ import { messages } from "./messages.js";
3
3
  import { isFinished } from "./request.js";
4
4
  import { ActionRunnerContext } from "./context.js";
5
5
  import { c } from "react/compiler-runtime";
6
- import { use } from "react";
6
+ import { use, useEffect } from "react";
7
7
  import { getActionLabel } from "@panneau/intl";
8
8
  import { Button, IconButton, usePanneauIntl } from "@panneau/ui";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -24,30 +24,43 @@ var STATUS_MESSAGES = {
24
24
  * that have. For a notification area. Renders nothing without runs.
25
25
  */
26
26
  function ActionRuns(t0) {
27
- const $ = c(13);
27
+ const $ = c(16);
28
28
  const { "aria-label": ariaLabel, className } = t0;
29
29
  const intl = usePanneauIntl();
30
30
  const context = use(ActionRunnerContext);
31
- if (context === null || context.runs.length === 0) return null;
32
- const canCancel = context.adapter.cancelActionRun !== void 0;
33
31
  let t1;
34
- if ($[0] !== ariaLabel || $[1] !== intl) {
35
- t1 = ariaLabel ?? intl.formatMessage(messages.runs);
36
- $[0] = ariaLabel;
37
- $[1] = intl;
38
- $[2] = t1;
39
- } else t1 = $[2];
40
32
  let t2;
41
- if ($[3] !== className) {
42
- t2 = [ActionRunner_module_default.runs, className].filter(Boolean);
43
- $[3] = className;
44
- $[4] = t2;
45
- } else t2 = $[4];
46
- const t3 = t2.join(" ");
33
+ if ($[0] !== context) {
34
+ t1 = () => context?.watchRuns();
35
+ t2 = [context];
36
+ $[0] = context;
37
+ $[1] = t1;
38
+ $[2] = t2;
39
+ } else {
40
+ t1 = $[1];
41
+ t2 = $[2];
42
+ }
43
+ useEffect(t1, t2);
44
+ if (context === null || context.runs.length === 0) return null;
45
+ const canCancel = context.adapter.cancelActionRun !== void 0;
46
+ let t3;
47
+ if ($[3] !== ariaLabel || $[4] !== intl) {
48
+ t3 = ariaLabel ?? intl.formatMessage(messages.runs);
49
+ $[3] = ariaLabel;
50
+ $[4] = intl;
51
+ $[5] = t3;
52
+ } else t3 = $[5];
47
53
  let t4;
48
- if ($[5] !== canCancel || $[6] !== context || $[7] !== intl) {
49
- t4 = context.runs.map((t5) => {
50
- const { run, target } = t5;
54
+ if ($[6] !== className) {
55
+ t4 = [ActionRunner_module_default.runs, className].filter(Boolean);
56
+ $[6] = className;
57
+ $[7] = t4;
58
+ } else t4 = $[7];
59
+ const t5 = t4.join(" ");
60
+ let t6;
61
+ if ($[8] !== canCancel || $[9] !== context || $[10] !== intl) {
62
+ t6 = context.runs.map((t7) => {
63
+ const { run, target } = t7;
51
64
  const label = getActionLabel(target.action, intl);
52
65
  const finished = isFinished(run.status);
53
66
  const status = intl.formatMessage(STATUS_MESSAGES[run.status]);
@@ -90,24 +103,24 @@ function ActionRuns(t0) {
90
103
  ]
91
104
  }, run.id);
92
105
  });
93
- $[5] = canCancel;
94
- $[6] = context;
95
- $[7] = intl;
96
- $[8] = t4;
97
- } else t4 = $[8];
98
- let t5;
99
- if ($[9] !== t1 || $[10] !== t3 || $[11] !== t4) {
100
- t5 = /* @__PURE__ */ jsx("ul", {
101
- "aria-label": t1,
102
- className: t3,
103
- children: t4
106
+ $[8] = canCancel;
107
+ $[9] = context;
108
+ $[10] = intl;
109
+ $[11] = t6;
110
+ } else t6 = $[11];
111
+ let t7;
112
+ if ($[12] !== t3 || $[13] !== t5 || $[14] !== t6) {
113
+ t7 = /* @__PURE__ */ jsx("ul", {
114
+ "aria-label": t3,
115
+ className: t5,
116
+ children: t6
104
117
  });
105
- $[9] = t1;
106
- $[10] = t3;
107
- $[11] = t4;
108
- $[12] = t5;
109
- } else t5 = $[12];
110
- return t5;
118
+ $[12] = t3;
119
+ $[13] = t5;
120
+ $[14] = t6;
121
+ $[15] = t7;
122
+ } else t7 = $[15];
123
+ return t7;
111
124
  }
112
125
  function _temp2(t0) {
113
126
  const { percentage, valueText } = t0;
@@ -1 +1 @@
1
- {"version":3,"file":"ActionRuns.js","names":["X","use","ProgressBar","getActionLabel","ActionRun","Button","IconButton","usePanneauIntl","styles","ActionRunnerContext","messages","isFinished","STATUS_MESSAGES","queued","runQueued","running","runRunning","succeeded","runSucceeded","partial","runPartial","failed","runFailed","cancelled","runCancelled","Record","ActionRunsProps","className","ActionRuns","t0","$","_c","ariaLabel","intl","context","runs","length","canCancel","adapter","cancelActionRun","undefined","t1","formatMessage","t2","filter","Boolean","t3","join","t4","map","t5","run","target","label","action","finished","status","id","runLabel","dismissRun","cancelRun","catch","_temp","cancel","runStatus","progress","total","_temp2","percentage","valueText","track","fill","width","_c","styles","_Fragment"],"sources":["../src/ActionRuns.tsx"],"sourcesContent":["import { X } from 'lucide-react';\nimport { use } from 'react';\nimport { ProgressBar } from 'react-aria-components';\n\nimport { getActionLabel } from '@panneau/intl';\nimport type { ActionRun } from '@panneau/protocol';\nimport { Button, IconButton, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './ActionRunner.module.css';\nimport { ActionRunnerContext } from './context';\nimport { messages } from './messages';\nimport { isFinished } from './request';\n\nconst STATUS_MESSAGES = {\n queued: messages.runQueued,\n running: messages.runRunning,\n succeeded: messages.runSucceeded,\n partial: messages.runPartial,\n failed: messages.runFailed,\n cancelled: messages.runCancelled,\n} satisfies Record<ActionRun['status'], unknown>;\n\nexport interface ActionRunsProps {\n /** Accessible name of the list. Defaults to \"Actions in progress\". */\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * The queued runs that the closest `ActionRunnerProvider` follows: their status and progress, a\n * button to cancel those that haven't finished (when the adapter can), and one to dismiss those\n * that have. For a notification area. Renders nothing without runs.\n */\nexport function ActionRuns({ 'aria-label': ariaLabel, className }: ActionRunsProps) {\n const intl = usePanneauIntl();\n const context = use(ActionRunnerContext);\n if (context === null || context.runs.length === 0) {\n return null;\n }\n const canCancel = context.adapter.cancelActionRun !== undefined;\n return (\n <ul\n aria-label={ariaLabel ?? intl.formatMessage(messages.runs)}\n className={[styles.runs, className].filter(Boolean).join(' ')}\n >\n {context.runs.map(({ run, target }) => {\n const label = getActionLabel(target.action, intl);\n const finished = isFinished(run.status);\n const status = intl.formatMessage(STATUS_MESSAGES[run.status]);\n return (\n <li key={run.id} className={styles.run}>\n <span className={styles.runLabel}>{label}</span>\n {finished ? (\n <IconButton\n icon={X}\n size=\"sm\"\n label={intl.formatMessage(messages.dismissRun, { action: label })}\n onPress={() => context.dismissRun(run.id)}\n />\n ) : canCancel ? (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n aria-label={intl.formatMessage(messages.cancelRun, {\n action: label,\n })}\n onPress={() => {\n context.cancelRun(run.id).catch(() => undefined);\n }}\n >\n {intl.formatMessage(messages.cancel)}\n </Button>\n ) : (\n <span />\n )}\n {finished ? (\n <span className={styles.runStatus}>{status}</span>\n ) : (\n <ProgressBar\n aria-label={label}\n className={styles.progress}\n value={run.progress}\n maxValue={run.total ?? undefined}\n isIndeterminate={run.total === null || run.total === 0}\n valueLabel={\n run.total !== null && run.total > 0\n ? intl.formatMessage(messages.progress, {\n progress: run.progress,\n total: run.total,\n })\n : status\n }\n >\n {({ percentage, valueText }) => (\n <>\n <span className={styles.runStatus}>{valueText}</span>\n <span className={styles.track}>\n <span\n className={styles.fill}\n style={{ width: `${percentage ?? 100}%` }}\n />\n </span>\n </>\n )}\n </ProgressBar>\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAaA,IAAMY,kBAAkB;CACpBC,QAAQH,SAASI;CACjBC,SAASL,SAASM;CAClBC,WAAWP,SAASQ;CACpBC,SAAST,SAASU;CAClBC,QAAQX,SAASY;CACjBC,WAAWb,SAASc;AACxB;;;;;;AAaA,SAAOI,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAoB,MAAA,EAAA,cAAAC,WAAAL,cAAAE;CACvB,MAAAI,OAAa1B,eAAe;CAC5B,MAAA2B,UAAgBjC,IAAIQ,mBAAmB;CACvC,IAAIyB,YAAY,QAAQA,QAAOC,KAAKC,WAAY,GAAC,OACtC;CAEX,MAAAC,YAAkBH,QAAOI,QAAQC,oBAAqBC,KAAAA;CAAU,IAAAC;CAAA,IAAAX,EAAA,OAAAE,aAAAF,EAAA,OAAAG,MAAA;EAG5CQ,KAAAT,aAAaC,KAAIS,cAAehC,SAAQyB,IAAK;EAACL,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAW;CAAA,OAAAA,KAAAX,E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use","useEffect","ProgressBar","getActionLabel","ActionRun","Button","IconButton","usePanneauIntl","styles","ActionRunnerContext","messages","isFinished","STATUS_MESSAGES","queued","runQueued","running","runRunning","succeeded","runSucceeded","partial","runPartial","failed","runFailed","cancelled","runCancelled","Record","ActionRunsProps","className","ActionRuns","t0","$","_c","ariaLabel","intl","context","t1","t2","watchRuns","runs","length","canCancel","adapter","cancelActionRun","undefined","t3","formatMessage","t4","filter","Boolean","t5","join","t6","map","t7","run","target","label","action","finished","status","id","runLabel","dismissRun","cancelRun","catch","_temp","cancel","runStatus","progress","total","_temp2","percentage","valueText","track","fill","width","_c","styles","_Fragment"],"sources":["../src/ActionRuns.tsx"],"sourcesContent":["import { X } from 'lucide-react';\nimport { use, useEffect } from 'react';\nimport { ProgressBar } from 'react-aria-components';\n\nimport { getActionLabel } from '@panneau/intl';\nimport type { ActionRun } from '@panneau/protocol';\nimport { Button, IconButton, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './ActionRunner.module.css';\nimport { ActionRunnerContext } from './context';\nimport { messages } from './messages';\nimport { isFinished } from './request';\n\nconst STATUS_MESSAGES = {\n queued: messages.runQueued,\n running: messages.runRunning,\n succeeded: messages.runSucceeded,\n partial: messages.runPartial,\n failed: messages.runFailed,\n cancelled: messages.runCancelled,\n} satisfies Record<ActionRun['status'], unknown>;\n\nexport interface ActionRunsProps {\n /** Accessible name of the list. Defaults to \"Actions in progress\". */\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * The queued runs that the closest `ActionRunnerProvider` follows: their status and progress, a\n * button to cancel those that haven't finished (when the adapter can), and one to dismiss those\n * that have. For a notification area. Renders nothing without runs.\n */\nexport function ActionRuns({ 'aria-label': ariaLabel, className }: ActionRunsProps) {\n const intl = usePanneauIntl();\n const context = use(ActionRunnerContext);\n // Its user sees the runs that end here: the runner shows no toast for them.\n useEffect(() => context?.watchRuns(), [context]);\n if (context === null || context.runs.length === 0) {\n return null;\n }\n const canCancel = context.adapter.cancelActionRun !== undefined;\n return (\n <ul\n aria-label={ariaLabel ?? intl.formatMessage(messages.runs)}\n className={[styles.runs, className].filter(Boolean).join(' ')}\n >\n {context.runs.map(({ run, target }) => {\n const label = getActionLabel(target.action, intl);\n const finished = isFinished(run.status);\n const status = intl.formatMessage(STATUS_MESSAGES[run.status]);\n return (\n <li key={run.id} className={styles.run}>\n <span className={styles.runLabel}>{label}</span>\n {finished ? (\n <IconButton\n icon={X}\n size=\"sm\"\n label={intl.formatMessage(messages.dismissRun, { action: label })}\n onPress={() => context.dismissRun(run.id)}\n />\n ) : canCancel ? (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n aria-label={intl.formatMessage(messages.cancelRun, {\n action: label,\n })}\n onPress={() => {\n context.cancelRun(run.id).catch(() => undefined);\n }}\n >\n {intl.formatMessage(messages.cancel)}\n </Button>\n ) : (\n <span />\n )}\n {finished ? (\n <span className={styles.runStatus}>{status}</span>\n ) : (\n <ProgressBar\n aria-label={label}\n className={styles.progress}\n value={run.progress}\n maxValue={run.total ?? undefined}\n isIndeterminate={run.total === null || run.total === 0}\n valueLabel={\n run.total !== null && run.total > 0\n ? intl.formatMessage(messages.progress, {\n progress: run.progress,\n total: run.total,\n })\n : status\n }\n >\n {({ percentage, valueText }) => (\n <>\n <span className={styles.runStatus}>{valueText}</span>\n <span className={styles.track}>\n <span\n className={styles.fill}\n style={{ width: `${percentage ?? 100}%` }}\n />\n </span>\n </>\n )}\n </ProgressBar>\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAaA,IAAMa,kBAAkB;CACpBC,QAAQH,SAASI;CACjBC,SAASL,SAASM;CAClBC,WAAWP,SAASQ;CACpBC,SAAST,SAASU;CAClBC,QAAQX,SAASY;CACjBC,WAAWb,SAASc;AACxB;;;;;;AAaA,SAAOI,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAoB,MAAA,EAAA,cAAAC,WAAAL,cAAAE;CACvB,MAAAI,OAAa1B,eAAe;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AA,MAAA;GACgB,cAAAT;GACD,WAAAK;GAEVE,UAAAA;EAgEA,CAAA;EAAArB,EAAA,MAAAc;EAAAd,EAAA,MAAAmB;EAAAnB,EAAA,MAAAqB;EAAArB,EAAA,MAAAuB;CAAA,OAAAA,KAAAvB,EAAA;CAAA,OApELuB;AAoEK;AA9EN,SAAAiB,OAAAzC,IAAA;CA8D2B,MAAA,EAAA0C,YAAAC,cAAA3C;CAAyB,OACvB,qBAAAiD,UAAA,EAAA,UAAA,CACI,oBAAA,QAAA;EAAiB,WAAAtE,4BAAM2D;EAAaK,UAAAA;CAAiB,CAAA,GACrD,oBAAA,QAAA;EAAiB,WAAAhE,4BAAMiE;EACnB,UAAA,oBAAA,QAAA;GACe,WAAAjE,4BAAMkE;GACV,OAAA,EAAAC,OAAS,GAAGJ,cAAA,IAAiB,GAAI;EAAC,CAAA;CAE1C,CAAA,CAAA,EAAA,CAAA;AACR;AAvEhC,SAAAN,QAAA,CAAA"}
package/dist/context.d.ts CHANGED
@@ -5,6 +5,11 @@ export interface ActionRunnerContextValue {
5
5
  runs: readonly FollowedRun[];
6
6
  cancelRun: (id: string) => Promise<void>;
7
7
  dismissRun: (id: string) => void;
8
+ /**
9
+ * Says that a list of the runs is on screen, until the function it returns is called: a run
10
+ * that ends there needs no toast.
11
+ */
12
+ watchRuns: () => () => void;
8
13
  }
9
14
  export declare const ActionRunnerContext: import("react").Context<ActionRunnerContextValue | null>;
10
15
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvF,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;IAChF,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IAC7B,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,mBAAmB,0DAAuD,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvF,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;IAChF,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IAC7B,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC;;;OAGG;IACH,SAAS,EAAE,MAAM,MAAM,IAAI,CAAC;CAC/B;AAED,eAAO,MAAM,mBAAmB,0DAAuD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":["createContext","ActionAdapter","ActionOutcome","ActionTarget","FollowedRun","ActionRunnerContextValue","adapter","run","resource","target","Promise","runs","cancelRun","id","dismissRun","ActionRunnerContext"],"sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport type { ActionAdapter, ActionOutcome, ActionTarget, FollowedRun } from './types';\n\nexport interface ActionRunnerContextValue {\n adapter: ActionAdapter;\n run: (resource: string, target: ActionTarget) => Promise<ActionOutcome | false>;\n runs: readonly FollowedRun[];\n cancelRun: (id: string) => Promise<void>;\n dismissRun: (id: string) => void;\n}\n\nexport const ActionRunnerContext = createContext<ActionRunnerContextValue | null>(null);\n"],"mappings":";;AAYA,IAAae,sBAAsBf,cAA+C,IAAI"}
1
+ {"version":3,"file":"context.js","names":["createContext","ActionAdapter","ActionOutcome","ActionTarget","FollowedRun","ActionRunnerContextValue","adapter","run","resource","target","Promise","runs","cancelRun","id","dismissRun","watchRuns","ActionRunnerContext"],"sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport type { ActionAdapter, ActionOutcome, ActionTarget, FollowedRun } from './types';\n\nexport interface ActionRunnerContextValue {\n adapter: ActionAdapter;\n run: (resource: string, target: ActionTarget) => Promise<ActionOutcome | false>;\n runs: readonly FollowedRun[];\n cancelRun: (id: string) => Promise<void>;\n dismissRun: (id: string) => void;\n /**\n * Says that a list of the runs is on screen, until the function it returns is called: a run\n * that ends there needs no toast.\n */\n watchRuns: () => () => void;\n}\n\nexport const ActionRunnerContext = createContext<ActionRunnerContextValue | null>(null);\n"],"mappings":";;AAiBA,IAAagB,sBAAsBhB,cAA+C,IAAI"}
@@ -1,8 +1,30 @@
1
1
  import type { IntlShape } from 'react-intl';
2
- import type { ActionItemResult, ActionResult } from '@panneau/protocol';
2
+ import type { ActionItemResult, ActionResult, Item, Resource } from '@panneau/protocol';
3
3
  import type { ToastContent } from '@panneau/ui';
4
- /** The toast of a result: its message, or "done", the counts, and a tone that says how it went. */
5
- export declare function describeResult(result: ActionResult, actionLabel: string, intl: IntlShape): Omit<ToastContent, 'action'>;
6
- /** Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`). */
4
+ import type { ActionTarget } from './types.js';
5
+ /**
6
+ * The title of an item: the value of the resource's `itemTitle` field, in the locale when it is
7
+ * localized. `null` without one.
8
+ */
9
+ export declare function getItemTitle(item: Partial<Item> | undefined, itemTitle: string | undefined, locale: string): string | null;
10
+ /**
11
+ * What an action applied to, for its toast: the item by its title ("“Spring contest”"), or the
12
+ * count of items with the resource's labels ("3 entries"). `null` when there is nothing to name:
13
+ * an item without a title, a selection without a count, or a resource the definition doesn't
14
+ * have.
15
+ */
16
+ export declare function describeSubject(target: ActionTarget, resource: Pick<Resource, 'label' | 'itemTitle'> | undefined, intl: IntlShape, count?: number | null): string | null;
17
+ /** Whether an item of a result was skipped because something else uses it (`in_use`). */
18
+ export declare function isInUse(entry: ActionItemResult): boolean;
19
+ /**
20
+ * The toast of a result: its message, or "done" with what it was done to (`subject`), the counts,
21
+ * and a tone that says how it went. Items skipped as `in_use` are explained, by the title of the
22
+ * item (`itemTitle`) when it is the only one: when every item is, that is the title of the toast.
23
+ */
24
+ export declare function describeResult(result: ActionResult, actionLabel: string, intl: IntlShape, subject?: string | null, itemTitle?: string | null): Omit<ToastContent, 'action'>;
25
+ /**
26
+ * Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`,
27
+ * `in_use`).
28
+ */
7
29
  export declare function describeItemResult(entry: ActionItemResult, intl: IntlShape): string;
8
30
  //# sourceMappingURL=describe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,mGAAmG;AACnG,wBAAgB,cAAc,CAC1B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,SAAS,GAChB,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAmB9B;AAED,sGAAsG;AACtG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAgBnF"}
1
+ {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,CAWf;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,WAAW,CAAC,GAAG,SAAS,EAC3D,IAAI,EAAE,SAAS,EACf,KAAK,GAAE,MAAM,GAAG,IAAW,GAC5B,MAAM,GAAG,IAAI,CAoBf;AAED,yFAAyF;AACzF,wBAAgB,OAAO,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAExD;AAeD;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,SAAS,EACf,OAAO,GAAE,MAAM,GAAG,IAAW,EAC7B,SAAS,GAAE,MAAM,GAAG,IAAW,GAChC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAiC9B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAkBnF"}
package/dist/describe.js CHANGED
@@ -1,32 +1,94 @@
1
1
  import { messages } from "./messages.js";
2
2
  import { getResultCounts } from "./request.js";
3
3
  //#region src/describe.ts
4
- /** The toast of a result: its message, or "done", the counts, and a tone that says how it went. */
5
- function describeResult(result, actionLabel, intl) {
4
+ /**
5
+ * The title of an item: the value of the resource's `itemTitle` field, in the locale when it is
6
+ * localized. `null` without one.
7
+ */
8
+ function getItemTitle(item, itemTitle, locale) {
9
+ const value = itemTitle !== void 0 ? item?.[itemTitle] : void 0;
10
+ if (typeof value === "string") return value;
11
+ if (value !== null && typeof value === "object") {
12
+ const first = value[locale] ?? Object.values(value)[0];
13
+ return typeof first === "string" ? first : null;
14
+ }
15
+ return null;
16
+ }
17
+ /**
18
+ * What an action applied to, for its toast: the item by its title ("“Spring contest”"), or the
19
+ * count of items with the resource's labels ("3 entries"). `null` when there is nothing to name:
20
+ * an item without a title, a selection without a count, or a resource the definition doesn't
21
+ * have.
22
+ */
23
+ function describeSubject(target, resource, intl, count = null) {
24
+ if (target.scope === "item" || target.item !== void 0) {
25
+ const title = getItemTitle(target.item, resource?.itemTitle, intl.locale);
26
+ return title !== null && title !== "" ? intl.formatMessage(messages.subjectItem, { title }) : null;
27
+ }
28
+ const total = count ?? target.count ?? null;
29
+ if (resource === void 0 || total === null) return null;
30
+ return intl.formatMessage(messages.subjectCount, {
31
+ count: total,
32
+ singular: resource.label.singular,
33
+ plural: resource.label.plural
34
+ });
35
+ }
36
+ /** Whether an item of a result was skipped because something else uses it (`in_use`). */
37
+ function isInUse(entry) {
38
+ return entry.status === "skipped" && entry.reason === "in_use";
39
+ }
40
+ /**
41
+ * What the toast says of the items skipped as `in_use`: the item by its title when it is the only
42
+ * one and `itemTitle` is known, or their count. `null` when there are none.
43
+ */
44
+ function describeInUse(count, intl, itemTitle) {
45
+ if (count === 0) return null;
46
+ return count === 1 && itemTitle !== null && itemTitle !== "" ? intl.formatMessage(messages.inUseItem, { title: itemTitle }) : intl.formatMessage(messages.inUseCount, { count });
47
+ }
48
+ /**
49
+ * The toast of a result: its message, or "done" with what it was done to (`subject`), the counts,
50
+ * and a tone that says how it went. Items skipped as `in_use` are explained, by the title of the
51
+ * item (`itemTitle`) when it is the only one: when every item is, that is the title of the toast.
52
+ */
53
+ function describeResult(result, actionLabel, intl, subject = null, itemTitle = null) {
6
54
  const { succeeded, failed, skipped } = getResultCounts(result);
55
+ const inUse = Math.min(skipped, (result.results ?? []).filter(isInUse).length);
56
+ const inUseText = describeInUse(inUse, intl, itemTitle);
57
+ if (inUseText !== null && (succeeded ?? 0) === 0 && failed === 0 && skipped === inUse) return {
58
+ title: inUseText,
59
+ tone: "warning"
60
+ };
7
61
  const parts = [
8
62
  ...succeeded !== null && (failed > 0 || skipped > 0) ? [intl.formatMessage(messages.succeededCount, { count: succeeded })] : [],
9
63
  ...failed > 0 ? [intl.formatMessage(messages.failedCount, { count: failed })] : [],
10
- ...skipped > 0 ? [intl.formatMessage(messages.skippedCount, { count: skipped })] : []
64
+ ...skipped > inUse ? [intl.formatMessage(messages.skippedCount, { count: skipped - inUse })] : []
11
65
  ];
66
+ const description = [...parts.length > 0 ? [intl.formatList(parts, { type: "unit" })] : [], ...inUseText !== null ? [inUseText] : []].join(". ");
12
67
  const tone = failed > 0 ? succeeded === 0 ? "danger" : "warning" : skipped > 0 ? "warning" : "success";
13
68
  return {
14
- title: result.message !== void 0 && result.message !== "" ? result.message : intl.formatMessage(messages.done, { action: actionLabel }),
15
- ...parts.length > 0 ? { description: intl.formatList(parts, { type: "unit" }) } : {},
69
+ title: result.message !== void 0 && result.message !== "" ? result.message : subject !== null ? intl.formatMessage(messages.doneFor, {
70
+ action: actionLabel,
71
+ subject
72
+ }) : intl.formatMessage(messages.done, { action: actionLabel }),
73
+ ...description !== "" ? { description } : {},
16
74
  tone
17
75
  };
18
76
  }
19
- /** Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`). */
77
+ /**
78
+ * Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`,
79
+ * `in_use`).
80
+ */
20
81
  function describeItemResult(entry, intl) {
21
82
  if (entry.message !== void 0 && entry.message !== "") return entry.message;
22
83
  switch (entry.reason) {
23
84
  case "forbidden": return intl.formatMessage(messages.reasonForbidden);
24
85
  case "not_found": return intl.formatMessage(messages.reasonNotFound);
25
86
  case "unchanged": return intl.formatMessage(messages.reasonUnchanged);
87
+ case "in_use": return intl.formatMessage(messages.reasonInUse);
26
88
  default: return intl.formatMessage(entry.status === "failed" ? messages.statusFailed : messages.statusSkipped);
27
89
  }
28
90
  }
29
91
  //#endregion
30
- export { describeItemResult, describeResult };
92
+ export { describeItemResult, describeResult, describeSubject, getItemTitle, isInUse };
31
93
 
32
94
  //# sourceMappingURL=describe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"describe.js","names":["IntlShape","ActionItemResult","ActionResult","ToastContent","messages","getResultCounts","describeResult","result","actionLabel","intl","Omit","succeeded","failed","skipped","parts","formatMessage","succeededCount","count","failedCount","skippedCount","tone","title","message","undefined","done","action","length","description","formatList","type","describeItemResult","entry","reason","reasonForbidden","reasonNotFound","reasonUnchanged","status","statusFailed","statusSkipped"],"sources":["../src/describe.ts"],"sourcesContent":["import type { IntlShape } from 'react-intl';\n\nimport type { ActionItemResult, ActionResult } from '@panneau/protocol';\nimport type { ToastContent } from '@panneau/ui';\n\nimport { messages } from './messages';\nimport { getResultCounts } from './request';\n\n/** The toast of a result: its message, or \"done\", the counts, and a tone that says how it went. */\nexport function describeResult(\n result: ActionResult,\n actionLabel: string,\n intl: IntlShape,\n): Omit<ToastContent, 'action'> {\n const { succeeded, failed, skipped } = getResultCounts(result);\n const parts = [\n ...(succeeded !== null && (failed > 0 || skipped > 0)\n ? [intl.formatMessage(messages.succeededCount, { count: succeeded })]\n : []),\n ...(failed > 0 ? [intl.formatMessage(messages.failedCount, { count: failed })] : []),\n ...(skipped > 0 ? [intl.formatMessage(messages.skippedCount, { count: skipped })] : []),\n ];\n const tone: ToastContent['tone'] =\n failed > 0 ? (succeeded === 0 ? 'danger' : 'warning') : skipped > 0 ? 'warning' : 'success';\n return {\n title:\n result.message !== undefined && result.message !== ''\n ? result.message\n : intl.formatMessage(messages.done, { action: actionLabel }),\n ...(parts.length > 0 ? { description: intl.formatList(parts, { type: 'unit' }) } : {}),\n tone,\n };\n}\n\n/** Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`). */\nexport function describeItemResult(entry: ActionItemResult, intl: IntlShape): string {\n if (entry.message !== undefined && entry.message !== '') {\n return entry.message;\n }\n switch (entry.reason) {\n case 'forbidden':\n return intl.formatMessage(messages.reasonForbidden);\n case 'not_found':\n return intl.formatMessage(messages.reasonNotFound);\n case 'unchanged':\n return intl.formatMessage(messages.reasonUnchanged);\n default:\n return intl.formatMessage(\n entry.status === 'failed' ? messages.statusFailed : messages.statusSkipped,\n );\n }\n}\n"],"mappings":";;;;AASA,SAAgBM,eACZC,QACAC,aACAC,MAC4B;CAC5B,MAAM,EAAEE,WAAWC,QAAQC,YAAYR,gBAAgBE,MAAM;CAC7D,MAAMO,QAAQ;EACV,GAAIH,cAAc,SAASC,SAAS,KAAKC,UAAU,KAC7C,CAACJ,KAAKM,cAAcX,SAASY,gBAAgB,EAAEC,OAAON,UAAU,CAAC,CAAC,IAClE,CAAA;EACN,GAAIC,SAAS,IAAI,CAACH,KAAKM,cAAcX,SAASc,aAAa,EAAED,OAAOL,OAAO,CAAC,CAAC,IAAI,CAAA;EACjF,GAAIC,UAAU,IAAI,CAACJ,KAAKM,cAAcX,SAASe,cAAc,EAAEF,OAAOJ,QAAQ,CAAC,CAAC,IAAI,CAAA;CAAG;CAE3F,MAAMO,OACFR,SAAS,IAAKD,cAAc,IAAI,WAAW,YAAaE,UAAU,IAAI,YAAY;CACtF,OAAO;EACHQ,OACId,OAAOe,YAAYC,KAAAA,KAAahB,OAAOe,YAAY,KAC7Cf,OAAOe,UACPb,KAAKM,cAAcX,SAASoB,MAAM,EAAEC,QAAQjB,YAAY,CAAC;EACnE,GAAIM,MAAMY,SAAS,IAAI,EAAEC,aAAalB,KAAKmB,WAAWd,OAAO,EAAEe,MAAM,OAAO,CAAC,EAAE,IAAI,CAAC;EACpFT;CACJ;AACJ;;AAGA,SAAgBU,mBAAmBC,OAAyBtB,MAAyB;CACjF,IAAIsB,MAAMT,YAAYC,KAAAA,KAAaQ,MAAMT,YAAY,IACjD,OAAOS,MAAMT;CAEjB,QAAQS,MAAMC,QAAd;EACI,KAAK,aACD,OAAOvB,KAAKM,cAAcX,SAAS6B,eAAe;EACtD,KAAK,aACD,OAAOxB,KAAKM,cAAcX,SAAS8B,cAAc;EACrD,KAAK,aACD,OAAOzB,KAAKM,cAAcX,SAAS+B,eAAe;EACtD,SACI,OAAO1B,KAAKM,cACRgB,MAAMK,WAAW,WAAWhC,SAASiC,eAAejC,SAASkC,aACjE;CACR;AACJ"}
1
+ {"version":3,"file":"describe.js","names":["IntlShape","ActionItemResult","ActionResult","Item","Resource","ToastContent","messages","getResultCounts","ActionTarget","getItemTitle","item","Partial","itemTitle","locale","value","undefined","localized","Record","first","Object","values","describeSubject","target","resource","Pick","intl","count","scope","title","formatMessage","subjectItem","total","subjectCount","singular","label","plural","isInUse","entry","status","reason","describeInUse","inUseItem","inUseCount","describeResult","result","actionLabel","subject","Omit","succeeded","failed","skipped","inUse","Math","min","results","filter","length","inUseText","tone","parts","succeededCount","failedCount","skippedCount","description","formatList","type","join","message","doneFor","action","done","describeItemResult","reasonForbidden","reasonNotFound","reasonUnchanged","reasonInUse","statusFailed","statusSkipped"],"sources":["../src/describe.ts"],"sourcesContent":["import type { IntlShape } from 'react-intl';\n\nimport type { ActionItemResult, ActionResult, Item, Resource } from '@panneau/protocol';\nimport type { ToastContent } from '@panneau/ui';\n\nimport { messages } from './messages';\nimport { getResultCounts } from './request';\nimport type { ActionTarget } from './types';\n\n/**\n * The title of an item: the value of the resource's `itemTitle` field, in the locale when it is\n * localized. `null` without one.\n */\nexport function getItemTitle(\n item: Partial<Item> | undefined,\n itemTitle: string | undefined,\n locale: string,\n): string | null {\n const value = itemTitle !== undefined ? item?.[itemTitle] : undefined;\n if (typeof value === 'string') {\n return value;\n }\n if (value !== null && typeof value === 'object') {\n const localized = (value as Record<string, unknown>)[locale];\n const first = localized ?? Object.values(value)[0];\n return typeof first === 'string' ? first : null;\n }\n return null;\n}\n\n/**\n * What an action applied to, for its toast: the item by its title (\"“Spring contest”\"), or the\n * count of items with the resource's labels (\"3 entries\"). `null` when there is nothing to name:\n * an item without a title, a selection without a count, or a resource the definition doesn't\n * have.\n */\nexport function describeSubject(\n target: ActionTarget,\n resource: Pick<Resource, 'label' | 'itemTitle'> | undefined,\n intl: IntlShape,\n count: number | null = null,\n): string | null {\n if (target.scope === 'item' || target.item !== undefined) {\n const title = getItemTitle(\n target.item as Partial<Item> | undefined,\n resource?.itemTitle,\n intl.locale,\n );\n return title !== null && title !== ''\n ? intl.formatMessage(messages.subjectItem, { title })\n : null;\n }\n const total = count ?? target.count ?? null;\n if (resource === undefined || total === null) {\n return null;\n }\n return intl.formatMessage(messages.subjectCount, {\n count: total,\n singular: resource.label.singular,\n plural: resource.label.plural,\n });\n}\n\n/** Whether an item of a result was skipped because something else uses it (`in_use`). */\nexport function isInUse(entry: ActionItemResult): boolean {\n return entry.status === 'skipped' && entry.reason === 'in_use';\n}\n\n/**\n * What the toast says of the items skipped as `in_use`: the item by its title when it is the only\n * one and `itemTitle` is known, or their count. `null` when there are none.\n */\nfunction describeInUse(count: number, intl: IntlShape, itemTitle: string | null): string | null {\n if (count === 0) {\n return null;\n }\n return count === 1 && itemTitle !== null && itemTitle !== ''\n ? intl.formatMessage(messages.inUseItem, { title: itemTitle })\n : intl.formatMessage(messages.inUseCount, { count });\n}\n\n/**\n * The toast of a result: its message, or \"done\" with what it was done to (`subject`), the counts,\n * and a tone that says how it went. Items skipped as `in_use` are explained, by the title of the\n * item (`itemTitle`) when it is the only one: when every item is, that is the title of the toast.\n */\nexport function describeResult(\n result: ActionResult,\n actionLabel: string,\n intl: IntlShape,\n subject: string | null = null,\n itemTitle: string | null = null,\n): Omit<ToastContent, 'action'> {\n const { succeeded, failed, skipped } = getResultCounts(result);\n const inUse = Math.min(skipped, (result.results ?? []).filter(isInUse).length);\n const inUseText = describeInUse(inUse, intl, itemTitle);\n if (inUseText !== null && (succeeded ?? 0) === 0 && failed === 0 && skipped === inUse) {\n // Nothing was done: the toast says why.\n return { title: inUseText, tone: 'warning' };\n }\n const parts = [\n ...(succeeded !== null && (failed > 0 || skipped > 0)\n ? [intl.formatMessage(messages.succeededCount, { count: succeeded })]\n : []),\n ...(failed > 0 ? [intl.formatMessage(messages.failedCount, { count: failed })] : []),\n ...(skipped > inUse\n ? [intl.formatMessage(messages.skippedCount, { count: skipped - inUse })]\n : []),\n ];\n const description = [\n ...(parts.length > 0 ? [intl.formatList(parts, { type: 'unit' })] : []),\n ...(inUseText !== null ? [inUseText] : []),\n ].join('. ');\n const tone: ToastContent['tone'] =\n failed > 0 ? (succeeded === 0 ? 'danger' : 'warning') : skipped > 0 ? 'warning' : 'success';\n return {\n title:\n result.message !== undefined && result.message !== ''\n ? result.message\n : subject !== null\n ? intl.formatMessage(messages.doneFor, { action: actionLabel, subject })\n : intl.formatMessage(messages.done, { action: actionLabel }),\n ...(description !== '' ? { description } : {}),\n tone,\n };\n}\n\n/**\n * Why an item didn't succeed: its message, or its reason (`forbidden`, `not_found`, `unchanged`,\n * `in_use`).\n */\nexport function describeItemResult(entry: ActionItemResult, intl: IntlShape): string {\n if (entry.message !== undefined && entry.message !== '') {\n return entry.message;\n }\n switch (entry.reason) {\n case 'forbidden':\n return intl.formatMessage(messages.reasonForbidden);\n case 'not_found':\n return intl.formatMessage(messages.reasonNotFound);\n case 'unchanged':\n return intl.formatMessage(messages.reasonUnchanged);\n case 'in_use':\n return intl.formatMessage(messages.reasonInUse);\n default:\n return intl.formatMessage(\n entry.status === 'failed' ? messages.statusFailed : messages.statusSkipped,\n );\n }\n}\n"],"mappings":";;;;;;;AAaA,SAAgBS,aACZC,MACAE,WACAC,QACa;CACb,MAAMC,QAAQF,cAAcG,KAAAA,IAAYL,OAAOE,aAAaG,KAAAA;CAC5D,IAAI,OAAO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AAmBlC,OAAyBZ,MAAyB;CACjF,IAAIY,MAAM8B,YAAYpD,KAAAA,KAAasB,MAAM8B,YAAY,IACjD,OAAO9B,MAAM8B;CAEjB,QAAQ9B,MAAME,QAAd;EACI,KAAK,aACD,OAAOd,KAAKI,cAAcvB,SAASkE,eAAe;EACtD,KAAK,aACD,OAAO/C,KAAKI,cAAcvB,SAASmE,cAAc;EACrD,KAAK,aACD,OAAOhD,KAAKI,cAAcvB,SAASoE,eAAe;EACtD,KAAK,UACD,OAAOjD,KAAKI,cAAcvB,SAASqE,WAAW;EAClD,SACI,OAAOlD,KAAKI,cACRQ,MAAMC,WAAW,WAAWhC,SAASsE,eAAetE,SAASuE,aACjE;CACR;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/actions",
3
- "version": "5.0.0-alpha.17",
3
+ "version": "5.0.0-alpha.19",
4
4
  "description": "Runs the actions of lists and forms: parameters in a dialog, the action through a data adapter, its result, and queued runs.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,15 +37,15 @@
37
37
  "react-intl": "^12.0.0"
38
38
  },
39
39
  "dependencies": {
40
- "@panneau/core": "5.0.0-alpha.17",
41
- "@panneau/data": "5.0.0-alpha.17",
42
- "@panneau/forms": "5.0.0-alpha.17",
43
- "@panneau/intl": "5.0.0-alpha.17",
44
- "@panneau/protocol": "5.0.0-alpha.17",
45
- "@panneau/ui": "5.0.0-alpha.17",
40
+ "@panneau/core": "5.0.0-alpha.19",
41
+ "@panneau/data": "5.0.0-alpha.19",
42
+ "@panneau/forms": "5.0.0-alpha.19",
43
+ "@panneau/intl": "5.0.0-alpha.19",
44
+ "@panneau/protocol": "5.0.0-alpha.19",
45
+ "@panneau/ui": "5.0.0-alpha.19",
46
46
  "lucide-react": "^1.57.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@panneau/lists": "5.0.0-alpha.17"
49
+ "@panneau/lists": "5.0.0-alpha.19"
50
50
  }
51
51
  }