muffin-admin 9.5.1 → 9.5.3
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/MuffinMenu.js +14 -2
- package/dist/actions/LinkAction.d.ts +1 -1
- package/dist/actions/LinkAction.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/MuffinMenu.tsx +15 -2
- package/src/actions/LinkAction.tsx +10 -3
- package/src/index.tsx +1 -1
- package/src/types.ts +7 -6
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
package/src/MuffinMenu.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import ListItemIcon from "@mui/material/ListItemIcon"
|
|
|
6
6
|
import ListItemText from "@mui/material/ListItemText"
|
|
7
7
|
import { matchPath, useLocation } from "react-router-dom"
|
|
8
8
|
|
|
9
|
-
import { Menu, MenuProps, useBasename, useTranslate } from "react-admin"
|
|
9
|
+
import { Menu, MenuProps, useBasename, useTheme, useTranslate } from "react-admin"
|
|
10
10
|
|
|
11
11
|
import find from "lodash/find"
|
|
12
12
|
import groupBy from "lodash/groupBy"
|
|
@@ -50,12 +50,25 @@ function MenuGroup({ name, resources }: { name: string; resources: AdminResource
|
|
|
50
50
|
(resource) => !!matchPath({ path: `${basename}/${resource.name}/*` }, pathname)
|
|
51
51
|
)
|
|
52
52
|
const [groupOpen, setGroupOpen] = useState(match)
|
|
53
|
+
const theme = useTheme()[0]
|
|
54
|
+
const colors =
|
|
55
|
+
theme == "dark"
|
|
56
|
+
? {
|
|
57
|
+
text: "rgba(255, 255, 255, 0.87)",
|
|
58
|
+
textSecondary: "rgba(255, 255, 255, 0.6)",
|
|
59
|
+
}
|
|
60
|
+
: {
|
|
61
|
+
text: "rgba(0, 0, 0, 0.87)",
|
|
62
|
+
textSecondary: "rgba(0, 0, 0, 0.6)",
|
|
63
|
+
}
|
|
53
64
|
|
|
54
65
|
return (
|
|
55
66
|
<div>
|
|
56
67
|
<ListItemButton
|
|
57
68
|
onClick={() => setGroupOpen(!groupOpen)}
|
|
58
|
-
sx={{
|
|
69
|
+
sx={{
|
|
70
|
+
color: match ? colors.text : colors.textSecondary,
|
|
71
|
+
}}
|
|
59
72
|
>
|
|
60
73
|
{Icon && (
|
|
61
74
|
<ListItemIcon sx={{ minWidth: 40 }}>
|
|
@@ -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({
|
|
7
|
-
|
|
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
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
| {
|
|
93
|
+
inputs: AdminInput[]
|
|
94
|
+
remove?: boolean
|
|
95
|
+
}
|
|
96
|
+
| false
|
|
96
97
|
list: {
|
|
97
98
|
limit: number
|
|
98
99
|
limitMax: number
|