fix sidebar
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 49s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 7s

This commit is contained in:
Mohamadzadeh 2026-08-19 18:16:49 +03:30
parent be4a6ed120
commit 70d99473e1
3 changed files with 83 additions and 92 deletions

View File

@ -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 استفاده می‌شود:

160
dist/layout.js vendored

File diff suppressed because one or more lines are too long

View File

@ -19,7 +19,7 @@ import {
VStack,
useDisclosure,
} 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 { IoExit } from "react-icons/io5/index.js";
import { logoutKeycloak } from "../core/keycloak.jsx";
@ -181,7 +181,7 @@ const SidebarRoot = ({
}) => {
const { isOpen, onOpen, onClose } = useDisclosure();
const moreButtonRef = useRef();
const { cannot, can, isLoading } = usePermission();
const { cannot } = usePermission();
const exitElement = Children.toArray(children).find(
(child) => isValidElement(child) && child.type === SidebarExit,
@ -190,13 +190,6 @@ const SidebarRoot = ({
const logoutTitle = exitElement?.props?.title || "خروج";
const logoutIcon = exitElement?.props?.icon || IoExit;
useEffect(() => {
if (isLoading) return;
if (!can("panel_access")) {
logoutKeycloak();
}
}, [can, isLoading]);
const resolvedCurrentPath =
currentPath ??