-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1581 from upalatucci/create-volume-snapshot
CNV-33095: add volumesnapshot option in the add bootable volume modal
- Loading branch information
Showing
18 changed files
with
545 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/utils/components/AddBootableVolumeModal/components/VolumeSource/components/PVCSource.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, { FC } from 'react'; | ||
import xbytes from 'xbytes'; | ||
|
||
import { | ||
AddBootableVolumeState, | ||
SetBootableVolumeFieldType, | ||
} from '@kubevirt-utils/components/AddBootableVolumeModal/utils/constants'; | ||
import { removeByteSuffix } from '@kubevirt-utils/components/CapacityInput/utils'; | ||
import DiskSourcePVCSelect from '@kubevirt-utils/components/DiskModal/DiskFormFields/DiskSourceFormSelect/components/DiskSourcePVCSelect'; | ||
import HelpTextIcon from '@kubevirt-utils/components/HelpTextIcon/HelpTextIcon'; | ||
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; | ||
import { hasSizeUnit } from '@kubevirt-utils/resources/vm/utils/disk/size'; | ||
import { Checkbox, PopoverPosition, Split, SplitItem } from '@patternfly/react-core'; | ||
|
||
type PVCSourceProps = { | ||
bootableVolume: AddBootableVolumeState; | ||
setBootableVolumeField: SetBootableVolumeFieldType; | ||
}; | ||
|
||
const PVCSource: FC<PVCSourceProps> = ({ bootableVolume, setBootableVolumeField }) => { | ||
const { t } = useKubevirtTranslation(); | ||
const { pvcName, pvcNamespace } = bootableVolume || {}; | ||
|
||
return ( | ||
<> | ||
<DiskSourcePVCSelect | ||
setDiskSize={(newSize) => | ||
setBootableVolumeField('size')( | ||
hasSizeUnit(newSize) | ||
? removeByteSuffix(newSize) | ||
: removeByteSuffix(xbytes(Number(newSize), { iec: true, space: false })), | ||
) | ||
} | ||
pvcNameSelected={pvcName} | ||
pvcNamespaceSelected={pvcNamespace} | ||
selectPVCName={setBootableVolumeField('pvcName')} | ||
selectPVCNamespace={setBootableVolumeField('pvcNamespace')} | ||
/> | ||
<Split hasGutter> | ||
<SplitItem> | ||
<Checkbox id="clone-pvc-checkbox" isChecked isDisabled label={t('Clone existing PVC')} /> | ||
</SplitItem> | ||
<SplitItem> | ||
<HelpTextIcon | ||
bodyContent={t('This will create a cloned copy of the PVC in the destination project.')} | ||
position={PopoverPosition.right} | ||
/> | ||
</SplitItem> | ||
</Split> | ||
</> | ||
); | ||
}; | ||
|
||
export default PVCSource; |
26 changes: 26 additions & 0 deletions
26
...s/components/AddBootableVolumeModal/components/VolumeSource/components/SnapshotSource.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { | ||
AddBootableVolumeState, | ||
SetBootableVolumeFieldType, | ||
} from '@kubevirt-utils/components/AddBootableVolumeModal/utils/constants'; | ||
import SelectSnapshot from '@kubevirt-utils/components/SelectSnapshot/SelectSnapshot'; | ||
|
||
type SnapshotSourceProps = { | ||
bootableVolume: AddBootableVolumeState; | ||
setBootableVolumeField: SetBootableVolumeFieldType; | ||
}; | ||
|
||
const SnapshotSource: FC<SnapshotSourceProps> = ({ bootableVolume, setBootableVolumeField }) => { | ||
const { snapshotName, snapshotNamespace } = bootableVolume || {}; | ||
return ( | ||
<SelectSnapshot | ||
selectSnapshotName={setBootableVolumeField('snapshotName')} | ||
selectSnapshotNamespace={setBootableVolumeField('snapshotNamespace')} | ||
snapshotNameSelected={snapshotName} | ||
snapshotNamespaceSelected={snapshotNamespace} | ||
/> | ||
); | ||
}; | ||
|
||
export default SnapshotSource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.