mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 22:58:17 +00:00
feat: better navigation in backoffice
This commit is contained in:
@@ -40,8 +40,10 @@ export const AppLayout = () => {
|
||||
drives collapse on desktop and the Sheet drawer on mobile. */}
|
||||
<Sidebar collapsible="icon">
|
||||
<SidebarHeader className="gap-1 border-b border-sidebar-border">
|
||||
{/* "/" resolves to the user's own landing page — an IAM-only admin
|
||||
has no overview to go back to. */}
|
||||
<Link
|
||||
to="/dashboard/overview"
|
||||
to="/"
|
||||
className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
|
||||
>
|
||||
<ArrowLeft className="size-4 shrink-0" />
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { ReactElement } from "react";
|
||||
import { Navigate, Outlet, Route } from "react-router-dom";
|
||||
|
||||
import { useAuth } from "@/auth/useAuth";
|
||||
import { NO_ACCESS_PATH, resolveLandingPath } from "@/lib/landing";
|
||||
import { isSuperAdmin } from "@/lib/permissions";
|
||||
import { WithPermission } from "@/shared/hooks/useHas";
|
||||
import PendingExternalUsers from "@/super-admin/components/externalUsers/PendingExternalUsers";
|
||||
@@ -85,7 +86,7 @@ function PrivateRoute({ allowedRoles }: { allowedRoles: string[] }): ReactElemen
|
||||
.filter((k): k is string => Boolean(k));
|
||||
const allowed =
|
||||
isSuperAdmin(user) || allowedRoles.some((r) => roleKeys.includes(r));
|
||||
return allowed ? <Outlet /> : <Navigate to="/dashboard/overview" replace />;
|
||||
return allowed ? <Outlet /> : <Navigate to={resolveLandingPath(user)} replace />;
|
||||
}
|
||||
|
||||
export const UserManagementRedirect = () => {
|
||||
@@ -100,7 +101,9 @@ export const UserManagementRedirect = () => {
|
||||
return <Navigate to="/user-management/user_management-dashboard" replace />;
|
||||
}
|
||||
|
||||
return <Navigate to="/" replace />; // fallback
|
||||
// No IAM role: "/" resolves back here for anyone whose only sidebar entry is
|
||||
// Staff, so bounce to the terminal page instead of ping-ponging.
|
||||
return <Navigate to={NO_ACCESS_PATH} replace />;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user