From 1d01b3dbc5cb81dbc195af108608ee7f278ad0b7 Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Fri, 22 Oct 2021 15:37:35 +0000 Subject: [PATCH] [server] Add preferences to choose a desktop IDE --- .../dashboard/src/images/golandLogo.svg | 1 + .../dashboard/src/images/intellijIdeaLogo.svg | 1 + .../dashboard/src/settings/Preferences.tsx | 52 +++++++++++++++++++ components/gitpod-protocol/java/.project | 2 +- components/gitpod-protocol/src/protocol.ts | 2 + 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 components/dashboard/src/images/golandLogo.svg create mode 100644 components/dashboard/src/images/intellijIdeaLogo.svg diff --git a/components/dashboard/src/images/golandLogo.svg b/components/dashboard/src/images/golandLogo.svg new file mode 100644 index 00000000000000..3640b1d89f2782 --- /dev/null +++ b/components/dashboard/src/images/golandLogo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/components/dashboard/src/images/intellijIdeaLogo.svg b/components/dashboard/src/images/intellijIdeaLogo.svg new file mode 100644 index 00000000000000..04d5d6155d2153 --- /dev/null +++ b/components/dashboard/src/images/intellijIdeaLogo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/components/dashboard/src/settings/Preferences.tsx b/components/dashboard/src/settings/Preferences.tsx index eea22268d4615a..22f62667de4c41 100644 --- a/components/dashboard/src/settings/Preferences.tsx +++ b/components/dashboard/src/settings/Preferences.tsx @@ -5,10 +5,13 @@ */ import { useContext, useState } from "react"; +import CheckBox from "../components/CheckBox"; import { PageWithSubMenu } from "../components/PageWithSubMenu"; import SelectableCard from "../components/SelectableCard"; import Tooltip from "../components/Tooltip"; import vscode from '../images/vscode.svg'; +import ideaLogo from '../images/intellijIdeaLogo.svg'; +import golandLogo from '../images/golandLogo.svg'; import { getGitpodService } from "../service/service"; import { ThemeContext } from "../theme-context"; import { UserContext } from "../user-context"; @@ -19,6 +22,7 @@ type Theme = 'light' | 'dark' | 'system'; export default function Preferences() { const { user } = useContext(UserContext); const { setIsDark } = useContext(ThemeContext); + const [defaultIde, setDefaultIde] = useState(user?.additionalData?.ideSettings?.defaultIde || 'code'); const actuallySetDefaultIde = async (value: string) => { const additionalData = user?.additionalData || {}; @@ -28,6 +32,31 @@ export default function Preferences() { await getGitpodService().server.updateLoggedInUser({ additionalData }); setDefaultIde(value); } + + const desktopIdeFeatureEnabled = !!user?.rolesOrPermissions?.includes('admin'); + + const [defaultDesktopIde, setDefaultDesktopIde] = useState(user?.additionalData?.ideSettings?.defaultDesktopIde || 'intellij'); + const actuallySetDefaultDesktopIde = async (value: string) => { + const additionalData = user?.additionalData || {}; + const settings = additionalData.ideSettings || {}; + settings.defaultDesktopIde = value; + additionalData.ideSettings = settings; + await getGitpodService().server.updateLoggedInUser({ additionalData }); + setDefaultDesktopIde(value); + } + + const [useDesktopIde, setUseDesktopIde] = useState(user?.additionalData?.ideSettings?.useDesktopIde || false); + const actuallySetUseDesktopIde = async (value: boolean) => { + const additionalData = user?.additionalData || {}; + const settings = additionalData.ideSettings || {}; + settings.useDesktopIde = value; + // Make sure that default desktop IDE is set even when the user did not explicitly select one. + settings.defaultDesktopIde = defaultDesktopIde; + additionalData.ideSettings = settings; + await getGitpodService().server.updateLoggedInUser({ additionalData }); + setUseDesktopIde(value); + } + const [theme, setTheme] = useState(localStorage.theme || 'light'); const actuallySetTheme = (theme: Theme) => { if (theme === 'dark' || theme === 'system') { @@ -59,6 +88,29 @@ export default function Preferences() { + {desktopIdeFeatureEnabled && +
+ actuallySetUseDesktopIde(evt.target.checked)} /> +
+ } + {desktopIdeFeatureEnabled && useDesktopIde && +
+ actuallySetDefaultDesktopIde('intellij')}> +
+ +
+
+ actuallySetDefaultDesktopIde('goland')}> +
+ +
+
+
+ }

Theme

Early bird or night owl? Choose your side.

diff --git a/components/gitpod-protocol/java/.project b/components/gitpod-protocol/java/.project index 2a230d24c39ebb..9dd6734ca4aba8 100644 --- a/components/gitpod-protocol/java/.project +++ b/components/gitpod-protocol/java/.project @@ -22,7 +22,7 @@ - 1632232136569 + 0 30 diff --git a/components/gitpod-protocol/src/protocol.ts b/components/gitpod-protocol/src/protocol.ts index 7579e21f37e444..a9625d9ff7073a 100644 --- a/components/gitpod-protocol/src/protocol.ts +++ b/components/gitpod-protocol/src/protocol.ts @@ -114,6 +114,8 @@ export interface EmailNotificationSettings { export type IDESettings = { defaultIde?: string + useDesktopIde?: boolean + defaultDesktopIde?: string } export interface UserPlatform {