fix sidebar
This commit is contained in:
parent
be4a6ed120
commit
70d99473e1
@ -178,7 +178,9 @@ function AppSidebar() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`Sidebar` باید داخل `BiProvider` استفاده شود. Permission هر آیتم از `perm` توسط خود UI Kit بررسی میشود، خروج با Keycloak توسط خود UI Kit انجام میشود و دسترسی `panel_access` نیز داخل Sidebar کنترل میشود. سامانه مقصد نیازی به `usePermission` یا `logoutKeycloak` برای Sidebar ندارد.
|
`Sidebar` باید داخل `BiProvider` استفاده شود. Permission هر آیتم از `perm` توسط خود UI Kit بررسی میشود و خروج با Keycloak توسط خود UI Kit انجام میشود. سامانه مقصد نیازی به `usePermission` یا `logoutKeycloak` برای Sidebar ندارد.
|
||||||
|
|
||||||
|
کنترل دسترسی کلی `panel_access` عمداً داخل Sidebar انجام نمیشود تا navigation هنگام render باعث redirect و لغو route در Next.js نشود. اگر سامانه به این guard نیاز دارد، از `PanelAccessGuard` موجود در `uikit/core` در سطح Layout/App استفاده کنید.
|
||||||
|
|
||||||
`aliases` نیز پشتیبانی میشود و برای تشخیص آیتم active استفاده میشود:
|
`aliases` نیز پشتیبانی میشود و برای تشخیص آیتم active استفاده میشود:
|
||||||
|
|
||||||
|
|||||||
160
dist/layout.js
vendored
160
dist/layout.js
vendored
File diff suppressed because one or more lines are too long
@ -19,7 +19,7 @@ import {
|
|||||||
VStack,
|
VStack,
|
||||||
useDisclosure,
|
useDisclosure,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { Children, forwardRef, isValidElement, useEffect, useRef } from "react";
|
import { Children, forwardRef, isValidElement, useRef } from "react";
|
||||||
import { FiMoreHorizontal } from "react-icons/fi/index.js";
|
import { FiMoreHorizontal } from "react-icons/fi/index.js";
|
||||||
import { IoExit } from "react-icons/io5/index.js";
|
import { IoExit } from "react-icons/io5/index.js";
|
||||||
import { logoutKeycloak } from "../core/keycloak.jsx";
|
import { logoutKeycloak } from "../core/keycloak.jsx";
|
||||||
@ -181,7 +181,7 @@ const SidebarRoot = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
const moreButtonRef = useRef();
|
const moreButtonRef = useRef();
|
||||||
const { cannot, can, isLoading } = usePermission();
|
const { cannot } = usePermission();
|
||||||
|
|
||||||
const exitElement = Children.toArray(children).find(
|
const exitElement = Children.toArray(children).find(
|
||||||
(child) => isValidElement(child) && child.type === SidebarExit,
|
(child) => isValidElement(child) && child.type === SidebarExit,
|
||||||
@ -190,13 +190,6 @@ const SidebarRoot = ({
|
|||||||
const logoutTitle = exitElement?.props?.title || "خروج";
|
const logoutTitle = exitElement?.props?.title || "خروج";
|
||||||
const logoutIcon = exitElement?.props?.icon || IoExit;
|
const logoutIcon = exitElement?.props?.icon || IoExit;
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isLoading) return;
|
|
||||||
|
|
||||||
if (!can("panel_access")) {
|
|
||||||
logoutKeycloak();
|
|
||||||
}
|
|
||||||
}, [can, isLoading]);
|
|
||||||
|
|
||||||
const resolvedCurrentPath =
|
const resolvedCurrentPath =
|
||||||
currentPath ??
|
currentPath ??
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user