Skip to content

Commit

Permalink
Merge pull request kubevirt-ui#2190 from avivtur/bug-boot-volume-list…
Browse files Browse the repository at this point in the history
…-show-all-project-for-non-priv-user

CNV-45815: No volumes found for nonpriv user in All projects
  • Loading branch information
openshift-merge-bot[bot] authored Sep 20, 2024
2 parents 66a2649 + d21a82c commit 0b09db7
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React, { FC, useMemo, useState } from 'react';
import React, { FC, useEffect, useMemo, useState } from 'react';

import { useInstanceTypeVMStore } from '@catalog/CreateFromInstanceTypes/state/useInstanceTypeVMStore';
import { UseBootableVolumesValues } from '@catalog/CreateFromInstanceTypes/state/utils/types';
import { CREATE_VM_TAB } from '@catalog/CreateVMHorizontalNav/constants';
import { V1beta1VirtualMachineClusterPreference } from '@kubevirt-ui/kubevirt-api/kubevirt';
import ListPageFilter from '@kubevirt-utils/components/ListPageFilter/ListPageFilter';
import ProjectDropdown from '@kubevirt-utils/components/ProjectDropdown/ProjectDropdown';
import { OPENSHIFT_OS_IMAGES_NS } from '@kubevirt-utils/constants/constants';
import { ALL_PROJECTS } from '@kubevirt-utils/hooks/constants';
import { useIsAdmin } from '@kubevirt-utils/hooks/useIsAdmin';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { UserSettingFavorites } from '@kubevirt-utils/hooks/useKubevirtUserSettings/utils/types';
import useHideDeprecatedBootableVolumes from '@kubevirt-utils/resources/bootableresources/hooks/useHideDeprecatedBootableVolumes';
Expand Down Expand Up @@ -47,6 +50,7 @@ const BootableVolumeList: FC<BootableVolumeListProps> = ({
selectedBootableVolumeState,
}) => {
const { t } = useKubevirtTranslation();
const isAdmin = useIsAdmin();

const {
instanceTypeVMState,
Expand Down Expand Up @@ -89,6 +93,12 @@ const BootableVolumeList: FC<BootableVolumeListProps> = ({
pagination,
);

useEffect(() => {
if (!isAdmin && volumeListNamespace === ALL_PROJECTS) {
setVolumeListNamespace(OPENSHIFT_OS_IMAGES_NS);
}
}, [isAdmin, volumeListNamespace, setVolumeListNamespace]);

const displayVolumes = !isEmpty(bootableVolumes) && loaded && loadedColumns;

const onModalBootableVolumeSelect = (modalSelectedVolume: BootableVolume) => {
Expand All @@ -110,6 +120,7 @@ const BootableVolumeList: FC<BootableVolumeListProps> = ({
label={t('Volumes project')}
>
<ProjectDropdown
includeAllProjects={isAdmin}
onChange={setVolumeListNamespace}
selectedProject={volumeListNamespace}
/>
Expand Down

0 comments on commit 0b09db7

Please sign in to comment.