Skip to content

Commit 3662485

Browse files
committed
[dashboard] display warning for latest IDE versions
Co-authored-by: George Tsiolis <[email protected]>
1 parent be80566 commit 3662485

File tree

7 files changed

+90
-15
lines changed

7 files changed

+90
-15
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
import exclamation from "../images/exclamation.svg";
8+
import exclamation2 from "../images/exclamation2.svg";
9+
import infoSvg from "../images/info.svg";
10+
11+
export type AlertType = "warning" | "info" | "error";
12+
13+
export interface AlertProps {
14+
className?: string;
15+
icon?: string;
16+
children?: React.ReactNode;
17+
type?: AlertType;
18+
closable?: boolean;
19+
}
20+
21+
interface AlertInfo {
22+
cls: string;
23+
icon: string;
24+
}
25+
26+
const infoMap: Record<AlertType, AlertInfo> = {
27+
warning: {
28+
cls: "bg-orange-100 dark:bg-orange-800 dark:bg-opacity-40 text-orange-600",
29+
icon: exclamation2,
30+
},
31+
info: {
32+
cls: "bg-gray-200 dark:bg-gray-800 text-gray-600 dark:text-gray-400",
33+
icon: infoSvg,
34+
},
35+
error: {
36+
cls: "bg-red-50 dark:bg-red-800 dark:bg-opacity-30 text-red-600",
37+
icon: exclamation,
38+
},
39+
};
40+
41+
export default function Alert(p: AlertProps) {
42+
const type: AlertType = p.type ?? "info";
43+
const info = infoMap[type];
44+
return (
45+
<div className={`flex rounded p-4 ${info.cls} ${p.className || ""}`}>
46+
<img className="w-4 h-4 m-1 ml-2 mr-4" src={p.icon ?? info.icon} />
47+
<span className="text-left">{p.children}</span>
48+
</div>
49+
);
50+
}
Lines changed: 3 additions & 0 deletions
Loading

components/dashboard/src/start/StartPage.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66

77
import { useEffect } from "react";
8+
import Alert from "../components/Alert";
89
import gitpodIconUA from "../icons/gitpod-ua.svg";
10+
import { gitpodHostUrl } from "../service/service";
911

1012
export enum StartPhase {
1113
Checking = 0,
@@ -74,6 +76,7 @@ export interface StartPageProps {
7476
error?: StartWorkspaceError;
7577
title?: string;
7678
children?: React.ReactNode;
79+
showLatestIdeWarning?: boolean;
7780
}
7881

7982
export interface StartWorkspaceError {
@@ -105,6 +108,27 @@ export function StartPage(props: StartPageProps) {
105108
)}
106109
{error && <StartError error={error} />}
107110
{props.children}
111+
{props.showLatestIdeWarning && (
112+
<Alert type="warning" className="mt-4 w-96">
113+
You’ve opted in for using the latest release for the editor. If you run into any issues, please{" "}
114+
<a
115+
className="text-blue-400 dark:text-blue-300 hover:text-blue-600 dark:hover:text-blue-400"
116+
target="_blank"
117+
href="https://github.com/gitpod-io/gitpod/issues/new?assignees=&labels=bug&template=bug_report.yml"
118+
>
119+
submit a bug report
120+
</a>{" "}
121+
or switch back to the stable release in{" "}
122+
<a
123+
className="text-blue-400 dark:text-blue-300 hover:text-blue-600 dark:hover:text-blue-400"
124+
target="_blank"
125+
href={gitpodHostUrl.asPreferences().toString()}
126+
>
127+
user preferences
128+
</a>
129+
.
130+
</Alert>
131+
)}
108132
</div>
109133
</div>
110134
);

components/dashboard/src/start/StartWorkspace.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,6 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
549549
{openLinkLabel}
550550
</button>
551551
</div>
552-
<div className="text-sm text-gray-400 dark:text-gray-500 mt-5">
553-
These IDE options are based on{" "}
554-
<a className="gp-link" href={gitpodHostUrl.asPreferences().toString()} target="_parent">
555-
your user preferences
556-
</a>
557-
.
558-
</div>
559552
</div>
560553
);
561554
}
@@ -650,9 +643,9 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
650643
);
651644
break;
652645
}
653-
646+
const useLatest = !!this.state.workspaceInstance?.configuration?.ideConfig?.useLatest;
654647
return (
655-
<StartPage phase={phase} error={error} title={title}>
648+
<StartPage phase={phase} error={error} title={title} showLatestIdeWarning={useLatest}>
656649
{statusMessage}
657650
</StartPage>
658651
);

components/gitpod-protocol/src/workspace-instance.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ export interface WorkspaceInstanceConfiguration {
221221

222222
// supervisorImage is the ref of the supervisor image this instance uses.
223223
supervisorImage?: string;
224+
225+
ideConfig?: {
226+
useLatest?: boolean;
227+
};
224228
}
225229

226230
/**

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,6 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
314314
delete res.status.ownerToken;
315315
// is an operational internal detail
316316
delete res.status.nodeName;
317-
// configuration contains feature flags and theia version.
318-
// we might want to share that in the future, but for the time being there's no need
319-
delete res.configuration;
320317
// internal operation detail
321318
// @ts-ignore
322319
delete res.workspaceImage;

components/server/src/workspace/workspace-starter.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,16 +522,20 @@ export class WorkspaceStarter {
522522
excludeFeatureFlags: NamedWorkspaceFeatureFlag[],
523523
ideConfig: IDEConfig,
524524
): Promise<WorkspaceInstance> {
525+
const ideChoice = user.additionalData?.ideSettings?.defaultIde;
526+
const useLatest = !!user.additionalData?.ideSettings?.useLatestVersion;
527+
525528
// TODO(cw): once we allow changing the IDE in the workspace config (i.e. .gitpod.yml), we must
526529
// give that value precedence over the default choice.
527530
const configuration: WorkspaceInstanceConfiguration = {
528531
ideImage: ideConfig.ideOptions.options[ideConfig.ideOptions.defaultIde].image,
529532
supervisorImage: ideConfig.supervisorImage,
533+
ideConfig: {
534+
// TODO(hw): set false when latestImage not found
535+
useLatest,
536+
},
530537
};
531538

532-
const ideChoice = user.additionalData?.ideSettings?.defaultIde;
533-
const useLatest = !!user.additionalData?.ideSettings?.useLatestVersion;
534-
535539
if (!!ideChoice) {
536540
const mappedImage = ideConfig.ideOptions.options[ideChoice];
537541
if (mappedImage.image != null) {

0 commit comments

Comments
 (0)