'use client'
import {
Shield, ArrowLeft, ExternalLink, CheckCircle2, Lock,
FileText, BookOpen, Scale, Pencil, Trash2, Eye, Clock,
} from 'lucide-react'
import type { CanonicalControl } from '../_types'
import { EFFORT_LABELS } from '../_types'
import { SeverityBadge, StateBadge, LicenseRuleBadge } from './Badges'
export function ControlDetailView({
ctrl,
onBack,
onEdit,
onDelete,
onReview,
}: {
ctrl: CanonicalControl
onBack: () => void
onEdit: () => void
onDelete: (controlId: string) => void
onReview: (controlId: string, action: string) => void
}) {
return (
{/* Header */}
{ctrl.control_id}
{ctrl.title}
{ctrl.risk_score !== null && Risiko-Score: {ctrl.risk_score}/10}
{ctrl.implementation_effort && Aufwand: {EFFORT_LABELS[ctrl.implementation_effort] || ctrl.implementation_effort}}
{/* Objective & Rationale */}
Begruendung
{ctrl.rationale}
{/* Scope */}
Geltungsbereich
{ctrl.scope.platforms && ctrl.scope.platforms.length > 0 && (
Plattformen
{ctrl.scope.platforms.map(p => (
{p}
))}
)}
{ctrl.scope.components && ctrl.scope.components.length > 0 && (
Komponenten
{ctrl.scope.components.map(c => (
{c}
))}
)}
{ctrl.scope.data_classes && ctrl.scope.data_classes.length > 0 && (
Datenklassen
{ctrl.scope.data_classes.map(d => (
{d}
))}
)}
{/* Requirements */}
Anforderungen
{ctrl.requirements.map((req, i) => (
-
{i + 1}
{req}
))}
{/* Test Procedure */}
Pruefverfahren
{ctrl.test_procedure.map((step, i) => (
-
{step}
))}
{/* Evidence */}
Nachweisanforderungen
{ctrl.evidence.map((ev, i) => (
{ev.type}
{ev.description}
))}
{/* Open Anchors — THE KEY SECTION */}
Open-Source-Referenzen
({ctrl.open_anchors.length} Quellen)
Dieses Control basiert auf frei verfuegbarem Wissen. Alle Referenzen sind offen und oeffentlich zugaenglich.
{ctrl.open_anchors.map((anchor, i) => (
{anchor.framework}
{anchor.ref}
Quelle
))}
{/* Tags */}
{ctrl.tags.length > 0 && (
Tags
{ctrl.tags.map(tag => (
{tag}
))}
)}
{/* License & Citation Info */}
{ctrl.license_rule && (
Lizenzinformationen
{ctrl.source_citation && (
Quelle: {ctrl.source_citation.source}
{ctrl.source_citation.license &&
Lizenz: {ctrl.source_citation.license}
}
{ctrl.source_citation.license_notice &&
Hinweis: {ctrl.source_citation.license_notice}
}
{ctrl.source_citation.url && (
Originalquelle
)}
)}
{ctrl.source_original_text && (
Originaltext anzeigen
{ctrl.source_original_text}
)}
{ctrl.license_rule === 3 && (
Eigenstaendig formuliert — keine Originalquelle gespeichert
)}
)}
{/* Generation Metadata (internal) */}
{ctrl.generation_metadata && (
Generierungsdetails (intern)
Pfad: {String(ctrl.generation_metadata.processing_path || '-')}
{ctrl.generation_metadata.similarity_status && (
Similarity: {String(ctrl.generation_metadata.similarity_status)}
)}
{Array.isArray(ctrl.generation_metadata.similar_controls) && (
Aehnliche Controls:
{(ctrl.generation_metadata.similar_controls as Array
>).map((s, i) => (
{String(s.control_id)} — {String(s.title)} ({String(s.similarity)})
))}
)}
)}
{/* Review Actions */}
{['needs_review', 'too_close', 'duplicate'].includes(ctrl.release_state) && (
Review erforderlich
)}
)
}