muffin-admin 3.6.2 → 3.7.0
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/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -20,11 +20,12 @@ export type ActionPayloadProps = {
|
|
|
20
20
|
onHandle: (payload: any) => void
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function ActionButton({
|
|
23
|
+
export function ActionButton({ paths, confirm, ...props }: AdminAction) {
|
|
24
24
|
const translate = useTranslate()
|
|
25
25
|
const record = useRecordContext()
|
|
26
26
|
const confirmation = useConfirmation()
|
|
27
|
-
const
|
|
27
|
+
const path = paths.find((p) => p.includes("{id}")) || paths[paths.length - 1]
|
|
28
|
+
const { mutate, isPending } = useAction(path)
|
|
28
29
|
|
|
29
30
|
const confirmMessage =
|
|
30
31
|
typeof confirm === "string" ? translate(confirm) : "Do you confirm this action?"
|
|
@@ -37,10 +38,11 @@ export function ActionButton({ action, confirm, ...props }: AdminAction) {
|
|
|
37
38
|
return <ActionButtonBase {...props} isPending={isPending} onHandle={onHandle} />
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export function BulkActionButton({
|
|
41
|
+
export function BulkActionButton({ paths, confirm, ...props }: AdminAction) {
|
|
41
42
|
const translate = useTranslate()
|
|
42
43
|
const { selectedIds } = useListContext()
|
|
43
|
-
const
|
|
44
|
+
const path = paths.find((p) => !p.includes("{id}")) || paths[0]
|
|
45
|
+
const { mutate, isPending } = useAction(path)
|
|
44
46
|
const confirmation = useConfirmation()
|
|
45
47
|
|
|
46
48
|
const confirmMessage =
|
|
@@ -85,7 +87,7 @@ function ActionButtonBase({
|
|
|
85
87
|
icon,
|
|
86
88
|
schema,
|
|
87
89
|
id,
|
|
88
|
-
}: Omit<AdminAction, "
|
|
90
|
+
}: Omit<AdminAction, "paths"> & {
|
|
89
91
|
isPending?: boolean
|
|
90
92
|
onHandle: (payload?: any) => void
|
|
91
93
|
}) {
|
package/src/types.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type AdminAction = {
|
|
|
8
8
|
label: string
|
|
9
9
|
title: string
|
|
10
10
|
icon: string
|
|
11
|
-
|
|
11
|
+
paths: string[]
|
|
12
12
|
confirm?: string | false
|
|
13
13
|
schema?: AdminInput[]
|
|
14
14
|
}
|
|
@@ -35,11 +35,11 @@ export type AdminResourceProps = {
|
|
|
35
35
|
actions: AdminAction[]
|
|
36
36
|
create: AdminInput[] | false
|
|
37
37
|
edit:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
| {
|
|
39
|
+
inputs: AdminInput[]
|
|
40
|
+
remove?: boolean
|
|
41
|
+
}
|
|
42
|
+
| false
|
|
43
43
|
list: {
|
|
44
44
|
limit: number
|
|
45
45
|
limitMax: number
|