Skip to content

Commit fee93f2

Browse files
committed
fix: Add tunneling label for service deployments
1 parent e1e9862 commit fee93f2

File tree

6 files changed

+41
-19
lines changed

6 files changed

+41
-19
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import NumberInputWithLabel from '@shared/NumberInputWithLabel';
44
import SelectWithLabel from '@shared/SelectWithLabel';
55
import { useFormContext } from 'react-hook-form';
66

7-
export default function AppParametersSection({ baseName = 'deployment' }: { baseName?: string }) {
7+
export default function AppParametersSection({
8+
baseName = 'deployment',
9+
enableTunnelingLabel = false,
10+
}: {
11+
baseName?: string;
12+
enableTunnelingLabel?: boolean;
13+
}) {
814
const { watch, trigger } = useFormContext();
915

1016
const enableTunneling: (typeof BOOLEAN_TYPES)[number] = watch(`${baseName}.enableTunneling`);
@@ -31,6 +37,15 @@ export default function AppParametersSection({ baseName = 'deployment' }: { base
3137
{enableTunneling === BOOLEAN_TYPES[0] && (
3238
<div className="flex gap-4">
3339
<InputWithLabel name={`${baseName}.tunnelingToken`} label="Tunnel Token" placeholder="Starts with 'ey'" />
40+
41+
{enableTunnelingLabel && (
42+
<InputWithLabel
43+
name={`${baseName}.tunnelingLabel`}
44+
label="Tunnel Label"
45+
placeholder="my-tunnel"
46+
isOptional
47+
/>
48+
)}
3449
</div>
3550
)}
3651
</div>

src/components/create-job/steps/deployment/ServiceDeployment.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function ServiceDeployment({ isEditingJob }: { isEditingJob?: boolean }) {
2727

2828
return (
2929
<div className="col gap-6">
30-
<SlateCard title="Service Identity" label={containerOrWorkerType?.icon}>
30+
<SlateCard title="Service Identity" label={containerOrWorkerType?.tag}>
3131
<div className="flex gap-4">
3232
<InputWithLabel name="deployment.jobAlias" label="Alias" placeholder="Service" />
3333
</div>
@@ -36,7 +36,7 @@ function ServiceDeployment({ isEditingJob }: { isEditingJob?: boolean }) {
3636
<TargetNodesCard isEditingJob={isEditingJob} />
3737

3838
<SlateCard title="App Parameters">
39-
<AppParametersSection />
39+
<AppParametersSection enableTunnelingLabel />
4040
</SlateCard>
4141

4242
{containerOrWorkerType.inputs && (

src/data/containerResources.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { JobType } from '@typedefs/deeploys';
2-
import { DiMysql } from 'react-icons/di';
3-
import { SiMongodb, SiPostgresql } from 'react-icons/si';
42

53
export type ContainerOrWorkerType = {
64
id: number;
@@ -21,7 +19,7 @@ export type Service = ContainerOrWorkerType & {
2119
port?: number;
2220
image?: string;
2321
dbSystem?: string;
24-
icon?: React.ReactNode;
22+
tag?: React.ReactNode;
2523
inputs?: { key: string; label: string }[];
2624
};
2725

@@ -49,7 +47,6 @@ export type RunningJobResources = {
4947
const getPostgresTag = () => (
5048
<div className="center-all h-[30px] rounded-md bg-blue-100 px-2">
5149
<div className="row gap-1.5 text-blue-600">
52-
<SiPostgresql className="text-xl" />
5350
<div className="compact">PostgreSQL</div>
5451
</div>
5552
</div>
@@ -58,7 +55,6 @@ const getPostgresTag = () => (
5855
const getMySQLTag = () => (
5956
<div className="center-all h-[30px] rounded-md bg-orange-100 px-2">
6057
<div className="row gap-0.5 text-orange-600">
61-
<DiMysql className="text-[28px]" />
6258
<div className="compact">MySQL</div>
6359
</div>
6460
</div>
@@ -67,7 +63,6 @@ const getMySQLTag = () => (
6763
const getMongoDBTag = () => (
6864
<div className="center-all h-[30px] rounded-md bg-green-100 px-2">
6965
<div className="row gap-0.5 text-green-600">
70-
<SiMongodb className="text-xl" />
7166
<div className="compact">MongoDB</div>
7267
</div>
7368
</div>
@@ -278,7 +273,7 @@ export const serviceContainerTypes: Service[] = [
278273
port: 5432,
279274
image: 'postgres:17',
280275
dbSystem: 'PostgreSQL',
281-
icon: getPostgresTag(),
276+
tag: getPostgresTag(),
282277
inputs: [{ key: 'POSTGRES_PASSWORD', label: 'PostgreSQL Password' }],
283278
},
284279
{
@@ -297,7 +292,7 @@ export const serviceContainerTypes: Service[] = [
297292
port: 5432,
298293
image: 'postgres:17',
299294
dbSystem: 'PostgreSQL',
300-
icon: getPostgresTag(),
295+
tag: getPostgresTag(),
301296
inputs: [{ key: 'POSTGRES_PASSWORD', label: 'PostgreSQL Password' }],
302297
},
303298
{
@@ -316,7 +311,7 @@ export const serviceContainerTypes: Service[] = [
316311
port: 3306,
317312
image: 'mysql',
318313
dbSystem: 'MySQL',
319-
icon: getMySQLTag(),
314+
tag: getMySQLTag(),
320315
inputs: [{ key: 'MYSQL_ROOT_PASSWORD', label: 'MySQL Root Password' }],
321316
},
322317
{
@@ -335,7 +330,7 @@ export const serviceContainerTypes: Service[] = [
335330
port: 3306,
336331
image: 'mysql',
337332
dbSystem: 'MySQL',
338-
icon: getMySQLTag(),
333+
tag: getMySQLTag(),
339334
inputs: [{ key: 'MYSQL_ROOT_PASSWORD', label: 'MySQL Root Password' }],
340335
},
341336
{
@@ -354,7 +349,7 @@ export const serviceContainerTypes: Service[] = [
354349
port: 27017,
355350
image: 'mongodb',
356351
dbSystem: 'MongoDB',
357-
icon: getMongoDBTag(),
352+
tag: getMongoDBTag(),
358353
inputs: [
359354
{ key: 'MONGO_INITDB_ROOT_USERNAME', label: 'MongoDB Root Username' },
360355
{ key: 'MONGO_INITDB_ROOT_PASSWORD', label: 'MongoDB Root Password' },
@@ -376,7 +371,7 @@ export const serviceContainerTypes: Service[] = [
376371
port: 27017,
377372
image: 'mongodb',
378373
dbSystem: 'MongoDB',
379-
icon: getMongoDBTag(),
374+
tag: getMongoDBTag(),
380375
inputs: [
381376
{ key: 'MONGO_INITDB_ROOT_USERNAME', label: 'MongoDB Root Username' },
382377
{ key: 'MONGO_INITDB_ROOT_PASSWORD', label: 'MongoDB Root Password' },

src/lib/deeploy-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,8 @@ export const formatServiceJobPayload = (
478478
CONTAINER_RESOURCES: containerResources,
479479
PORT: formatPort(containerType.port),
480480
TUNNEL_ENGINE: 'ngrok',
481-
NGROK_AUTH_TOKEN: deployment.tunnelingToken || null,
482-
NGROK_EDGE_LABEL: deployment.tunnelingLabel || null,
481+
NGROK_AUTH_TOKEN: deployment.tunnelingToken ?? null,
482+
NGROK_EDGE_LABEL: deployment.tunnelingLabel ?? null,
483483
TUNNEL_ENGINE_ENABLED: deployment.enableTunneling === 'True',
484484
NGROK_USE_API: true,
485485
ENV: envVars,

src/pages/deeploys/job/EditJob.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export default function EditJob() {
280280
target_nodes: targetNodes,
281281
target_nodes_count: 0,
282282
app_params: {
283-
CONTAINER_RESOURCES: formatContainerResources(containerType, undefined),
283+
CONTAINER_RESOURCES: formatContainerResources(containerType, []),
284284
},
285285
project_id: job.projectHash,
286286
chainstore_response: true,

src/schemas/steps/deployment.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,19 @@ const baseDeploymentSchema = z.object({
247247
enableTunneling: z.enum(BOOLEAN_TYPES, { required_error: 'Value is required' }),
248248
port: validations.port,
249249
tunnelingToken: getOptionalStringSchema(512),
250-
tunnelingLabel: getOptionalStringSchema(64),
250+
tunnelingLabel: z
251+
.union([
252+
z.literal(''),
253+
z
254+
.string()
255+
.min(3, 'Value must be at least 3 characters')
256+
.max(64, 'Value cannot exceed 64 characters')
257+
.regex(
258+
/^[a-zA-Z0-9!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]*$/,
259+
'Only letters, numbers and special characters allowed',
260+
),
261+
])
262+
.optional(),
251263
});
252264

253265
const containerDeploymentTypeSchema = z.object({

0 commit comments

Comments
 (0)