Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
chore: add shadcn AI and crud reference components
Sergey Kozyrenko58f3c09cb094
diff --git a/frontend/src/components/ai/file-tree.tsx b/frontend/src/components/ai/file-tree.tsxnew file mode 100644index 00000000..bfab02c5--- /dev/null+++ b/frontend/src/components/ai/file-tree.tsx@@ -0,0 +1,218 @@+import { ChevronRightIcon, FileIcon, FolderIcon, FolderOpenIcon } from 'lucide-react';+import { createContext, type HTMLAttributes, type ReactNode, useContext, useState } from 'react';++import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';+import { cn } from '@/lib/utils';++interface FileTreeContextType {+ expandedPaths: Set<string>;+ onSelect?: (path: string) => void;+ selectedPath?: string;+ togglePath: (path: string) => void;+}++const FileTreeContext = createContext<FileTreeContextType>({+ expandedPaths: new Set(),+ togglePath: () => undefined,+});++export type FileTreeProps = HTMLAttributes<HTMLDivElement> & {+ defaultExpanded?: Set<string>;+ expanded?: Set<string>;+ onExpandedChange?: (expanded: Set<string>) => void;+ onSelect?: (path: string) => void;+ selectedPath?: string;+};++export const FileTree = ({+ children,+ className,+ defaultExpanded = new Set(),+ expanded: controlledExpanded,+ onExpandedChange,+ onSelect,+ selectedPath,+ ...props+}: FileTreeProps) => {+ const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);+ const expandedPaths = controlledExpanded ?? internalExpanded;++ const togglePath = (path: string) => {+ const newExpanded = new Set(expandedPaths);++ if (newExpanded.has(path)) {+ newExpanded.delete(path);+ } else {+ newExpanded.add(path);+ }++ setInternalExpanded(newExpanded);+ onExpandedChange?.(newExpanded);+ };++ return (+ <FileTreeContext.Provider value={{ expandedPaths, onSelect, selectedPath, togglePath }}>+ <div+ className={cn('bg-background rounded-lg border font-mono text-sm', className)}+ role="tree"+ {...props}+ >+ <div className="p-2">{children}</div>+ </div>+ </FileTreeContext.Provider>+ );+};++interface FileTreeFolderContextType {+ isExpanded: boolean;+ name: string;+ path: string;+}++const FileTreeFolderContext = createContext<FileTreeFolderContextType>({+ isExpanded: false,+ name: '',+ path: '',+});++export type FileTreeFolderProps = HTMLAttributes<HTMLDivElement> & {+ name: string;+ path: string;+};++export const FileTreeFolder = ({ children, className, name, path, ...props }: FileTreeFolderProps) => {+ const { expandedPaths, onSelect, selectedPath, togglePath } = useContext(FileTreeContext);+ const isExpanded = expandedPaths.has(path);+ const isSelected = selectedPath === path;++ return (+ <FileTreeFolderContext.Provider value={{ isExpanded, name, path }}>+ <Collapsible+ onOpenChange={() => togglePath(path)}+ open={isExpanded}+ >+ <div+ className={cn('', className)}+ role="treeitem"+ tabIndex={0}+ {...props}+ >+ <CollapsibleTrigger asChild>+ <button+ className={cn(+ 'hover:bg-muted/50 flex w-full items-center gap-1 rounded px-2 py-1 text-left transition-colors',+ isSelected && 'bg-muted',+ )}+ onClick={() => onSelect?.(path)}+ type="button"+ >+ <ChevronRightIcon+ className={cn(+ 'text-muted-foreground size-4 shrink-0 transition-transform',+ isExpanded && 'rotate-90',+ )}+ />+ <FileTreeIcon>+ {isExpanded ? (+ <FolderOpenIcon className="size-4 text-blue-500" />+ ) : (+ <FolderIcon className="size-4 text-blue-500" />+ )}+ </FileTreeIcon>+ <FileTreeName>{name}</FileTreeName>+ </button>+ </CollapsibleTrigger>+ <CollapsibleContent>+ <div className="ml-4 border-l pl-2">{children}</div>+ </CollapsibleContent>+ </div>+ </Collapsible>+ </FileTreeFolderContext.Provider>+ );+};++interface FileTreeFileContextType {+ name: string;+ path: string;+}++const FileTreeFileContext = createContext<FileTreeFileContextType>({+ name: '',+ path: '',+});++export type FileTreeFileProps = HTMLAttributes<HTMLDivElement> & {+ icon?: ReactNode;+ name: string;+ path: string;+};++export const FileTreeFile = ({ children, className, icon, name, path, ...props }: FileTreeFileProps) => {+ const { onSelect, selectedPath } = useContext(FileTreeContext);+ const isSelected = selectedPath === path;++ return (+ <FileTreeFileContext.Provider value={{ name, path }}>+ <div+ className={cn(+ 'hover:bg-muted/50 flex cursor-pointer items-center gap-1 rounded px-2 py-1 transition-colors',+ isSelected && 'bg-muted',+ className,+ )}+ onClick={() => onSelect?.(path)}+ onKeyDown={(event) => {+ if (event.key === 'Enter' || event.key === ' ') {+ onSelect?.(path);+ }+ }}+ role="treeitem"+ tabIndex={0}+ {...props}+ >+ {children ?? (+ <>+ <span className="size-4" />+ <FileTreeIcon>{icon ?? <FileIcon className="text-muted-foreground size-4" />}</FileTreeIcon>+ <FileTreeName>{name}</FileTreeName>+ </>+ )}+ </div>+ </FileTreeFileContext.Provider>+ );+};++export type FileTreeIconProps = HTMLAttributes<HTMLSpanElement>;++export const FileTreeIcon = ({ children, className, ...props }: FileTreeIconProps) => (+ <span+ className={cn('shrink-0', className)}+ {...props}+ >+ {children}+ </span>+);++export type FileTreeNameProps = HTMLAttributes<HTMLSpanElement>;++export const FileTreeName = ({ children, className, ...props }: FileTreeNameProps) => (+ <span+ className={cn('truncate', className)}+ {...props}+ >+ {children}+ </span>+);++export type FileTreeActionsProps = HTMLAttributes<HTMLDivElement>;++export const FileTreeActions = ({ children, className, ...props }: FileTreeActionsProps) => (+ <div+ className={cn('ml-auto flex items-center gap-1', className)}+ onClick={(event) => event.stopPropagation()}+ onKeyDown={(event) => event.stopPropagation()}+ role="group"+ {...props}+ >+ {children}+ </div>+);diff --git a/frontend/src/components/blocks/crud/crud-file-manager.tsx b/frontend/src/components/blocks/crud/crud-file-manager.tsxnew file mode 100644index 00000000..84d425a0--- /dev/null+++ b/frontend/src/components/blocks/crud/crud-file-manager.tsx@@ -0,0 +1,323 @@+import {+ ChevronRight,+ Download,+ Edit2,+ File,+ FileText,+ FolderOpen,+ Image,+ MoreVertical,+ Move,+ Sheet,+ Trash2,+ Upload,+} from 'lucide-react';+import { useState } from 'react';++import { Button } from '@/components/ui/button';+import { Checkbox } from '@/components/ui/checkbox';+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from '@/components/ui/dropdown-menu';++interface FileItem {+ folder?: string;+ id: string;+ modified: string;+ name: string;+ sharedWith: number;+ size?: string;+ type: 'document' | 'file' | 'folder' | 'image' | 'pdf' | 'spreadsheet';+}++const files: FileItem[] = [+ {+ id: 'f1',+ modified: '2 days ago',+ name: 'Documents',+ sharedWith: 0,+ type: 'folder',+ },+ {+ id: 'f2',+ modified: '1 week ago',+ name: 'Images',+ sharedWith: 3,+ type: 'folder',+ },+ {+ id: 'f3',+ modified: '3 hours ago',+ name: 'Q4_Report_2025.pdf',+ sharedWith: 5,+ size: '2.4 MB',+ type: 'pdf',+ },+ {+ id: 'f4',+ modified: 'Yesterday',+ name: 'Product_Mockup.png',+ sharedWith: 2,+ size: '1.8 MB',+ type: 'image',+ },+ {+ id: 'f5',+ modified: '5 hours ago',+ name: 'Meeting_Notes.docx',+ sharedWith: 8,+ size: '145 KB',+ type: 'document',+ },+ {+ id: 'f6',+ modified: '2 days ago',+ name: 'Budget_2026.xlsx',+ sharedWith: 4,+ size: '892 KB',+ type: 'spreadsheet',+ },+ {+ id: 'f7',+ modified: '1 week ago',+ name: 'Presentation.pptx',+ sharedWith: 12,+ size: '5.2 MB',+ type: 'document',+ },+ {+ id: 'f8',+ modified: '3 weeks ago',+ name: 'Archive',+ sharedWith: 0,+ type: 'folder',+ },+];++const getFileIcon = (type: FileItem['type']) => {+ switch (type) {+ case 'document':+ return FileText;+ case 'folder':+ return FolderOpen;+ case 'image':+ return Image;+ case 'pdf':+ return FileText;+ case 'spreadsheet':+ return Sheet;+ default:+ return File;+ }+};++const getTypeBadge = (type: FileItem['type']) => {+ switch (type) {+ case 'document':+ return 'Document';+ case 'image':+ return 'Image';+ case 'pdf':+ return 'PDF';+ case 'spreadsheet':+ return 'Spreadsheet';+ default:+ return null;+ }+};++export default function CrudFileManager() {+ const [selected, setSelected] = useState<string[]>([]);+ const [path] = useState(['My Files']);++ const toggleSelect = (id: string) => {+ setSelected((prev) => (prev.includes(id) ? prev.filter((i) => i !== id) : [...prev, id]));+ };++ const toggleSelectAll = () => {+ setSelected((prev) => (prev.length === files.length ? [] : files.map((f) => f.id)));+ };++ const handleBulkDelete = () => {+ setSelected([]);+ };++ return (+ <section className="mx-auto w-full max-w-4xl p-4">+ <div className="bg-card overflow-hidden rounded-lg border">+ {/* Header with breadcrumb and upload */}+ <div className="flex items-center justify-between border-b px-4 py-3">+ <div className="flex items-center gap-1 text-sm">+ <button+ className="text-muted-foreground hover:text-foreground transition-colors"+ type="button"+ >+ Home+ </button>+ {path.map((segment, i) => (+ <div+ className="flex items-center gap-1"+ key={segment}+ >+ <ChevronRight className="text-muted-foreground size-4" />+ <button+ className={+ i === path.length - 1+ ? 'text-foreground font-medium'+ : 'text-muted-foreground hover:text-foreground transition-colors'+ }+ type="button"+ >+ {segment}+ </button>+ </div>+ ))}+ </div>+ <Button+ className="h-7 gap-1.5 text-xs"+ size="sm"+ variant="outline"+ >+ <Upload className="size-3.5" />+ Upload+ </Button>+ </div>++ {/* Bulk actions bar */}+ {selected.length > 0 && (+ <div className="bg-muted/50 flex items-center justify-between border-b px-4 py-2">+ <span className="text-muted-foreground text-sm">{selected.length} selected</span>+ <Button+ className="h-7 gap-1.5 text-xs text-red-600 hover:text-red-700"+ onClick={handleBulkDelete}+ size="sm"+ variant="ghost"+ >+ <Trash2 className="size-3.5" />+ Delete+ </Button>+ </div>+ )}++ {/* Column headers */}+ <div className="bg-muted/30 text-muted-foreground grid grid-cols-[auto_1fr_auto_auto_auto_auto] items-center gap-4 border-b px-4 py-2 text-xs font-medium">+ <Checkbox+ checked={selected.length === files.length}+ onCheckedChange={toggleSelectAll}+ />+ <span>Name</span>+ <span>Type</span>+ <span>Size</span>+ <span>Modified</span>+ <span className="w-8" />+ </div>++ {/* File list */}+ <div>+ {files.map((file) => {+ const Icon = getFileIcon(file.type);+ const badge = getTypeBadge(file.type);++ return (+ <div+ className="hover:bg-muted/50 grid grid-cols-[auto_1fr_auto_auto_auto_auto] items-center gap-4 border-b px-4 py-3 transition-colors last:border-b-0"+ key={file.id}+ >+ <Checkbox+ checked={selected.includes(file.id)}+ onCheckedChange={() => toggleSelect(file.id)}+ />++ <div className="flex min-w-0 items-center gap-2.5">+ <Icon+ className={`size-4 shrink-0 ${+ file.type === 'folder' ? 'text-blue-500' : 'text-muted-foreground'+ }`}+ />+ <div className="min-w-0">+ <p className="truncate text-sm font-medium">{file.name}</p>+ {file.sharedWith > 0 && (+ <p className="text-muted-foreground text-xs">+ Shared with {file.sharedWith}+ </p>+ )}+ </div>+ </div>++ <div>+ {badge && (+ <span className="bg-muted text-muted-foreground inline-flex rounded-md px-2 py-0.5 text-xs">+ {badge}+ </span>+ )}+ </div>++ <span className="text-muted-foreground text-sm">{file.size || '—'}</span>++ <span className="text-muted-foreground text-sm">{file.modified}</span>++ {file.type !== 'folder' && (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ className="size-8 p-0"+ size="sm"+ variant="ghost"+ >+ <MoreVertical className="size-4" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem>+ <Download className="mr-2 size-4" />+ Download+ </DropdownMenuItem>+ <DropdownMenuItem>+ <Edit2 className="mr-2 size-4" />+ Rename+ </DropdownMenuItem>+ <DropdownMenuItem>+ <Move className="mr-2 size-4" />+ Move+ </DropdownMenuItem>+ <DropdownMenuItem className="text-red-600">+ <Trash2 className="mr-2 size-4" />+ Delete+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ {file.type === 'folder' && (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ className="size-8 p-0"+ size="sm"+ variant="ghost"+ >+ <MoreVertical className="size-4" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem>+ <Edit2 className="mr-2 size-4" />+ Rename+ </DropdownMenuItem>+ <DropdownMenuItem className="text-red-600">+ <Trash2 className="mr-2 size-4" />+ Delete+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ </div>+ );+ })}+ </div>+ </div>+ </section>+ );+}diff --git a/frontend/src/components/blocks/skeleton/skeleton-file-manager.tsx b/frontend/src/components/blocks/skeleton/skeleton-file-manager.tsxnew file mode 100644index 00000000..4637fe4d--- /dev/null+++ b/frontend/src/components/blocks/skeleton/skeleton-file-manager.tsx@@ -0,0 +1,63 @@+import { Skeleton } from '@/components/ui/skeleton';++const fileRows = [+ { date: 'w-24', hasAction: true, name: 'w-44', size: 'w-14' },+ { date: 'w-20', hasAction: true, name: 'w-56', size: 'w-10' },+ { date: 'w-24', hasAction: true, name: 'w-36', size: 'w-12' },+ { date: 'w-20', hasAction: true, name: 'w-48', size: 'w-16' },+ { date: 'w-24', hasAction: true, name: 'w-40', size: 'w-10' },+ { date: 'w-20', hasAction: true, name: 'w-52', size: 'w-14' },+];++export default function SkeletonFileManager() {+ return (+ <section className="mx-auto w-full max-w-2xl p-4">+ <div className="bg-card overflow-hidden rounded-lg border">+ {/* Toolbar with breadcrumb and actions */}+ <div className="flex items-center justify-between border-b px-4 py-3">+ <div className="flex items-center gap-1.5">+ <Skeleton className="h-4 w-12" />+ <Skeleton className="h-3 w-1.5" />+ <Skeleton className="h-4 w-20" />+ <Skeleton className="h-3 w-1.5" />+ <Skeleton className="h-4 w-24" />+ </div>+ <div className="flex items-center gap-2">+ <Skeleton className="size-7 rounded-md" />+ <Skeleton className="size-7 rounded-md" />+ <Skeleton className="h-7 w-20 rounded-md" />+ </div>+ </div>++ {/* Column headers */}+ <div className="bg-muted/50 flex items-center gap-4 border-b px-4 py-2.5">+ <div className="flex min-w-0 flex-1 items-center gap-3">+ <Skeleton className="size-4 shrink-0" />+ <Skeleton className="h-3 w-10" />+ </div>+ <Skeleton className="h-3 w-8 shrink-0" />+ <Skeleton className="h-3 w-16 shrink-0" />+ <div className="w-7 shrink-0" />+ </div>++ {/* File list */}+ <div>+ {fileRows.map((row, i) => (+ <div+ className={`flex items-center gap-4 px-4 py-3 ${i < fileRows.length - 1 ? 'border-b' : ''}`}+ key={i}+ >+ <div className="flex min-w-0 flex-1 items-center gap-3">+ <Skeleton className="size-4 shrink-0" />+ <Skeleton className={`h-4 ${row.name}`} />+ </div>+ <Skeleton className={`h-3 shrink-0 ${row.size}`} />+ <Skeleton className={`h-3 shrink-0 ${row.date}`} />+ <Skeleton className="size-7 shrink-0 rounded-md" />+ </div>+ ))}+ </div>+ </div>+ </section>+ );+}