muffin-admin 1.45.3 → 1.45.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
@@ -19,6 +19,7 @@ export type AdminShowLink = {
19
19
  label: string;
20
20
  title?: string;
21
21
  icon?: string;
22
+ fk?: string;
22
23
  };
23
24
  export type AdminShowProps = {
24
25
  actions: AdminAction[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "1.45.3",
3
+ "version": "1.45.4",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -1,10 +1,16 @@
1
+ import { useContext } from "react"
1
2
  import { useRecordContext, useResourceContext } from "react-admin"
2
3
  import LinkButton from "../buttons/LinkButton"
3
4
  import { AdminShowLink } from "../types"
5
+ import { AdminPropsContext } from "../utils"
4
6
 
5
- export function LinkAction(props: AdminShowLink & { resource: string }) {
7
+ export function LinkAction({ fk, icon, ...props }: AdminShowLink & { resource: string }) {
8
+ const adminProps = useContext(AdminPropsContext)
6
9
  const record = useRecordContext()
7
10
  const currentResource = useResourceContext()
8
11
  if (!record) return null
9
- return <LinkButton {...props} filters={{ [currentResource]: record.id }} />
12
+
13
+ icon = icon || adminProps?.resources[props.resource]?.icon
14
+
15
+ return <LinkButton {...props} icon={icon} filters={{ [currentResource]: record[fk || "id"] }} />
10
16
  }
package/src/types.ts CHANGED
@@ -17,6 +17,7 @@ export type AdminShowLink = {
17
17
  label: string
18
18
  title?: string
19
19
  icon?: string
20
+ fk?: string
20
21
  }
21
22
  export type AdminShowProps = {
22
23
  actions: AdminAction[]