Skip to content

Commit 0b59efd

Browse files
authored
Merge pull request #193 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents ed05661 + 6c6a98f commit 0b59efd

File tree

1 file changed

+74
-38
lines changed
  • src/pages/tenant/standards/compare

1 file changed

+74
-38
lines changed

src/pages/tenant/standards/compare/index.js

Lines changed: 74 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ const Page = () => {
8080

8181
if (selectedTemplate && comparisonApi.isSuccess && comparisonApi.data) {
8282
const tenantData = comparisonApi.data;
83-
83+
8484
// Find the current tenant's data by matching tenantFilter with currentTenant
85-
const currentTenantObj = tenantData.find(t => t.tenantFilter === currentTenant);
85+
const currentTenantObj = tenantData.find((t) => t.tenantFilter === currentTenant);
8686
const currentTenantData = currentTenantObj ? currentTenantObj.standardsResults || [] : [];
87-
87+
8888
const allStandards = [];
8989
if (selectedTemplate.standards) {
9090
Object.entries(selectedTemplate.standards).forEach(([standardKey, standardConfig]) => {
@@ -99,33 +99,38 @@ const Page = () => {
9999

100100
// Determine compliance status
101101
let isCompliant = false;
102-
102+
103103
// Check if the standard is directly in the tenant object (like "standards.AuditLog": true)
104-
const standardIdWithoutPrefix = standardId.replace('standards.', '');
104+
const standardIdWithoutPrefix = standardId.replace("standards.", "");
105105
const directStandardValue = currentTenantObj?.[standardId];
106-
106+
107107
// Special case for boolean standards that are true in the tenant
108108
if (directStandardValue === true) {
109109
// If the standard is directly in the tenant and is true, it's compliant
110110
isCompliant = true;
111111
} else if (directStandardValue !== undefined) {
112112
// For non-boolean values, use strict equality
113-
isCompliant = JSON.stringify(directStandardValue) === JSON.stringify(standardSettings);
113+
isCompliant =
114+
JSON.stringify(directStandardValue) === JSON.stringify(standardSettings);
114115
} else if (currentTenantStandard) {
115116
// Fall back to the previous logic if the standard is not directly in the tenant object
116-
if (typeof standardSettings === 'boolean' && standardSettings === true) {
117+
if (typeof standardSettings === "boolean" && standardSettings === true) {
117118
isCompliant = currentTenantStandard.value === true;
118119
} else {
119-
isCompliant = JSON.stringify(currentTenantStandard.value) === JSON.stringify(standardSettings);
120+
isCompliant =
121+
JSON.stringify(currentTenantStandard.value) === JSON.stringify(standardSettings);
120122
}
121123
}
122124

123125
// Use the direct standard value from the tenant object if it exists
124-
126+
125127
allStandards.push({
126128
standardId,
127129
standardName: standardInfo?.label || standardKey,
128-
currentTenantValue: directStandardValue !== undefined ? directStandardValue : currentTenantStandard?.value,
130+
currentTenantValue:
131+
directStandardValue !== undefined
132+
? directStandardValue
133+
: currentTenantStandard?.value,
129134
standardValue: standardSettings,
130135
complianceStatus: isCompliant ? "Compliant" : "Non-Compliant",
131136
complianceDetails: standardInfo?.docsDescription || standardInfo?.helpText || "",
@@ -396,7 +401,7 @@ const Page = () => {
396401
</Typography>
397402
<Typography variant="body2">
398403
{typeof value === "object" && value !== null
399-
? (value.label || JSON.stringify(value))
404+
? value.label || JSON.stringify(value)
400405
: value === true
401406
? "Enabled"
402407
: value === false
@@ -407,11 +412,27 @@ const Page = () => {
407412
))
408413
) : (
409414
<Typography variant="body2">
410-
{standard.standardValue !== undefined
411-
? typeof standard.standardValue === "object"
412-
? "No settings configured"
413-
: String(standard.standardValue)
414-
: "Not configured"}
415+
{standard.standardValue === true ? (
416+
<Alert severity="success" sx={{ mt: 1 }}>
417+
This setting is configured correctly
418+
</Alert>
419+
) : standard.standardValue === false ? (
420+
<Alert severity="warning" sx={{ mt: 1 }}>
421+
This setting is not configured correctly
422+
</Alert>
423+
) : standard.standardValue !== undefined ? (
424+
typeof standard.standardValue === "object" ? (
425+
"No settings configured"
426+
) : (
427+
String(standard.standardValue)
428+
)
429+
) : (
430+
<Alert severity="info" sx={{ mt: 1 }}>
431+
This setting is not configured, or data has not been collected.
432+
If you are getting this after data collection, the tenant might
433+
not be licensed for this feature
434+
</Alert>
435+
)}
415436
</Typography>
416437
)}
417438
</Box>
@@ -531,23 +552,27 @@ const Page = () => {
531552
<Typography
532553
variant="body2"
533554
sx={{
534-
color: standard.complianceStatus === "Compliant"
535-
? "success.main"
536-
: (isDifferent ? "error.main" : "inherit"),
537-
fontWeight: standard.complianceStatus !== "Compliant" && isDifferent
538-
? "medium"
539-
: "inherit",
555+
color:
556+
standard.complianceStatus === "Compliant"
557+
? "success.main"
558+
: isDifferent
559+
? "error.main"
560+
: "inherit",
561+
fontWeight:
562+
standard.complianceStatus !== "Compliant" && isDifferent
563+
? "medium"
564+
: "inherit",
540565
}}
541566
>
542567
{standard.complianceStatus === "Compliant" && value === true
543568
? "Compliant"
544-
: (typeof value === "object" && value !== null
545-
? (value.label || JSON.stringify(value))
546-
: value === true
547-
? "Enabled"
548-
: value === false
549-
? "Disabled"
550-
: String(value))}
569+
: typeof value === "object" && value !== null
570+
? value.label || JSON.stringify(value)
571+
: value === true
572+
? "Enabled"
573+
: value === false
574+
? "Disabled"
575+
: String(value)}
551576
</Typography>
552577
</Box>
553578
);
@@ -563,16 +588,27 @@ const Page = () => {
563588
? "success.main"
564589
: "error.main",
565590
fontWeight:
566-
standard.complianceStatus !== "Compliant"
567-
? "medium"
568-
: "inherit",
591+
standard.complianceStatus !== "Compliant" ? "medium" : "inherit",
569592
}}
570593
>
571-
{standard.complianceStatus === "Compliant" && standard.currentTenantValue === true
572-
? "Compliant"
573-
: (standard.currentTenantValue !== undefined
574-
? String(standard.currentTenantValue)
575-
: "Not configured")}
594+
{standard.complianceStatus === "Compliant" &&
595+
standard.currentTenantValue === true ? (
596+
<Alert severity="success" sx={{ mt: 1 }}>
597+
This setting is configured correctly
598+
</Alert>
599+
) : standard.currentTenantValue === false ? (
600+
<Alert severity="warning" sx={{ mt: 1 }}>
601+
This setting is not configured correctly
602+
</Alert>
603+
) : standard.currentTenantValue !== undefined ? (
604+
String(standard.currentTenantValue)
605+
) : (
606+
<Alert severity="info" sx={{ mt: 1 }}>
607+
This setting is not configured, or data has not been collected. If you
608+
are getting this after data collection, the tenant might not be licensed
609+
for this feature
610+
</Alert>
611+
)}
576612
</Typography>
577613
)}
578614
</Box>

0 commit comments

Comments
 (0)