fix(edgestack): broken parallel setting in create view [EE-7245] (#11945)

pull/12057/head
Oscar Zhou 2024-07-29 09:42:05 +12:00 committed by GitHub
parent e3364457c4
commit 6486a5d971
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 8 deletions

View File

@ -124,7 +124,15 @@ export function InnerForm({
<StaggerFieldset
isEdit={false}
values={values.staggerConfig}
onChange={(value) => setFieldValue('staggerConfig', value)}
onChange={(newStaggerValues) =>
setValues((values) => ({
...values,
staggerConfig: {
...values.staggerConfig,
...newStaggerValues,
},
}))
}
/>
<FormActions

View File

@ -1,7 +1,11 @@
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { mutationOptions, withError } from '@/react-tools/react-query';
import {
mutationOptions,
withError,
withInvalidate,
} from '@/react-tools/react-query';
import {
AutoUpdateResponse,
GitAuthenticationResponse,
@ -11,6 +15,8 @@ import { DeploymentType, EdgeStack } from '@/react/edge/edge-stacks/types';
import { EdgeGroup } from '@/react/edge/edge-groups/types';
import { Registry } from '@/react/portainer/registries/types/registry';
import { queryKeys } from '../../../queries/query-keys';
export interface UpdateEdgeStackGitPayload {
id: EdgeStack['Id'];
autoUpdate: AutoUpdateResponse | null;
@ -23,9 +29,14 @@ export interface UpdateEdgeStackGitPayload {
}
export function useUpdateEdgeStackGitMutation() {
const queryClient = useQueryClient();
return useMutation(
updateEdgeStackGit,
mutationOptions(withError('Failed updating stack'))
mutationOptions(
withError('Failed updating stack'),
withInvalidate(queryClient, [queryKeys.base()])
)
);
}

View File

@ -186,6 +186,7 @@ function InnerForm({
setFieldValue,
isValid,
errors,
setValues,
setFieldError,
initialValues,
} = useFormikContext<FormValues>();
@ -327,10 +328,14 @@ function InnerForm({
<StaggerFieldset
values={values.staggerConfig}
onChange={(value) =>
Object.entries(value).forEach(([key, value]) =>
setFieldValue(`staggerConfig.${key}`, value)
)
onChange={(newStaggerValues) =>
setValues((values) => ({
...values,
staggerConfig: {
...values.staggerConfig,
...newStaggerValues,
},
}))
}
errors={errors.staggerConfig}
/>