diff --git a/src/utils/components/AddBootableVolumeModal/AddBootableVolumeModal.tsx b/src/utils/components/AddBootableVolumeModal/AddBootableVolumeModal.tsx index 2bd695ecb..3b20b3dea 100644 --- a/src/utils/components/AddBootableVolumeModal/AddBootableVolumeModal.tsx +++ b/src/utils/components/AddBootableVolumeModal/AddBootableVolumeModal.tsx @@ -4,14 +4,12 @@ import { DEFAULT_PREFERENCE_LABEL } from '@catalog/CreateFromInstanceTypes/utils import { IoK8sApiCoreV1PersistentVolumeClaim } from '@kubevirt-ui/kubevirt-api/kubernetes'; import HelpTextIcon from '@kubevirt-utils/components/HelpTextIcon/HelpTextIcon'; import TabModal from '@kubevirt-utils/components/TabModal/TabModal'; -import { DEFAULT_NAMESPACE } from '@kubevirt-utils/constants/constants'; -import { ALL_NAMESPACES_SESSION_KEY } from '@kubevirt-utils/hooks/constants'; import { useCDIUpload } from '@kubevirt-utils/hooks/useCDIUpload/useCDIUpload'; import { UPLOAD_STATUS } from '@kubevirt-utils/hooks/useCDIUpload/utils'; import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; import useStorageProfileClaimPropertySets from '@kubevirt-utils/hooks/useStorageProfileClaimPropertySets'; import { BootableVolume } from '@kubevirt-utils/resources/bootableresources/types'; -import { kubevirtConsole } from '@kubevirt-utils/utils/utils'; +import { getValidNamespace, kubevirtConsole } from '@kubevirt-utils/utils/utils'; import { useActiveNamespace } from '@openshift-console/dynamic-plugin-sdk'; import { Form, PopoverPosition, Title } from '@patternfly/react-core'; @@ -34,7 +32,6 @@ import { createBootableVolume } from './utils/utils'; import './AddBootableVolumeModal.scss'; type AddBootableVolumeModalProps = { - enforceNamespace?: string; isOpen: boolean; onClose: () => void; onCreateVolume?: ( @@ -45,23 +42,23 @@ type AddBootableVolumeModalProps = { }; const AddBootableVolumeModal: FC = ({ - enforceNamespace, isOpen, onClose, onCreateVolume, }) => { const { t } = useKubevirtTranslation(); const [activeNamespace] = useActiveNamespace(); - const selectedNamespace = - activeNamespace === ALL_NAMESPACES_SESSION_KEY ? undefined : activeNamespace; - const namespace = enforceNamespace ?? selectedNamespace ?? DEFAULT_NAMESPACE; + const namespace = getValidNamespace(activeNamespace); + + const [bootableVolume, setBootableVolume] = useState({ + ...initialBootableVolumeState, + bootableVolumeNamespace: namespace, + }); - const [bootableVolume, setBootableVolume] = useState( - initialBootableVolumeState, - ); const [sourceType, setSourceType] = useState( DROPDOWN_FORM_SELECTION.UPLOAD_IMAGE, ); + const applyStorageProfileState = useState(true); const { upload, uploadData } = useCDIUpload(); @@ -103,7 +100,6 @@ const AddBootableVolumeModal: FC = ({ applyStorageProfileSettings: applyStorageProfileState[0], bootableVolume, claimPropertySets: claimPropertySetsData?.claimPropertySets, - namespace, onCreateVolume, sourceType, uploadData, @@ -137,7 +133,6 @@ const AddBootableVolumeModal: FC = ({ applyStorageProfileState={applyStorageProfileState} bootableVolume={bootableVolume} claimPropertySetsData={claimPropertySetsData} - namespace={namespace} setBootableVolumeField={setBootableVolumeField} /> diff --git a/src/utils/components/AddBootableVolumeModal/components/VolumeDestination/VolumeDestination.tsx b/src/utils/components/AddBootableVolumeModal/components/VolumeDestination/VolumeDestination.tsx index 8a7a6f0ba..cfcc80c01 100644 --- a/src/utils/components/AddBootableVolumeModal/components/VolumeDestination/VolumeDestination.tsx +++ b/src/utils/components/AddBootableVolumeModal/components/VolumeDestination/VolumeDestination.tsx @@ -2,6 +2,7 @@ import React, { Dispatch, FC, SetStateAction, useState } from 'react'; import ApplyStorageProfileSettingsCheckbox from '@kubevirt-utils/components/ApplyStorageProfileSettingsCheckbox/ApplyStorageProfileSettingsCheckbox'; import CapacityInput from '@kubevirt-utils/components/CapacityInput/CapacityInput'; +import ProjectDropdown from '@kubevirt-utils/components/ProjectDropdown/ProjectDropdown'; import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; import { UseStorageProfileClaimPropertySetsValue } from '@kubevirt-utils/hooks/useStorageProfileClaimPropertySets'; import { FormGroup, Grid, GridItem, TextInput } from '@patternfly/react-core'; @@ -15,7 +16,6 @@ type VolumeDestinationProps = { applyStorageProfileState: [boolean, Dispatch>]; bootableVolume: AddBootableVolumeState; claimPropertySetsData: UseStorageProfileClaimPropertySetsValue; - namespace: string; setBootableVolumeField: SetBootableVolumeFieldType; }; @@ -23,13 +23,13 @@ const VolumeDestination: FC = ({ applyStorageProfileState, bootableVolume, claimPropertySetsData, - namespace, setBootableVolumeField, }) => { const { t } = useKubevirtTranslation(); const [showSCAlert, setShowSCAlert] = useState(false); - const { bootableVolumeName, size, storageClassName } = bootableVolume || {}; + const { bootableVolumeName, bootableVolumeNamespace, size, storageClassName } = + bootableVolume || {}; const [applyStorageProfile, setApplyStorageProfile] = applyStorageProfileState; @@ -76,7 +76,11 @@ const VolumeDestination: FC = ({ /> - + ); diff --git a/src/utils/components/AddBootableVolumeModal/utils/constants.ts b/src/utils/components/AddBootableVolumeModal/utils/constants.ts index 214771d9f..e94c9f79a 100644 --- a/src/utils/components/AddBootableVolumeModal/utils/constants.ts +++ b/src/utils/components/AddBootableVolumeModal/utils/constants.ts @@ -28,6 +28,7 @@ export const optionsValueLabelMapper = { export type AddBootableVolumeState = { annotations: { [key: string]: string }; bootableVolumeName: string; + bootableVolumeNamespace: string; cronExpression: string; labels: { [key: string]: string }; pvcName: string; @@ -51,6 +52,7 @@ export type SetBootableVolumeFieldType = ( export const initialBootableVolumeState: AddBootableVolumeState = { annotations: {}, bootableVolumeName: null, + bootableVolumeNamespace: null, cronExpression: null, labels: {}, pvcName: null, diff --git a/src/utils/components/AddBootableVolumeModal/utils/utils.ts b/src/utils/components/AddBootableVolumeModal/utils/utils.ts index 848a1570f..0559743ee 100644 --- a/src/utils/components/AddBootableVolumeModal/utils/utils.ts +++ b/src/utils/components/AddBootableVolumeModal/utils/utils.ts @@ -28,7 +28,6 @@ type createBootableVolumeType = (input: { applyStorageProfileSettings: boolean; bootableVolume: AddBootableVolumeState; claimPropertySets: ClaimPropertySets; - namespace: string; onCreateVolume: (createdVolume: BootableVolume) => void; sourceType: DROPDOWN_FORM_SELECTION; uploadData: ({ dataVolume, file }: UploadDataProps) => Promise; @@ -39,19 +38,23 @@ export const createBootableVolume: createBootableVolumeType = applyStorageProfileSettings, bootableVolume, claimPropertySets, - namespace, onCreateVolume, sourceType, uploadData, }) => async (dataSource: V1beta1DataSource) => { - const draftDataSource = setDataSourceMetadata(bootableVolume, namespace, dataSource); + const { bootableVolumeNamespace } = bootableVolume; + const draftDataSource = setDataSourceMetadata( + bootableVolume, + bootableVolumeNamespace, + dataSource, + ); const actionBySourceType: Record Promise> = { [DROPDOWN_FORM_SELECTION.UPLOAD_IMAGE]: () => createBootableVolumeFromUpload( bootableVolume, - namespace, + bootableVolumeNamespace, applyStorageProfileSettings, claimPropertySets, draftDataSource, @@ -60,7 +63,7 @@ export const createBootableVolume: createBootableVolumeType = [DROPDOWN_FORM_SELECTION.USE_EXISTING_PVC]: () => createPVCBootableVolume( bootableVolume, - namespace, + bootableVolumeNamespace, applyStorageProfileSettings, claimPropertySets, draftDataSource, diff --git a/src/utils/components/ProjectDropdown/ProjectDropdown.scss b/src/utils/components/ProjectDropdown/ProjectDropdown.scss new file mode 100644 index 000000000..3cb054f4f --- /dev/null +++ b/src/utils/components/ProjectDropdown/ProjectDropdown.scss @@ -0,0 +1,5 @@ +.project-dropdown { + width: 220px; + padding: 0 var(--pf-global--spacer--sm); + margin-bottom: var(--pf-global--spacer--md); +} diff --git a/src/utils/components/ProjectDropdown/ProjectDropdown.tsx b/src/utils/components/ProjectDropdown/ProjectDropdown.tsx new file mode 100644 index 000000000..65e63168c --- /dev/null +++ b/src/utils/components/ProjectDropdown/ProjectDropdown.tsx @@ -0,0 +1,42 @@ +import React, { FC } from 'react'; + +import { modelToGroupVersionKind, ProjectModel } from '@kubevirt-ui/kubevirt-api/console'; +import InlineFilterSelect from '@kubevirt-utils/components/FilterSelect/InlineFilterSelect'; +import { getProjectOptions } from '@kubevirt-utils/components/ProjectDropdown/utils/utils'; +import { ALL_PROJECTS } from '@kubevirt-utils/hooks/constants'; +import { K8sResourceCommon, useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk'; + +type ProjectDropdownProps = { + includeAllProjects?: boolean; + onChange: (project: string) => void; + selectedProject: string; +}; + +const ProjectDropdown: FC = ({ + includeAllProjects = true, + onChange, + selectedProject, +}) => { + const [projects] = useK8sWatchResource({ + groupVersionKind: modelToGroupVersionKind(ProjectModel), + isList: true, + namespaced: false, + }); + + const onSelect = (value: string) => { + onChange(value === ALL_PROJECTS ? '' : value); + }; + + return ( +
+ +
+ ); +}; + +export default ProjectDropdown; diff --git a/src/utils/components/ProjectDropdown/utils/utils.ts b/src/utils/components/ProjectDropdown/utils/utils.ts new file mode 100644 index 000000000..914780503 --- /dev/null +++ b/src/utils/components/ProjectDropdown/utils/utils.ts @@ -0,0 +1,29 @@ +import { modelToGroupVersionKind, ProjectModel } from '@kubevirt-ui/kubevirt-api/console'; +import { ALL_PROJECTS } from '@kubevirt-utils/hooks/constants'; +import { getName } from '@kubevirt-utils/resources/shared'; +import { K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk'; + +export const getProjectOptions = (includeAllProjects: boolean, projects: K8sResourceCommon[]) => { + const projectOptions = projects + .sort((a, b) => getName(a).localeCompare(getName(b))) + .map((proj) => { + const name = getName(proj); + return { + children: name, + groupVersionKind: modelToGroupVersionKind(ProjectModel), + value: name, + }; + }); + + const allProjects = includeAllProjects + ? [ + { + children: ALL_PROJECTS, + groupVersionKind: modelToGroupVersionKind(ProjectModel), + value: ALL_PROJECTS, + }, + ].concat(projectOptions) + : projectOptions; + + return allProjects; +}; diff --git a/src/utils/hooks/constants.ts b/src/utils/hooks/constants.ts index abe074f9d..9591a4491 100644 --- a/src/utils/hooks/constants.ts +++ b/src/utils/hooks/constants.ts @@ -1,4 +1,5 @@ export const ALL_NAMESPACES_SESSION_KEY = '#ALL_NS#'; export const ALL_NAMESPACES = 'all-namespaces'; +export const ALL_PROJECTS = 'All projects'; export const EVENT_LOCALSTORAGE = 'event_localstorage'; diff --git a/src/utils/resources/bootableresources/helpers.ts b/src/utils/resources/bootableresources/helpers.ts index e240585f5..c914d77a3 100644 --- a/src/utils/resources/bootableresources/helpers.ts +++ b/src/utils/resources/bootableresources/helpers.ts @@ -2,14 +2,16 @@ import { modelToGroupVersionKind, PersistentVolumeClaimModel, } from '@kubevirt-ui/kubevirt-api/console'; -import { DataSourceModelGroupVersionKind } from '@kubevirt-ui/kubevirt-api/console/models/DataSourceModel'; +import DataSourceModel, { + DataSourceModelGroupVersionKind, +} from '@kubevirt-ui/kubevirt-api/console/models/DataSourceModel'; import DataVolumeModel from '@kubevirt-ui/kubevirt-api/console/models/DataVolumeModel'; import { V1beta1DataSource, V1beta1DataVolume, } from '@kubevirt-ui/kubevirt-api/containerized-data-importer/models'; import { IoK8sApiCoreV1PersistentVolumeClaim } from '@kubevirt-ui/kubevirt-api/kubernetes'; -import { isEmpty } from '@kubevirt-utils/utils/utils'; +import { isEmpty, kubevirtConsole } from '@kubevirt-utils/utils/utils'; import { k8sDelete } from '@openshift-console/dynamic-plugin-sdk'; import { BootableVolume } from './types'; @@ -44,8 +46,9 @@ export const getInstanceTypePrefix = (instanceTypeNamePrefix: string): string => return instanceTypeNamePrefix; }; -export const deleteDVAndPVC = async ( +export const deleteDVAndRelatedResources = async ( dataVolume: BootableVolume | V1beta1DataVolume, + dataSource: BootableVolume | V1beta1DataSource, persistentVolumeClaim: BootableVolume | IoK8sApiCoreV1PersistentVolumeClaim, ): Promise => { // We try to delete the created DV, if already GC, we want to fallback to delete the PVC @@ -54,4 +57,11 @@ export const deleteDVAndPVC = async ( } catch { await k8sDelete({ model: PersistentVolumeClaimModel, resource: persistentVolumeClaim }); } + + // A PVC not found error will be thrown if the DV and DS are in the same try block + try { + await k8sDelete({ model: DataSourceModel, resource: dataSource }); + } catch (error) { + kubevirtConsole.log(error); + } }; diff --git a/src/utils/resources/bootableresources/hooks/useBootableVolumes.ts b/src/utils/resources/bootableresources/hooks/useBootableVolumes.ts index 81e147090..eb6e94983 100644 --- a/src/utils/resources/bootableresources/hooks/useBootableVolumes.ts +++ b/src/utils/resources/bootableresources/hooks/useBootableVolumes.ts @@ -11,6 +11,7 @@ import { import { V1beta1DataSource } from '@kubevirt-ui/kubevirt-api/containerized-data-importer/models'; import { IoK8sApiCoreV1PersistentVolumeClaim } from '@kubevirt-ui/kubevirt-api/kubernetes'; import { VolumeSnapshotKind } from '@kubevirt-utils/components/SelectSnapshot/types'; +import { ALL_PROJECTS } from '@kubevirt-utils/hooks/constants'; import { BootableVolume } from '@kubevirt-utils/resources/bootableresources/types'; import { convertResourceArrayToMap, @@ -22,12 +23,14 @@ import { Operator, useK8sWatchResource } from '@openshift-console/dynamic-plugin type UseBootableVolumes = (namespace?: string) => UseBootableVolumesValues; const useBootableVolumes: UseBootableVolumes = (namespace) => { + const projectsNamespace = namespace === ALL_PROJECTS ? null : namespace; + const [dataSources, loadedDataSources, dataSourcesError] = useK8sWatchResource< V1beta1DataSource[] >({ groupVersionKind: DataSourceModelGroupVersionKind, isList: true, - namespace, + namespace: projectsNamespace, selector: { matchExpressions: [{ key: DEFAULT_PREFERENCE_LABEL, operator: Operator.Exists }], }, @@ -39,14 +42,14 @@ const useBootableVolumes: UseBootableVolumes = (namespace) => { >({ groupVersionKind: modelToGroupVersionKind(PersistentVolumeClaimModel), isList: true, - namespace, + namespace: projectsNamespace, }); // getting volumesnapshot as this can also be a source of DS const [volumeSnapshots] = useK8sWatchResource({ groupVersionKind: modelToGroupVersionKind(VolumeSnapshotModel), isList: true, - namespace, + namespace: projectsNamespace, }); const error = useMemo(() => dataSourcesError || loadErrorPVCs, [dataSourcesError, loadErrorPVCs]); diff --git a/src/views/bootablevolumes/actions/hooks/useBootableVolumesActions.tsx b/src/views/bootablevolumes/actions/hooks/useBootableVolumesActions.tsx index a721573a8..ddc411971 100644 --- a/src/views/bootablevolumes/actions/hooks/useBootableVolumesActions.tsx +++ b/src/views/bootablevolumes/actions/hooks/useBootableVolumesActions.tsx @@ -5,7 +5,7 @@ import { V1beta1VirtualMachineClusterPreference } from '@kubevirt-ui/kubevirt-ap import DeleteModal from '@kubevirt-utils/components/DeleteModal/DeleteModal'; import { useModal } from '@kubevirt-utils/components/ModalProvider/ModalProvider'; import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; -import { deleteDVAndPVC } from '@kubevirt-utils/resources/bootableresources/helpers'; +import { deleteDVAndRelatedResources } from '@kubevirt-utils/resources/bootableresources/helpers'; import { asAccessReview } from '@kubevirt-utils/resources/shared'; import { Action, K8sVerb, useAccessReview } from '@openshift-console/dynamic-plugin-sdk'; @@ -63,7 +63,7 @@ const useBootableVolumesActions: BootableVolumesActionsProps = (source, preferen createModal(({ isOpen, onClose }) => ( { - await deleteDVAndPVC(source, source); + await deleteDVAndRelatedResources(source, source, source); }} headerText={t('Delete {{kind}}', { kind: source?.kind })} isOpen={isOpen} diff --git a/src/views/catalog/CreateFromInstanceTypes/components/BootableVolumeList/BootableVolumeList.tsx b/src/views/catalog/CreateFromInstanceTypes/components/BootableVolumeList/BootableVolumeList.tsx index 6f561c092..3aa21cecb 100644 --- a/src/views/catalog/CreateFromInstanceTypes/components/BootableVolumeList/BootableVolumeList.tsx +++ b/src/views/catalog/CreateFromInstanceTypes/components/BootableVolumeList/BootableVolumeList.tsx @@ -4,6 +4,7 @@ import { useInstanceTypeVMStore } from '@catalog/CreateFromInstanceTypes/state/u import { UseBootableVolumesValues } from '@catalog/CreateFromInstanceTypes/state/utils/types'; 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 { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; import { UserSettingFavorites } from '@kubevirt-utils/hooks/useKubevirtUserSettings/utils/types'; import { BootableVolume } from '@kubevirt-utils/resources/bootableresources/types'; @@ -14,7 +15,6 @@ import { FormGroup, Split, SplitItem } from '@patternfly/react-core'; import BootableVolumeEmptyState from '../BootableVolumeEmptyState/BootableVolumeEmptyState'; -import BootableVolumeListNamespaceSelect from './components/BootableVolumeListNamespaceSelect/BootableVolumeListNamespaceSelect'; import BootableVolumeListPagination from './components/BootableVolumeListPagination/BootableVolumeListPagination'; import BootableVolumesPipelinesHint from './components/BootableVolumesPipelinesHint/BootableVolumesPipelinesHint'; import BootableVolumeTable from './components/BootableVolumeTable/BootableVolumeTable'; @@ -43,7 +43,12 @@ const BootableVolumeList: FC = ({ selectedBootableVolumeState, }) => { const { t } = useKubevirtTranslation(); - const { instanceTypeVMState, onSelectCreatedVolume } = useInstanceTypeVMStore(); + const { + instanceTypeVMState, + onSelectCreatedVolume, + setVolumeListNamespace, + volumeListNamespace, + } = useInstanceTypeVMStore(); const { pvcSource, selectedBootableVolume, volumeSnapshotSource } = instanceTypeVMState; const { bootableVolumes, loaded, pvcSources, volumeSnapshotSources } = bootableVolumesData; @@ -96,7 +101,10 @@ const BootableVolumeList: FC = ({ className="bootable-volume-list-bar__volume-namespace" label={t('Volumes project')} > - + diff --git a/src/views/catalog/CreateFromInstanceTypes/components/BootableVolumeList/components/BootableVolumeListNamespaceSelect/BootableVolumeListNamespaceSelect.tsx b/src/views/catalog/CreateFromInstanceTypes/components/BootableVolumeList/components/BootableVolumeListNamespaceSelect/BootableVolumeListNamespaceSelect.tsx deleted file mode 100644 index f48825b9d..000000000 --- a/src/views/catalog/CreateFromInstanceTypes/components/BootableVolumeList/components/BootableVolumeListNamespaceSelect/BootableVolumeListNamespaceSelect.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React, { FC } from 'react'; - -import { useInstanceTypeVMStore } from '@catalog/CreateFromInstanceTypes/state/useInstanceTypeVMStore'; -import { modelToGroupVersionKind, ProjectModel } from '@kubevirt-ui/kubevirt-api/console'; -import InlineFilterSelect from '@kubevirt-utils/components/FilterSelect/InlineFilterSelect'; -import useProjects from '@kubevirt-utils/hooks/useProjects'; - -const BootableVolumeListNamespaceSelect: FC = () => { - const { setVolumeListNamespace, volumeListNamespace } = useInstanceTypeVMStore(); - const [projectNames] = useProjects(); - return ( - ({ - children: name, - groupVersionKind: modelToGroupVersionKind(ProjectModel), - value: name, - }))} - toggleProps={{ - isFullWidth: true, - }} - popperProps={{ enableFlip: true }} - selected={volumeListNamespace} - setSelected={setVolumeListNamespace} - /> - ); -}; - -export default BootableVolumeListNamespaceSelect; diff --git a/src/views/catalog/CreateFromInstanceTypes/state/utils/state.ts b/src/views/catalog/CreateFromInstanceTypes/state/utils/state.ts index 687edb2fc..2f6a08a4c 100644 --- a/src/views/catalog/CreateFromInstanceTypes/state/utils/state.ts +++ b/src/views/catalog/CreateFromInstanceTypes/state/utils/state.ts @@ -1,9 +1,8 @@ -import { getOSImagesNS } from 'src/views/clusteroverview/OverviewTab/inventory-card/utils/utils'; - import { initialSSHCredentials, initialSysprepData, } from '@kubevirt-utils/components/SSHSecretModal/utils/constants'; +import { ALL_PROJECTS } from '@kubevirt-utils/hooks/constants'; import { InstanceTypeVMState, InstanceTypeVMStoreState } from './types'; @@ -26,5 +25,5 @@ export const instanceTypeVMStoreInitialState: InstanceTypeVMStoreState = { startVM: true, vm: null, vmNamespaceTarget: '', - volumeListNamespace: getOSImagesNS(), + volumeListNamespace: ALL_PROJECTS, }; diff --git a/src/views/catalog/templatescatalog/components/TemplatesCatalogProjectsDropdown/TemplatesCatalogProjectsDropdown.tsx b/src/views/catalog/templatescatalog/components/TemplatesCatalogProjectsDropdown/TemplatesCatalogProjectsDropdown.tsx index f124f6016..bb6dbb17f 100644 --- a/src/views/catalog/templatescatalog/components/TemplatesCatalogProjectsDropdown/TemplatesCatalogProjectsDropdown.tsx +++ b/src/views/catalog/templatescatalog/components/TemplatesCatalogProjectsDropdown/TemplatesCatalogProjectsDropdown.tsx @@ -2,6 +2,7 @@ import React, { FC, memo } from 'react'; import { modelToGroupVersionKind, ProjectModel } from '@kubevirt-ui/kubevirt-api/console'; import InlineFilterSelect from '@kubevirt-utils/components/FilterSelect/InlineFilterSelect'; +import { ALL_PROJECTS } from '@kubevirt-utils/hooks/constants'; import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; import { getName } from '@kubevirt-utils/resources/shared'; import { K8sResourceCommon, useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk'; @@ -14,8 +15,6 @@ type TemplatesCatalogProjectsDropdownProps = { selectedProject: string; }; -const ALL_PROJECTS_SELECTOR = 'All projects'; - export const TemplatesCatalogProjectsDropdown: FC = memo( ({ onChange, selectedProject }) => { const { t } = useKubevirtTranslation(); @@ -26,7 +25,7 @@ export const TemplatesCatalogProjectsDropdown: FC { - onChange(value === ALL_PROJECTS_SELECTOR ? '' : value); + onChange(value === ALL_PROJECTS ? '' : value); }; return ( @@ -36,7 +35,7 @@ export const TemplatesCatalogProjectsDropdown: FC getName(a).localeCompare(getName(b))) .map((proj) => { @@ -44,7 +43,7 @@ export const TemplatesCatalogProjectsDropdown: FC diff --git a/src/views/datasources/actions/DeleteDataSourceModal/DeleteDataSourceModal.tsx b/src/views/datasources/actions/DeleteDataSourceModal/DeleteDataSourceModal.tsx index e4860b224..dba6d2782 100644 --- a/src/views/datasources/actions/DeleteDataSourceModal/DeleteDataSourceModal.tsx +++ b/src/views/datasources/actions/DeleteDataSourceModal/DeleteDataSourceModal.tsx @@ -10,7 +10,7 @@ import { import ConfirmActionMessage from '@kubevirt-utils/components/ConfirmActionMessage/ConfirmActionMessage'; import TabModal from '@kubevirt-utils/components/TabModal/TabModal'; import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; -import { deleteDVAndPVC } from '@kubevirt-utils/resources/bootableresources/helpers'; +import { deleteDVAndRelatedResources } from '@kubevirt-utils/resources/bootableresources/helpers'; import { getName, getNamespace } from '@kubevirt-utils/resources/shared'; import { kubevirtConsole } from '@kubevirt-utils/utils/utils'; import { k8sDelete } from '@openshift-console/dynamic-plugin-sdk'; @@ -52,7 +52,7 @@ const DeleteDataSourceModal: FC = ({ } if (deletePVC && sourceExists) { - await deleteDVAndPVC(dv, pvc); + await deleteDVAndRelatedResources(dv, dataSource, pvc); } };