From 3d57a56105a050d4353a62785eb0539f87ddb07d Mon Sep 17 00:00:00 2001 From: John Duprey Date: Fri, 10 May 2024 13:37:37 -0400 Subject: [PATCH] Standards - Fix all tenant settings Add FormSpy on enabled settings Remove disable on all tenants --- .../tenant/standards/ListAppliedStandards.jsx | 335 +++++++++--------- 1 file changed, 170 insertions(+), 165 deletions(-) diff --git a/src/views/tenant/standards/ListAppliedStandards.jsx b/src/views/tenant/standards/ListAppliedStandards.jsx index cdb3960b0f86..66966301559f 100644 --- a/src/views/tenant/standards/ListAppliedStandards.jsx +++ b/src/views/tenant/standards/ListAppliedStandards.jsx @@ -307,21 +307,6 @@ const ApplyNewStandard = () => { (tenant) => tenant.displayName === 'AllTenants', ) - function getLabel(item, type) { - if (!item || !item.name) { - return '' - } - const keys = item.name.split('.') - let value = keys.reduce((prev, curr) => prev && prev[curr], allTenantsStandard) - if ( - !value || - !value[type] || - listStandardResults[0]?.standards?.OverrideAllTenants?.remediate === true - ) { - return '' - } - return `* Enabled via All Tenants` - } function isAllTenantEnabled(item, type) { if (!item || !item.name) { return '' @@ -344,28 +329,6 @@ const ApplyNewStandard = () => { return acc }, {}) - // Function to count enabled standards - function countEnabledStandards(standards, type) { - let count = 0 - if (standards.length > 0) { - Object.keys(standards).forEach((standard) => { - var setting = standard?.Settings - if (setting) { - if (type in Object.keys(setting) && setting[type] === true) { - count++ - } - } - }) - } - return count - } - - // Assuming listStandardResults[0] contains your JSON object - //console.log(consolidatedStandards) - const enabledStandards = consolidatedStandards ? consolidatedStandards : [] - /*const enabledAlertsCount = countEnabledStandards(enabledStandards, 'alert') - const enabledRemediationsCount = countEnabledStandards(enabledStandards, 'remediate') - const enabledWarningsCount = countEnabledStandards(enabledStandards, 'report') */ const totalAvailableStandards = allStandardsList.length useEffect(() => { @@ -386,8 +349,6 @@ const ApplyNewStandard = () => { }) } }) - console.log(enabledCounts) - setEnabledAlertsCount(enabledCounts['alert']) setEnabledRemediationsCount(enabledCounts['remediate']) setEnabledWarningsCount(enabledCounts['report']) @@ -588,137 +549,181 @@ const ApplyNewStandard = () => { )} - {Object.keys(groupedStandards).map((cat, catIndex) => ( - - {cat} - - {groupedStandards[cat].map((obj, index) => ( - - -
-
{obj.label}
-
- {obj.impact} -
-
-

- {obj.helpText} -

-
- -
Report
- -
- -
Alert
- -
- -
Remediate
- -
- -
Optional Input
- {obj.addedComponent && - obj.addedComponent.map((component) => ( - <> - {component.type === 'Select' && ( - - )} - {component.type === 'input' && ( - - )} - {component.type === 'number' && ( - - )} - {component.type === 'boolean' && ( + + {/* eslint-disable react/prop-types */} + {(props) => { + return ( + <> + {Object.keys(groupedStandards).map((cat, catIndex) => ( + + {cat} + + {groupedStandards[cat].map((obj, index) => ( + + +
+
{obj.label}
+
+ + {obj.impact} + +
+
+

+ {obj.helpText} +

+
+ +
Report
- )} - {component.type === 'AdminRolesMultiSelect' && ( - ({ - value: role.ObjectId, - name: role.Name, - }))} +
+ +
Alert
+ - )} - {component.type === 'TimezoneSelect' && ( - ({ - value: tz.timezone, - name: tz.timezone, - }))} +
+ +
Remediate
+ - )} - +
+ +
Optional Input
+ {obj.addedComponent && + obj.addedComponent.map((component) => ( + <> + {component.type === 'Select' && ( + + )} + {component.type === 'input' && ( + + )} + {component.type === 'number' && ( + + )} + {component.type === 'boolean' && ( + + )} + {component.type === + 'AdminRolesMultiSelect' && ( + ({ + value: role.ObjectId, + name: role.Name, + }))} + /> + )} + {component.type === 'TimezoneSelect' && ( + ({ + value: tz.timezone, + name: tz.timezone, + }))} + /> + )} + + ))} +
+
))} -
-
- ))} -
-
- ))} + + + ))} + + ) + }} + Templates Standard Deployment