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 (
- 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)} + | +