diff --git a/src/fireedge/src/client/features/OneApi/cluster.js b/src/fireedge/src/client/features/OneApi/cluster.js index 827c877461..2648902e11 100644 --- a/src/fireedge/src/client/features/OneApi/cluster.js +++ b/src/fireedge/src/client/features/OneApi/cluster.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/cluster' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { Cluster } from 'client/constants' const { CLUSTER } = ONE_RESOURCES +const { CLUSTER_POOL } = ONE_RESOURCES_POOL const clusterApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -35,7 +40,16 @@ const clusterApi = oneApi.injectEndpoints({ return { command } }, transformResponse: (data) => [data?.CLUSTER_POOL?.CLUSTER ?? []].flat(), - providesTags: [CLUSTER], + providesTags: (clusters) => + clusters + ? [ + ...clusters.map(({ ID }) => ({ + type: CLUSTER_POOL, + id: `${ID}`, + })), + CLUSTER_POOL, + ] + : [CLUSTER_POOL], }), getCluster: builder.query({ /** @@ -87,7 +101,7 @@ const clusterApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [CLUSTER], + invalidatesTags: [CLUSTER_POOL], }), removeCluster: builder.mutation({ /** @@ -103,7 +117,7 @@ const clusterApi = oneApi.injectEndpoints({ return { params: { id }, command } }, - invalidatesTags: [CLUSTER], + invalidatesTags: [CLUSTER_POOL], }), updateCluster: builder.mutation({ /** @@ -143,7 +157,7 @@ const clusterApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }], + invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER_POOL], }), removeHostFromCluster: builder.mutation({ /** @@ -161,7 +175,7 @@ const clusterApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }], + invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER_POOL], }), addDatastoreToCluster: builder.mutation({ /** @@ -179,7 +193,7 @@ const clusterApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }], + invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER_POOL], }), removeDatastoreFromCluster: builder.mutation({ /** @@ -197,7 +211,7 @@ const clusterApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }], + invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER_POOL], }), addNetworkToCluster: builder.mutation({ /** @@ -215,7 +229,7 @@ const clusterApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }], + invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER_POOL], }), removeNetworkFromCluster: builder.mutation({ /** @@ -233,7 +247,7 @@ const clusterApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }], + invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER_POOL], }), renameCluster: builder.mutation({ /** @@ -251,7 +265,7 @@ const clusterApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER], + invalidatesTags: (_, __, { id }) => [{ type: CLUSTER, id }, CLUSTER_POOL], }), }), }) diff --git a/src/fireedge/src/client/features/OneApi/datastore.js b/src/fireedge/src/client/features/OneApi/datastore.js index 9476b65905..d6e8dbd94e 100644 --- a/src/fireedge/src/client/features/OneApi/datastore.js +++ b/src/fireedge/src/client/features/OneApi/datastore.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/datastore' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { Permission, Datastore } from 'client/constants' const { DATASTORE } = ONE_RESOURCES +const { DATASTORE_POOL } = ONE_RESOURCES_POOL const datastoreApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -36,7 +41,16 @@ const datastoreApi = oneApi.injectEndpoints({ }, transformResponse: (data) => [data?.DATASTORE_POOL?.DATASTORE ?? []].flat(), - providesTags: [DATASTORE], + providesTags: (datastores) => + datastores + ? [ + ...datastores.map(({ ID }) => ({ + type: DATASTORE_POOL, + id: `${ID}`, + })), + DATASTORE_POOL, + ] + : [DATASTORE_POOL], }), getDatastore: builder.query({ /** @@ -73,7 +87,7 @@ const datastoreApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [DATASTORE], + invalidatesTags: [DATASTORE_POOL], }), removeDatastore: builder.mutation({ /** @@ -89,7 +103,7 @@ const datastoreApi = oneApi.injectEndpoints({ return { params: { id }, command } }, - invalidatesTags: [DATASTORE], + invalidatesTags: [DATASTORE_POOL], }), updateDatastore: builder.mutation({ /** @@ -158,7 +172,10 @@ const datastoreApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: DATASTORE, id }, DATASTORE], + invalidatesTags: (_, __, { id }) => [ + { type: DATASTORE, id }, + DATASTORE_POOL, + ], }), renameDatastore: builder.mutation({ /** @@ -176,7 +193,10 @@ const datastoreApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: DATASTORE, id }, DATASTORE], + invalidatesTags: (_, __, { id }) => [ + { type: DATASTORE, id }, + DATASTORE_POOL, + ], }), enableDatastore: builder.mutation({ /** @@ -192,7 +212,7 @@ const datastoreApi = oneApi.injectEndpoints({ return { params: { id, enable: true }, command } }, - invalidatesTags: (_, __, id) => [{ type: DATASTORE, id }, DATASTORE], + invalidatesTags: (_, __, id) => [{ type: DATASTORE, id }, DATASTORE_POOL], }), disableDatastore: builder.mutation({ /** @@ -208,7 +228,7 @@ const datastoreApi = oneApi.injectEndpoints({ return { params: { id, enable: false }, command } }, - invalidatesTags: (_, __, id) => [{ type: DATASTORE, id }, DATASTORE], + invalidatesTags: (_, __, id) => [{ type: DATASTORE, id }, DATASTORE_POOL], }), }), }) diff --git a/src/fireedge/src/client/features/OneApi/group.js b/src/fireedge/src/client/features/OneApi/group.js index c2089a5a92..379bb8b7b9 100644 --- a/src/fireedge/src/client/features/OneApi/group.js +++ b/src/fireedge/src/client/features/OneApi/group.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/group' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { Group } from 'client/constants' const { GROUP } = ONE_RESOURCES +const { GROUP_POOL } = ONE_RESOURCES_POOL const groupApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -35,7 +40,13 @@ const groupApi = oneApi.injectEndpoints({ return { command } }, transformResponse: (data) => [data?.GROUP_POOL?.GROUP ?? []].flat(), - providesTags: [GROUP], + providesTags: (groups) => + groups + ? [ + ...groups.map(({ ID }) => ({ type: GROUP_POOL, id: `${ID}` })), + GROUP_POOL, + ] + : [GROUP_POOL], }), getGroup: builder.query({ /** @@ -69,7 +80,7 @@ const groupApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [GROUP], + invalidatesTags: [GROUP_POOL], }), updateGroup: builder.mutation({ /** @@ -108,7 +119,7 @@ const groupApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [GROUP], + invalidatesTags: [GROUP_POOL], }), addAdminToGroup: builder.mutation({ /** diff --git a/src/fireedge/src/client/features/OneApi/host.js b/src/fireedge/src/client/features/OneApi/host.js index e7be460324..f6ab5d7b41 100644 --- a/src/fireedge/src/client/features/OneApi/host.js +++ b/src/fireedge/src/client/features/OneApi/host.js @@ -14,11 +14,16 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/host' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { UpdateFromSocket } from 'client/features/OneApi/socket' import { Host } from 'client/constants' const { HOST } = ONE_RESOURCES +const { HOST_POOL } = ONE_RESOURCES_POOL const hostApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -36,7 +41,13 @@ const hostApi = oneApi.injectEndpoints({ return { command } }, transformResponse: (data) => [data?.HOST_POOL?.HOST ?? []].flat(), - providesTags: [HOST], + providesTags: (hosts) => + hosts + ? [ + ...hosts.map(({ ID }) => ({ type: HOST_POOL, id: `${ID}` })), + HOST_POOL, + ] + : [HOST_POOL], }), getHost: builder.query({ /** @@ -94,7 +105,7 @@ const hostApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [HOST], + invalidatesTags: [HOST_POOL], }), updateHost: builder.mutation({ /** @@ -133,7 +144,7 @@ const hostApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [HOST], + invalidatesTags: [HOST_POOL], }), enableHost: builder.mutation({ /** @@ -149,7 +160,7 @@ const hostApi = oneApi.injectEndpoints({ return { params: { id, status: 0 }, command } }, - invalidatesTags: (_, __, id) => [{ type: HOST, id }, HOST], + invalidatesTags: (_, __, id) => [{ type: HOST, id }, HOST_POOL], }), disableHost: builder.mutation({ /** @@ -165,7 +176,7 @@ const hostApi = oneApi.injectEndpoints({ return { params: { id, status: 1 }, command } }, - invalidatesTags: (_, __, id) => [{ type: HOST, id }, HOST], + invalidatesTags: (_, __, id) => [{ type: HOST, id }, HOST_POOL], }), offlineHost: builder.mutation({ /** @@ -181,7 +192,7 @@ const hostApi = oneApi.injectEndpoints({ return { params: { id, status: 2 }, command } }, - invalidatesTags: (_, __, id) => [{ type: HOST, id }, HOST], + invalidatesTags: (_, __, id) => [{ type: HOST, id }, HOST_POOL], }), renameHost: builder.mutation({ /** diff --git a/src/fireedge/src/client/features/OneApi/image.js b/src/fireedge/src/client/features/OneApi/image.js index af4d4354ba..3b3dde9c15 100644 --- a/src/fireedge/src/client/features/OneApi/image.js +++ b/src/fireedge/src/client/features/OneApi/image.js @@ -14,7 +14,11 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/image' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { UpdateFromSocket } from 'client/features/OneApi/socket' import { FilterFlag, @@ -24,6 +28,7 @@ import { } from 'client/constants' const { IMAGE } = ONE_RESOURCES +const { IMAGE_POOL } = ONE_RESOURCES_POOL const imageApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -45,7 +50,13 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, transformResponse: (data) => [data?.IMAGE_POOL?.IMAGE ?? []].flat(), - providesTags: [IMAGE], + providesTags: (images) => + images + ? [ + ...images.map(({ ID }) => ({ type: IMAGE_POOL, id: `${ID}` })), + IMAGE_POOL, + ] + : [IMAGE_POOL], }), getImage: builder.query({ /** @@ -89,7 +100,7 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [IMAGE], + invalidatesTags: [IMAGE_POOL], }), cloneImage: builder.mutation({ /** @@ -108,7 +119,7 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [IMAGE], + invalidatesTags: [IMAGE_POOL], }), removeImage: builder.mutation({ /** @@ -125,7 +136,7 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [IMAGE], + invalidatesTags: [IMAGE_POOL], }), enableImage: builder.mutation({ /** @@ -141,7 +152,7 @@ const imageApi = oneApi.injectEndpoints({ return { params: { id, enable: true }, command } }, - invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE], + invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE_POOL], }), disableImage: builder.mutation({ /** @@ -157,7 +168,7 @@ const imageApi = oneApi.injectEndpoints({ return { params: { id, enable: false }, command } }, - invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE], + invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE_POOL], }), persistentImage: builder.mutation({ /** @@ -175,7 +186,7 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE], + invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE_POOL], }), changeImageType: builder.mutation({ /** @@ -193,7 +204,7 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE], + invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE_POOL], }), updateImage: builder.mutation({ /** @@ -258,7 +269,7 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: IMAGE, id }, IMAGE], + invalidatesTags: (_, __, { id }) => [{ type: IMAGE, id }, IMAGE_POOL], }), renameImage: builder.mutation({ /** @@ -276,7 +287,7 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: IMAGE, id }, IMAGE], + invalidatesTags: (_, __, { id }) => [{ type: IMAGE, id }, IMAGE_POOL], }), deleteImageSnapshot: builder.mutation({ /** @@ -352,7 +363,7 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: IMAGE, id }, IMAGE], + invalidatesTags: (_, __, { id }) => [{ type: IMAGE, id }, IMAGE_POOL], }), unlockImage: builder.mutation({ /** @@ -369,7 +380,7 @@ const imageApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE], + invalidatesTags: (_, __, id) => [{ type: IMAGE, id }, IMAGE_POOL], }), }), }) diff --git a/src/fireedge/src/client/features/OneApi/index.js b/src/fireedge/src/client/features/OneApi/index.js index 24bd035024..b6f26edda4 100644 --- a/src/fireedge/src/client/features/OneApi/index.js +++ b/src/fireedge/src/client/features/OneApi/index.js @@ -45,23 +45,37 @@ const ONE_RESOURCES = { ZONE: 'Zone', } +const ONE_RESOURCES_POOL = Object.entries(ONE_RESOURCES).reduce( + (pools, [key, value]) => ({ ...pools, [`${key}_POOL`]: `${value}_POOL` }), + {} +) + const DOCUMENT = { SERVICE: 'applicationService', SERVICE_TEMPLATE: 'applicationServiceTemplate', PROVISION: 'provision', - PROVISION_TEMPLATE: 'provisionTemplate', PROVIDER: 'provider', +} + +const DOCUMENT_POOL = Object.entries(DOCUMENT).reduce( + (pools, [key, value]) => ({ ...pools, [`${key}_POOL`]: `${value}_POOL` }), + {} +) + +const PROVISION_CONFIG = { + PROVISION_DEFAULTS: 'provisionDefaults', PROVIDER_CONFIG: 'providerConfig', - PROVISION_RESOURCES: { - CLUSTER: 'provisionCluster', - DATASTORE: 'provisionDatastore', - HOST: 'provisionHost', - TEMPLATE: 'provisionVmTemplate', - IMAGE: 'provisionImage', - NETWORK: 'provisionVNetwork', - VNTEMPLATE: 'provisionNetworkTemplate', - FLOWTEMPLATE: 'provisionFlowTemplate', - }, +} + +const PROVISION_RESOURCES = { + CLUSTER: 'provisionCluster', + DATASTORE: 'provisionDatastore', + HOST: 'provisionHost', + TEMPLATE: 'provisionVmTemplate', + IMAGE: 'provisionImage', + NETWORK: 'provisionVNetwork', + VNTEMPLATE: 'provisionNetworkTemplate', + FLOWTEMPLATE: 'provisionFlowTemplate', } const oneApi = createApi({ @@ -99,15 +113,21 @@ const oneApi = createApi({ refetchOnMountOrArgChange: 30, tagTypes: [ ...Object.values(ONE_RESOURCES), - DOCUMENT.SERVICE, - DOCUMENT.SERVICE_TEMPLATE, - DOCUMENT.PROVISION, - DOCUMENT.PROVISION_TEMPLATE, - DOCUMENT.PROVIDER, - DOCUMENT.PROVIDER_CONFIG, - ...Object.values(DOCUMENT.PROVISION_RESOURCES), + ...Object.values(ONE_RESOURCES_POOL), + ...Object.values(DOCUMENT), + ...Object.values(DOCUMENT_POOL), + ...Object.values(PROVISION_CONFIG), + ...Object.values(PROVISION_RESOURCES), ], endpoints: () => ({}), }) -export { oneApi, ONE_RESOURCES, DOCUMENT } +export { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, + DOCUMENT, + DOCUMENT_POOL, + PROVISION_CONFIG, + PROVISION_RESOURCES, +} diff --git a/src/fireedge/src/client/features/OneApi/marketplace.js b/src/fireedge/src/client/features/OneApi/marketplace.js index 94b9d192c2..83602775b2 100644 --- a/src/fireedge/src/client/features/OneApi/marketplace.js +++ b/src/fireedge/src/client/features/OneApi/marketplace.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/market' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { Permission, Marketplace } from 'client/constants' const { MARKETPLACE } = ONE_RESOURCES +const { MARKETPLACE_POOL } = ONE_RESOURCES_POOL const marketplaceApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -36,7 +41,16 @@ const marketplaceApi = oneApi.injectEndpoints({ }, transformResponse: (data) => [data?.MARKETPLACE_POOL?.MARKETPLACE ?? []].flat(), - providesTags: [MARKETPLACE], + providesTags: (marketplaces) => + marketplaces + ? [ + ...marketplaces.map(({ ID }) => ({ + type: MARKETPLACE_POOL, + id: `${ID}`, + })), + MARKETPLACE_POOL, + ] + : [MARKETPLACE_POOL], }), getMarketplace: builder.query({ /** @@ -72,7 +86,7 @@ const marketplaceApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [MARKETPLACE], + invalidatesTags: [MARKETPLACE_POOL], }), removeMarketplace: builder.mutation({ /** @@ -89,7 +103,7 @@ const marketplaceApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [MARKETPLACE], + invalidatesTags: [MARKETPLACE_POOL], }), updateMarketplace: builder.mutation({ /** @@ -160,7 +174,7 @@ const marketplaceApi = oneApi.injectEndpoints({ }, invalidatesTags: (_, __, { id }) => [ { type: MARKETPLACE, id }, - MARKETPLACE, + MARKETPLACE_POOL, ], }), renameMarketplace: builder.mutation({ @@ -181,7 +195,7 @@ const marketplaceApi = oneApi.injectEndpoints({ }, invalidatesTags: (_, __, { id }) => [ { type: MARKETPLACE, id }, - MARKETPLACE, + MARKETPLACE_POOL, ], }), enableMarketplace: builder.mutation({ @@ -199,7 +213,10 @@ const marketplaceApi = oneApi.injectEndpoints({ return { params: { id, enable: true }, command } }, - invalidatesTags: (_, __, id) => [{ type: MARKETPLACE, id }, MARKETPLACE], + invalidatesTags: (_, __, id) => [ + { type: MARKETPLACE, id }, + MARKETPLACE_POOL, + ], }), disableMarketplace: builder.mutation({ /** @@ -216,7 +233,10 @@ const marketplaceApi = oneApi.injectEndpoints({ return { params: { id, enable: false }, command } }, - invalidatesTags: (_, __, id) => [{ type: MARKETPLACE, id }, MARKETPLACE], + invalidatesTags: (_, __, id) => [ + { type: MARKETPLACE, id }, + MARKETPLACE_POOL, + ], }), }), }) diff --git a/src/fireedge/src/client/features/OneApi/marketplaceApp.js b/src/fireedge/src/client/features/OneApi/marketplaceApp.js index f191dd67ea..007f134472 100644 --- a/src/fireedge/src/client/features/OneApi/marketplaceApp.js +++ b/src/fireedge/src/client/features/OneApi/marketplaceApp.js @@ -19,10 +19,15 @@ import { Commands as ExtraCommands, } from 'server/routes/api/marketapp/routes' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { FilterFlag, Permission, MarketplaceApp } from 'client/constants' const { APP } = ONE_RESOURCES +const { APP_POOL } = ONE_RESOURCES_POOL const marketAppApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -46,7 +51,13 @@ const marketAppApi = oneApi.injectEndpoints({ }, transformResponse: (data) => [data?.MARKETPLACEAPP_POOL?.MARKETPLACEAPP ?? []].flat(), - providesTags: [APP], + providesTags: (apps) => + apps + ? [ + ...apps.map(({ ID }) => ({ type: APP_POOL, id: `${ID}` })), + APP_POOL, + ] + : [APP_POOL], }), getMarketplaceApp: builder.query({ /** @@ -98,7 +109,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [APP], + invalidatesTags: [APP_POOL], }), updateApp: builder.mutation({ /** @@ -120,7 +131,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params, command } }, - providesTags: (_, __, { id }) => [{ type: APP, id }], + invalidatesTags: (_, __, { id }) => [{ type: APP, id }], }), removeApp: builder.mutation({ /** @@ -136,7 +147,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params: { id }, command } }, - providesTags: [APP], + invalidatesTags: (_, __, id) => [{ type: APP_POOL, id }, APP_POOL], }), enableApp: builder.mutation({ /** @@ -152,7 +163,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params: { id, enable: true }, command } }, - invalidatesTags: (_, __, id) => [{ type: APP, id }, APP], + invalidatesTags: (_, __, id) => [{ type: APP, id }, APP_POOL], }), disableApp: builder.mutation({ /** @@ -168,7 +179,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params: { id, enable: false }, command } }, - invalidatesTags: (_, __, id) => [{ type: APP, id }, APP], + invalidatesTags: (_, __, id) => [{ type: APP, id }, APP_POOL], }), changeAppPermissions: builder.mutation({ /** @@ -215,7 +226,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: APP, id }, APP], + invalidatesTags: (_, __, { id }) => [{ type: APP, id }, APP_POOL], }), renameApp: builder.mutation({ /** @@ -233,7 +244,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: APP, id }, APP], + invalidatesTags: (_, __, { id }) => [{ type: APP, id }, APP_POOL], }), lockApp: builder.mutation({ /** @@ -255,7 +266,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: APP, id }, APP], + invalidatesTags: (_, __, { id }) => [{ type: APP, id }, APP_POOL], }), unlockApp: builder.mutation({ /** @@ -271,7 +282,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params: { id }, command } }, - invalidatesTags: (_, __, id) => [{ type: APP, id }, APP], + invalidatesTags: (_, __, id) => [{ type: APP, id }, APP_POOL], }), importApp: builder.mutation({ /** @@ -292,7 +303,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [APP], + invalidatesTags: [APP_POOL], }), exportApp: builder.mutation({ /** @@ -316,7 +327,7 @@ const marketAppApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [APP], + invalidatesTags: [APP_POOL], }), }), }) diff --git a/src/fireedge/src/client/features/OneApi/network.js b/src/fireedge/src/client/features/OneApi/network.js index 705ef3c3af..6dfca2f331 100644 --- a/src/fireedge/src/client/features/OneApi/network.js +++ b/src/fireedge/src/client/features/OneApi/network.js @@ -14,7 +14,11 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/vn' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { LockLevel, FilterFlag, @@ -23,6 +27,7 @@ import { } from 'client/constants' const { VNET } = ONE_RESOURCES +const { VNET_POOL } = ONE_RESOURCES_POOL const vNetworkApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -44,7 +49,13 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params, command } }, transformResponse: (data) => [data?.VNET_POOL?.VNET ?? []].flat(), - providesTags: [VNET], + providesTags: (networks) => + networks + ? [ + ...networks.map(({ ID }) => ({ type: VNET_POOL, id: `${ID}` })), + VNET_POOL, + ] + : [VNET_POOL], }), getVNetwork: builder.query({ /** @@ -81,7 +92,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [VNET], + invalidatesTags: [VNET_POOL], }), removeVNet: builder.mutation({ /** @@ -97,7 +108,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params: { id }, command } }, - invalidatesTags: [VNET], + invalidatesTags: [VNET_POOL], }), addRangeToVNet: builder.mutation({ /** @@ -115,7 +126,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET], + invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], }), removeRangeFromVNet: builder.mutation({ /** @@ -133,7 +144,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET], + invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], }), updateVNetRange: builder.mutation({ /** @@ -151,7 +162,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET], + invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], }), reserveAddress: builder.mutation({ /** @@ -195,7 +206,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET], + invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], }), holdLease: builder.mutation({ /** @@ -300,7 +311,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET], + invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], }), renameVNet: builder.mutation({ /** @@ -318,7 +329,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET], + invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], }), lockVNet: builder.mutation({ /** @@ -337,7 +348,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET], + invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], }), unlockVNet: builder.mutation({ /** @@ -353,7 +364,7 @@ const vNetworkApi = oneApi.injectEndpoints({ return { params: { id }, command } }, - invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET], + invalidatesTags: (_, __, { id }) => [{ type: VNET, id }, VNET_POOL], }), }), }) diff --git a/src/fireedge/src/client/features/OneApi/networkTemplate.js b/src/fireedge/src/client/features/OneApi/networkTemplate.js index 0a5d3e5021..10d95a1e56 100644 --- a/src/fireedge/src/client/features/OneApi/networkTemplate.js +++ b/src/fireedge/src/client/features/OneApi/networkTemplate.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/vntemplate' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { FilterFlag, Permission, VNetworkTemplate } from 'client/constants' -const { VNET, VNTEMPLATE } = ONE_RESOURCES +const { VNTEMPLATE } = ONE_RESOURCES +const { VNET_POOL, VNTEMPLATE_POOL } = ONE_RESOURCES_POOL const vNetworkTemplateApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -40,7 +45,16 @@ const vNetworkTemplateApi = oneApi.injectEndpoints({ }, transformResponse: (data) => [data?.VNTEMPLATE_POOL?.VNTEMPLATE ?? []].flat(), - providesTags: [VNTEMPLATE], + providesTags: (vNetTemplates) => + vNetTemplates + ? [ + ...vNetTemplates.map(({ ID }) => ({ + type: VNTEMPLATE_POOL, + id: `${ID}`, + })), + VNTEMPLATE_POOL, + ] + : [VNTEMPLATE_POOL], }), getVNTemplate: builder.query({ /** @@ -76,7 +90,7 @@ const vNetworkTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [VNTEMPLATE], + invalidatesTags: [VNTEMPLATE_POOL], }), cloneVNTemplate: builder.mutation({ /** @@ -94,7 +108,7 @@ const vNetworkTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [VNTEMPLATE], + invalidatesTags: [VNTEMPLATE_POOL], }), removeVNTemplate: builder.mutation({ /** @@ -111,7 +125,7 @@ const vNetworkTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [VNTEMPLATE], + invalidatesTags: [VNTEMPLATE_POOL], }), instantiateVNTemplate: builder.mutation({ /** @@ -132,7 +146,7 @@ const vNetworkTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [VNET], + invalidatesTags: [VNET_POOL], }), updateVNTemplate: builder.mutation({ /** @@ -203,7 +217,7 @@ const vNetworkTemplateApi = oneApi.injectEndpoints({ }, invalidatesTags: (_, __, { id }) => [ { type: VNTEMPLATE, id }, - VNTEMPLATE, + VNTEMPLATE_POOL, ], }), renameVNTemplate: builder.mutation({ @@ -224,7 +238,7 @@ const vNetworkTemplateApi = oneApi.injectEndpoints({ }, invalidatesTags: (_, __, { id }) => [ { type: VNTEMPLATE, id }, - VNTEMPLATE, + VNTEMPLATE_POOL, ], }), lockVNTemplate: builder.mutation({ @@ -249,7 +263,7 @@ const vNetworkTemplateApi = oneApi.injectEndpoints({ }, invalidatesTags: (_, __, { id }) => [ { type: VNTEMPLATE, id }, - VNTEMPLATE, + VNTEMPLATE_POOL, ], }), unlockVNTemplate: builder.mutation({ @@ -266,7 +280,10 @@ const vNetworkTemplateApi = oneApi.injectEndpoints({ return { params: { id }, command } }, - invalidatesTags: (_, __, id) => [{ type: VNTEMPLATE, id }, VNTEMPLATE], + invalidatesTags: (_, __, id) => [ + { type: VNTEMPLATE, id }, + VNTEMPLATE_POOL, + ], }), }), }) diff --git a/src/fireedge/src/client/features/OneApi/provider.js b/src/fireedge/src/client/features/OneApi/provider.js index 9cab558df8..7731677f36 100644 --- a/src/fireedge/src/client/features/OneApi/provider.js +++ b/src/fireedge/src/client/features/OneApi/provider.js @@ -17,9 +17,16 @@ import { Actions, Commands, } from 'server/routes/api/oneprovision/provider/routes' -import { oneApi, DOCUMENT } from 'client/features/OneApi' +import { + oneApi, + DOCUMENT, + DOCUMENT_POOL, + PROVISION_CONFIG, +} from 'client/features/OneApi' -const { PROVIDER, PROVIDER_CONFIG } = DOCUMENT +const { PROVIDER } = DOCUMENT +const { PROVIDER_POOL } = DOCUMENT_POOL +const { PROVIDER_CONFIG } = PROVISION_CONFIG const providerApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -52,7 +59,16 @@ const providerApi = oneApi.injectEndpoints({ return { command } }, transformResponse: (data) => [data?.DOCUMENT_POOL?.DOCUMENT ?? []].flat(), - providesTags: [PROVIDER], + providesTags: (providers) => + providers + ? [ + ...providers.map(({ ID }) => ({ + type: PROVIDER_POOL, + id: `${ID}`, + })), + PROVIDER_POOL, + ] + : [PROVIDER_POOL], }), getProvider: builder.query({ /** @@ -118,7 +134,7 @@ const providerApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [PROVIDER], + invalidatesTags: [PROVIDER_POOL], }), updateProvider: builder.mutation({ /** @@ -136,7 +152,10 @@ const providerApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: PROVIDER, id }, PROVIDER], + invalidatesTags: (_, __, { id }) => [ + { type: PROVIDER, id }, + PROVIDER_POOL, + ], }), deleteProvider: builder.mutation({ /** @@ -153,7 +172,7 @@ const providerApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [PROVIDER], + invalidatesTags: [PROVIDER_POOL], }), }), }) diff --git a/src/fireedge/src/client/features/OneApi/provision.js b/src/fireedge/src/client/features/OneApi/provision.js index 70d959bce1..0ac343b855 100644 --- a/src/fireedge/src/client/features/OneApi/provision.js +++ b/src/fireedge/src/client/features/OneApi/provision.js @@ -17,9 +17,17 @@ import { Actions, Commands, } from 'server/routes/api/oneprovision/provision/routes' -import { oneApi, DOCUMENT } from 'client/features/OneApi' +import { + oneApi, + DOCUMENT, + DOCUMENT_POOL, + PROVISION_CONFIG, + PROVISION_RESOURCES, +} from 'client/features/OneApi' -const { PROVISION, PROVISION_TEMPLATE, PROVISION_RESOURCES } = DOCUMENT +const { PROVISION } = DOCUMENT +const { PROVISION_POOL } = DOCUMENT_POOL +const { PROVISION_DEFAULTS } = PROVISION_CONFIG const provisionApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -37,7 +45,16 @@ const provisionApi = oneApi.injectEndpoints({ return { command } }, transformResponse: (data) => [data?.DOCUMENT_POOL?.DOCUMENT ?? []].flat(), - providesTags: [PROVISION], + providesTags: (provisions) => + provisions + ? [ + ...provisions.map(({ ID }) => ({ + type: PROVISION_POOL, + id: `${ID}`, + })), + PROVISION_POOL, + ] + : [PROVISION_POOL], }), getProvision: builder.query({ /** @@ -85,7 +102,7 @@ const provisionApi = oneApi.injectEndpoints({ return { command } }, - providesTags: [PROVISION_TEMPLATE], + providesTags: [PROVISION_DEFAULTS], }), getProvisionLog: builder.query({ /** @@ -148,7 +165,7 @@ const provisionApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [PROVISION], + invalidatesTags: [PROVISION_POOL], }), configureProvision: builder.mutation({ /** @@ -165,7 +182,10 @@ const provisionApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: PROVISION, id }], + invalidatesTags: (_, __, { id }) => [ + { type: PROVISION, id }, + PROVISION_POOL, + ], }), deleteProvision: builder.mutation({ /** @@ -184,7 +204,7 @@ const provisionApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [PROVISION], + invalidatesTags: [PROVISION_POOL], }), removeResource: builder.mutation({ /** diff --git a/src/fireedge/src/client/features/OneApi/securityGroup.js b/src/fireedge/src/client/features/OneApi/securityGroup.js index 60ab103966..a51b633cc3 100644 --- a/src/fireedge/src/client/features/OneApi/securityGroup.js +++ b/src/fireedge/src/client/features/OneApi/securityGroup.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/secgroup' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { FilterFlag } from 'client/constants' const { SECURITYGROUP } = ONE_RESOURCES +const { SECURITYGROUP_POOL } = ONE_RESOURCES_POOL const securityGroupApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -40,7 +45,16 @@ const securityGroupApi = oneApi.injectEndpoints({ }, transformResponse: (data) => [data?.SECURITY_GROUP_POOL?.SECURITY_GROUP ?? []].flat(), - providesTags: [SECURITYGROUP], + providesTags: (secGroups) => + secGroups + ? [ + ...secGroups.map(({ ID }) => ({ + type: SECURITYGROUP_POOL, + id: `${ID}`, + })), + SECURITYGROUP_POOL, + ] + : [SECURITYGROUP_POOL], }), getSecGroup: builder.query({ /** diff --git a/src/fireedge/src/client/features/OneApi/service.js b/src/fireedge/src/client/features/OneApi/service.js index 2d8252e86a..897bb4cd3d 100644 --- a/src/fireedge/src/client/features/OneApi/service.js +++ b/src/fireedge/src/client/features/OneApi/service.js @@ -14,10 +14,11 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/routes/api/oneflow/service/routes' -import { oneApi, DOCUMENT } from 'client/features/OneApi' +import { oneApi, DOCUMENT, DOCUMENT_POOL } from 'client/features/OneApi' import { Service } from 'client/constants' const { SERVICE } = DOCUMENT +const { SERVICE_POOL } = DOCUMENT_POOL const serviceApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -35,7 +36,13 @@ const serviceApi = oneApi.injectEndpoints({ return { command } }, transformResponse: (data) => [data?.DOCUMENT_POOL?.DOCUMENT ?? []].flat(), - providesTags: [SERVICE], + providesTags: (services) => + services + ? [ + services.map(({ ID }) => ({ type: SERVICE_POOL, id: `${ID}` })), + SERVICE_POOL, + ] + : [SERVICE_POOL], }), getService: builder.query({ /** diff --git a/src/fireedge/src/client/features/OneApi/serviceTemplate.js b/src/fireedge/src/client/features/OneApi/serviceTemplate.js index 58098690ae..f3347ea4d6 100644 --- a/src/fireedge/src/client/features/OneApi/serviceTemplate.js +++ b/src/fireedge/src/client/features/OneApi/serviceTemplate.js @@ -14,10 +14,11 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/routes/api/oneflow/template/routes' -import { oneApi, DOCUMENT } from 'client/features/OneApi' +import { oneApi, DOCUMENT, DOCUMENT_POOL } from 'client/features/OneApi' import { ServiceTemplate } from 'client/constants' -const { SERVICE, SERVICE_TEMPLATE } = DOCUMENT +const { SERVICE_TEMPLATE } = DOCUMENT +const { SERVICE_POOL, SERVICE_TEMPLATE_POOL } = DOCUMENT_POOL const serviceTemplateApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -35,7 +36,16 @@ const serviceTemplateApi = oneApi.injectEndpoints({ return { command } }, transformResponse: (data) => [data?.DOCUMENT_POOL?.DOCUMENT ?? []].flat(), - providesTags: [SERVICE_TEMPLATE], + providesTags: (serviceTemplates) => + serviceTemplates + ? [ + serviceTemplates.map(({ ID }) => ({ + type: SERVICE_TEMPLATE_POOL, + id: `${ID}`, + })), + SERVICE_TEMPLATE_POOL, + ] + : [SERVICE_TEMPLATE_POOL], }), getServiceTemplate: builder.query({ /** @@ -86,7 +96,7 @@ const serviceTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - providesTags: [SERVICE_TEMPLATE], + providesTags: [SERVICE_TEMPLATE_POOL], }), updateServiceTemplate: builder.mutation({ /** @@ -121,7 +131,7 @@ const serviceTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - providesTags: [SERVICE_TEMPLATE], + providesTags: [SERVICE_TEMPLATE_POOL], }), instantiateServiceTemplate: builder.mutation({ /** @@ -149,7 +159,7 @@ const serviceTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - providesTags: [SERVICE], + providesTags: [SERVICE_POOL], }), }), }) diff --git a/src/fireedge/src/client/features/OneApi/user.js b/src/fireedge/src/client/features/OneApi/user.js index 6b9cc6ca53..6e41952fbf 100644 --- a/src/fireedge/src/client/features/OneApi/user.js +++ b/src/fireedge/src/client/features/OneApi/user.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/user' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { User } from 'client/constants' const { USER } = ONE_RESOURCES +const { USER_POOL } = ONE_RESOURCES_POOL const userApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -35,7 +40,13 @@ const userApi = oneApi.injectEndpoints({ return { command } }, transformResponse: (data) => [data?.USER_POOL?.USER ?? []].flat(), - providesTags: [USER], + providesTags: (users) => + users + ? [ + ...users.map(({ ID }) => ({ type: USER_POOL, id: `${ID}` })), + USER_POOL, + ] + : [USER_POOL], }), getUser: builder.query({ /** @@ -75,7 +86,7 @@ const userApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [USER], + invalidatesTags: [USER_POOL], }), updateUser: builder.mutation({ /** @@ -114,7 +125,7 @@ const userApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: USER, id }, USER], + invalidatesTags: (_, __, { id }) => [{ type: USER, id }, USER_POOL], }), changePassword: builder.mutation({ /** @@ -200,7 +211,7 @@ const userApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: USER, id }, USER], + invalidatesTags: (_, __, { id }) => [{ type: USER, id }, USER_POOL], }), removeFromGroup: builder.mutation({ /** @@ -218,7 +229,7 @@ const userApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: USER, id }, USER], + invalidatesTags: (_, __, { id }) => [{ type: USER, id }, USER_POOL], }), enableUser: builder.mutation({ /** @@ -234,7 +245,7 @@ const userApi = oneApi.injectEndpoints({ return { params: { id, enable: false }, command } }, - invalidatesTags: (_, __, id) => [{ type: USER, id }, USER], + invalidatesTags: (_, __, id) => [{ type: USER, id }, USER_POOL], }), disableUser: builder.mutation({ /** @@ -250,7 +261,7 @@ const userApi = oneApi.injectEndpoints({ return { params: { id, enable: false }, command } }, - invalidatesTags: (_, __, id) => [{ type: USER, id }, USER], + invalidatesTags: (_, __, id) => [{ type: USER, id }, USER_POOL], }), getUserQuota: builder.query({ /** diff --git a/src/fireedge/src/client/features/OneApi/vm.js b/src/fireedge/src/client/features/OneApi/vm.js index e7dd27f63c..53eb79e24c 100644 --- a/src/fireedge/src/client/features/OneApi/vm.js +++ b/src/fireedge/src/client/features/OneApi/vm.js @@ -14,7 +14,11 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/vm' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { UpdateFromSocket } from 'client/features/OneApi/socket' import http from 'client/utils/rest' import { @@ -25,6 +29,7 @@ import { } from 'client/constants' const { VM } = ONE_RESOURCES +const { VM_POOL } = ONE_RESOURCES_POOL const vmApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -41,15 +46,15 @@ const vmApi = oneApi.injectEndpoints({ * @param {number} [params.state] - VM state to filter by * - `-2`: Any state, including DONE * - `-1`: Any state, except DONE - * - `0`: INIT - * - `1`: PENDING - * - `2`: HOLD - * - `3`: ACTIVE - * - `4`: STOPPED - * - `5`: SUSPENDED - * - `6`: DONE - * - `8`: POWEROFF - * - `9`: UNDEPLOYED + * - `0`: INIT + * - `1`: PENDING + * - `2`: HOLD + * - `3`: ACTIVE + * - `4`: STOPPED + * - `5`: SUSPENDED + * - `6`: DONE + * - `8`: POWEROFF + * - `9`: UNDEPLOYED * - `10`: CLONING * - `11`: CLONING_FAILURE * @param {string} [params.filterByKey] - Filter in KEY=VALUE format @@ -65,7 +70,10 @@ const vmApi = oneApi.injectEndpoints({ return { params, command } }, transformResponse: (data) => [data?.VM_POOL?.VM ?? []].flat(), - providesTags: [VM], + providesTags: (vms) => + vms + ? [vms.map(({ ID }) => ({ type: VM_POOL, id: `${ID}` })), VM_POOL] + : [VM_POOL], }), getVm: builder.query({ /** @@ -209,7 +217,7 @@ const vmApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [VM], + invalidatesTags: [VM_POOL], }), saveAsTemplate: builder.mutation({ /** @@ -258,7 +266,7 @@ const vmApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [VM], + invalidatesTags: [VM_POOL], }), actionVm: builder.mutation({ /** diff --git a/src/fireedge/src/client/features/OneApi/vmGroup.js b/src/fireedge/src/client/features/OneApi/vmGroup.js index f4fc100618..8fb3db9eb8 100644 --- a/src/fireedge/src/client/features/OneApi/vmGroup.js +++ b/src/fireedge/src/client/features/OneApi/vmGroup.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/vmgroup' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { FilterFlag } from 'client/constants' const { VMGROUP } = ONE_RESOURCES +const { VMGROUP_POOL } = ONE_RESOURCES_POOL const vmGroupApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -39,10 +44,13 @@ const vmGroupApi = oneApi.injectEndpoints({ return { params, command } }, transformResponse: (data) => [data?.VM_GROUP_POOL?.VM_GROUP ?? []].flat(), - providesTags: (result) => - result - ? [...result.map(({ ID }) => ({ type: VMGROUP, ID })), VMGROUP] - : [VMGROUP], + providesTags: (vmGroups) => + vmGroups + ? [ + ...vmGroups.map(({ ID }) => ({ type: VMGROUP_POOL, ID })), + VMGROUP_POOL, + ] + : [VMGROUP_POOL], }), getVMGroup: builder.query({ /** diff --git a/src/fireedge/src/client/features/OneApi/vmTemplate.js b/src/fireedge/src/client/features/OneApi/vmTemplate.js index db02a3fa44..84e0d11139 100644 --- a/src/fireedge/src/client/features/OneApi/vmTemplate.js +++ b/src/fireedge/src/client/features/OneApi/vmTemplate.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/template' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { LockLevel, FilterFlag, Permission, VmTemplate } from 'client/constants' -const { TEMPLATE, VM } = ONE_RESOURCES +const { TEMPLATE } = ONE_RESOURCES +const { TEMPLATE_POOL, VM_POOL } = ONE_RESOURCES_POOL const vmTemplateApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -40,7 +45,13 @@ const vmTemplateApi = oneApi.injectEndpoints({ }, transformResponse: (data) => [data?.VMTEMPLATE_POOL?.VMTEMPLATE ?? []].flat(), - providesTags: [TEMPLATE], + providesTags: (vmTemplates) => + vmTemplates + ? [ + ...vmTemplates.map(({ ID }) => ({ type: TEMPLATE_POOL, ID })), + TEMPLATE_POOL, + ] + : [TEMPLATE_POOL], }), getTemplate: builder.query({ /** @@ -93,7 +104,7 @@ const vmTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [TEMPLATE], + invalidatesTags: [TEMPLATE_POOL], }), cloneTemplate: builder.mutation({ /** @@ -114,7 +125,7 @@ const vmTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [TEMPLATE], + invalidatesTags: [TEMPLATE_POOL], }), removeTemplate: builder.mutation({ /** @@ -132,7 +143,7 @@ const vmTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [TEMPLATE], + invalidatesTags: [TEMPLATE_POOL], }), instantiateTemplate: builder.mutation({ /** @@ -153,7 +164,7 @@ const vmTemplateApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: [VM], + invalidatesTags: [VM_POOL], }), updateTemplate: builder.mutation({ /** diff --git a/src/fireedge/src/client/features/OneApi/vrouter.js b/src/fireedge/src/client/features/OneApi/vrouter.js index ed4cbe29a5..64996a165c 100644 --- a/src/fireedge/src/client/features/OneApi/vrouter.js +++ b/src/fireedge/src/client/features/OneApi/vrouter.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/vrouter' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { FilterFlag } from 'client/constants' const { VROUTER } = ONE_RESOURCES +const { VROUTER_POOL } = ONE_RESOURCES_POOL const virtualRouterApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -39,7 +44,13 @@ const virtualRouterApi = oneApi.injectEndpoints({ return { params, command } }, transformResponse: (data) => [data?.VROUTER_POOL?.VROUTER ?? []].flat(), - providesTags: [VROUTER], + providesTags: (vRouters) => + vRouters + ? [ + ...vRouters.map(({ ID }) => ({ type: VROUTER_POOL, ID })), + VROUTER_POOL, + ] + : [VROUTER_POOL], }), getVRouter: builder.query({ /** diff --git a/src/fireedge/src/client/features/OneApi/zone.js b/src/fireedge/src/client/features/OneApi/zone.js index 0e25ae6415..6b5e9aec06 100644 --- a/src/fireedge/src/client/features/OneApi/zone.js +++ b/src/fireedge/src/client/features/OneApi/zone.js @@ -14,10 +14,15 @@ * limitations under the License. * * ------------------------------------------------------------------------- */ import { Actions, Commands } from 'server/utils/constants/commands/zone' -import { oneApi, ONE_RESOURCES } from 'client/features/OneApi' +import { + oneApi, + ONE_RESOURCES, + ONE_RESOURCES_POOL, +} from 'client/features/OneApi' import { Zone } from 'client/constants' const { ZONE } = ONE_RESOURCES +const { ZONE_POOL } = ONE_RESOURCES_POOL const zoneApi = oneApi.injectEndpoints({ endpoints: (builder) => ({ @@ -35,7 +40,10 @@ const zoneApi = oneApi.injectEndpoints({ return { command } }, transformResponse: (data) => [data?.ZONE_POOL?.ZONE ?? []].flat(), - providesTags: [ZONE], + providesTags: (zones) => + zones + ? [...zones.map(({ ID }) => ({ type: ZONE_POOL, ID })), ZONE_POOL] + : [ZONE_POOL], }), getZone: builder.query({ /** @@ -99,7 +107,7 @@ const zoneApi = oneApi.injectEndpoints({ return { params: { id }, command } }, - invalidatesTags: [ZONE], + invalidatesTags: [ZONE_POOL], }), updateZone: builder.mutation({ /** @@ -121,7 +129,7 @@ const zoneApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: ZONE, id }, ZONE], + invalidatesTags: (_, __, { id }) => [{ type: ZONE, id }, ZONE_POOL], }), renameZone: builder.mutation({ /** @@ -139,7 +147,7 @@ const zoneApi = oneApi.injectEndpoints({ return { params, command } }, - invalidatesTags: (_, __, { id }) => [{ type: ZONE, id }, ZONE], + invalidatesTags: (_, __, { id }) => [{ type: ZONE, id }, ZONE_POOL], }), }), })