Skip to content

Commit faa677c

Browse files
[server] Add preferences to choose a desktop IDE
1 parent c6e8671 commit faa677c

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

components/dashboard/src/settings/Preferences.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
*/
66

77
import { useContext, useState } from "react";
8+
import CheckBox from "../components/CheckBox";
89
import { PageWithSubMenu } from "../components/PageWithSubMenu";
910
import SelectableCard from "../components/SelectableCard";
1011
import Tooltip from "../components/Tooltip";
1112
import vscode from '../images/vscode.svg';
13+
import ideaLogo from '../images/intellijIdeaLogo.svg';
14+
import golandLogo from '../images/golandLogo.svg';
1215
import { getGitpodService } from "../service/service";
1316
import { ThemeContext } from "../theme-context";
1417
import { UserContext } from "../user-context";
@@ -19,6 +22,7 @@ type Theme = 'light' | 'dark' | 'system';
1922
export default function Preferences() {
2023
const { user } = useContext(UserContext);
2124
const { setIsDark } = useContext(ThemeContext);
25+
2226
const [defaultIde, setDefaultIde] = useState<string>(user?.additionalData?.ideSettings?.defaultIde || 'code');
2327
const actuallySetDefaultIde = async (value: string) => {
2428
const additionalData = user?.additionalData || {};
@@ -28,6 +32,31 @@ export default function Preferences() {
2832
await getGitpodService().server.updateLoggedInUser({ additionalData });
2933
setDefaultIde(value);
3034
}
35+
36+
const desktopIdeFeatureEnabled = !!user?.rolesOrPermissions?.includes('admin');
37+
38+
const [defaultDesktopIde, setDefaultDesktopIde] = useState<string>(user?.additionalData?.ideSettings?.defaultDesktopIde || 'intellij');
39+
const actuallySetDefaultDesktopIde = async (value: string) => {
40+
const additionalData = user?.additionalData || {};
41+
const settings = additionalData.ideSettings || {};
42+
settings.defaultDesktopIde = value;
43+
additionalData.ideSettings = settings;
44+
await getGitpodService().server.updateLoggedInUser({ additionalData });
45+
setDefaultDesktopIde(value);
46+
}
47+
48+
const [useDesktopIde, setUseDesktopIde] = useState<boolean>(user?.additionalData?.ideSettings?.useDesktopIde || false);
49+
const actuallySetUseDesktopIde = async (value: boolean) => {
50+
const additionalData = user?.additionalData || {};
51+
const settings = additionalData.ideSettings || {};
52+
settings.useDesktopIde = value;
53+
// Make sure that default desktop IDE is set even when the user did not explicitly select one.
54+
settings.defaultDesktopIde = defaultDesktopIde;
55+
additionalData.ideSettings = settings;
56+
await getGitpodService().server.updateLoggedInUser({ additionalData });
57+
setUseDesktopIde(value);
58+
}
59+
3160
const [theme, setTheme] = useState<Theme>(localStorage.theme || 'light');
3261
const actuallySetTheme = (theme: Theme) => {
3362
if (theme === 'dark' || theme === 'system') {
@@ -59,6 +88,29 @@ export default function Preferences() {
5988
</SelectableCard>
6089
</Tooltip>
6190
</div>
91+
{desktopIdeFeatureEnabled &&
92+
<div className="mt-4 space-x-4 flex">
93+
<CheckBox
94+
title="Use Desktop IDE"
95+
desc="Choose whether you would like to open your workspace in a desktop IDE instead."
96+
checked={useDesktopIde}
97+
onChange={(evt) => actuallySetUseDesktopIde(evt.target.checked)} />
98+
</div>
99+
}
100+
{desktopIdeFeatureEnabled && useDesktopIde &&
101+
<div className="mt-4 space-x-4 flex">
102+
<SelectableCard className="w-36 h-40" title="IntelliJ IDEA" selected={defaultDesktopIde === 'intellij'} onClick={() => actuallySetDefaultDesktopIde('intellij')}>
103+
<div className="flex justify-center mt-3">
104+
<img className="w-16 filter-grayscale self-center" src={ideaLogo} />
105+
</div>
106+
</SelectableCard>
107+
<SelectableCard className="w-36 h-40" title="GoLand" selected={defaultDesktopIde === 'goland'} onClick={() => actuallySetDefaultDesktopIde('goland')}>
108+
<div className="flex justify-center mt-3">
109+
<img className="w-16 filter-grayscale self-center" src={golandLogo} />
110+
</div>
111+
</SelectableCard>
112+
</div>
113+
}
62114
<h3 className="mt-12">Theme</h3>
63115
<p className="text-base text-gray-500">Early bird or night owl? Choose your side.</p>
64116
<div className="mt-4 space-x-4 flex">

components/gitpod-protocol/java/.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</natures>
2323
<filteredResources>
2424
<filter>
25-
<id>1632232136569</id>
25+
<id>0</id>
2626
<name></name>
2727
<type>30</type>
2828
<matcher>

components/gitpod-protocol/src/protocol.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ export interface EmailNotificationSettings {
114114

115115
export type IDESettings = {
116116
defaultIde?: string
117+
useDesktopIde?: boolean
118+
defaultDesktopIde?: string
117119
}
118120

119121
export interface UserPlatform {

0 commit comments

Comments
 (0)