mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
fix(cluster): faster submitting load times [EE-5524] (#10280)
* faster submitting load times * scroll to selected tz option --------- Co-authored-by: testa113 <testa113>
This commit is contained in:
parent
dfd415c62e
commit
dde4b95426
3 changed files with 21 additions and 4 deletions
|
@ -64,6 +64,8 @@ export async function handleSubmitConfigureCluster(
|
|||
{
|
||||
id: environment.Id,
|
||||
updateEnvironmentPayload: updatedEnvironment,
|
||||
initialIngressControllers:
|
||||
initialValues?.ingressClasses as IngressControllerClassMapRowData[],
|
||||
ingressControllers:
|
||||
values.ingressClasses as IngressControllerClassMapRowData[],
|
||||
storageClassPatches,
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { useMutation, useQueryClient } from 'react-query';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { withError, withInvalidate } from '@/react-tools/react-query';
|
||||
import { withError } from '@/react-tools/react-query';
|
||||
import { environmentQueryKeys } from '@/react/portainer/environments/queries/query-keys';
|
||||
import {
|
||||
UpdateEnvironmentPayload,
|
||||
|
@ -16,6 +17,7 @@ import { IngressControllerClassMapRowData } from '../../ingressClass/types';
|
|||
export type ConfigureClusterPayloads = {
|
||||
id: number;
|
||||
updateEnvironmentPayload: Partial<UpdateEnvironmentPayload>;
|
||||
initialIngressControllers: IngressControllerClassMapRowData[];
|
||||
ingressControllers: IngressControllerClassMapRowData[];
|
||||
storageClassPatches: {
|
||||
name: string;
|
||||
|
@ -30,6 +32,7 @@ export function useConfigureClusterMutation() {
|
|||
async ({
|
||||
id,
|
||||
updateEnvironmentPayload,
|
||||
initialIngressControllers,
|
||||
ingressControllers,
|
||||
storageClassPatches,
|
||||
}: ConfigureClusterPayloads) => {
|
||||
|
@ -39,10 +42,16 @@ export function useConfigureClusterMutation() {
|
|||
patchStorageClass(id, name, patch)
|
||||
)
|
||||
);
|
||||
await updateIngressControllerClassMap(id, ingressControllers);
|
||||
// only update the ingress classes if they have changed
|
||||
if (!_.isEqual(initialIngressControllers, ingressControllers)) {
|
||||
await updateIngressControllerClassMap(id, ingressControllers);
|
||||
}
|
||||
},
|
||||
{
|
||||
...withInvalidate(queryClient, [environmentQueryKeys.base()]),
|
||||
onSuccess: () => {
|
||||
// not returning the promise here because we don't want to wait for the invalidateQueries to complete (longer than the mutation itself)
|
||||
queryClient.invalidateQueries(environmentQueryKeys.base());
|
||||
},
|
||||
...withError('Unable to apply configuration', 'Failure'),
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue