@campxdev/shared 1.8.34 → 1.8.35
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
|
@@ -9,6 +9,8 @@ import { ReactNode } from 'react'
|
|
|
9
9
|
import { Link } from 'react-router-dom'
|
|
10
10
|
import { DrawerButtonProps } from '../ModalButtons/DrawerButton'
|
|
11
11
|
import { StyledMenuItem } from './styles'
|
|
12
|
+
import { ValidateAccess } from '../../permissions'
|
|
13
|
+
import { Permission } from '../../shared-state'
|
|
12
14
|
|
|
13
15
|
const StyledLink = styled(Link)(({ theme }) => ({
|
|
14
16
|
display: 'block',
|
|
@@ -53,6 +55,7 @@ export type IMenuItemProps = Omit<MenuItemButtonProps, 'onClick'> & {
|
|
|
53
55
|
onClick?: () => void
|
|
54
56
|
dialogProps?: Omit<DialogProps, 'open'>
|
|
55
57
|
drawerProps?: Omit<DrawerProps, 'open'>
|
|
58
|
+
permissionKey?: Permission
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
export interface IRenderMenuItemProps extends IMenuItemProps {
|
|
@@ -70,6 +73,7 @@ export const RenderMenuItem = ({
|
|
|
70
73
|
link,
|
|
71
74
|
drawerProps,
|
|
72
75
|
dialogProps,
|
|
76
|
+
permissionKey,
|
|
73
77
|
...props
|
|
74
78
|
}: IRenderMenuItemProps) => {
|
|
75
79
|
const renderMenuItem: Record<MenuItemType, ReactNode> = {
|
|
@@ -106,5 +110,13 @@ export const RenderMenuItem = ({
|
|
|
106
110
|
</StyledLink>
|
|
107
111
|
),
|
|
108
112
|
}
|
|
113
|
+
|
|
114
|
+
if (permissionKey)
|
|
115
|
+
return (
|
|
116
|
+
<ValidateAccess accessKey={permissionKey}>
|
|
117
|
+
{renderMenuItem[actionType]}
|
|
118
|
+
</ValidateAccess>
|
|
119
|
+
)
|
|
120
|
+
|
|
109
121
|
return <>{renderMenuItem[actionType]}</>
|
|
110
122
|
}
|