Skip to content

Commit 7b727dc

Browse files
committed
Redirect to url when workspace stops
1 parent 493b3ba commit 7b727dc

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

components/dashboard/src/service/service.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export class IDEFrontendService implements IDEFrontendDashboardService.IServer {
252252
workspaceType: this.workspace.spec?.type === WorkspaceSpec_WorkspaceType.PREBUILD ? "prebuild" : "regular",
253253
credentialsToken: this.ideCredentials,
254254
ownerId: this.workspace.metadata?.ownerId ?? "",
255+
contextUrl: this.workspace.metadata?.originalContextUrl ?? "",
255256
};
256257
}
257258

components/gitpod-protocol/src/frontend-dashboard-service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export namespace IDEFrontendDashboardService {
5151
workspaceDescription: string;
5252
workspaceType: string;
5353
credentialsToken: string;
54+
contextUrl: string;
5455
}
5556

5657
export interface SetStateData {

components/supervisor/frontend/src/index.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ require("../src/shared/index.css");
4949

5050
import { WorkspaceInstancePhase } from "@gitpod/gitpod-protocol";
5151
import { DisposableCollection } from "@gitpod/gitpod-protocol/lib/util/disposable";
52+
import { IDEFrontendDashboardService } from "@gitpod/gitpod-protocol/lib/frontend-dashboard-service";
5253
import * as heartBeat from "./ide/heart-beat";
5354
import * as IDEFrontendService from "./ide/ide-frontend-service-impl";
5455
import * as IDEWorker from "./ide/ide-worker";
@@ -286,7 +287,7 @@ LoadingFrame.load().then(async (loading) => {
286287
IDEWebSocket.connectWorkspace(),
287288
frontendDashboardServiceClient.onInfoUpdate((status) => {
288289
if (status.statusPhase === "stopping" || status.statusPhase === "stopped") {
289-
maybeRedirectToCustomUrl();
290+
maybeRedirectToCustomUrl(frontendDashboardServiceClient.latestInfo);
290291
toStop.dispose();
291292
}
292293
}),
@@ -299,14 +300,29 @@ LoadingFrame.load().then(async (loading) => {
299300
})();
300301
});
301302

302-
async function maybeRedirectToCustomUrl() {
303-
const redirectURL = await experimentsClient.getValueAsync("dataops", "", {});
304-
if (!redirectURL) {
303+
async function maybeRedirectToCustomUrl(info: IDEFrontendDashboardService.Info) {
304+
const isDataOps = await experimentsClient.getValueAsync("dataops", false, {
305+
user: { id: info.loggedUserId },
306+
});
307+
const dataOpsRedirectUrl = await experimentsClient.getValueAsync("dataops_redirect_url", "undefined", {
308+
user: { id: info.loggedUserId },
309+
});
310+
311+
if (!isDataOps) {
305312
return;
306313
}
307314

308315
try {
316+
const params: Record<string, string> = { workspaceID: info.workspaceID };
317+
let redirectURL: string;
318+
if (dataOpsRedirectUrl === "undefined") {
319+
redirectURL = info.contextUrl;
320+
} else {
321+
redirectURL = dataOpsRedirectUrl;
322+
params.contextURL = info.contextUrl;
323+
}
309324
const url = new URL(redirectURL);
325+
url.search = new URLSearchParams(params).toString();
310326
window.location.href = url.toString();
311327
} catch {
312328
console.error("Invalid redirect URL");

0 commit comments

Comments
 (0)