Skip to content

Commit

Permalink
Filter by all concerns
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Szwajkowski <[email protected]>
  • Loading branch information
rszwajko committed Sep 28, 2023
1 parent 4cbc3ef commit 5a66153
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export const oVirtVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [
},
{
resourceFieldId: 'concerns',
jsonPath: '$.concerns',
jsonPath: (data: VmData) => (data.vm.providerType === 'ovirt' ? data?.vm?.concerns : []),
label: t('Concerns'),
isVisible: true,
sortable: true,
filter: {
type: 'enum',
type: 'concerns',
primary: true,
placeholderLabel: t('Concerns'),
values: EnumToTuple({ Critical: 'Critical', Warning: 'Warning', Information: 'Information' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import StandardPage from 'src/components/page/StandardPage';
import { ProviderData } from 'src/modules/Providers/utils';
import { useForkliftTranslation } from 'src/utils/i18n';

import { loadUserSettings, ResourceFieldFactory, RowProps } from '@kubev2v/common';
import { ProviderVirtualMachine } from '@kubev2v/types';
import {
EnumFilter,
loadUserSettings,
ResourceFieldFactory,
RowProps,
ValueMatcher,
} from '@kubev2v/common';
import { Concern, ProviderVirtualMachine } from '@kubev2v/types';

import { useInventoryVms } from '../utils/useInventoryVms';

Expand Down Expand Up @@ -49,6 +55,16 @@ export const ProviderVirtualMachinesList: React.FC<ProviderVirtualMachinesListPr
namespace={obj?.provider?.metadata?.namespace}
title={t('Virtual Machines')}
userSettings={userSettings}
extraSupportedFilters={{
concerns: EnumFilter,
}}
extraSupportedMatchers={[concernsMatcher]}
/>
);
};

const concernsMatcher: ValueMatcher = {
filterType: 'concerns',
matchValue: (concerns: Concern[]) => (filter: string) =>
concerns.some(({ category }) => category === filter),
};

0 comments on commit 5a66153

Please sign in to comment.