Feat: RBAC, Keys Extension, Invites
feat: org members page — invite users, cancel invites, change roles feat: show pending invitations banner on profile page feat: invite accept flow for existing users (no password needed) feat: departments page updates feat: SSH keys page — dept cert policy UI (expiry + extensions) feat: wire up auth pages to real API (register, verify, reset, OIDC) feat: CLI auth bridge — login page handles CLI token flow feat: admin users — suspend/unsuspend, role badges, role filter feat: add admin OAuth providers management page feat: activity page — org-wide audit log view for admins feat: add my memberships page chore: add isOrgAdmin/isOrgMember to AuthContext, restrict sidebar chore: update app routing and shared layout
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
||||
Users,
|
||||
Settings,
|
||||
FileText,
|
||||
Key,
|
||||
Layers,
|
||||
GitBranch,
|
||||
ScrollText,
|
||||
@@ -17,6 +16,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { GatehouseLogo } from "@/components/branding/GatehouseLogo";
|
||||
import { NavLink } from "@/components/NavLink";
|
||||
import { useAuth } from "@/contexts/AuthContext";
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
@@ -40,19 +40,25 @@ const userNavItems = [
|
||||
{ title: "Activity", url: "/activity", icon: Activity },
|
||||
];
|
||||
|
||||
const orgNavItems = [
|
||||
// Visible to ALL org members
|
||||
const orgMemberNavItems = [
|
||||
{ title: "Overview", url: "/org", icon: Building2 },
|
||||
{ title: "My Memberships", url: "/org/my-memberships", icon: Layers },
|
||||
];
|
||||
|
||||
// Visible to org admins/owners only (management)
|
||||
const orgAdminNavItems = [
|
||||
{ title: "Overview", url: "/org", icon: Building2 },
|
||||
{ title: "Members", url: "/org/members", icon: Users },
|
||||
{ title: "Departments", url: "/org/departments", icon: Layers },
|
||||
{ title: "Principals", url: "/org/principals", icon: GitBranch },
|
||||
{ title: "Policies", url: "/org/policies", icon: Settings },
|
||||
{ title: "Audit Log", url: "/org/audit", icon: FileText },
|
||||
];
|
||||
|
||||
const adminNavItems = [
|
||||
{ title: "OIDC Clients", url: "/org/clients", icon: Key },
|
||||
{ title: "Users", url: "/admin/users", icon: Users },
|
||||
{ title: "Certificate Auth.", url: "/org/cas", icon: ShieldCheck },
|
||||
// { title: "Users", url: "/admin/users", icon: Users },
|
||||
{ title: "Org Audit Log", url: "/org/audit", icon: FileText },
|
||||
{ title: "System Logs", url: "/admin/audit", icon: ScrollText },
|
||||
];
|
||||
|
||||
@@ -60,10 +66,11 @@ export function AppSidebar() {
|
||||
const { state } = useSidebar();
|
||||
const collapsed = state === "collapsed";
|
||||
const location = useLocation();
|
||||
const { isOrgAdmin, isOrgMember } = useAuth();
|
||||
|
||||
const isActive = (path: string) => location.pathname === path;
|
||||
const isOrgActive = orgNavItems.some((item) => isActive(item.url)) || adminNavItems.some((item) => isActive(item.url));
|
||||
const isUserActive = userNavItems.some((item) => isActive(item.url));
|
||||
const isOrgActive = orgAdminNavItems.some((item) => isActive(item.url)) || adminNavItems.some((item) => isActive(item.url));
|
||||
void isOrgActive; // used for future active state tracking
|
||||
|
||||
return (
|
||||
<Sidebar
|
||||
@@ -88,9 +95,11 @@ export function AppSidebar() {
|
||||
<SidebarContent className="py-4">
|
||||
{/* User Section */}
|
||||
<SidebarGroup>
|
||||
<SidebarGroupLabel className="px-4 text-xs font-medium text-sidebar-muted uppercase tracking-wider">
|
||||
{!collapsed && "Account"}
|
||||
</SidebarGroupLabel>
|
||||
{!collapsed && (
|
||||
<SidebarGroupLabel className="px-4 text-xs font-medium text-sidebar-muted uppercase tracking-wider">
|
||||
Account
|
||||
</SidebarGroupLabel>
|
||||
)}
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{userNavItems.map((item) => (
|
||||
@@ -100,8 +109,11 @@ export function AppSidebar() {
|
||||
to={item.url}
|
||||
end
|
||||
className={cn(
|
||||
"flex items-center gap-3 px-4 py-2.5 text-sm text-sidebar-foreground rounded-lg mx-2 transition-colors",
|
||||
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
|
||||
"flex items-center text-sm text-sidebar-foreground rounded-lg transition-colors",
|
||||
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
||||
collapsed
|
||||
? "justify-center w-10 h-10 mx-auto p-0"
|
||||
: "gap-3 px-4 py-2.5 mx-2"
|
||||
)}
|
||||
activeClassName="bg-sidebar-accent text-sidebar-primary font-medium"
|
||||
>
|
||||
@@ -115,22 +127,28 @@ export function AppSidebar() {
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
|
||||
{/* Organization Section */}
|
||||
{/* Organization Section — content differs by role */}
|
||||
{isOrgMember && (
|
||||
<SidebarGroup className="mt-4">
|
||||
<SidebarGroupLabel className="px-4 text-xs font-medium text-sidebar-muted uppercase tracking-wider">
|
||||
{!collapsed && "Organization"}
|
||||
</SidebarGroupLabel>
|
||||
{!collapsed && (
|
||||
<SidebarGroupLabel className="px-4 text-xs font-medium text-sidebar-muted uppercase tracking-wider">
|
||||
Organization
|
||||
</SidebarGroupLabel>
|
||||
)}
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{orgNavItems.map((item) => (
|
||||
{(isOrgAdmin ? orgAdminNavItems : orgMemberNavItems).map((item) => (
|
||||
<SidebarMenuItem key={item.title}>
|
||||
<SidebarMenuButton asChild>
|
||||
<NavLink
|
||||
to={item.url}
|
||||
end
|
||||
className={cn(
|
||||
"flex items-center gap-3 px-4 py-2.5 text-sm text-sidebar-foreground rounded-lg mx-2 transition-colors",
|
||||
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
|
||||
"flex items-center text-sm text-sidebar-foreground rounded-lg transition-colors",
|
||||
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
||||
collapsed
|
||||
? "justify-center w-10 h-10 mx-auto p-0"
|
||||
: "gap-3 px-4 py-2.5 mx-2"
|
||||
)}
|
||||
activeClassName="bg-sidebar-accent text-sidebar-primary font-medium"
|
||||
>
|
||||
@@ -143,12 +161,16 @@ export function AppSidebar() {
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
)}
|
||||
|
||||
{/* Admin Section */}
|
||||
{/* Admin Section — only visible to org admins/owners */}
|
||||
{isOrgAdmin && (
|
||||
<SidebarGroup className="mt-4">
|
||||
<SidebarGroupLabel className="px-4 text-xs font-medium text-sidebar-muted uppercase tracking-wider">
|
||||
{!collapsed && "Admin"}
|
||||
</SidebarGroupLabel>
|
||||
{!collapsed && (
|
||||
<SidebarGroupLabel className="px-4 text-xs font-medium text-sidebar-muted uppercase tracking-wider">
|
||||
Admin
|
||||
</SidebarGroupLabel>
|
||||
)}
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{adminNavItems.map((item) => (
|
||||
@@ -158,8 +180,11 @@ export function AppSidebar() {
|
||||
to={item.url}
|
||||
end
|
||||
className={cn(
|
||||
"flex items-center gap-3 px-4 py-2.5 text-sm text-sidebar-foreground rounded-lg mx-2 transition-colors",
|
||||
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
|
||||
"flex items-center text-sm text-sidebar-foreground rounded-lg transition-colors",
|
||||
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
||||
collapsed
|
||||
? "justify-center w-10 h-10 mx-auto p-0"
|
||||
: "gap-3 px-4 py-2.5 mx-2"
|
||||
)}
|
||||
activeClassName="bg-sidebar-accent text-sidebar-primary font-medium"
|
||||
>
|
||||
@@ -172,6 +197,7 @@ export function AppSidebar() {
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
)}
|
||||
</SidebarContent>
|
||||
|
||||
<SidebarFooter className="p-4 border-t border-sidebar-border">
|
||||
|
||||
Reference in New Issue
Block a user