Skip to content

Commit 99343f6

Browse files
committed
fix: Use project name when creating tunnel
1 parent ad57cb1 commit 99343f6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ import { useEffect, useState } from 'react';
1616
import { useFormContext } from 'react-hook-form';
1717
import { toast } from 'react-hot-toast';
1818
import { RiCodeSSlashLine } from 'react-icons/ri';
19-
import { Link } from 'react-router-dom';
19+
import { Link, useParams } from 'react-router-dom';
2020

2121
function ServiceDeployment({ isEditingRunningJob }: { isEditingRunningJob?: boolean }) {
22-
const { setFormSubmissionDisabled } = useDeploymentContext() as DeploymentContextType;
22+
const { setFormSubmissionDisabled, getProjectName } = useDeploymentContext() as DeploymentContextType;
2323
const { tunnelingSecrets } = useTunnelsContext() as TunnelsContextType;
2424

2525
const { watch, setValue } = useFormContext();
26+
const { projectHash } = useParams();
2627

2728
const serviceId: number = watch('serviceId');
2829
const alias: string = watch('deployment.jobAlias');
@@ -50,8 +51,11 @@ function ServiceDeployment({ isEditingRunningJob }: { isEditingRunningJob?: bool
5051
setCreatingTunnel(true);
5152

5253
try {
53-
console.log('Creating tunnel', stripToAlphanumeric(service.name));
54-
const response = await createTunnel(alias, tunnelingSecrets, stripToAlphanumeric(service.name));
54+
const projectName = projectHash ? getProjectName(projectHash) : '';
55+
const tunnelAlias = projectName ? `${stripToAlphanumeric(projectName).toLowerCase()}-${alias}` : alias;
56+
57+
console.log('Creating tunnel', tunnelAlias, stripToAlphanumeric(service.name).toLowerCase());
58+
const response = await createTunnel(tunnelAlias, tunnelingSecrets, stripToAlphanumeric(service.name).toLowerCase());
5559

5660
if (!response.result.id) {
5761
throw new Error('Failed to create tunnel.');

0 commit comments

Comments
 (0)