@@ -16,13 +16,14 @@ import { useEffect, useState } from 'react';
1616import { useFormContext } from 'react-hook-form' ;
1717import { toast } from 'react-hot-toast' ;
1818import { RiCodeSSlashLine } from 'react-icons/ri' ;
19- import { Link } from 'react-router-dom' ;
19+ import { Link , useParams } from 'react-router-dom' ;
2020
2121function 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