@@ -221,7 +221,7 @@ export class IDEFrontendService implements IDEFrontendDashboardService.IServer {
221
221
this . workspace = workspaceResponse . workspace ! ;
222
222
this . user = user ;
223
223
this . ideCredentials = ideCredentials ;
224
- const reconcile = ( status ?: WorkspaceStatus ) => {
224
+ const reconcile = async ( status ?: WorkspaceStatus ) => {
225
225
const info = this . parseInfo ( status ?? this . workspace . status ! ) ;
226
226
this . latestInfo = info ;
227
227
const oldInstanceID = this . instanceID ;
@@ -231,6 +231,15 @@ export class IDEFrontendService implements IDEFrontendDashboardService.IServer {
231
231
if ( info . instanceId && oldInstanceID !== info . instanceId ) {
232
232
this . auth ( ) ;
233
233
}
234
+
235
+ // Redirect to custom url
236
+ if (
237
+ ( info . statusPhase === "stopping" || info . statusPhase === "stopped" ) &&
238
+ info . workspaceType === "regular"
239
+ ) {
240
+ await this . redirectToCustomUrl ( info ) ;
241
+ }
242
+
234
243
this . sendInfoUpdate ( this . latestInfo ) ;
235
244
} ;
236
245
reconcile ( ) ;
@@ -255,6 +264,40 @@ export class IDEFrontendService implements IDEFrontendDashboardService.IServer {
255
264
} ;
256
265
}
257
266
267
+ private async redirectToCustomUrl ( info : IDEFrontendDashboardService . Info ) {
268
+ const isDataOps = await getExperimentsClient ( ) . getValueAsync ( "dataops" , false , {
269
+ user : { id : this . user ! . id } ,
270
+ gitpodHost : gitpodHostUrl . toString ( ) ,
271
+ } ) ;
272
+ const dataOpsRedirectUrl = await getExperimentsClient ( ) . getValueAsync ( "dataops_redirect_url" , "undefined" , {
273
+ user : { id : this . user ! . id } ,
274
+ gitpodHost : gitpodHostUrl . toString ( ) ,
275
+ } ) ;
276
+
277
+ if ( ! isDataOps ) {
278
+ return ;
279
+ }
280
+
281
+ try {
282
+ const params : Record < string , string > = { workspaceID : info . workspaceID } ;
283
+ let redirectURL : string ;
284
+ if ( dataOpsRedirectUrl === "undefined" ) {
285
+ redirectURL = this . workspace . metadata ?. originalContextUrl ?? "" ;
286
+ } else {
287
+ redirectURL = dataOpsRedirectUrl ;
288
+ params . contextURL = this . workspace . metadata ?. originalContextUrl ?? "" ;
289
+ }
290
+ const url = new URL ( redirectURL ) ;
291
+ url . search = new URLSearchParams ( [
292
+ ...Array . from ( url . searchParams . entries ( ) ) ,
293
+ ...Object . entries ( params ) ,
294
+ ] ) . toString ( ) ;
295
+ this . relocate ( url . toString ( ) ) ;
296
+ } catch {
297
+ console . error ( "Invalid redirect URL" ) ;
298
+ }
299
+ }
300
+
258
301
// implements
259
302
260
303
private async auth ( ) {
0 commit comments