Skip to content

Commit 1e7cb54

Browse files
committed
fix: update default plugin signatures for native apps
1 parent ec4b43f commit 1e7cb54

File tree

3 files changed

+54
-20
lines changed

3 files changed

+54
-20
lines changed

src/components/create-job/plugins/NativeInputsSection.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
import ConfigSectionTitle from '@components/job/config/ConfigSectionTitle';
2+
import { BOOLEAN_TYPES } from '@data/booleanTypes';
23
import { PLUGIN_SIGNATURE_TYPES } from '@data/pluginSignatureTypes';
34
import CustomParametersSection from '@shared/jobs/native/CustomParametersSection';
45
import NativeAppIdentitySection from '@shared/jobs/native/NativeAppIdentitySection';
56
import PortMappingSection from '@shared/PortMappingSection';
7+
import { useEffect } from 'react';
68
import { useFormContext } from 'react-hook-form';
79
import AppParametersSection from '../sections/AppParametersSection';
810

11+
const CUSTOM_SIGNATURE = PLUGIN_SIGNATURE_TYPES[PLUGIN_SIGNATURE_TYPES.length - 1];
12+
913
export default function NativeInputsSection({ name }: { name: string }) {
10-
const { watch } = useFormContext();
14+
const { watch, setValue } = useFormContext();
1115

1216
const pluginSignature: (typeof PLUGIN_SIGNATURE_TYPES)[number] = watch(`${name}.pluginSignature`);
1317

18+
const isCustomSignature = pluginSignature === CUSTOM_SIGNATURE;
19+
20+
useEffect(() => {
21+
if (!isCustomSignature) {
22+
setValue(`${name}.enableTunneling`, BOOLEAN_TYPES[1]);
23+
setValue(`${name}.tunnelingToken`, undefined);
24+
}
25+
}, [isCustomSignature, name, setValue]);
26+
1427
return (
1528
<div className="col gap-4">
1629
<NativeAppIdentitySection pluginSignature={pluginSignature} baseName={name} />
1730

1831
<ConfigSectionTitle title="App Parameters" />
19-
<AppParametersSection baseName={name} />
32+
<AppParametersSection
33+
baseName={name}
34+
disableTunneling={!isCustomSignature}
35+
tunnelingDisabledNote="Tunneling is disabled by default for the selected plugin signature."
36+
/>
2037

2138
<ConfigSectionTitle title="Port Mapping" />
2239
<PortMappingSection baseName={name} />

src/components/create-job/sections/AppParametersSection.tsx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ export default function AppParametersSection({
1010
enablePort = true,
1111
enableTunnelingLabel = false,
1212
forceTunnelingEnabled = false,
13+
disableTunneling = false,
14+
tunnelingDisabledNote,
1315
}: {
1416
baseName?: string;
1517
isCreatingTunnel?: boolean;
1618
enablePort?: boolean;
1719
enableTunnelingLabel?: boolean;
1820
forceTunnelingEnabled?: boolean;
21+
disableTunneling?: boolean;
22+
tunnelingDisabledNote?: string;
1923
}) {
2024
const { watch, trigger } = useFormContext();
2125

@@ -24,24 +28,31 @@ export default function AppParametersSection({
2428
return (
2529
<div className="col gap-4">
2630
{(!forceTunnelingEnabled || enablePort) && (
27-
<div className="flex gap-4">
28-
{!forceTunnelingEnabled && (
29-
<SelectWithLabel
30-
name={`${baseName}.enableTunneling`}
31-
label="Enable Tunneling"
32-
options={BOOLEAN_TYPES}
33-
onSelect={() => {
34-
trigger(`${baseName}.port`);
35-
}}
36-
/>
37-
)}
31+
<div className="col gap-2">
32+
<div className="flex gap-4">
33+
{!forceTunnelingEnabled && (
34+
<SelectWithLabel
35+
name={`${baseName}.enableTunneling`}
36+
label="Enable Tunneling"
37+
options={BOOLEAN_TYPES}
38+
isDisabled={disableTunneling}
39+
onSelect={() => {
40+
trigger(`${baseName}.port`);
41+
}}
42+
/>
43+
)}
3844

39-
{enablePort && (
40-
<NumberInputWithLabel
41-
name={`${baseName}.port`}
42-
label="Port"
43-
isOptional={enableTunneling === BOOLEAN_TYPES[1]}
44-
/>
45+
{enablePort && (
46+
<NumberInputWithLabel
47+
name={`${baseName}.port`}
48+
label="Port"
49+
isOptional={enableTunneling === BOOLEAN_TYPES[1]}
50+
/>
51+
)}
52+
</div>
53+
54+
{disableTunneling && tunnelingDisabledNote && (
55+
<p className="text-sm text-default-500">{tunnelingDisabledNote}</p>
4556
)}
4657
</div>
4758
)}

src/data/pluginSignatureTypes.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
// 'CUSTOM' must be the last element in the array
2-
export const PLUGIN_SIGNATURE_TYPES = ['A_SIMPLE_PLUGIN', 'EDGE_NODE_API_TEST', 'CUSTOM'] as const;
2+
export const PLUGIN_SIGNATURE_TYPES = [
3+
'LLM_INFERENCE_API',
4+
'STRUCT_DATA_API',
5+
'CV_INFERENCE_API',
6+
'SD_INFERENCE_API',
7+
'CUSTOM',
8+
] as const;

0 commit comments

Comments
 (0)