diff --git a/assets/js/components/ChecksResults.jsx b/assets/js/components/ChecksResults.jsx index ea1841f9d0..b54ba21d58 100644 --- a/assets/js/components/ChecksResults.jsx +++ b/assets/js/components/ChecksResults.jsx @@ -19,30 +19,6 @@ const getChecksResults = (cluster) => { return {}; }; -const getDescriptionFromCatalog = - (catalog = []) => - (check_id) => { - return catalog.reduce((acc, check) => { - if (check.id === check_id) { - return check.description; - } - - return acc; - }, ''); - }; - -const getGroupFromCatalog = - (catalog = []) => - (checkId) => { - return catalog.reduce((acc, check) => { - if (check.id === checkId) { - return check.group; - } - - return acc; - }, ''); - }; - const getHostname = (hosts = []) => (hostId) => { @@ -55,6 +31,12 @@ const getHostname = }, ''); }; +const getCatalogByProvider = (catalogProvider) => (state) => { + return state.catalog.catalog.find( + ({ provider }) => provider === catalogProvider + ); +}; + const sortChecksResults = (checksResults = [], group) => { return checksResults.sort((a, b) => { if (a.check_id === b.check_id) { @@ -83,16 +65,18 @@ const ChecksResults = () => { state.clustersList.clusters.find((cluster) => cluster.id === clusterID) ); - const hostname = getHostname(useSelector((state) => state.hostsList.hosts)); + const checksResults = getChecksResults(cluster); - const catalog = useSelector((state) => state.catalog.catalog).flatMap( - ({ checks }) => checks - ); + const hostname = getHostname(useSelector((state) => state.hostsList.hosts)); - const checksResults = getChecksResults(cluster); + // FIXME: Check the provider by cluster + const catalog = useSelector(getCatalogByProvider('azure')); - const description = getDescriptionFromCatalog(catalog); - const group = getGroupFromCatalog(catalog); + const description = (checkId) => { + return catalog?.groups + ?.flatMap(({ checks }) => checks) + .find(({ id }) => id === checkId).description; + }; return (
@@ -109,12 +93,6 @@ const ChecksResults = () => { - - {sortChecksResults(checksResults[c], group).map( - (checkResult) => ( - - - - - - - ) - )} + {sortChecksResults(checksResults[c]).map((checkResult) => ( + + + + + + ))}
- Group - {
- {group(checkResult.check_id)} - - {checkResult.check_id} - - {description(checkResult.check_id)} - - {getResultIcon(checkResult.result)} -
+ {checkResult.check_id} + + {description(checkResult.check_id)} + + {getResultIcon(checkResult.result)} +
diff --git a/assets/js/components/ChecksSelection.jsx b/assets/js/components/ChecksSelection.jsx index 44e3f97b50..5d02002db9 100644 --- a/assets/js/components/ChecksSelection.jsx +++ b/assets/js/components/ChecksSelection.jsx @@ -37,65 +37,69 @@ const ChecksSelection = () => { return (
- {catalog.map(({ group, checks }) => ( -
-
-

- {group} -

-
- -
- ))} + + + ))} + +
+ ))}