Add RBAC menu and role management

Adds permission, menu, and role administration with hierarchical access controls, plus admin breadcrumbs and a redirect from the legacy user-role page. Remove `credentials.md` before committing; it contains server credentials.
This commit is contained in:
Ichsan Kurniawan
2026-11-05 19:01:40 +07:00
parent 4d2ceefba7
commit 751b28fab2
35 changed files with 3004 additions and 1160 deletions
+58
View File
@@ -0,0 +1,58 @@
'use client';
import { usePathname } from 'next/navigation';
import Link from 'next/link';
export default function AdminBreadcrumb() {
const pathname = usePathname();
const segments = (pathname || '')
.split('/')
.filter(Boolean)
.slice(1); // skip 'admin'
const formatSegment = (seg: string) => {
return seg
.split('-')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
};
if (segments.length === 0) {
return (
<div className="flex items-center text-xs font-medium text-muted-foreground">
<span>Pages</span>
<span className="mx-1.5 text-zinc-400">/</span>
<span className="text-zinc-900 dark:text-zinc-100 font-semibold">Dashboard</span>
</div>
);
}
return (
<div className="flex items-center text-xs font-medium text-muted-foreground flex-wrap">
<Link href="/admin" className="hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors">
Pages
</Link>
{segments.map((seg, idx) => {
const isLast = idx === segments.length - 1;
const href = '/admin/' + segments.slice(0, idx + 1).join('/');
return (
<span key={href} className="inline-flex items-center">
<span className="mx-1.5 text-zinc-400">/</span>
{isLast ? (
<span className="text-zinc-900 dark:text-zinc-100 font-semibold">
{formatSegment(seg)}
</span>
) : (
<Link href={href} className="hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors">
{formatSegment(seg)}
</Link>
)}
</span>
);
})}
</div>
);
}
+8 -3
View File
@@ -41,7 +41,13 @@ const SidebarItem: FC<Props> = ({ menu, expand, onChangeExpand }) => {
}
const getActiveBackgroundMenu = () => {
if (pathanme === '/admin' + menu.path) {
const currentPath = pathanme || '';
const fullPath = '/admin' + (menu.path || '');
const isActive = menu.path === ''
? currentPath === '/admin' || currentPath === '/admin/'
: currentPath === fullPath || (menu.path && currentPath.startsWith(fullPath + '/'));
if (isActive) {
return {
color: theme === 'dark' ? '#fff' : theme === 'system' && systemTheme === 'dark' ? '#fff' : '#fff',
fontWeight: theme === 'light' ? 600 : theme === 'system' && systemTheme === 'light' ? 600 : undefined,
@@ -77,7 +83,6 @@ const SidebarItem: FC<Props> = ({ menu, expand, onChangeExpand }) => {
{submenuItems && submenuItems.length > 0 && submenuIdActive?.includes(submenuId) && expand &&
<motion.ul
// className='ml-4'
animate={
submenuIdActive?.includes(submenuId) ?
{
@@ -99,4 +104,4 @@ const SidebarItem: FC<Props> = ({ menu, expand, onChangeExpand }) => {
);
}
export default SidebarItem;
export default SidebarItem;