muffin-admin 9.4.0 → 9.4.1

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": "9.4.0",
3
+ "version": "9.4.1",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -7,6 +7,7 @@ import ListItemText from "@mui/material/ListItemText"
7
7
 
8
8
  import { Menu, MenuProps, useTranslate } from "react-admin"
9
9
 
10
+ import find from "lodash/find"
10
11
  import groupBy from "lodash/groupBy"
11
12
  import { useContext, useState } from "react"
12
13
  import { MuffinAdminContext } from "./context"
@@ -25,12 +26,12 @@ export function MuffinMenu(props: MenuProps) {
25
26
  return (
26
27
  <Menu {...props}>
27
28
  <Menu.DashboardItem />
28
- {resources.map(({ name, group, icon }) => {
29
+ {resources.map(({ name, group }) => {
29
30
  if (!group) return <Menu.ResourceItem name={name} key={name} />
30
31
  if (groupRendered.includes(group)) return null
31
32
  groupRendered.push(group)
32
33
  const groupResources = groups[group]
33
- return <MenuGroup name={group} icon={icon} resources={groupResources} key={group} />
34
+ return <MenuGroup name={group} resources={groupResources} key={group} />
34
35
  })}
35
36
  </Menu>
36
37
  )
@@ -38,25 +39,20 @@ export function MuffinMenu(props: MenuProps) {
38
39
 
39
40
  setupAdmin(["menu"], MuffinMenu)
40
41
 
41
- function MenuGroup({
42
- name,
43
- icon,
44
- resources,
45
- }: {
46
- name: string
47
- icon: string
48
- resources: AdminResourceProps[]
49
- }) {
50
- const Icon = findIcon(icon)
42
+ function MenuGroup({ name, resources }: { name: string; resources: AdminResourceProps[] }) {
43
+ const iconRes = find(resources, "icon")
44
+ const Icon = iconRes ? findIcon(iconRes.icon) : null
51
45
  const translate = useTranslate()
52
46
  const [groupOpen, setGroupOpen] = useState(false)
53
47
 
54
48
  return (
55
49
  <div>
56
50
  <ListItemButton onClick={() => setGroupOpen(!groupOpen)}>
57
- <ListItemIcon sx={{ minWidth: 40 }}>
58
- <Icon />
59
- </ListItemIcon>
51
+ {Icon && (
52
+ <ListItemIcon sx={{ minWidth: 40 }}>
53
+ <Icon />
54
+ </ListItemIcon>
55
+ )}
60
56
  <ListItemText primary={translate(`groups.${name}`)} />
61
57
  {groupOpen ? <ExpandLess /> : <ExpandMore />}
62
58
  </ListItemButton>
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.4.0"
40
+ export const VERSION = "9.4.1"