mirror of https://github.com/portainer/portainer
fix(cluster): faster submitting load times [EE-5524] (#10280)
* faster submitting load times * scroll to selected tz option --------- Co-authored-by: testa113 <testa113>pull/10283/head
parent
dfd415c62e
commit
dde4b95426
|
@ -64,6 +64,8 @@ export async function handleSubmitConfigureCluster(
|
||||||
{
|
{
|
||||||
id: environment.Id,
|
id: environment.Id,
|
||||||
updateEnvironmentPayload: updatedEnvironment,
|
updateEnvironmentPayload: updatedEnvironment,
|
||||||
|
initialIngressControllers:
|
||||||
|
initialValues?.ingressClasses as IngressControllerClassMapRowData[],
|
||||||
ingressControllers:
|
ingressControllers:
|
||||||
values.ingressClasses as IngressControllerClassMapRowData[],
|
values.ingressClasses as IngressControllerClassMapRowData[],
|
||||||
storageClassPatches,
|
storageClassPatches,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { useMutation, useQueryClient } from 'react-query';
|
import { useMutation, useQueryClient } from 'react-query';
|
||||||
import { Operation } from 'fast-json-patch';
|
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 { environmentQueryKeys } from '@/react/portainer/environments/queries/query-keys';
|
||||||
import {
|
import {
|
||||||
UpdateEnvironmentPayload,
|
UpdateEnvironmentPayload,
|
||||||
|
@ -16,6 +17,7 @@ import { IngressControllerClassMapRowData } from '../../ingressClass/types';
|
||||||
export type ConfigureClusterPayloads = {
|
export type ConfigureClusterPayloads = {
|
||||||
id: number;
|
id: number;
|
||||||
updateEnvironmentPayload: Partial<UpdateEnvironmentPayload>;
|
updateEnvironmentPayload: Partial<UpdateEnvironmentPayload>;
|
||||||
|
initialIngressControllers: IngressControllerClassMapRowData[];
|
||||||
ingressControllers: IngressControllerClassMapRowData[];
|
ingressControllers: IngressControllerClassMapRowData[];
|
||||||
storageClassPatches: {
|
storageClassPatches: {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -30,6 +32,7 @@ export function useConfigureClusterMutation() {
|
||||||
async ({
|
async ({
|
||||||
id,
|
id,
|
||||||
updateEnvironmentPayload,
|
updateEnvironmentPayload,
|
||||||
|
initialIngressControllers,
|
||||||
ingressControllers,
|
ingressControllers,
|
||||||
storageClassPatches,
|
storageClassPatches,
|
||||||
}: ConfigureClusterPayloads) => {
|
}: ConfigureClusterPayloads) => {
|
||||||
|
@ -39,10 +42,16 @@ export function useConfigureClusterMutation() {
|
||||||
patchStorageClass(id, name, patch)
|
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'),
|
...withError('Unable to apply configuration', 'Failure'),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -57,6 +57,12 @@ export function TimeWindowPickerInputGroup({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// find the option index for react-select to scroll to the current option
|
||||||
|
const timeZoneOptionIndex = useMemo(
|
||||||
|
() => timeZoneOptions.findIndex((option) => option.value === timeZone),
|
||||||
|
[timeZone, timeZoneOptions]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-wrap items-center gap-x-5">
|
<div className="flex flex-wrap items-center gap-x-5">
|
||||||
<div className="flex items-center gap-x-5">
|
<div className="flex items-center gap-x-5">
|
||||||
|
@ -90,7 +96,7 @@ export function TimeWindowPickerInputGroup({
|
||||||
</div>
|
</div>
|
||||||
<Select<Option<string>>
|
<Select<Option<string>>
|
||||||
options={timeZoneOptions}
|
options={timeZoneOptions}
|
||||||
value={{ value: timeZone, label: timeZone }}
|
value={timeZoneOptions[timeZoneOptionIndex]}
|
||||||
className="w-72 min-w-fit"
|
className="w-72 min-w-fit"
|
||||||
onChange={(newTimeZone) => {
|
onChange={(newTimeZone) => {
|
||||||
if (!newTimeZone) return;
|
if (!newTimeZone) return;
|
||||||
|
|
Loading…
Reference in New Issue