@panneau/actions 5.0.0-alpha.5 → 5.0.0-alpha.51
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 +6 -6
- package/dist/ActionRunner.css +1 -1
- package/dist/ActionRunner.module.js.map +1 -1
- package/dist/ActionRunnerProvider.d.ts +8 -2
- package/dist/ActionRunnerProvider.d.ts.map +1 -1
- package/dist/ActionRunnerProvider.js +449 -197
- package/dist/ActionRunnerProvider.js.map +1 -1
- package/dist/ActionRuns.d.ts.map +1 -1
- package/dist/ActionRuns.js +53 -39
- package/dist/ActionRuns.js.map +1 -1
- package/dist/ParametersDialog.d.ts +4 -1
- package/dist/ParametersDialog.d.ts.map +1 -1
- package/dist/ParametersDialog.js +152 -74
- package/dist/ParametersDialog.js.map +1 -1
- package/dist/ResultsDialog.d.ts.map +1 -1
- package/dist/ResultsDialog.js +1 -2
- package/dist/ResultsDialog.js.map +1 -1
- package/dist/context.d.ts +6 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/describe.d.ts +35 -4
- package/dist/describe.d.ts.map +1 -1
- package/dist/describe.js +89 -7
- package/dist/describe.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js.map +1 -1
- package/dist/request.d.ts +1 -1
- package/dist/request.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/useActionRunner.d.ts +2 -2
- package/dist/useActionRunner.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -44,9 +44,7 @@ function Pages() {
|
|
|
44
44
|
list={list}
|
|
45
45
|
items={items}
|
|
46
46
|
columns={columns}
|
|
47
|
-
actions={actions}
|
|
48
|
-
onAction={runAction}
|
|
49
|
-
previewAction={previewAction}
|
|
47
|
+
actions={{ available: actions, onRun: runAction, preview: previewAction }}
|
|
50
48
|
/>
|
|
51
49
|
);
|
|
52
50
|
}
|
|
@@ -63,13 +61,15 @@ function Pages() {
|
|
|
63
61
|
- **`server` actions:**
|
|
64
62
|
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
63
|
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;
|
|
64
|
+
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
65
|
4. calls `onResult` (refresh what it changed), opens the `download`, and goes to the `redirect`.
|
|
68
|
-
- **Queued runs** (`202`):
|
|
66
|
+
- **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
67
|
- **`link` actions** go to their `url` (with `{id}`) or `route`, through `onNavigate`.
|
|
70
68
|
- **`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
69
|
|
|
72
|
-
**
|
|
70
|
+
**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".
|
|
71
|
+
|
|
72
|
+
**Dry runs.** `useActionPreview(resource)` is the `preview` of a list's `actions`. 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
73
|
|
|
74
74
|
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).
|
|
75
75
|
|
package/dist/ActionRunner.css
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
height: 100%;
|
|
75
75
|
background: var(--panneau-color-accent);
|
|
76
76
|
border-radius: inherit;
|
|
77
|
-
transition: width var(--panneau-duration) ease-out;
|
|
77
|
+
transition: width var(--panneau-duration) var(--panneau-ease-out);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionRunner.module.js","names":[],"sources":["../src/ActionRunner.module.css"],"sourcesContent":[".parameters {\n margin: 0;\n}\n\n.summary {\n margin: 0 0 var(--panneau-space-3);\n color: var(--panneau-color-text-muted);\n}\n\n.results {\n display: grid;\n gap: var(--panneau-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.result {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--panneau-space-2);\n padding: var(--panneau-space-2) 0;\n border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n.resultItem {\n font-weight: var(--panneau-font-weight-medium);\n}\n\n.resultReason {\n flex: 1 1 12rem;\n color: var(--panneau-color-text-muted);\n}\n\n.runs {\n display: grid;\n gap: var(--panneau-space-3);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.run {\n display: grid;\n grid-template-columns: 1fr auto;\n align-items: center;\n gap: var(--panneau-space-1) var(--panneau-space-2);\n}\n\n.runLabel {\n font-weight: var(--panneau-font-weight-medium);\n}\n\n.runStatus {\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n}\n\n.progress {\n grid-column: 1 / -1;\n display: grid;\n gap: var(--panneau-space-1);\n}\n\n.track {\n height: 0.375rem;\n overflow: hidden;\n background: var(--panneau-color-surface-sunken);\n border-radius: var(--panneau-radius-full);\n}\n\n.fill {\n height: 100%;\n background: var(--panneau-color-accent);\n border-radius: inherit;\n transition: width var(--panneau-duration) ease-out;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .fill {\n transition: none;\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ActionRunner.module.js","names":[],"sources":["../src/ActionRunner.module.css"],"sourcesContent":[".parameters {\n margin: 0;\n}\n\n.summary {\n margin: 0 0 var(--panneau-space-3);\n color: var(--panneau-color-text-muted);\n}\n\n.results {\n display: grid;\n gap: var(--panneau-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.result {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--panneau-space-2);\n padding: var(--panneau-space-2) 0;\n border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n.resultItem {\n font-weight: var(--panneau-font-weight-medium);\n}\n\n.resultReason {\n flex: 1 1 12rem;\n color: var(--panneau-color-text-muted);\n}\n\n.runs {\n display: grid;\n gap: var(--panneau-space-3);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.run {\n display: grid;\n grid-template-columns: 1fr auto;\n align-items: center;\n gap: var(--panneau-space-1) var(--panneau-space-2);\n}\n\n.runLabel {\n font-weight: var(--panneau-font-weight-medium);\n}\n\n.runStatus {\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n}\n\n.progress {\n grid-column: 1 / -1;\n display: grid;\n gap: var(--panneau-space-1);\n}\n\n.track {\n height: 0.375rem;\n overflow: hidden;\n background: var(--panneau-color-surface-sunken);\n border-radius: var(--panneau-radius-full);\n}\n\n.fill {\n height: 100%;\n background: var(--panneau-color-accent);\n border-radius: inherit;\n transition: width var(--panneau-duration) var(--panneau-ease-out);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .fill {\n transition: none;\n }\n}\n"],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { ActionResult, RouteReference } from '@panneau/protocol';
|
|
3
|
-
import type { ActionAdapter, ActionDownload, ActionResultContext, ClientActionHandler } from './types';
|
|
3
|
+
import type { ActionAdapter, ActionDownload, ActionResultContext, ClientActionHandler } from './types.js';
|
|
4
4
|
export interface ActionRunnerProviderProps {
|
|
5
5
|
/** Runs the actions: a `DataAdapter`, or any object with its action methods. */
|
|
6
6
|
adapter: ActionAdapter;
|
|
@@ -16,6 +16,12 @@ export interface ActionRunnerProviderProps {
|
|
|
16
16
|
* `window.location.assign()` for URLs; routes need it.
|
|
17
17
|
*/
|
|
18
18
|
onNavigate?: (to: string | RouteReference) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Opens the list of a resource filtered on the items a run changed (`filter[ids]`, decision
|
|
21
|
+
* 0069). With it, the toast of a run offers "Show" when it has nothing more to say: no "Undo",
|
|
22
|
+
* "Details" or "Download". Without it, there is no "Show".
|
|
23
|
+
*/
|
|
24
|
+
onShowItems?: (resource: string, ids: readonly string[]) => void;
|
|
19
25
|
/** Opens the `download` of a result. Defaults to a link to its URL, clicked. */
|
|
20
26
|
onDownload?: (download: ActionDownload) => void;
|
|
21
27
|
/** Handlers of `client` actions by their `component`, over those of the plugins. */
|
|
@@ -32,5 +38,5 @@ export interface ActionRunnerProviderProps {
|
|
|
32
38
|
* redirects and opens downloads. Put it inside `PanneauRoot`, and above the router of an app, so
|
|
33
39
|
* that runs are followed from page to page. `useActionRunner(resource)` runs an action.
|
|
34
40
|
*/
|
|
35
|
-
export declare function ActionRunnerProvider({ adapter, children, onResult, onNavigate, onDownload, clientActions, pollInterval, locales, }: ActionRunnerProviderProps): import("react").JSX.Element;
|
|
41
|
+
export declare function ActionRunnerProvider({ adapter, children, onResult, onNavigate, onDownload, onShowItems, clientActions, pollInterval, locales, }: ActionRunnerProviderProps): import("react").JSX.Element;
|
|
36
42
|
//# sourceMappingURL=ActionRunnerProvider.d.ts.map
|
|
@@ -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;
|
|
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;AAejF,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;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;IACjE,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,CAAC;IACtB,qEAAqE;IACrE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAmCD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,EACjC,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAuB,EACvB,UAAyB,EACzB,WAAW,EACX,aAAa,EACb,YAAmB,EACnB,OAAO,GACV,EAAE,yBAAyB,+BA6Z3B"}
|