Skip to content

Commit

Permalink
fix(workloads details): fixed a total risk filter and added missing e…
Browse files Browse the repository at this point in the history
…mpty state (#668)
  • Loading branch information
Fewwy authored Jan 30, 2024
1 parent bdb6381 commit 10514e4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Components/Common/Tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export const passFilterWorkloads = (workloads, filters) => {

export const passFilterWorkloadsRecs = (recommendation, filters) => {
return Object.entries(filters).some(([filterKey, filterValue]) => {
console.log(filterKey, filterValue);
if (filterValue.length === 0) {
return false;
} else {
Expand All @@ -333,9 +334,8 @@ export const passFilterWorkloadsRecs = (recommendation, filters) => {
return recommendation.objects.some((obj) =>
obj.uid.toLowerCase().includes(filterValue.toLowerCase())
);
//NOTE IS NOT AVAILABLE IN THE API YET
/* case 'total_risk':
return filterValue.includes(String(recs.total_risk)); */
case 'total_risk':
return filterValue.includes(String(recommendation.total_risk));
default:
return false;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Components/MessageState/EmptyStates.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,15 @@ const NoMatchingWorkloads = () => {
);
};

const NoMatchingRecsForWorkloads = () => {
return (
<MessageState
title={'No matching recommendations found'}
text={'To continue, edit your filter settings and search again.'}
/>
);
};

export {
ErrorState,
NoAffectedClusters,
Expand All @@ -357,4 +366,5 @@ export {
NoWorkloadsRecsAvailable,
NoRecsForWorkloadsDetails,
NoMatchingWorkloads,
NoMatchingRecsForWorkloads,
};
7 changes: 5 additions & 2 deletions src/Components/WorkloadRules/WorkloadRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import PropTypes from 'prop-types';
import Loading from '../Loading/Loading';
import {
ErrorState,
NoMatchingRecsForWorkloads,
NoRecsForWorkloadsDetails,
NoWorkloadsRecsAvailable,
} from '../MessageState/EmptyStates';
// import DateFormat from '@redhat-cloud-services/frontend-components/DateFormat/DateFormat';
import InsightsLabel from '@redhat-cloud-services/frontend-components/InsightsLabel';
import ExpandedRulesDetails from '../ExpandedRulesDetails.js/ExpandedRulesDetails';
import { useDispatch, useSelector } from 'react-redux';
Expand Down Expand Up @@ -63,6 +63,7 @@ const WorkloadRules = ({ workload }) => {
const { search } = useLocation();
//FILTERS
const filters = useSelector(({ filters }) => filters.workloadsRecsListState);
const noMatchingRecs = filteredRows.length === 0 ? true : false;

const updateFilters = (payload) =>
dispatch(updateWorkloadsRecsListFilters(payload));
Expand Down Expand Up @@ -273,7 +274,7 @@ const WorkloadRules = ({ workload }) => {
ouiaSafe={!loadingState}
onCollapse={handleOnCollapse} // TODO: set undefined when there is an empty state
rows={
errorState || loadingState || noInput ? (
errorState || loadingState || noInput || noMatchingRecs ? (
[
{
fullWidth: true,
Expand All @@ -286,6 +287,8 @@ const WorkloadRules = ({ workload }) => {
<NoWorkloadsRecsAvailable />
) : loadingState ? (
<Loading />
) : noMatchingRecs ? (
<NoMatchingRecsForWorkloads />
) : (
<NoRecsForWorkloadsDetails />
),
Expand Down

0 comments on commit 10514e4

Please sign in to comment.