muffin-admin 9.5.2 → 9.5.4

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
@@ -29,6 +29,7 @@ export type AdminShowLink = {
29
29
  title?: string;
30
30
  icon?: string;
31
31
  field?: string;
32
+ filter?: string;
32
33
  };
33
34
  export type AdminShowProps = {
34
35
  fields: AdminField[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "9.5.2",
3
+ "version": "9.5.4",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -3,10 +3,17 @@ import LinkButton from "../buttons/LinkButton"
3
3
  import { useMuffinAdminOpts } from "../hooks"
4
4
  import { AdminShowLink } from "../types"
5
5
 
6
- export function LinkAction({ field, icon, label, ...props }: AdminShowLink & { resource: string }) {
7
- const { resources } = useMuffinAdminOpts()
6
+ export function LinkAction({
7
+ field,
8
+ filter,
9
+ icon,
10
+ label,
11
+ ...props
12
+ }: AdminShowLink & { resource: string }) {
8
13
  const record = useRecordContext()
14
+ const { resources } = useMuffinAdminOpts()
9
15
  const currentResource = useResourceContext()
16
+
10
17
  if (!record) return null
11
18
 
12
19
  const resource = resources.find((r) => r.name === props.resource)
@@ -16,7 +23,7 @@ export function LinkAction({ field, icon, label, ...props }: AdminShowLink & { r
16
23
  {...props}
17
24
  icon={icon || resource?.icon}
18
25
  label={label || `resources.${props.resource}.name`}
19
- filters={{ [currentResource]: encodeURIComponent(record[field || "id"]) }}
26
+ filters={{ [filter || currentResource]: encodeURIComponent(record[field || "id"]) }}
20
27
  />
21
28
  )
22
29
  }
package/src/index.tsx CHANGED
@@ -37,4 +37,4 @@ export async function initAdmin(prefix = "", containerId: string = "root") {
37
37
  )
38
38
  }
39
39
 
40
- export const VERSION = "9.5.2"
40
+ export const VERSION = "9.5.4"
package/src/types.ts CHANGED
@@ -56,13 +56,14 @@ export type AdminAction = {
56
56
  }
57
57
 
58
58
  export type AdminField = [string, { source: string }]
59
- export type AdminInput = [string, { required: boolean; source: string;[key: string]: any }]
59
+ export type AdminInput = [string, { required: boolean; source: string; [key: string]: any }]
60
60
 
61
61
  export type AdminShowLink = {
62
62
  label: string
63
63
  title?: string
64
64
  icon?: string
65
65
  field?: string
66
+ filter?: string
66
67
  }
67
68
  export type AdminShowProps = {
68
69
  fields: AdminField[]
@@ -88,11 +89,11 @@ export type AdminResourceProps = {
88
89
  actions: AdminAction[]
89
90
  create: AdminInput[] | false
90
91
  edit:
91
- | {
92
- inputs: AdminInput[]
93
- remove?: boolean
94
- }
95
- | false
92
+ | {
93
+ inputs: AdminInput[]
94
+ remove?: boolean
95
+ }
96
+ | false
96
97
  list: {
97
98
  limit: number
98
99
  limitMax: number