Skip to content

Commit

Permalink
Bug 2100436: VM list filter failed vms
Browse files Browse the repository at this point in the history
  • Loading branch information
upalatucci committed Jul 1, 2022
1 parent 97894c0 commit 882ba97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/views/virtualmachines/utils/virtualMachineRowFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ import {
} from '@kubevirt-utils/resources/vm/utils/operation-system/operationSystem';
import { RowFilter } from '@openshift-console/dynamic-plugin-sdk';

import { printableVMStatus } from './virtualMachineStatuses';
import { isFailedPrintableStatus, printableVMStatus } from './virtualMachineStatuses';

export const getStatusFilter = (t: TFunction): RowFilter[] => [
{
filterGroupName: t('Status'),
type: 'status',
reducer: (obj) => obj?.status?.printableStatus,
filter: (statuses, obj) => {
const status = obj?.status?.printableStatus;
isMatch: (obj, id) => {
return (
statuses.selected?.length === 0 ||
statuses.selected?.includes(status) ||
!statuses?.all?.find((s) => s === status)
id === obj?.status?.printableStatus ||
(id === printableVMStatus.Failed && isFailedPrintableStatus(obj?.status?.printableStatus))
);
},
filter: (statuses, obj) => {
const status = obj?.status?.printableStatus;

if (isFailedPrintableStatus(status) && statuses.selected?.includes(printableVMStatus.Failed))
return true;

return statuses.selected?.length === 0 || statuses.selected?.includes(status);
},
items: Object.keys(printableVMStatus).map((status) => ({
id: status,
title: status,
Expand Down
4 changes: 4 additions & 0 deletions src/views/virtualmachines/utils/virtualMachineStatuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ export const printableVMStatus = {
Paused: 'Paused',
Stopping: 'Stopping',
Terminating: 'Terminating',
Failed: 'Failed',
Unknown: 'Unknown',
};

export const isFailedPrintableStatus = (printableStatus: string) =>
printableStatus?.toLowerCase()?.includes('error');

export const getVMStatusIcon = (
status: string,
// arePendingChanges: boolean,
Expand Down

0 comments on commit 882ba97

Please sign in to comment.