Skip to content

Commit

Permalink
feat(RHINENG-9189): adding back severity column to the workloads table (
Browse files Browse the repository at this point in the history
#764)

* feat(RHINENG-9189): return severity column

* fixed tests fixed sorting

* fixed url param and removed commented out text
  • Loading branch information
Fewwy authored Jul 15, 2024
1 parent 749dbdc commit ef55434
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
12 changes: 6 additions & 6 deletions src/AppConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,10 @@ export const WORKLOADS_LIST_COLUMNS = [
title: 'Recommendations',
transforms: [sortable, cellWidth(15)],
},
/* {
{
title: 'Severity',
transforms: [sortable, cellWidth(15)],
}, */
},
{
title: 'Objects',
transforms: [sortable, fitContent],
Expand All @@ -424,16 +424,16 @@ export const WORKLOADS_LIST_COLUMNS = [
export const WORKLOADS_LIST_COLUMNS_KEYS = [
'name',
'recommendations',
// 'severity',
'severity',
'objects',
'last_seen',
];

export const WORKLOADS_TABLE_CELL_NAME = 0;
export const WORKLOADS_TABLE_CELL_RECOMMENDATIONS = 1;
// export const WORKLOADS_TABLE_SEVERITY = 2;
export const WORKLOADS_TABLE_CELL_OBJECTS = 2; // 3
export const WORKLOADS_TABLE_CELL_LAST_SEEN = 3; // 4
export const WORKLOADS_TABLE_SEVERITY = 2;
export const WORKLOADS_TABLE_CELL_OBJECTS = 3;
export const WORKLOADS_TABLE_CELL_LAST_SEEN = 4;

export const WORKLOADS_TABLE_FILTER_CATEGORIES = {
severity: {
Expand Down
3 changes: 1 addition & 2 deletions src/Components/WorkloadsListTable/WorkloadsListTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ describe('workloads list table', () => {

describe('sorting', () => {
_.zip(
// ['name', 'recommendations', 'severity', 'objects', 'last_seen'],
['name', 'recommendations', 'objects', 'last_seen'],
['name', 'recommendations', 'severity', 'objects', 'last_seen'],
TABLE_HEADERS
).forEach(([category, label]) => {
SORTING_ORDERS.forEach((order) => {
Expand Down
38 changes: 22 additions & 16 deletions src/Components/WorkloadsListTable/WorkloadsListTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import {
WORKLOADS_TABLE_CELL_OBJECTS,
WORKLOADS_TABLE_CELL_RECOMMENDATIONS,
WORKLOADS_TABLE_FILTER_CATEGORIES,
// WORKLOADS_TABLE_SEVERITY,
WORKLOADS_TABLE_SEVERITY,
} from '../../AppConstants';
import DateFormat from '@redhat-cloud-services/frontend-components/DateFormat';
import { Link, useLocation } from 'react-router-dom';
import { BASE_PATH } from '../../Routes';
import { Pagination } from '@patternfly/react-core';
/* import { conditionalFilterType } from '@redhat-cloud-services/frontend-components/ConditionalFilter/conditionalFilterConstants'; */
import { conditionalFilterType } from '@redhat-cloud-services/frontend-components/ConditionalFilter/conditionalFilterConstants';
import { useDispatch, useSelector } from 'react-redux';
import {
WORKLOADS_TABLE_INITIAL_STATE,
Expand All @@ -34,7 +34,7 @@ import {
buildFilterChips,
passFilterWorkloads,
removeFilterParam as _removeFilterParam,
/* addFilterParam as _addFilterParam, */
addFilterParam as _addFilterParam,
translateSortParams,
paramParser,
updateSearchParams,
Expand All @@ -45,7 +45,7 @@ import {
NoDVOInstalledOrDataCollected,
} from '../MessageState/EmptyStates';
import Loading from '../Loading/Loading';
/* import ShieldSet from '../ShieldSet'; */
import ShieldSet from '../ShieldSet';
import { filtersAreApplied } from '../../Utilities/Workloads';

const WorkloadsListTable = ({
Expand Down Expand Up @@ -81,8 +81,8 @@ const WorkloadsListTable = ({
const successState = isSuccess;
const { search } = useLocation();

/* const addFilterParam = (param, values) =>
_addFilterParam(filters, updateFilters, param, values); */
const addFilterParam = (param, values) =>
_addFilterParam(filters, updateFilters, param, values);

useEffect(() => {
setFilteredRows(buildFilteredRows(workloads));
Expand Down Expand Up @@ -148,14 +148,14 @@ const WorkloadsListTable = ({
fst = a.metadata.recommendations || 0;
snd = b.metadata.recommendations || 0;
return fst > snd ? d : snd > fst ? -d : 0;
// case WORKLOADS_TABLE_SEVERITY:
// fst = a.metadata.hits_by_severity || { 1: 0, 2: 0, 3: 0, 4: 0 };
// snd = b.metadata.hits_by_severity || { 1: 0, 2: 0, 3: 0, 4: 0 };
// for (let i = 4; i > 0; i--) {
// if (fst[i] > snd[i]) return d;
// if (fst[i] < snd[i]) return -d;
// }
// return 0;
case WORKLOADS_TABLE_SEVERITY:
fst = a.metadata.hits_by_severity || { 1: 0, 2: 0, 3: 0, 4: 0 };
snd = b.metadata.hits_by_severity || { 1: 0, 2: 0, 3: 0, 4: 0 };
for (let i = 4; i > 0; i--) {
if (fst[i] > snd[i]) return d;
if (fst[i] < snd[i]) return -d;
}
return 0;
case WORKLOADS_TABLE_CELL_OBJECTS:
fst = a.metadata.objects || 0;
snd = b.metadata.objects || 0;
Expand Down Expand Up @@ -189,6 +189,12 @@ const WorkloadsListTable = ({
</Link>
</span>,
item.metadata.recommendations,
<span key={index}>
<ShieldSet
hits_by_severity={item.metadata.hits_by_severity}
basePath={`${BASE_PATH}/workloads/${item.cluster.uuid}/${item.namespace.uuid}`}
/>
</span>,
item.metadata.objects,
<span key={index}>
<DateFormat
Expand Down Expand Up @@ -224,7 +230,7 @@ const WorkloadsListTable = ({
placeholder: 'Filter by namespace name',
},
},
/* {
{
label: 'Severity',
type: conditionalFilterType.checkbox,
id: WORKLOADS_TABLE_FILTER_CATEGORIES.severity.urlParam,
Expand All @@ -236,7 +242,7 @@ const WorkloadsListTable = ({
items: WORKLOADS_TABLE_FILTER_CATEGORIES.severity.values,
placeholder: 'Filter by severity',
},
}, */
},
];

const activeFiltersConfig = {
Expand Down

0 comments on commit ef55434

Please sign in to comment.