Skip to content

Commit 43a41f2

Browse files
mustard-mhroboquat
authored andcommitted
Redirect web page when instance changed
1 parent fe7795b commit 43a41f2

File tree

2 files changed

+16
-43
lines changed

2 files changed

+16
-43
lines changed

components/dashboard/src/start/StartWorkspace.tsx

+6-43
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,11 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
324324

325325
// Redirect to workspaceURL if we are not yet running in an iframe.
326326
// It happens this late if we were waiting for a docker build.
327-
if (!this.props.runsInIFrame && workspaceInstance.ideUrl && !this.props.dontAutostart) {
327+
if (
328+
!this.props.runsInIFrame &&
329+
workspaceInstance.ideUrl &&
330+
(!this.props.dontAutostart || workspaceInstance.status.phase === "running")
331+
) {
328332
this.redirectTo(workspaceInstance.ideUrl);
329333
return;
330334
}
@@ -431,48 +435,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
431435
}
432436
if (!this.state.desktopIde) {
433437
phase = StartPhase.Running;
434-
435-
if (this.props.dontAutostart) {
436-
// hide the progress bar, as we're already running
437-
phase = undefined;
438-
title = "Running";
439-
440-
// in case we dontAutostart the IDE we have to provide controls to do so
441-
statusMessage = (
442-
<div>
443-
<div className="flex space-x-3 items-center text-left rounded-xl m-auto px-4 h-16 w-72 mt-4 mb-2 bg-gray-100 dark:bg-gray-800">
444-
<div className="rounded-full w-3 h-3 text-sm bg-green-500">&nbsp;</div>
445-
<div>
446-
<p className="text-gray-700 dark:text-gray-200 font-semibold w-56 truncate">
447-
{this.state.workspaceInstance.workspaceId}
448-
</p>
449-
<a target="_parent" href={contextURL}>
450-
<p className="w-56 truncate hover:text-blue-600 dark:hover:text-blue-400">
451-
{contextURL}
452-
</p>
453-
</a>
454-
</div>
455-
</div>
456-
<div className="mt-10 justify-center flex space-x-2">
457-
<a target="_parent" href={gitpodHostUrl.asDashboard().toString()}>
458-
<button className="secondary">Go to Dashboard</button>
459-
</a>
460-
<a
461-
target="_parent"
462-
href={
463-
gitpodHostUrl
464-
.asStart(this.props.workspaceId)
465-
.toString() /** move over 'start' here to fetch fresh credentials in case this is an older tab */
466-
}
467-
>
468-
<button>Open Workspace</button>
469-
</a>
470-
</div>
471-
</div>
472-
);
473-
} else {
474-
statusMessage = <p className="text-base text-gray-400">Opening Workspace …</p>;
475-
}
438+
statusMessage = <p className="text-base text-gray-400">Opening Workspace …</p>;
476439
} else {
477440
phase = StartPhase.IdeReady;
478441
const openLink = this.state.desktopIde.link;

components/supervisor/frontend/src/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,19 @@ const toStop = new DisposableCollection();
108108
//#region current-frame
109109
let current: HTMLElement = loading.frame;
110110
let desktopRedirected = false;
111+
let currentInstanceId = "";
111112
const nextFrame = () => {
112113
const instance = gitpodServiceClient.info.latestInstance;
113114
if (instance) {
115+
// refresh web page when instanceId changed
116+
if (currentInstanceId !== "") {
117+
if (instance.id !== currentInstanceId && instance.ideUrl !== "") {
118+
currentInstanceId = instance.id;
119+
window.location.href = instance.ideUrl;
120+
}
121+
} else {
122+
currentInstanceId = instance.id;
123+
}
114124
if (instance.status.phase === 'running') {
115125
if (!hideDesktopIde) {
116126
if (isDesktopIde == undefined) {

0 commit comments

Comments
 (0)