1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B OpenNebula/one#6739: Fix VM restore disk selection (#3248)

* Correctly displays the VM disks when restoring a backup from the VM
  action menu

Signed-off-by: Victor Hansson <vhansson@opennebula.io>
(cherry picked from commit 8f0d20580e6c56d768f5d1ec7fde0bea9e7c1dec)
This commit is contained in:
vichansson 2024-09-27 14:19:04 +03:00 committed by Tino Vázquez
parent 93459a9497
commit 3d337d9ff5
No known key found for this signature in database
GPG Key ID: 14201E424D02047E

View File

@ -21,11 +21,20 @@ import { SCHEMA } from 'client/components/Forms/Backup/RestoreForm/Steps/VmDisks
import { Step } from 'client/utils'
import { T } from 'client/constants'
import { STEP_ID as IMAGE_STEP_ID } from 'client/components/Forms/Backup/RestoreForm/Steps/BackupsTable'
export const STEP_ID = 'vmdisk'
const Content = ({ data, app: { backupDiskIds = [], vmsId = [] } = {} }) => {
const { setValue } = useFormContext()
const { setValue, getValues } = useFormContext()
const BACKUP_IMAGE = getValues(IMAGE_STEP_ID)?.[0]
const BACKUP_IMAGE_DISK_IDS = BACKUP_IMAGE?.BACKUP_DISK_IDS?.ID
const getValidArray = (arr) =>
Array.isArray(arr) && arr?.length > 0 ? arr : false
const formatBackupDiskIds =
getValidArray(backupDiskIds) || getValidArray(BACKUP_IMAGE_DISK_IDS) || []
const selectedRow = data?.[0]
const handleSelectedRows = (rows) => {
@ -51,7 +60,7 @@ const Content = ({ data, app: { backupDiskIds = [], vmsId = [] } = {} }) => {
filter={(disks) =>
disks &&
disks?.length > 0 &&
disks?.filter((disk) => backupDiskIds?.includes(disk?.DISK_ID))
disks?.filter((disk) => formatBackupDiskIds?.includes(disk?.DISK_ID))
}
/>
)