Skip to content

Commit

Permalink
CNV-41689: Fix fetching for all namespaces on user instance types
Browse files Browse the repository at this point in the history
Signed-off-by: Matan Schatzman <[email protected]>
  • Loading branch information
metalice committed May 15, 2024
1 parent 3940540 commit 9e87171
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ import { V1beta1VirtualMachineInstancetype } from '@kubevirt-ui/kubevirt-api/kub
import { ALL_NAMESPACES_SESSION_KEY } from '@kubevirt-utils/hooks/constants';
import { useActiveNamespace, useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';

type UseVirtualMachineInstanceTypes = () => [
instanceTypes: V1beta1VirtualMachineInstancetype[],
loaded: boolean,
loadError: Error,
];
type UseVirtualMachineInstanceTypes = (
fetchAllProjects?: boolean,
) => [instanceTypes: V1beta1VirtualMachineInstancetype[], loaded: boolean, loadError: Error];

const useVirtualMachineInstanceTypes: UseVirtualMachineInstanceTypes = () => {
const useVirtualMachineInstanceTypes: UseVirtualMachineInstanceTypes = (fetchAllProjects) => {
const [activeNamespace] = useActiveNamespace();
const isAllNamespace = activeNamespace === ALL_NAMESPACES_SESSION_KEY;
const [instanceTypes, loaded, loadError] = useK8sWatchResource<
V1beta1VirtualMachineInstancetype[]
>(
activeNamespace !== ALL_NAMESPACES_SESSION_KEY && {
(fetchAllProjects || !isAllNamespace) && {
groupVersionKind: VirtualMachineInstancetypeModelGroupVersionKind,
isList: true,
...(activeNamespace !== ALL_NAMESPACES_SESSION_KEY && { namespace: activeNamespace }),
...(!isAllNamespace && { namespace: activeNamespace }),
},
);

Expand Down
2 changes: 1 addition & 1 deletion src/views/instancetypes/list/UserInstancetypeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import '@kubevirt-utils/styles/list-managment-group.scss';
const UserInstancetypeList: FC = () => {
const { t } = useKubevirtTranslation();
const [activeNamespace] = useActiveNamespace();
const [instanceTypes, loaded, loadError] = useVirtualMachineInstanceTypes();
const [instanceTypes, loaded, loadError] = useVirtualMachineInstanceTypes(true);
const { onPaginationChange, pagination } = usePagination();
const [unfilteredData, data, onFilterChange] = useListPageFilter<
V1beta1VirtualMachineInstancetype,
Expand Down

0 comments on commit 9e87171

Please sign in to comment.