modcomms/frontend/components/Sidebar.tsx
michael 9e2473c3e9 Add Knowledge Base management system for AI agent specs
Full-stack implementation enabling UI-driven management of the 5 AI agent knowledge bases
(Legal, Brand Barclays, Brand Barclaycard, Channel Best Practices, Channel Tech Specs).

Backend:
- 4 new DB models: KnowledgeBase, SourceDocument, SpecVersion, ProcessingJob
- Migration 006: creates tables, seeds 5 KB rows, imports existing prompts/*.md as v1 specs
- KnowledgeBaseRepository with full CRUD for all 4 tables
- LlamaParseService for document parsing, KnowledgeBaseService for pipeline orchestration
- ReferenceDocsService updated with DB-backed spec loading + cache invalidation
- 11 REST endpoints under /api/knowledge-base (list, detail, upload, delete, process, job status, versions, diff, activate)
- StorageService extended with KB document storage

Frontend:
- TypeScript types for all KB entities (KnowledgeBaseListItem, SourceDocument, ProcessingJob, SpecVersion, DiffResult)
- ApiService methods for all KB endpoints including multipart file upload
- KnowledgeBase component with 3-level UI: agent grid, detail view (documents + versions tabs), diff viewer
- Drag-and-drop file upload, processing progress bar with 3s polling, version comparison
- KnowledgeBaseIcon + Sidebar nav item with adminOnly filtering

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-12 15:00:36 -06:00

97 lines
4.7 KiB
TypeScript
Executable file

import React from 'react';
import { BarclaysLogo } from './icons/BarclaysLogo';
import { DashboardIcon } from './icons/DashboardIcon';
import { AnalyticsIcon } from './icons/AnalyticsIcon';
import { SettingsIcon } from './icons/SettingsIcon';
import { UserIcon } from './icons/UserIcon';
import { CampaignsIcon } from './icons/CampaignsIcon';
import { AuditIcon } from './icons/AuditIcon';
import { KnowledgeBaseIcon } from './icons/KnowledgeBaseIcon';
const navigation = [
{ name: 'Home', icon: DashboardIcon },
{ name: 'Campaigns', icon: CampaignsIcon },
// { name: 'WIP Reviewer', icon: ClipboardIcon }, // Hidden: Moved to Settings > Beta
// { name: 'CopyGenAI', icon: CopyGenAIIcon }, // Hidden: Moved to Settings > Beta
{ name: 'Analytics', icon: AnalyticsIcon },
{ name: 'Auditing', icon: AuditIcon },
{ name: 'Knowledge Base', icon: KnowledgeBaseIcon, adminOnly: true },
{ name: 'Settings', icon: SettingsIcon },
];
interface SidebarProps {
activeItem: string;
onNavigate: (viewName: string) => void;
userName?: string;
userEmail?: string;
isAdmin?: boolean;
}
export const Sidebar: React.FC<SidebarProps> = ({ activeItem, onNavigate, userName, userEmail, isAdmin = true }) => {
return (
<aside className="w-72 flex-shrink-0 bg-primary-blue text-slate-200 flex flex-col border-r border-white/10 font-sans">
{/* Brand Header */}
<div className="py-6 px-8 border-b border-white/10 flex flex-col items-center text-center">
<BarclaysLogo className="h-10 w-auto text-cyan-brand mb-2" />
<span className="text-lg font-bold tracking-tight text-white leading-tight">
Mod Comms
</span>
<span className="text-xs text-lime uppercase tracking-widest font-semibold">
Compliance AI
</span>
<span className="text-xs text-grey-700 tracking-wider mt-0.5">
powered by <span className="font-bold">OLIVER</span>
</span>
</div>
{/* Navigation */}
<nav className="flex-1 pr-4 pl-0 py-8 space-y-2 overflow-y-auto">
{navigation.filter(item => !(item as any).adminOnly || isAdmin).map((item) => {
const Icon = item.icon;
const isActive = item.name === activeItem;
const isComingSoon = (item as any).isComingSoon;
return (
<button
key={item.name}
onClick={() => !isComingSoon && onNavigate(item.name)}
className={`group w-full flex items-center pl-8 pr-4 py-3.5 text-left text-sm font-medium transition-all duration-300 ease-in-out ${
isActive
? 'bg-white text-primary-blue shadow-lg rounded-r-[10px] rounded-l-none'
: isComingSoon
? 'text-slate-600 cursor-not-allowed rounded-[10px]'
: 'text-slate-300 hover:bg-white/10 hover:text-white rounded-[10px]'
}`}
aria-current={isActive ? 'page' : undefined}
disabled={isComingSoon}
>
<Icon className={`h-5 w-5 mr-4 transition-transform duration-300 ${isActive ? 'scale-110' : 'group-hover:scale-110'}`} />
<span className="flex-1 tracking-wide">{item.name}</span>
</button>
);
})}
</nav>
{/* User Profile Snippet */}
<div className="p-4 border-t border-white/10 bg-primary-blue/80">
<button
onClick={() => onNavigate('Profile')}
className={`group w-full flex items-center gap-3 p-3 rounded-[10px] text-left transition-all duration-200 ${
activeItem === 'Profile'
? 'bg-white/10'
: 'hover:bg-white/10'
}`}
>
<div className="w-10 h-10 rounded-full bg-active-blue flex items-center justify-center ring-2 ring-white/20 group-hover:ring-active-blue/50 transition-all">
<UserIcon className="h-5 w-5 text-white" />
</div>
<div className="overflow-hidden">
<p className="font-semibold text-sm text-white truncate">{userName || 'Unknown User'}</p>
<p className="text-xs text-slate-400 truncate">{userEmail || ''}</p>
</div>
</button>
</div>
</aside>
);
};