@panneau/actions 5.0.0-alpha.1 → 5.0.0-alpha.10
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 +13 -4
- package/dist/ActionRunner.css +14 -14
- package/dist/ActionRunner.module.js +13 -13
- package/dist/ActionRunnerProvider.d.ts +1 -1
- package/dist/ActionRunnerProvider.d.ts.map +1 -1
- package/dist/ActionRunnerProvider.js +334 -191
- package/dist/ActionRunnerProvider.js.map +1 -1
- package/dist/ActionRuns.d.ts.map +1 -1
- package/dist/ActionRuns.js +3 -2
- package/dist/ActionRuns.js.map +1 -1
- package/dist/ParametersDialog.d.ts +1 -1
- package/dist/ParametersDialog.d.ts.map +1 -1
- package/dist/ParametersDialog.js +99 -79
- package/dist/ParametersDialog.js.map +1 -1
- package/dist/ResultsDialog.js +1 -1
- package/dist/ResultsDialog.js.map +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/context.js.map +1 -1
- package/dist/describe.js.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/preview.d.ts +21 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +30 -0
- package/dist/preview.js.map +1 -0
- package/dist/request.d.ts +1 -1
- package/dist/request.js.map +1 -1
- package/dist/useActionRunner.d.ts +11 -1
- package/dist/useActionRunner.d.ts.map +1 -1
- package/dist/useActionRunner.js +15 -1
- package/dist/useActionRunner.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -5,7 +5,12 @@ Runs the actions of lists and forms: parameters in a dialog, the action through
|
|
|
5
5
|
```tsx
|
|
6
6
|
import { useQueryClient } from '@tanstack/react-query';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ActionRunnerProvider,
|
|
10
|
+
ActionRuns,
|
|
11
|
+
useActionPreview,
|
|
12
|
+
useActionRunner,
|
|
13
|
+
} from '@panneau/actions';
|
|
9
14
|
import { createRestAdapter } from '@panneau/data';
|
|
10
15
|
import { invalidateActionResult } from '@panneau/data/query';
|
|
11
16
|
import { ListView } from '@panneau/lists';
|
|
@@ -33,6 +38,7 @@ function App() {
|
|
|
33
38
|
|
|
34
39
|
function Pages() {
|
|
35
40
|
const runAction = useActionRunner('pages');
|
|
41
|
+
const previewAction = useActionPreview('pages');
|
|
36
42
|
return (
|
|
37
43
|
<ListView
|
|
38
44
|
list={list}
|
|
@@ -40,14 +46,15 @@ function Pages() {
|
|
|
40
46
|
columns={columns}
|
|
41
47
|
actions={actions}
|
|
42
48
|
onAction={runAction}
|
|
49
|
+
previewAction={previewAction}
|
|
43
50
|
/>
|
|
44
51
|
);
|
|
45
52
|
}
|
|
46
53
|
```
|
|
47
54
|
|
|
48
|
-
| Export | Content
|
|
49
|
-
| ------------------ |
|
|
50
|
-
| `@panneau/actions` | `ActionRunnerProvider`, `useActionRunner()`, `ActionRuns` and `useActionRuns()`, the dialogs (`ParametersDialog`, `ResultsDialog`), and their helpers |
|
|
55
|
+
| Export | Content |
|
|
56
|
+
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `@panneau/actions` | `ActionRunnerProvider`, `useActionRunner()`, `useActionPreview()`, `ActionRuns` and `useActionRuns()`, the dialogs (`ParametersDialog`, `ResultsDialog`), and their helpers |
|
|
51
58
|
|
|
52
59
|
## What the runner does
|
|
53
60
|
|
|
@@ -62,6 +69,8 @@ function Pages() {
|
|
|
62
69
|
- **`link` actions** go to their `url` (with `{id}`) or `route`, through `onNavigate`.
|
|
63
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()`.
|
|
64
71
|
|
|
72
|
+
**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
|
+
|
|
65
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).
|
|
66
75
|
|
|
67
76
|
## The adapter
|
package/dist/ActionRunner.css
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
.panneau-parameters
|
|
1
|
+
.panneau-action-runner-parameters {
|
|
2
2
|
margin: 0;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
.panneau-summary
|
|
5
|
+
.panneau-action-runner-summary {
|
|
6
6
|
margin: 0 0 var(--panneau-space-3);
|
|
7
7
|
color: var(--panneau-color-text-muted);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.panneau-results
|
|
10
|
+
.panneau-action-runner-results {
|
|
11
11
|
display: grid;
|
|
12
12
|
gap: var(--panneau-space-2);
|
|
13
13
|
margin: 0;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
list-style: none;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
.panneau-result
|
|
18
|
+
.panneau-action-runner-result {
|
|
19
19
|
display: flex;
|
|
20
20
|
flex-wrap: wrap;
|
|
21
21
|
align-items: center;
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
.panneau-
|
|
27
|
+
.panneau-action-runner-result-item {
|
|
28
28
|
font-weight: var(--panneau-font-weight-medium);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
.panneau-
|
|
31
|
+
.panneau-action-runner-result-reason {
|
|
32
32
|
flex: 1 1 12rem;
|
|
33
33
|
color: var(--panneau-color-text-muted);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.panneau-runs
|
|
36
|
+
.panneau-action-runner-runs {
|
|
37
37
|
display: grid;
|
|
38
38
|
gap: var(--panneau-space-3);
|
|
39
39
|
margin: 0;
|
|
@@ -41,36 +41,36 @@
|
|
|
41
41
|
list-style: none;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.panneau-run
|
|
44
|
+
.panneau-action-runner-run {
|
|
45
45
|
display: grid;
|
|
46
46
|
grid-template-columns: 1fr auto;
|
|
47
47
|
align-items: center;
|
|
48
48
|
gap: var(--panneau-space-1) var(--panneau-space-2);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.panneau-
|
|
51
|
+
.panneau-action-runner-run-label {
|
|
52
52
|
font-weight: var(--panneau-font-weight-medium);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
.panneau-
|
|
55
|
+
.panneau-action-runner-run-status {
|
|
56
56
|
font-size: var(--panneau-font-size-sm);
|
|
57
57
|
color: var(--panneau-color-text-muted);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.panneau-progress
|
|
60
|
+
.panneau-action-runner-progress {
|
|
61
61
|
grid-column: 1 / -1;
|
|
62
62
|
display: grid;
|
|
63
63
|
gap: var(--panneau-space-1);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
.panneau-track
|
|
66
|
+
.panneau-action-runner-track {
|
|
67
67
|
height: 0.375rem;
|
|
68
68
|
overflow: hidden;
|
|
69
69
|
background: var(--panneau-color-surface-sunken);
|
|
70
70
|
border-radius: var(--panneau-radius-full);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
.panneau-fill
|
|
73
|
+
.panneau-action-runner-fill {
|
|
74
74
|
height: 100%;
|
|
75
75
|
background: var(--panneau-color-accent);
|
|
76
76
|
border-radius: inherit;
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
@media (prefers-reduced-motion: reduce) {
|
|
81
|
-
.panneau-fill
|
|
81
|
+
.panneau-action-runner-fill {
|
|
82
82
|
transition: none;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import "./ActionRunner.css";
|
|
2
2
|
//#region src/ActionRunner.module.css
|
|
3
|
-
var parameters = "panneau-parameters
|
|
4
|
-
var summary = "panneau-summary
|
|
5
|
-
var results = "panneau-results
|
|
6
|
-
var result = "panneau-result
|
|
7
|
-
var resultItem = "panneau-
|
|
8
|
-
var resultReason = "panneau-
|
|
9
|
-
var runs = "panneau-runs
|
|
10
|
-
var run = "panneau-run
|
|
11
|
-
var runLabel = "panneau-
|
|
12
|
-
var runStatus = "panneau-
|
|
13
|
-
var progress = "panneau-progress
|
|
14
|
-
var track = "panneau-track
|
|
15
|
-
var fill = "panneau-fill
|
|
3
|
+
var parameters = "panneau-action-runner-parameters";
|
|
4
|
+
var summary = "panneau-action-runner-summary";
|
|
5
|
+
var results = "panneau-action-runner-results";
|
|
6
|
+
var result = "panneau-action-runner-result";
|
|
7
|
+
var resultItem = "panneau-action-runner-result-item";
|
|
8
|
+
var resultReason = "panneau-action-runner-result-reason";
|
|
9
|
+
var runs = "panneau-action-runner-runs";
|
|
10
|
+
var run = "panneau-action-runner-run";
|
|
11
|
+
var runLabel = "panneau-action-runner-run-label";
|
|
12
|
+
var runStatus = "panneau-action-runner-run-status";
|
|
13
|
+
var progress = "panneau-action-runner-progress";
|
|
14
|
+
var track = "panneau-action-runner-track";
|
|
15
|
+
var fill = "panneau-action-runner-fill";
|
|
16
16
|
var ActionRunner_module_default = {
|
|
17
17
|
parameters,
|
|
18
18
|
summary,
|
|
@@ -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;
|
|
@@ -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;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,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,aAAa,EACb,YAAmB,EACnB,OAAO,GACV,EAAE,yBAAyB,+BAwP3B"}
|