From 2dbcde78f154c9eee08d6e16767f724193dcec04 Mon Sep 17 00:00:00 2001 From: "DESKTOP-RTLN3BA\\$punk" Date: Tue, 27 Jan 2026 00:01:26 -0800 Subject: [PATCH] feat(rbac): unify category configuration for role permissions with enhanced descriptions --- .../dashboard/[search_space_id]/team/page.tsx | 151 ++++++++---------- 1 file changed, 69 insertions(+), 82 deletions(-) diff --git a/surfsense_web/app/dashboard/[search_space_id]/team/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/team/page.tsx index ccec9f623..298871cf7 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/team/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/team/page.tsx @@ -105,7 +105,6 @@ import { TableRow, } from "@/components/ui/table"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; -import { Textarea } from "@/components/ui/textarea"; import type { CreateInviteRequest, DeleteInviteRequest, @@ -763,17 +762,71 @@ function MembersTab({ // ============ Role Permissions Display ============ -const CATEGORY_CONFIG: Record = { - documents: { label: "Documents", icon: FileText, order: 1 }, - chats: { label: "Chats", icon: MessageSquare, order: 2 }, - comments: { label: "Comments", icon: MessageCircle, order: 3 }, - llm_configs: { label: "LLM Configs", icon: Bot, order: 4 }, - podcasts: { label: "Podcasts", icon: Mic, order: 5 }, - connectors: { label: "Connectors", icon: Plug, order: 6 }, - logs: { label: "Logs", icon: Logs, order: 7 }, - members: { label: "Members", icon: Users, order: 8 }, - roles: { label: "Roles", icon: Shield, order: 9 }, - settings: { label: "Settings", icon: Settings, order: 10 }, +// Unified category configuration used across all role-related components +const CATEGORY_CONFIG: Record< + string, + { label: string; icon: LucideIcon; description: string; order: number } +> = { + documents: { + label: "Documents", + icon: FileText, + description: "Manage files, notes, and content", + order: 1, + }, + chats: { + label: "AI Chats", + icon: MessageSquare, + description: "Create and manage AI conversations", + order: 2, + }, + comments: { + label: "Comments", + icon: MessageCircle, + description: "Add annotations to documents", + order: 3, + }, + llm_configs: { + label: "AI Models", + icon: Bot, + description: "Configure AI model settings", + order: 4, + }, + podcasts: { + label: "Podcasts", + icon: Mic, + description: "Generate AI podcasts from content", + order: 5, + }, + connectors: { + label: "Integrations", + icon: Plug, + description: "Connect external data sources", + order: 6, + }, + logs: { + label: "Activity Logs", + icon: Logs, + description: "View and manage audit trail", + order: 7, + }, + members: { + label: "Team Members", + icon: Users, + description: "Manage team membership", + order: 8, + }, + roles: { + label: "Roles", + icon: Shield, + description: "Configure role permissions", + order: 9, + }, + settings: { + label: "Settings", + icon: Settings, + description: "Manage search space settings", + order: 10, + }, }; const ACTION_LABELS: Record = { @@ -1560,73 +1613,6 @@ const ROLE_PRESETS = { }, }; -// Category display configuration with icons and descriptions -const CATEGORY_DISPLAY: Record< - string, - { label: string; icon: LucideIcon; description: string; order: number } -> = { - documents: { - label: "Documents", - icon: FileText, - description: "Manage files, notes, and content", - order: 1, - }, - chats: { - label: "AI Chats", - icon: MessageSquare, - description: "Create and manage AI conversations", - order: 2, - }, - comments: { - label: "Comments", - icon: MessageCircle, - description: "Add annotations to documents", - order: 3, - }, - llm_configs: { - label: "AI Models", - icon: Bot, - description: "Configure AI model settings", - order: 4, - }, - podcasts: { - label: "Podcasts", - icon: Mic, - description: "Generate AI podcasts from content", - order: 5, - }, - connectors: { - label: "Integrations", - icon: Plug, - description: "Connect external data sources", - order: 6, - }, - logs: { - label: "Activity Logs", - icon: Logs, - description: "View and manage audit trail", - order: 7, - }, - members: { - label: "Team Members", - icon: Users, - description: "Manage team membership", - order: 8, - }, - roles: { - label: "Roles", - icon: Shield, - description: "Configure role permissions", - order: 9, - }, - settings: { - label: "Settings", - icon: Settings, - description: "Manage search space settings", - order: 10, - }, -}; - // Action display labels const ACTION_DISPLAY: Record = { create: { label: "Create", color: "text-emerald-600 bg-emerald-500/10" }, @@ -1661,8 +1647,8 @@ function CreateRoleSection({ // Sort categories by order const sortedCategories = useMemo(() => { return Object.keys(groupedPermissions).sort((a, b) => { - const orderA = CATEGORY_DISPLAY[a]?.order ?? 99; - const orderB = CATEGORY_DISPLAY[b]?.order ?? 99; + const orderA = CATEGORY_CONFIG[a]?.order ?? 99; + const orderB = CATEGORY_CONFIG[b]?.order ?? 99; return orderA - orderB; }); }, [groupedPermissions]); @@ -1859,10 +1845,11 @@ function CreateRoleSection({
{sortedCategories.map((category) => { - const config = CATEGORY_DISPLAY[category] || { + const config = CATEGORY_CONFIG[category] || { label: category, icon: FileText, description: "", + order: 99, }; const IconComponent = config.icon; const stats = getCategoryStats(category);