Skip to content

Commit

Permalink
M #-: fix vm cache validation (#3184)
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Hansson <vhansson@opennebula.io>
Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
  • Loading branch information
vichansson and tinova authored Aug 1, 2024
1 parent 4cb89d8 commit aed1993
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { DatastoresTable } from 'client/components/Tables'
import { SCHEMA } from 'client/components/Forms/Vm/BackupForm/Steps/DatastoresTable/schema'

import { Step } from 'client/utils'
import { T } from 'client/constants'
import { T, VM_EXTENDED_POOL } from 'client/constants'

export const STEP_ID = 'datastore'

Expand Down Expand Up @@ -66,7 +66,7 @@ const DatastoreStep = (app) => ({
resolver: SCHEMA,
defaultDisabled: {
statePaths: [
'oneApi.queries.getVms(undefined).data',
`oneApi.queries.getVms({"extended":${VM_EXTENDED_POOL}}).data`,
'general.selectedIds',
],
condition: (vmsData, selectedIds) =>
Expand Down
13 changes: 8 additions & 5 deletions src/fireedge/src/client/components/Tables/Vms/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { memo, useCallback, useMemo } from 'react'

import { ConsoleButton } from 'client/components/Buttons'
import { VirtualMachineCard } from 'client/components/Cards'
import { VM_ACTIONS } from 'client/constants'
import { VM_ACTIONS, VM_EXTENDED_POOL } from 'client/constants'
import { useGeneral } from 'client/features/General'
import vmApi, { useUpdateUserTemplateMutation } from 'client/features/OneApi/vm'
import { jsonToXml } from 'client/models/Helper'
Expand All @@ -33,10 +33,13 @@ const Row = memo(

const [update] = useUpdateUserTemplateMutation()

const state = vmApi.endpoints.getVms.useQueryState(undefined, {
selectFromResult: ({ data = [] }) =>
data.find((vm) => +vm.ID === +original.ID),
})
const state = vmApi.endpoints.getVms.useQueryState(
{ extended: VM_EXTENDED_POOL },
{
selectFromResult: ({ data = [] }) =>
data.find((vm) => +vm.ID === +original.ID),
}
)

const memoVm = useMemo(() => state ?? original, [state, original])

Expand Down
Loading

0 comments on commit aed1993

Please sign in to comment.