diff --git a/src/fireedge/src/client/components/FormControl/InformationUnitController.js b/src/fireedge/src/client/components/FormControl/InformationUnitController.js index 3f141cbe08..6d3f472727 100644 --- a/src/fireedge/src/client/components/FormControl/InformationUnitController.js +++ b/src/fireedge/src/client/components/FormControl/InformationUnitController.js @@ -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) => ( - ))} diff --git a/src/fireedge/src/client/components/Tables/Datastores/row.js b/src/fireedge/src/client/components/Tables/Datastores/row.js index 6f37bb3ea5..32b8650b15 100644 --- a/src/fireedge/src/client/components/Tables/Datastores/row.js +++ b/src/fireedge/src/client/components/Tables/Datastores/row.js @@ -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 ( { const classes = rowStyles() const { id: ID, - NAME, + name: NAME, UNAME, GNAME, REGTIME, diff --git a/src/fireedge/src/client/features/OneApi/cluster.js b/src/fireedge/src/client/features/OneApi/cluster.js index 0e8f9bcaf5..87085007aa 100644 --- a/src/fireedge/src/client/features/OneApi/cluster.js +++ b/src/fireedge/src/client/features/OneApi/cluster.js @@ -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({ /** diff --git a/src/fireedge/src/client/features/OneApi/datastore.js b/src/fireedge/src/client/features/OneApi/datastore.js index 40ff703b03..58845a9cb1 100644 --- a/src/fireedge/src/client/features/OneApi/datastore.js +++ b/src/fireedge/src/client/features/OneApi/datastore.js @@ -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(