Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | 7x 19x 36x 17x | import React from "react";
import { SecurityLevel } from "../../../types/cia";
import { ComplianceStatusType } from "../../../types/compliance";
import { getComplianceRequirementText } from "../../../utils/complianceTextUtils";
import { getComplianceStatusText } from "../../../utils/statusUtils";
/**
* Props for SecurityComplianceTab component
*/
export interface SecurityComplianceTabProps {
availabilityLevel: SecurityLevel;
integrityLevel: SecurityLevel;
confidentialityLevel: SecurityLevel;
securityScore: number;
complianceStatus: ComplianceStatusType | null;
testId: string;
}
/**
* Compliance tab component for SecuritySummaryWidget
* Displays compliance status, framework alignment, and component requirements
*/
export const SecurityComplianceTab: React.FC<SecurityComplianceTabProps> = ({
availabilityLevel,
integrityLevel,
confidentialityLevel,
securityScore,
complianceStatus,
testId,
}) => {
return (
<div data-testid={`${testId}-content-compliance`} className="space-y-4">
{/* Compliance introduction */}
<div className="p-3 bg-blue-50 dark:bg-blue-900 dark:bg-opacity-20 rounded-lg mb-4">
<p className="text-sm">
This section summarizes your compliance status based on selected
security levels, highlighting alignment with regulatory frameworks and
standards.
</p>
</div>
{/* Compliance Status */}
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4 border border-gray-100 dark:border-gray-700">
<h3 className="text-lg font-medium mb-3 text-gray-800 dark:text-gray-100">
Compliance Status Overview
</h3>
{!complianceStatus ? (
<div className="p-3 bg-gray-50 dark:bg-gray-700 rounded-lg">
<div className="flex justify-between items-center mb-2">
<span className="font-medium">Compliance Score</span>
<span className="text-xl font-bold">{securityScore}%</span>
</div>
<div className="w-full bg-gray-200 dark:bg-gray-600 rounded-full h-2.5 mb-2">
<div
className={`h-2.5 rounded-full ${
securityScore >= 80
? "bg-green-500"
: securityScore >= 50
? "bg-yellow-500"
: "bg-red-500"
}`}
style={{ width: `${securityScore}%` }}
></div>
</div>
<p className="text-sm text-gray-600 dark:text-gray-400">
{getComplianceStatusText(securityScore)}
</p>
</div>
) : (
<div className="p-3 bg-gray-50 dark:bg-gray-700 rounded-lg">
<div className="flex justify-between items-center mb-2">
<span className="font-medium">Compliance Score</span>
<span className="text-xl font-bold">
{complianceStatus.complianceScore}%
</span>
</div>
<div className="w-full bg-gray-200 dark:bg-gray-600 rounded-full h-2.5 mb-2">
<div
className={`h-2.5 rounded-full ${
(complianceStatus.complianceScore || 0) >= 80
? "bg-green-500"
: (complianceStatus.complianceScore || 0) >= 50
? "bg-yellow-500"
: "bg-red-500"
}`}
style={{
width: `${complianceStatus.complianceScore || 0}%`,
}}
></div>
</div>
<p className="text-sm text-gray-600 dark:text-gray-400">
{complianceStatus.status ||
getComplianceStatusText(complianceStatus.complianceScore || 0)}
</p>
</div>
)}
</div>
{/* Framework Status */}
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4 border border-gray-100 dark:border-gray-700">
<h3 className="text-lg font-medium mb-3 text-gray-800 dark:text-gray-100">
Framework Compliance Status
</h3>
{!complianceStatus ? (
<p className="text-sm text-gray-600 dark:text-gray-400 italic">
Detailed compliance information is not available.
</p>
) : (
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
<div className="p-3 bg-green-50 dark:bg-green-900 dark:bg-opacity-20 rounded-lg">
<h4 className="font-medium text-green-700 dark:text-green-300 flex items-center justify-between">
<span>Compliant</span>
<span className="text-sm bg-green-100 dark:bg-green-800 px-2 py-0.5 rounded-full">
{complianceStatus.compliantFrameworks.length}
</span>
</h4>
{complianceStatus.compliantFrameworks.length > 0 ? (
<ul className="mt-2 space-y-1 list-disc list-inside text-sm text-gray-600 dark:text-gray-400">
{complianceStatus.compliantFrameworks.map(
(framework, idx) => (
<li key={`compliant-${idx}`}>{framework}</li>
)
)}
</ul>
) : (
<p className="mt-2 text-sm text-gray-600 dark:text-gray-400 italic">
No fully compliant frameworks
</p>
)}
</div>
<div className="p-3 bg-yellow-50 dark:bg-yellow-900 dark:bg-opacity-20 rounded-lg">
<h4 className="font-medium text-yellow-700 dark:text-yellow-300 flex items-center justify-between">
<span>Partially Compliant</span>
<span className="text-sm bg-yellow-100 dark:bg-yellow-800 px-2 py-0.5 rounded-full">
{complianceStatus.partiallyCompliantFrameworks.length}
</span>
</h4>
{complianceStatus.partiallyCompliantFrameworks.length > 0 ? (
<ul className="mt-2 space-y-1 list-disc list-inside text-sm text-gray-600 dark:text-gray-400">
{complianceStatus.partiallyCompliantFrameworks.map(
(framework, idx) => (
<li key={`partial-${idx}`}>{framework}</li>
)
)}
</ul>
) : (
<p className="mt-2 text-sm text-gray-600 dark:text-gray-400 italic">
No partially compliant frameworks
</p>
)}
</div>
</div>
)}
</div>
{/* Component Requirements */}
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4 border border-gray-100 dark:border-gray-700">
<h3 className="text-lg font-medium mb-3 text-gray-800 dark:text-gray-100">
Component Compliance Requirements
</h3>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{/* Confidentiality compliance */}
<div className="p-3 bg-purple-50 dark:bg-purple-900 dark:bg-opacity-20 rounded">
<h5 className="text-sm font-medium mb-1 text-purple-700 dark:text-purple-300">
Confidentiality
</h5>
<p className="text-xs">
<span className="font-medium">Level:</span> {confidentialityLevel}
</p>
<p className="text-xs text-gray-600 dark:text-gray-400 mt-1">
{getComplianceRequirementText(
"confidentiality",
confidentialityLevel
)}
</p>
</div>
{/* Integrity compliance */}
<div className="p-3 bg-green-50 dark:bg-green-900 dark:bg-opacity-20 rounded">
<h5 className="text-sm font-medium mb-1 text-green-700 dark:text-green-300">
Integrity
</h5>
<p className="text-xs">
<span className="font-medium">Level:</span> {integrityLevel}
</p>
<p className="text-xs text-gray-600 dark:text-gray-400 mt-1">
{getComplianceRequirementText("integrity", integrityLevel)}
</p>
</div>
{/* Availability compliance */}
<div className="p-3 bg-blue-50 dark:bg-blue-900 dark:bg-opacity-20 rounded">
<h5 className="text-sm font-medium mb-1 text-blue-700 dark:text-blue-300">
Availability
</h5>
<p className="text-xs">
<span className="font-medium">Level:</span> {availabilityLevel}
</p>
<p className="text-xs text-gray-600 dark:text-gray-400 mt-1">
{getComplianceRequirementText("availability", availabilityLevel)}
</p>
</div>
</div>
</div>
</div>
);
};
|