diff --git a/components/dashboard/src/settings/Preferences.tsx b/components/dashboard/src/settings/Preferences.tsx index 3e1f2f8958f3ac..b210213e2a3b36 100644 --- a/components/dashboard/src/settings/Preferences.tsx +++ b/components/dashboard/src/settings/Preferences.tsx @@ -6,7 +6,6 @@ import { IDEOption, IDEOptions } from "@gitpod/gitpod-protocol/lib/ide-protocol"; import { useContext, useEffect, useState } from "react"; -import CheckBox from "../components/CheckBox"; import InfoBox from "../components/InfoBox"; import { PageWithSubMenu } from "../components/PageWithSubMenu"; import PillLabel from "../components/PillLabel"; @@ -19,6 +18,15 @@ import settingsMenu from "./settings-menu"; type Theme = 'light' | 'dark' | 'system'; +const DesktopNoneId = "none" +const DesktopNone: IDEOption = { + "image": "", + "logo": "", + "orderKey": "-1", + "title": "None", + "type": "desktop" +} + export default function Preferences() { const { user } = useContext(UserContext); const { setIsDark } = useContext(ThemeContext); @@ -43,6 +51,10 @@ export default function Preferences() { const [defaultDesktopIde, setDefaultDesktopIde] = useState(user?.additionalData?.ideSettings?.defaultDesktopIde || ""); const actuallySetDefaultDesktopIde = async (value: string) => { + actuallySetUseDesktopIde(value !== DesktopNoneId) + if (value === DesktopNoneId) { + return + } const additionalData = user?.additionalData || {}; const settings = additionalData.ideSettings || {}; settings.defaultDesktopIde = value; @@ -83,6 +95,7 @@ export default function Preferences() { useEffect(() => { (async () => { const ideopts = await getGitpodService().server.getIDEOptions(); + ideopts.options[DesktopNoneId] = DesktopNone; setIdeOptions(ideopts); if (!(defaultIde)) { setDefaultIde(ideopts.defaultIde); @@ -118,50 +131,44 @@ export default function Preferences() { return
{ideOptions && browserIdeOptions && <> -

Editor

-

Choose which IDE you want to use.

-
- { - browserIdeOptions.map(([id, option]) => { - const selected = defaultIde === id; - const onSelect = () => actuallySetDefaultIde(id); - return renderIdeOption(option, selected, onSelect); - }) - } -
- {ideOptions.options[defaultIde].notes && -
    - {ideOptions.options[defaultIde].notes?.map((x, idx) =>
  • 0 ? "mt-2" : ""}>{x}
  • )} -
- } - {desktopIdeOptions && desktopIdeOptions.length > 0 && <> -
- Open in Desktop IDE Beta
} - desc="Choose whether you would like to open your workspace in a desktop IDE instead." - checked={useDesktopIde} - onChange={(evt) => actuallySetUseDesktopIde(evt.target.checked)} /> + {browserIdeOptions && <> +

Default Browser Editor

+

Choose which IDE you want to use.

+
+ { + browserIdeOptions.map(([id, option]) => { + const selected = defaultIde === id; + const onSelect = () => actuallySetDefaultIde(id); + return renderIdeOption(option, selected, onSelect); + }) + }
- {useDesktopIde && <> -
- { - desktopIdeOptions.map(([id, option]) => { - const selected = defaultDesktopIde === id; - const onSelect = () => actuallySetDefaultDesktopIde(id); - return renderIdeOption(option, selected, onSelect); - }) - } -
- - {ideOptions.options[defaultDesktopIde].notes && -
    - {ideOptions.options[defaultDesktopIde].notes?.map((x, idx) =>
  • 0 ? "mt-2" : ""}>{x}
  • )} -
+ {ideOptions.options[defaultIde].notes && +
    + {ideOptions.options[defaultIde].notes?.map((x, idx) =>
  • 0 ? "mt-2" : ""}>{x}
  • )} +
+ } + } + {desktopIdeOptions && <> +

Default Desktop Editor

+

Open new workspaces with your preferred choice of desktop editor. Whilst using a desktop editor,
you can also work concurrently via the browser editor.

+
+ { + desktopIdeOptions.map(([id, option]) => { + const selected = defaultDesktopIde === id; + const onSelect = () => actuallySetDefaultDesktopIde(id); + return renderIdeOption(option, selected, onSelect); + }) } -

- The JetBrains desktop IDEs are currently in beta. Send feedback · Documentation -

- } +
+ {ideOptions.options[defaultDesktopIde].notes && +
    + {ideOptions.options[defaultDesktopIde].notes?.map((x, idx) =>
  • 0 ? "mt-2" : ""}>{x}
  • )} +
+ } +

+ The JetBrains desktop IDEs are currently in beta. Send feedback · Documentation +

} }

Theme

@@ -201,6 +208,7 @@ export default function Preferences() { } function orderedIdeOptions(ideOptions: IDEOptions, type: "browser" | "desktop") { + // TODO: Maybe convert orderKey to number return Object.entries(ideOptions.options) .filter(([_, x]) => x.type === type && !x.hidden) .sort((a, b) => { @@ -213,8 +221,12 @@ function orderedIdeOptions(ideOptions: IDEOptions, type: "browser" | "desktop") function renderIdeOption(option: IDEOption, selected: boolean, onSelect: () => void): JSX.Element { const card =
- logo +
+ {option.logo && option.logo.length > 0 && <> + logo + } +
{option.label ?
{option.label}
: <>}
;