|
1 | 1 | import ConfigSectionTitle from '@components/job/config/ConfigSectionTitle'; |
2 | 2 | import { BOOLEAN_TYPES } from '@data/booleanTypes'; |
3 | | -import { PLUGIN_SIGNATURE_TYPES } from '@data/pluginSignatureTypes'; |
| 3 | +import { CUSTOM_PLUGIN_SIGNATURE, PLUGIN_SIGNATURE_TYPES } from '@data/pluginSignatureTypes'; |
4 | 4 | import CustomParametersSection from '@shared/jobs/native/CustomParametersSection'; |
5 | 5 | import NativeAppIdentitySection from '@shared/jobs/native/NativeAppIdentitySection'; |
6 | 6 | import PortMappingSection from '@shared/PortMappingSection'; |
7 | 7 | import { useEffect } from 'react'; |
8 | 8 | import { useFormContext } from 'react-hook-form'; |
9 | 9 | import AppParametersSection from '../sections/AppParametersSection'; |
10 | 10 |
|
11 | | -const CUSTOM_SIGNATURE = PLUGIN_SIGNATURE_TYPES[PLUGIN_SIGNATURE_TYPES.length - 1]; |
12 | | - |
13 | 11 | export default function NativeInputsSection({ name }: { name: string }) { |
14 | | - const { watch, setValue } = useFormContext(); |
| 12 | + const { watch, setValue, clearErrors } = useFormContext(); |
15 | 13 |
|
16 | 14 | const pluginSignature: (typeof PLUGIN_SIGNATURE_TYPES)[number] = watch(`${name}.pluginSignature`); |
17 | 15 |
|
18 | | - const isCustomSignature = pluginSignature === CUSTOM_SIGNATURE; |
| 16 | + const isCustomSignature = pluginSignature === CUSTOM_PLUGIN_SIGNATURE; |
19 | 17 |
|
20 | 18 | useEffect(() => { |
21 | 19 | if (!isCustomSignature) { |
22 | 20 | setValue(`${name}.enableTunneling`, BOOLEAN_TYPES[1]); |
23 | 21 | setValue(`${name}.tunnelingToken`, undefined); |
| 22 | + clearErrors(`${name}.tunnelingToken`); |
24 | 23 | } |
25 | | - }, [isCustomSignature, name, setValue]); |
| 24 | + }, [isCustomSignature, name, setValue, clearErrors]); |
26 | 25 |
|
27 | 26 | return ( |
28 | 27 | <div className="col gap-4"> |
|
0 commit comments