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

B OpenNebula/One#6362: General bug fixes (#2851)

This commit is contained in:
vichansson 2023-12-01 12:07:30 +02:00 committed by GitHub
parent 3fa1eb58b8
commit 63bc3e5c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 36 deletions

View File

@ -139,12 +139,17 @@ const InformationUnitController = memo(
value={unit}
InputProps={{
readOnly,
'data-cy': `${cy}-unit`,
}}
label={Tr(T.MemoryUnit)}
onChange={(e) => handleChange('unit', e.target.value)}
>
{ARRAY_UNITS.map((option, index) => (
<option key={`${option}-${index}`} value={option}>
<option
key={`${option}-${index}`}
value={option}
data-cy={`${cy}-unit-${option}`}
>
{option}
</option>
))}

View File

@ -16,7 +16,8 @@
import { memo, useCallback, useMemo } from 'react'
import PropTypes from 'prop-types'
import datastoreApi, {
import {
useGetDatastoresQuery,
useUpdateDatastoreMutation,
} from 'client/features/OneApi/datastore'
import { DatastoreCard } from 'client/components/Cards'
@ -24,22 +25,15 @@ import { jsonToXml } from 'client/models/Helper'
const Row = memo(
({ original, onClickLabel, ...props }) => {
const { data: datastores } = useGetDatastoresQuery(undefined)
const selectedDatastore = datastores?.find(
(datastore) => +datastore.ID === +original.ID
)
const [update] = useUpdateDatastoreMutation()
const {
data: datastores,
error,
isLoading,
} = datastoreApi.endpoints.getDatastores.useQuery(undefined)
const datastore = useMemo(
() => datastores?.find((ds) => +ds.ID === +original.ID) ?? original,
[datastores, original]
)
const memoDs = useMemo(
() => datastore ?? original,
[datastore, original, update, isLoading, error, datastores]
() => selectedDatastore ?? original,
[datastores, original]
)
const handleDeleteLabel = useCallback(
@ -56,7 +50,7 @@ const Row = memo(
return (
<DatastoreCard
datastore={memoDs}
datastore={memoDs ?? original}
onClickLabel={onClickLabel}
onDeleteLabel={handleDeleteLabel}
rootProps={props}

View File

@ -48,7 +48,7 @@ const Row = ({ original, value, onClickLabel, ...props }) => {
const classes = rowStyles()
const {
id: ID,
NAME,
name: NAME,
UNAME,
GNAME,
REGTIME,

View File

@ -26,8 +26,8 @@ import {
} from 'client/features/OneApi'
import { Cluster } from 'client/constants'
const { CLUSTER, HOST } = ONE_RESOURCES
const { CLUSTER_POOL, HOST_POOL } = ONE_RESOURCES_POOL
const { CLUSTER, HOST, DATASTORE } = ONE_RESOURCES
const { CLUSTER_POOL, HOST_POOL, DATASTORE_POOL } = ONE_RESOURCES_POOL
const clusterApi = oneApi.injectEndpoints({
endpoints: (builder) => ({
@ -223,7 +223,12 @@ const clusterApi = oneApi.injectEndpoints({
return { params, command }
},
invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER_POOL],
invalidatesTags: (_, __, { id, datastore }) => [
{ type: CLUSTER, id },
CLUSTER_POOL,
DATASTORE_POOL,
{ type: DATASTORE, id: datastore },
],
}),
removeDatastoreFromCluster: builder.mutation({
/**
@ -241,7 +246,12 @@ const clusterApi = oneApi.injectEndpoints({
return { params, command }
},
invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER_POOL],
invalidatesTags: (_, __, { id, datastore }) => [
{ type: CLUSTER, id },
CLUSTER_POOL,
DATASTORE_POOL,
{ type: DATASTORE, id: datastore },
],
}),
addNetworkToCluster: builder.mutation({
/**

View File

@ -35,14 +35,6 @@ const { DATASTORE_POOL } = ONE_RESOURCES_POOL
const datastoreApi = oneApi.injectEndpoints({
endpoints: (builder) => ({
getDatastores: builder.query({
/**
* Retrieves information for all or part of the datastores in the pool.
*
* @param {object} params - Request params
* @param {string} [params.zone] - Zone from where to get the resources
* @returns {Datastore[]} List of datastores
* @throws Fails when response isn't code 200
*/
query: (params) => {
const name = Actions.DATASTORE_POOL_INFO
const command = { name, ...Commands[name] }
@ -51,8 +43,8 @@ const datastoreApi = oneApi.injectEndpoints({
},
transformResponse: (data) =>
[data?.DATASTORE_POOL?.DATASTORE ?? []].flat(),
providesTags: (datastores) =>
datastores
providesTags: (datastores) => {
const tags = datastores
? [
...datastores.map(({ ID }) => ({
type: DATASTORE_POOL,
@ -60,7 +52,10 @@ const datastoreApi = oneApi.injectEndpoints({
})),
DATASTORE_POOL,
]
: [DATASTORE_POOL],
: [DATASTORE_POOL]
return tags
},
}),
getDatastore: builder.query({
/**
@ -158,10 +153,7 @@ const datastoreApi = oneApi.injectEndpoints({
return { params, command }
},
invalidatesTags: (_, __, { id }) => [
{ type: DATASTORE, id },
{ type: DATASTORE_POOL, id },
],
invalidatesTags: (_, __, { id }) => [{ type: DATASTORE, id }],
async onQueryStarted(params, { dispatch, queryFulfilled }) {
try {
const patchDatastore = dispatch(