Skip to content

Commit

Permalink
Change hide deprecated bootable volumes to show deprecated bootable v…
Browse files Browse the repository at this point in the history
…olumes
  • Loading branch information
pcbailey committed Jan 13, 2025
1 parent b6a1884 commit 983571d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 35 deletions.
2 changes: 1 addition & 1 deletion locales/en/plugin__kubevirt-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@
"Headless mode": "Headless mode",
"Healthy": "Healthy",
"Help": "Help",
"Hide deprecated bootable volumes": "Hide deprecated bootable volumes",
"Hide deprecated templates": "Hide deprecated templates",
"High performance": "High performance",
"History": "History",
Expand Down Expand Up @@ -1134,6 +1133,7 @@
"Shared access (RWX)": "Shared access (RWX)",
"Show all": "Show all",
"Show all alerts": "Show all alerts",
"Show deprecated bootable volumes": "Show deprecated bootable volumes",
"Show less": "Show less",
"Show only projects with VirtualMachines": "Show only projects with VirtualMachines",
"Show top 10": "Show top 10",
Expand Down
6 changes: 3 additions & 3 deletions src/utils/resources/bootableresources/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const INSTANCETYPE_CLASS_ANNOTATION = 'instancetype.kubevirt.io/class';
export const KUBEVIRT_ISO_LABEL = 'kubevirt.io/iso';
export const ISO = 'ISO';

export const deprecatedOSNames = ['centos-stream8', 'centos7'];
export const deprecatedOSNames = ['centos-stream8', 'centos7', 'rhel8'];

export const HIDE_DEPRECATED_BOOTABLE_VOLUMES = 'hideDeprecatedBootableVolumes';
export const HIDE_DEPRECATED_BOOTABLE_VOLUMES_LABEL = 'Hide deprecated bootable volumes';
export const SHOW_DEPRECATED_BOOTABLE_VOLUMES = 'showDeprecatedBootableVolumes';
export const SHOW_DEPRECATED_BOOTABLE_VOLUMES_LABEL = 'Show deprecated bootable volumes';
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { useEffect } from 'react';

import { CREATE_VM_TAB } from '@catalog/CreateVMHorizontalNav/constants';
import { useURLParams } from '@kubevirt-utils/hooks/useURLParams';
import {
HIDE_DEPRECATED_BOOTABLE_VOLUMES,
HIDE_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
} from '@kubevirt-utils/resources/bootableresources/constants';
import { SHOW_DEPRECATED_BOOTABLE_VOLUMES } from '@kubevirt-utils/resources/bootableresources/constants';
import { FilterValue } from '@openshift-console/dynamic-plugin-sdk';

type UseHideDeprecatedBootableVolumes = (
Expand All @@ -17,22 +13,15 @@ const useHideDeprecatedBootableVolumes: UseHideDeprecatedBootableVolumes = (
onFilterChange,
currentTab,
) => {
const { setParam } = useURLParams();

useEffect(() => {
if (currentTab !== CREATE_VM_TAB.INSTANCE_TYPES && currentTab !== undefined) return null;

// This is to select the 'Hide deprecated bootable volumes' filter by default
onFilterChange(HIDE_DEPRECATED_BOOTABLE_VOLUMES, {
all: [HIDE_DEPRECATED_BOOTABLE_VOLUMES],
selected: [HIDE_DEPRECATED_BOOTABLE_VOLUMES],
// Calculate the filtered bootable volumes once causing deprecated volumes to be hidden by default
onFilterChange(SHOW_DEPRECATED_BOOTABLE_VOLUMES, {
all: [],
selected: [],
});

setParam(
`rowFilter-${HIDE_DEPRECATED_BOOTABLE_VOLUMES}`,
HIDE_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
);
}, [currentTab]);
}, [currentTab, onFilterChange]);
};

export default useHideDeprecatedBootableVolumes;
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { PersistentVolumeClaimModel } from '@kubevirt-ui/kubevirt-api/console';
import DataSourceModel from '@kubevirt-ui/kubevirt-api/console/models/DataSourceModel';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import {
HIDE_DEPRECATED_BOOTABLE_VOLUMES,
HIDE_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
ISO,
SHOW_DEPRECATED_BOOTABLE_VOLUMES,
SHOW_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
} from '@kubevirt-utils/resources/bootableresources/constants';
import {
isBootableVolumeISO,
Expand All @@ -24,16 +24,16 @@ const useBootableVolumesFilters = (): RowFilter<BootableResource>[] => {
return [
{
filter: (availableResourceNames, obj) =>
availableResourceNames?.selected?.length === 0 || !isDeprecated(getName(obj)),
availableResourceNames?.selected?.length === 0 ? !isDeprecated(getName(obj)) : true,
filterGroupName: ' ',
items: [
{
id: t('Hide deprecated bootable volumes'),
title: t('Hide deprecated bootable volumes'),
id: t('Show deprecated bootable volumes'),
title: t('Show deprecated bootable volumes'),
},
],
reducer: (obj) => isDeprecated(getName(obj)) && HIDE_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
type: HIDE_DEPRECATED_BOOTABLE_VOLUMES,
reducer: (obj) => isDeprecated(getName(obj)) && SHOW_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
type: SHOW_DEPRECATED_BOOTABLE_VOLUMES,
},
{
filter: (availableOsNames, obj) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import DataSourceModel from '@kubevirt-ui/kubevirt-api/console/models/DataSourceModel';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import {
HIDE_DEPRECATED_BOOTABLE_VOLUMES,
HIDE_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
ISO,
SHOW_DEPRECATED_BOOTABLE_VOLUMES,
SHOW_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
} from '@kubevirt-utils/resources/bootableresources/constants';
import {
isBootableVolumeISO,
Expand All @@ -23,16 +23,16 @@ const useBootVolumeFilters = (isModal: boolean): RowFilter<BootableVolume>[] =>
return [
{
filter: (availableResourceNames, obj) =>
availableResourceNames?.selected?.length === 0 || !isDeprecated(getName(obj)),
availableResourceNames?.selected?.length === 0 ? !isDeprecated(getName(obj)) : true,
filterGroupName: ' ',
items: [
{
id: t('Hide deprecated bootable volumes'),
title: t('Hide deprecated bootable volumes'),
id: t('Show deprecated bootable volumes'),
title: t('Show deprecated bootable volumes'),
},
],
reducer: (obj) => isDeprecated(getName(obj)) && HIDE_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
type: HIDE_DEPRECATED_BOOTABLE_VOLUMES,
reducer: (obj) => isDeprecated(getName(obj)) && SHOW_DEPRECATED_BOOTABLE_VOLUMES_LABEL,
type: SHOW_DEPRECATED_BOOTABLE_VOLUMES,
},
{
filter: (availableOsNames, obj) => {
Expand Down

0 comments on commit 983571d

Please sign in to comment.