muffin-admin 2.9.2 → 3.0.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/MuffinResourceCreate.js +3 -3
- package/dist/MuffinResourceEdit.d.ts +3 -1
- package/dist/MuffinResourceEdit.js +15 -9
- package/dist/MuffinResourceList.d.ts +1 -1
- package/dist/MuffinResourceList.js +6 -6
- package/dist/MuffinResourceShow.d.ts +4 -1
- package/dist/MuffinResourceShow.js +19 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/MuffinResourceCreate.tsx +4 -5
- package/src/MuffinResourceEdit.tsx +23 -12
- package/src/MuffinResourceList.tsx +6 -7
- package/src/MuffinResourceShow.tsx +32 -27
package/package.json
CHANGED
|
@@ -7,21 +7,20 @@ export function MuffinResourceCreate() {
|
|
|
7
7
|
const { name, create } = useMuffinResourceOpts()
|
|
8
8
|
if (!create) return null
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const ActionsToolbar = findBuilder(["create-toolbar", name])
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<Create actions={<
|
|
13
|
+
<Create actions={<ActionsToolbar />}>
|
|
14
14
|
<SimpleForm>{buildAdmin(["create-inputs", name], create)}</SimpleForm>
|
|
15
15
|
</Create>
|
|
16
16
|
)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
setupAdmin(["create"], MuffinResourceCreate)
|
|
20
|
+
setupAdmin(["create-inputs"], buildRA)
|
|
20
21
|
|
|
21
|
-
setupAdmin(["create-
|
|
22
|
+
setupAdmin(["create-toolbar"], () => (
|
|
22
23
|
<TopToolbar>
|
|
23
24
|
<ListButton />
|
|
24
25
|
</TopToolbar>
|
|
25
26
|
))
|
|
26
|
-
|
|
27
|
-
setupAdmin(["create-inputs"], buildRA)
|
|
@@ -13,7 +13,7 @@ import { ActionButton } from "./buttons"
|
|
|
13
13
|
import { useMuffinAdminOpts, useMuffinResourceOpts } from "./hooks"
|
|
14
14
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils"
|
|
15
15
|
|
|
16
|
-
export function
|
|
16
|
+
export function MuffinEdit() {
|
|
17
17
|
const {
|
|
18
18
|
adminProps: { mutationMode = "optimistic" },
|
|
19
19
|
} = useMuffinAdminOpts()
|
|
@@ -21,10 +21,10 @@ export function MuffinResourceEdit() {
|
|
|
21
21
|
if (!edit) return null
|
|
22
22
|
|
|
23
23
|
const { inputs, remove } = edit
|
|
24
|
-
const
|
|
24
|
+
const ActionsToolbar = findBuilder(["edit-toolbar", name])
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
|
-
<Edit actions={<
|
|
27
|
+
<Edit actions={<ActionsToolbar />} mutationMode={mutationMode}>
|
|
28
28
|
<SimpleForm
|
|
29
29
|
toolbar={
|
|
30
30
|
<Toolbar>
|
|
@@ -45,23 +45,34 @@ export function MuffinResourceEdit() {
|
|
|
45
45
|
)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
setupAdmin(["edit"],
|
|
48
|
+
setupAdmin(["edit"], MuffinEdit)
|
|
49
|
+
setupAdmin(["edit-inputs"], buildRA)
|
|
50
|
+
|
|
51
|
+
export function MuffinEditToolbar() {
|
|
52
|
+
const { name } = useMuffinResourceOpts()
|
|
53
|
+
const Actions = findBuilder(["edit-actions", name])
|
|
54
|
+
return (
|
|
55
|
+
<TopToolbar>
|
|
56
|
+
<Actions />
|
|
57
|
+
<ListButton />
|
|
58
|
+
<ShowButton />
|
|
59
|
+
</TopToolbar>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setupAdmin(["edit-toolbar"], MuffinEditToolbar)
|
|
49
64
|
|
|
50
|
-
function
|
|
65
|
+
export function MuffinEditActions() {
|
|
51
66
|
const { edit } = useMuffinResourceOpts()
|
|
52
67
|
if (!edit) return null
|
|
53
68
|
const { actions = [] } = edit
|
|
54
69
|
return (
|
|
55
|
-
|
|
70
|
+
<>
|
|
56
71
|
{actions.map((props, idx) => (
|
|
57
72
|
<ActionButton key={idx} {...props} />
|
|
58
73
|
))}
|
|
59
|
-
|
|
60
|
-
<ShowButton />
|
|
61
|
-
</TopToolbar>
|
|
74
|
+
</>
|
|
62
75
|
)
|
|
63
76
|
}
|
|
64
77
|
|
|
65
|
-
setupAdmin(["edit-actions"],
|
|
66
|
-
|
|
67
|
-
setupAdmin(["edit-inputs"], buildRA)
|
|
78
|
+
setupAdmin(["edit-actions"], MuffinEditActions)
|
|
@@ -17,18 +17,18 @@ import { BulkActionButton } from "./buttons"
|
|
|
17
17
|
import { useMuffinResourceOpts } from "./hooks"
|
|
18
18
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils"
|
|
19
19
|
|
|
20
|
-
export function
|
|
20
|
+
export function MuffinList() {
|
|
21
21
|
const { name, list } = useMuffinResourceOpts()
|
|
22
22
|
const { fields, edit, show, limit, limitMax, filters, sort } = list
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const Toolbar = findBuilder(["list-toolbar", name])
|
|
25
25
|
const BulkActions = findBuilder(["list-bulk-actions", name])
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
28
|
<List
|
|
29
29
|
sort={sort}
|
|
30
30
|
perPage={limit}
|
|
31
|
-
actions={<
|
|
31
|
+
actions={<Toolbar />}
|
|
32
32
|
filters={buildAdmin(["list-filters", name], filters)}
|
|
33
33
|
bulkActionButtons={<BulkActions />}
|
|
34
34
|
pagination={
|
|
@@ -43,12 +43,11 @@ export function MuffinResourceList() {
|
|
|
43
43
|
)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
setupAdmin(["list"],
|
|
46
|
+
setupAdmin(["list"], MuffinList)
|
|
47
47
|
setupAdmin(["list-fields"], buildRA)
|
|
48
|
-
|
|
49
48
|
setupAdmin(["list-filters"], buildRA)
|
|
50
49
|
|
|
51
|
-
function
|
|
50
|
+
function MuffinListToolbar() {
|
|
52
51
|
const {
|
|
53
52
|
list: { create },
|
|
54
53
|
} = useMuffinResourceOpts()
|
|
@@ -61,7 +60,7 @@ function MuffinListActions() {
|
|
|
61
60
|
</TopToolbar>
|
|
62
61
|
)
|
|
63
62
|
}
|
|
64
|
-
setupAdmin(["list-
|
|
63
|
+
setupAdmin(["list-toolbar"], MuffinListToolbar)
|
|
65
64
|
|
|
66
65
|
function MuffinListBulkActions() {
|
|
67
66
|
const {
|
|
@@ -5,45 +5,26 @@ import { ActionButton } from "./buttons"
|
|
|
5
5
|
import { useMuffinResourceOpts } from "./hooks"
|
|
6
6
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils"
|
|
7
7
|
|
|
8
|
-
export function
|
|
8
|
+
export function MuffinShow() {
|
|
9
9
|
const { show, name } = useMuffinResourceOpts()
|
|
10
|
-
const
|
|
10
|
+
const ActionsToolbar = findBuilder(["show-toolbar", name])
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<Show actions={<
|
|
13
|
+
<Show actions={<ActionsToolbar />}>
|
|
14
14
|
<SimpleShowLayout>{buildAdmin(["show-fields", name], show)}</SimpleShowLayout>
|
|
15
15
|
</Show>
|
|
16
16
|
)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
setupAdmin(["
|
|
20
|
-
const { show } = useMuffinResourceOpts()
|
|
21
|
-
const { actions } = show
|
|
22
|
-
return actions.map((props) => <ActionButton key={props.id} {...props} />)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
setupAdmin(["record-links"], () => {
|
|
26
|
-
const { show } = useMuffinResourceOpts()
|
|
27
|
-
const { links } = show
|
|
28
|
-
return (
|
|
29
|
-
<div style={{ marginRight: "auto" }}>
|
|
30
|
-
{links.map(([key, props]) => (
|
|
31
|
-
<LinkAction key={key} resource={key} {...props} />
|
|
32
|
-
))}
|
|
33
|
-
</div>
|
|
34
|
-
)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
setupAdmin(["show"], (props) => <MuffinResourceShow {...props} />)
|
|
38
|
-
|
|
19
|
+
setupAdmin(["show"], (props) => <MuffinShow {...props} />)
|
|
39
20
|
setupAdmin(["show-fields"], ({ fields }) => buildRA(fields))
|
|
40
21
|
|
|
41
|
-
|
|
22
|
+
export function MuffinShowToolbar() {
|
|
42
23
|
const { show, name } = useMuffinResourceOpts()
|
|
43
24
|
const { edit } = show
|
|
44
25
|
|
|
45
|
-
const Links = findBuilder(["
|
|
46
|
-
const Actions = findBuilder(["
|
|
26
|
+
const Links = findBuilder(["show-links", name])
|
|
27
|
+
const Actions = findBuilder(["show-actions", name])
|
|
47
28
|
|
|
48
29
|
return (
|
|
49
30
|
<TopToolbar>
|
|
@@ -53,4 +34,28 @@ setupAdmin(["show-actions"], () => {
|
|
|
53
34
|
{edit && <EditButton />}
|
|
54
35
|
</TopToolbar>
|
|
55
36
|
)
|
|
56
|
-
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setupAdmin(["show-toolbar"], MuffinShowToolbar)
|
|
40
|
+
|
|
41
|
+
export function MuffinShowActions() {
|
|
42
|
+
const { show } = useMuffinResourceOpts()
|
|
43
|
+
const { actions } = show
|
|
44
|
+
return actions.map((props) => <ActionButton key={props.id} {...props} />)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setupAdmin(["show-actions"], MuffinShowActions)
|
|
48
|
+
|
|
49
|
+
export function MuffinShowLinks() {
|
|
50
|
+
const { show } = useMuffinResourceOpts()
|
|
51
|
+
const { links } = show
|
|
52
|
+
return (
|
|
53
|
+
<div style={{ marginRight: "auto" }}>
|
|
54
|
+
{links.map(([key, props]) => (
|
|
55
|
+
<LinkAction key={key} resource={key} {...props} />
|
|
56
|
+
))}
|
|
57
|
+
</div>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setupAdmin(["show-links"], MuffinShowLinks)
|