muffin-admin 2.6.1 → 2.6.2
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/dist/MuffinResourceList.js +1 -1
- package/dist/MuffinResourceShow.js +2 -2
- package/dist/buttons/ActionButton.d.ts +2 -2
- package/dist/buttons/ActionButton.js +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +3 -2
- package/package.json +1 -1
- package/src/MuffinResourceList.tsx +2 -2
- package/src/MuffinResourceShow.tsx +7 -3
- package/src/buttons/ActionButton.tsx +4 -4
- package/src/types.ts +9 -8
package/dist/types.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ export type TProps = {
|
|
|
3
3
|
};
|
|
4
4
|
export type AdminAction = {
|
|
5
5
|
view: string;
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
title: string;
|
|
6
9
|
icon: string;
|
|
7
10
|
action: string;
|
|
8
|
-
title: string;
|
|
9
|
-
label: string;
|
|
10
11
|
};
|
|
11
12
|
export type AdminField = [string, {
|
|
12
13
|
source: string;
|
package/package.json
CHANGED
|
@@ -40,8 +40,8 @@ setupAdmin(
|
|
|
40
40
|
["list-actions"],
|
|
41
41
|
({ actions, remove }: { actions: AdminAction[]; remove?: boolean }) => (
|
|
42
42
|
<>
|
|
43
|
-
{actions.map((props
|
|
44
|
-
<BulkActionButton key={
|
|
43
|
+
{actions.map((props) => (
|
|
44
|
+
<BulkActionButton key={props.id} {...props} />
|
|
45
45
|
))}
|
|
46
46
|
{remove && <BulkDeleteButton />}
|
|
47
47
|
</>
|
|
@@ -23,14 +23,18 @@ export function MuffinResourceShow(props: AdminShowProps) {
|
|
|
23
23
|
)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
setupAdmin(["show"], (props) => <MuffinResourceShow {...props} />)
|
|
27
|
-
setupAdmin(["show-fields"], ({ fields }) => buildRA(fields))
|
|
28
26
|
setupAdmin(["record-actions"], ({ actions }: { actions: AdminAction[] }) =>
|
|
29
|
-
actions.map((props
|
|
27
|
+
actions.map((props) => <ActionButton key={props.id} {...props} />)
|
|
30
28
|
)
|
|
29
|
+
|
|
31
30
|
setupAdmin(["record-links"], ({ links }: { links: AdminShowProps["links"] }) =>
|
|
32
31
|
links.map(([key, props]) => <LinkAction key={key} resource={key} {...props} />)
|
|
33
32
|
)
|
|
33
|
+
|
|
34
|
+
setupAdmin(["show"], (props) => <MuffinResourceShow {...props} />)
|
|
35
|
+
|
|
36
|
+
setupAdmin(["show-fields"], ({ fields }) => buildRA(fields))
|
|
37
|
+
|
|
34
38
|
setupAdmin(["show-actions"], ({ actions, links, edit }: AdminShowProps) => {
|
|
35
39
|
const resourceName = useResourceContext()
|
|
36
40
|
const Actions = findBuilder(["record-actions", resourceName])
|
|
@@ -13,12 +13,12 @@ import { useAction } from "../hooks/useAction"
|
|
|
13
13
|
import { AdminAction } from "../types"
|
|
14
14
|
import { buildIcon, findBuilder } from "../utils"
|
|
15
15
|
|
|
16
|
-
export function BulkActionButton({ label, icon, title, action }: AdminAction) {
|
|
16
|
+
export function BulkActionButton({ label, icon, title, action, id }: AdminAction) {
|
|
17
17
|
const resource = useResourceContext()
|
|
18
18
|
const { selectedIds } = useListContext()
|
|
19
19
|
const [payloadActive, setPayloadActive] = useState(false)
|
|
20
20
|
|
|
21
|
-
const PayloadBuilder = findBuilder(["action", "payload",
|
|
21
|
+
const PayloadBuilder = findBuilder(["action", "payload", id])
|
|
22
22
|
|
|
23
23
|
const refresh = useRefresh(),
|
|
24
24
|
unselectAll = useUnselectAll(resource),
|
|
@@ -65,13 +65,13 @@ export function BulkActionButton({ label, icon, title, action }: AdminAction) {
|
|
|
65
65
|
)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export function ActionButton({ icon, label, title, action }: AdminAction) {
|
|
68
|
+
export function ActionButton({ icon, label, title, action, id }: AdminAction) {
|
|
69
69
|
const [payloadActive, setPayloadActive] = useState(false)
|
|
70
70
|
|
|
71
71
|
const record = useRecordContext()
|
|
72
72
|
const { mutate, isLoading } = useAction(action)
|
|
73
73
|
|
|
74
|
-
const PayloadBuilder = findBuilder(["action", "payload",
|
|
74
|
+
const PayloadBuilder = findBuilder(["action", "payload", id])
|
|
75
75
|
|
|
76
76
|
const refresh = useRefresh(),
|
|
77
77
|
notify = useNotify()
|
package/src/types.ts
CHANGED
|
@@ -4,10 +4,11 @@ export type TProps = {
|
|
|
4
4
|
|
|
5
5
|
export type AdminAction = {
|
|
6
6
|
view: string
|
|
7
|
+
id: string
|
|
8
|
+
label: string
|
|
9
|
+
title: string
|
|
7
10
|
icon: string
|
|
8
11
|
action: string
|
|
9
|
-
title: string
|
|
10
|
-
label: string
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export type AdminField = [string, { source: string }]
|
|
@@ -32,12 +33,12 @@ export type AdminResourceProps = {
|
|
|
32
33
|
label: string
|
|
33
34
|
create: AdminInput[] | false
|
|
34
35
|
edit:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
| {
|
|
37
|
+
actions: AdminAction[]
|
|
38
|
+
inputs: AdminInput[]
|
|
39
|
+
remove?: boolean
|
|
40
|
+
}
|
|
41
|
+
| false
|
|
41
42
|
list: {
|
|
42
43
|
limit: number
|
|
43
44
|
limitMax: number
|