Skip to content

Commit

Permalink
Merge pull request kubevirt-ui#2185 from upalatucci/add-storage-other…
Browse files Browse the repository at this point in the history
…disk

CNV-44913 missing storage settings on other disk modal
  • Loading branch information
openshift-merge-bot[bot] authored Sep 19, 2024
2 parents c0adc9f + d31fea6 commit 49db145
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/utils/components/DiskModal/OtherDiskModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import DiskInterfaceSelect from './components/DiskInterfaceSelect/DiskInterfaceS
import DiskNameInput from './components/DiskNameInput/DiskNameInput';
import DiskTypeSelect from './components/DiskTypeSelect/DiskTypeSelect';
import PendingChanges from './components/PendingChanges';
import StorageClassAndPreallocation from './components/StorageClassAndPreallocation/StorageClassAndPreallocation';
import { getDefaultCreateValues, getDefaultEditValues } from './utils/form';
import { diskModalTitle } from './utils/helpers';
import { diskModalTitle, doesDataVolumeTemplateHaveDisk } from './utils/helpers';
import { submit } from './utils/submit';
import { SourceTypes, V1DiskFormState, V1DiskModalProps } from './utils/types';

Expand Down Expand Up @@ -50,6 +51,9 @@ const OtherDiskModal: FC<V1DiskModalProps> = ({ editDiskName, isOpen, onClose, o
<DiskNameInput />
<DiskTypeSelect isVMRunning={isVMRunning} />
<DiskInterfaceSelect isVMRunning={isVMRunning} />
{doesDataVolumeTemplateHaveDisk(vm, editDiskName) && (
<StorageClassAndPreallocation vm={vm} />
)}
<AdvancedSettings />
</Form>
</TabModal>
Expand Down
11 changes: 10 additions & 1 deletion src/utils/components/DiskModal/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { ANNOTATIONS } from '@kubevirt-utils/resources/template';
import { getBootDisk, getDataVolumeTemplates, getVolumes } from '@kubevirt-utils/resources/vm';
import { getOperatingSystem } from '@kubevirt-utils/resources/vm/utils/operation-system/operationSystem';
import { ensurePath } from '@kubevirt-utils/utils/utils';
import { ensurePath, isEmpty } from '@kubevirt-utils/utils/utils';
import { k8sCreate } from '@openshift-console/dynamic-plugin-sdk';
import { addPersistentVolume, removeVolume } from '@virtualmachines/actions/actions';

Expand Down Expand Up @@ -229,3 +229,12 @@ export const diskModalTitle = (isEditDisk: boolean, isVMRunning: boolean) => {

export const getOS = (vm: V1VirtualMachine) =>
getAnnotation(vm?.spec?.template, ANNOTATIONS.os) || getOperatingSystem(vm);

export const doesDataVolumeTemplateHaveDisk = (vm: V1VirtualMachine, diskName: string) => {
const diskVolume = getVolumes(vm)?.find((volume) => volume.name === diskName);
const dataVolumeTemplate = getDataVolumeTemplates(vm)?.find(
(dv) => getName(dv) === diskVolume?.dataVolume?.name,
);

return !isEmpty(dataVolumeTemplate);
};
2 changes: 1 addition & 1 deletion src/utils/resources/vm/utils/disk/rowData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const getDiskRowDataLayout = (
namespace: device?.pvc?.metadata?.namespace,
size: NO_DATA_DASH,
source: OTHER,
storageClass: NO_DATA_DASH,
storageClass: device?.dataVolumeTemplate?.spec?.storage?.storageClassName || NO_DATA_DASH,
};

const pvcSize = device?.pvc?.spec?.resources?.requests?.storage;
Expand Down

0 comments on commit 49db145

Please sign in to comment.