muffin-admin 1.45.7 → 2.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/types.d.ts CHANGED
@@ -24,17 +24,17 @@ export type AdminShowLink = {
24
24
  export type AdminShowProps = {
25
25
  actions: AdminAction[];
26
26
  fields: AdminField[];
27
- links: Record<string, AdminShowLink>;
27
+ links: [string, AdminShowLink][];
28
28
  };
29
29
  export type AdminResourceProps = {
30
30
  name: string;
31
31
  icon?: string;
32
32
  label: string;
33
- create: AdminInput[];
33
+ create: AdminInput[] | false;
34
34
  edit: {
35
35
  actions: AdminAction[];
36
36
  inputs: AdminInput[];
37
- };
37
+ } | false;
38
38
  list: {
39
39
  limit: number;
40
40
  limitMax: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "1.45.7",
3
+ "version": "2.0.0",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -15,8 +15,8 @@ export function MuffinResource({
15
15
  <Resource
16
16
  name={name}
17
17
  icon={findIcon(icon)}
18
- create={buildAdmin(["create", name], createProps)}
19
- edit={buildAdmin(["edit", name], editProps)}
18
+ create={createProps ? buildAdmin(["create", name], createProps) : undefined}
19
+ edit={editProps ? buildAdmin(["edit", name], editProps) : undefined}
20
20
  list={buildAdmin(["list", name], listProps)}
21
21
  show={buildAdmin(["show", name], showProps)}
22
22
  {...props}
@@ -12,17 +12,20 @@ import { ActionButton } from "./buttons"
12
12
  import { AdminAction, AdminOpts, AdminResourceProps } from "./types"
13
13
  import { AdminPropsContext, buildAdmin, setupAdmin } from "./utils"
14
14
 
15
- export function MuffinResourceEdit({ actions, inputs, ...props }: AdminResourceProps["edit"]) {
15
+ export function MuffinResourceEdit(props: AdminResourceProps["edit"]) {
16
16
  const resourceName = useResourceContext()
17
17
  const {
18
18
  adminProps: { mutationMode },
19
19
  } = useContext(AdminPropsContext) as AdminOpts
20
20
 
21
+ if (!props) return null
22
+ const { actions, inputs, ...opts } = props
23
+
21
24
  return (
22
25
  <Edit
23
26
  actions={buildAdmin(["edit-actions", resourceName], actions)}
24
27
  mutationMode={mutationMode || "optimistic"}
25
- {...props}
28
+ {...opts}
26
29
  >
27
30
  <SimpleForm>{buildAdmin(["edit-inputs", resourceName], inputs)}</SimpleForm>
28
31
  </Edit>
@@ -26,8 +26,8 @@ setupAdmin(["show-fields"], ({ fields }) => buildRA(fields))
26
26
  setupAdmin(["show-actions"], ({ actions, links }) => (
27
27
  <TopToolbar>
28
28
  <div style={{ marginRight: "auto" }}>
29
- {Object.keys(links).map((key) => (
30
- <LinkAction key={key} resource={key} {...links[key]} />
29
+ {links.map(([key, props]) => (
30
+ <LinkAction key={key} resource={key} {...props} />
31
31
  ))}
32
32
  </div>
33
33
  {actions.map((props, idx) => (
package/src/types.ts CHANGED
@@ -22,18 +22,20 @@ export type AdminShowLink = {
22
22
  export type AdminShowProps = {
23
23
  actions: AdminAction[]
24
24
  fields: AdminField[]
25
- links: Record<string, AdminShowLink>
25
+ links: [string, AdminShowLink][]
26
26
  }
27
27
 
28
28
  export type AdminResourceProps = {
29
29
  name: string
30
30
  icon?: string
31
31
  label: string
32
- create: AdminInput[]
33
- edit: {
34
- actions: AdminAction[]
35
- inputs: AdminInput[]
36
- }
32
+ create: AdminInput[] | false
33
+ edit:
34
+ | {
35
+ actions: AdminAction[]
36
+ inputs: AdminInput[]
37
+ }
38
+ | false
37
39
  list: {
38
40
  limit: number
39
41
  limitMax: number