@@ -15,9 +15,14 @@ import type { SSHHost } from "@/types";
1515interface GuacamoleAppProps {
1616 hostId ?: string ;
1717 tabId ?: string ;
18+ protocol ?: "rdp" | "vnc" | "telnet" ;
1819}
1920
20- const GuacamoleApp : React . FC < GuacamoleAppProps > = ( { hostId, tabId } ) => {
21+ const GuacamoleApp : React . FC < GuacamoleAppProps > = ( {
22+ hostId,
23+ tabId,
24+ protocol,
25+ } ) => {
2126 const { t } = useTranslation ( ) ;
2227
2328 return (
@@ -76,6 +81,7 @@ const GuacamoleApp: React.FC<GuacamoleAppProps> = ({ hostId, tabId }) => {
7681 hostId = { parseInt ( hostId , 10 ) }
7782 hostConfig = { hostConfig }
7883 tabId = { tabId }
84+ protocol = { protocol }
7985 />
8086 ) ;
8187 } }
@@ -87,12 +93,14 @@ interface GuacamoleAppInnerProps {
8793 hostId : number ;
8894 hostConfig : Pick < SSHHost , "connectionType" > ;
8995 tabId ?: string ;
96+ protocol ?: "rdp" | "vnc" | "telnet" ;
9097}
9198
9299const GuacamoleAppInner : React . FC < GuacamoleAppInnerProps > = ( {
93100 hostId,
94101 hostConfig,
95102 tabId,
103+ protocol,
96104} ) => {
97105 const { t } = useTranslation ( ) ;
98106 const [ token , setToken ] = useState < string | null > ( null ) ;
@@ -110,7 +118,7 @@ const GuacamoleAppInner: React.FC<GuacamoleAppInnerProps> = ({
110118 setError ( t ( "guacamole.guacdUnavailable" ) ) ;
111119 return ;
112120 }
113- return getGuacamoleTokenFromHost ( hostId ) ;
121+ return getGuacamoleTokenFromHost ( hostId , protocol ) ;
114122 } )
115123 . then ( ( result ) => {
116124 if ( result ) setToken ( result . token ) ;
@@ -172,14 +180,21 @@ const GuacamoleAppInner: React.FC<GuacamoleAppInnerProps> = ({
172180 < SimpleLoader
173181 visible = { true }
174182 message = { t ( "guacamole.connecting" , {
175- type : ( hostConfig . connectionType || "remote" ) . toUpperCase ( ) ,
183+ type : (
184+ protocol ||
185+ hostConfig . connectionType ||
186+ "remote"
187+ ) . toUpperCase ( ) ,
176188 } ) }
177189 />
178190 </ div >
179191 ) ;
180192 }
181193
182- const protocol = hostConfig . connectionType as "rdp" | "vnc" | "telnet" ;
194+ const resolvedProtocol = ( protocol ?? hostConfig . connectionType ) as
195+ | "rdp"
196+ | "vnc"
197+ | "telnet" ;
183198
184199 return (
185200 < div className = "relative w-full h-full" >
@@ -213,13 +228,17 @@ const GuacamoleAppInner: React.FC<GuacamoleAppInnerProps> = ({
213228 < GuacamoleDisplay
214229 key = { token }
215230 ref = { displayRef }
216- connectionConfig = { { token, protocol, type : protocol } }
231+ connectionConfig = { {
232+ token,
233+ protocol : resolvedProtocol ,
234+ type : resolvedProtocol ,
235+ } }
217236 isVisible = { true }
218237 onError = { ( err ) => setConnectionError ( err ) }
219238 />
220239 < GuacamoleToolbar
221240 displayRef = { displayRef }
222- protocol = { protocol }
241+ protocol = { resolvedProtocol }
223242 onReconnect = { handleReconnect }
224243 />
225244 </ div >
0 commit comments