'use client' /** * DevOps Pipeline Sidebar * * Kompakte Sidebar-Komponente fuer Cross-Navigation zwischen DevOps-Modulen. * Zeigt Pipeline-Flow und ermoeglicht schnelle Navigation. * * Features: * - Desktop: Fixierte Sidebar rechts * - Mobile: Floating Action Button mit Slide-In Drawer * - Live Pipeline-Status Badge * - Backlog-Count Badge * - Security-Findings-Count Badge * - Quick-Action: Pipeline triggern * * Datenfluss: CI/CD -> Tests -> SBOM -> Security */ import Link from 'next/link' import { useState, useEffect } from 'react' import type { DevOpsToolId, DevOpsPipelineSidebarProps, DevOpsPipelineSidebarResponsiveProps, PipelineLiveStatus, } from '@/types/infrastructure-modules' import { DEVOPS_PIPELINE_MODULES } from '@/types/infrastructure-modules' // ============================================================================= // Icons // ============================================================================= const ToolIcon = ({ id }: { id: DevOpsToolId }) => { switch (id) { case 'ci-cd': return ( ) case 'tests': return ( ) case 'sbom': return ( ) case 'security': return ( ) default: return null } } // Server/Pipeline Icon fuer Header const ServerIcon = () => ( ) // Play Icon fuer Quick Action const PlayIcon = () => ( ) // ============================================================================= // Live Status Hook (optional - fetches status from API) // ============================================================================= function usePipelineLiveStatus(): PipelineLiveStatus | null { const [status, setStatus] = useState(null) useEffect(() => { // Optional: Fetch live status from API // For now, return null and display static content // Uncomment below to enable live status fetching /* const fetchStatus = async () => { try { const response = await fetch('/api/admin/infrastructure/woodpecker/status') if (response.ok) { const data = await response.json() setStatus(data) } } catch (error) { console.error('Failed to fetch pipeline status:', error) } } fetchStatus() const interval = setInterval(fetchStatus, 30000) // Poll every 30s return () => clearInterval(interval) */ }, []) return status } // ============================================================================= // Status Badge Component // ============================================================================= interface StatusBadgeProps { count: number type: 'backlog' | 'security' | 'running' } function StatusBadge({ count, type }: StatusBadgeProps) { if (count === 0) return null const colors = { backlog: 'bg-amber-500', security: 'bg-red-500', running: 'bg-green-500 animate-pulse', } return ( {count} ) } // ============================================================================= // Main Sidebar Component // ============================================================================= export function DevOpsPipelineSidebar({ currentTool, compact = false, className = '', }: DevOpsPipelineSidebarProps) { const [isExpanded, setIsExpanded] = useState(!compact) const liveStatus = usePipelineLiveStatus() return (
{/* Header */}
setIsExpanded(!isExpanded)} >
DevOps Pipeline {/* Live status indicator */} {liveStatus?.isRunning && ( )}
{/* Content */} {isExpanded && (
{/* Tool Links */}
{DEVOPS_PIPELINE_MODULES.map((tool) => (
{tool.name}
{tool.description}
{/* Status badges */} {tool.id === 'tests' && liveStatus && ( )} {tool.id === 'security' && liveStatus && ( )} {currentTool === tool.id && ( )} ))}
{/* Pipeline Flow Visualization */}
Pipeline Flow
📝 🏗️ 📦 🛡️ 🚀
{/* Quick Info zum aktuellen Tool */}
{currentTool === 'ci-cd' && ( Verwalten Sie Woodpecker Pipelines und Deployments )} {currentTool === 'tests' && ( Ueberwachen Sie 280+ Tests ueber alle Services )} {currentTool === 'sbom' && ( Pruefen Sie Abhaengigkeiten und Lizenzen )} {currentTool === 'security' && ( Analysieren Sie Vulnerabilities und Security-Scans )}
{/* Quick Action: Pipeline triggern */}
)}
) } // ============================================================================= // Responsive Version with Mobile FAB + Drawer // ============================================================================= /** * Responsive DevOps Sidebar mit Mobile FAB + Drawer * * Desktop (xl+): Fixierte Sidebar rechts * Mobile/Tablet: Floating Action Button unten rechts, oeffnet Drawer */ export function DevOpsPipelineSidebarResponsive({ currentTool, compact = false, className = '', fabPosition = 'bottom-right', }: DevOpsPipelineSidebarResponsiveProps) { const [isMobileOpen, setIsMobileOpen] = useState(false) const liveStatus = usePipelineLiveStatus() // Close drawer on escape key useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape') setIsMobileOpen(false) } window.addEventListener('keydown', handleEscape) return () => window.removeEventListener('keydown', handleEscape) }, []) // Prevent body scroll when drawer is open useEffect(() => { if (isMobileOpen) { document.body.style.overflow = 'hidden' } else { document.body.style.overflow = '' } return () => { document.body.style.overflow = '' } }, [isMobileOpen]) const fabPositionClasses = fabPosition === 'bottom-right' ? 'right-4 bottom-20' : 'left-4 bottom-20' // Calculate total badge count for FAB const totalBadgeCount = liveStatus ? liveStatus.backlogCount + liveStatus.securityFindingsCount : 0 return ( <> {/* Desktop: Fixed Sidebar */}
{/* Mobile/Tablet: FAB */} {/* Mobile/Tablet: Drawer Overlay */} {isMobileOpen && (
{/* Backdrop */}
setIsMobileOpen(false)} /> {/* Drawer */}
{/* Drawer Header */}
DevOps Pipeline {liveStatus?.isRunning && ( )}
{/* Drawer Content */}
{/* Tool Links */}
{DEVOPS_PIPELINE_MODULES.map((tool) => ( setIsMobileOpen(false)} className={`flex items-center gap-3 px-4 py-3 rounded-xl transition-all ${ currentTool === tool.id ? 'bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300 font-medium shadow-sm' : 'text-slate-600 dark:text-slate-400 hover:bg-slate-100 dark:hover:bg-gray-800' }`} >
{tool.name}
{tool.description}
{/* Status badges */} {tool.id === 'tests' && liveStatus && ( )} {tool.id === 'security' && liveStatus && ( )} {currentTool === tool.id && ( )} ))}
{/* Pipeline Flow Visualization */}
Pipeline Flow
📝 Code
🏗️ Build
Test
🚀 Deploy
{/* Quick Info */}
{currentTool === 'ci-cd' && ( <> Aktuell: Woodpecker Pipelines und Deployments verwalten )} {currentTool === 'tests' && ( <> Aktuell: 280+ Tests ueber alle Services ueberwachen )} {currentTool === 'sbom' && ( <> Aktuell: Abhaengigkeiten und Lizenzen pruefen )} {currentTool === 'security' && ( <> Aktuell: Vulnerabilities und Security-Scans analysieren )}
{/* Quick Action: Pipeline triggern */}
{/* Link to Infrastructure Overview */}
setIsMobileOpen(false)} className="flex items-center gap-2 px-3 py-2 text-sm text-orange-600 dark:text-orange-400 hover:bg-orange-50 dark:hover:bg-orange-900/20 rounded-lg transition-colors" > Zur Infrastructure-Uebersicht
)} {/* CSS for slide-in animation */} ) } export default DevOpsPipelineSidebar