muffin-admin 2.9.0 → 2.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "2.9.0",
3
+ "version": "2.9.2",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -11,7 +11,6 @@ import {
11
11
  import { buildRA } from "./buildRA"
12
12
  import { ActionButton } from "./buttons"
13
13
  import { useMuffinAdminOpts, useMuffinResourceOpts } from "./hooks"
14
- import { AdminAction } from "./types"
15
14
  import { buildAdmin, findBuilder, setupAdmin } from "./utils"
16
15
 
17
16
  export function MuffinResourceEdit() {
@@ -21,11 +20,11 @@ export function MuffinResourceEdit() {
21
20
  const { edit, name } = useMuffinResourceOpts()
22
21
  if (!edit) return null
23
22
 
24
- const { actions, inputs, remove, ...opts } = edit
25
- const Actions = findBuilder(["edit-actions", name])
23
+ const { inputs, remove } = edit
24
+ const Actions = findBuilder(["edit-actions", name]) as unknown as any
26
25
 
27
26
  return (
28
- <Edit actions={<Actions actions={actions} />} mutationMode={mutationMode} {...opts}>
27
+ <Edit actions={<Actions />} mutationMode={mutationMode}>
29
28
  <SimpleForm
30
29
  toolbar={
31
30
  <Toolbar>
@@ -48,7 +47,10 @@ export function MuffinResourceEdit() {
48
47
 
49
48
  setupAdmin(["edit"], MuffinResourceEdit)
50
49
 
51
- function MuffinResourceEditActions({ actions }: { actions: AdminAction[] }) {
50
+ function MuffinResourceEditActions() {
51
+ const { edit } = useMuffinResourceOpts()
52
+ if (!edit) return null
53
+ const { actions = [] } = edit
52
54
  return (
53
55
  <TopToolbar>
54
56
  {actions.map((props, idx) => (
@@ -1,16 +1,8 @@
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
8
  export function MuffinResourceShow() {
@@ -18,34 +10,45 @@ export function MuffinResourceShow() {
18
10
  const ShowActions = findBuilder(["show-actions", name])
19
11
 
20
12
  return (
21
- <Show actions={<ShowActions {...show} />}>
13
+ <Show actions={<ShowActions />}>
22
14
  <SimpleShowLayout>{buildAdmin(["show-fields", name], show)}</SimpleShowLayout>
23
15
  </Show>
24
16
  )
25
17
  }
26
18
 
27
- setupAdmin(["record-actions"], ({ actions }: { actions: AdminAction[] }) =>
28
- actions.map((props) => <ActionButton key={props.id} {...props} />)
29
- )
19
+ setupAdmin(["record-actions"], () => {
20
+ const { show } = useMuffinResourceOpts()
21
+ const { actions } = show
22
+ return actions.map((props) => <ActionButton key={props.id} {...props} />)
23
+ })
30
24
 
31
- setupAdmin(["record-links"], ({ links }: { links: AdminShowProps["links"] }) =>
32
- links.map(([key, props]) => <LinkAction key={key} resource={key} {...props} />)
33
- )
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
+ })
34
36
 
35
37
  setupAdmin(["show"], (props) => <MuffinResourceShow {...props} />)
36
38
 
37
39
  setupAdmin(["show-fields"], ({ fields }) => buildRA(fields))
38
40
 
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])
41
+ setupAdmin(["show-actions"], () => {
42
+ const { show, name } = useMuffinResourceOpts()
43
+ const { edit } = show
44
+
45
+ const Links = findBuilder(["record-links", name])
46
+ const Actions = findBuilder(["record-actions", name])
47
+
43
48
  return (
44
49
  <TopToolbar>
45
- <div style={{ marginRight: "auto" }}>
46
- <Links links={links} />
47
- </div>
48
- <Actions actions={actions} />
50
+ <Links />
51
+ <Actions />
49
52
  <ListButton />
50
53
  {edit && <EditButton />}
51
54
  </TopToolbar>