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