Skip to content

Commit 3849537

Browse files
committed
[dashboard] Re-implement default IDE switch for new dashboard
1 parent 26cbae4 commit 3849537

File tree

7 files changed

+71
-16
lines changed

7 files changed

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

components/dashboard/public/images/vscode.svg

Lines changed: 11 additions & 0 deletions
Loading

components/dashboard/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Notifications = React.lazy(() => import('./settings/Notifications'));
1414
const Plans = React.lazy(() => import('./settings/Plans'));
1515
const EnvironmentVariables = React.lazy(() => import('./settings/EnvironmentVariables'));
1616
const GitIntegrations = React.lazy(() => import('./settings/GitIntegrations'));
17-
const DefaultIDE = React.lazy(() => import('./settings/DefaultIDE'));
17+
const Preferences = React.lazy(() => import('./settings/Preferences'));
1818

1919
function Loading() {
2020
return (<h3>Loading...</h3>);
@@ -73,7 +73,7 @@ function App() {
7373
<Route path="/plans" exact component={Plans} />
7474
<Route path="/variables" exact component={EnvironmentVariables} />
7575
<Route path="/integrations" exact component={GitIntegrations} />
76-
<Route path="/default-ide" exact component={DefaultIDE} />
76+
<Route path="/preferences" exact component={Preferences} />
7777
</React.Fragment>
7878
)}
7979
</Switch>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export interface OptionCardProps {
2+
title: string;
3+
selected: boolean;
4+
className?: string;
5+
onClick: () => void;
6+
children?: React.ReactNode;
7+
}
8+
9+
function OptionCard(props: OptionCardProps) {
10+
return <div className={`rounded-xl px-4 py-3 flex flex-col group border-2 ${props.selected ? 'border-green-600' : 'border-gray-300 hover:border-gray-400'} ${props.className || ''}`} onClick={props.onClick}>
11+
<div className="flex items-center">
12+
<p className={`w-full text-base font-semibold ${props.selected ? 'text-green-600' : 'text-gray-300 group-hover:text-gray-400'}`}>{props.title}</p>
13+
<input type="radio" checked={props.selected} />
14+
</div>
15+
{props.children}
16+
</div>;
17+
}
18+
19+
export default OptionCard;

components/dashboard/src/settings/DefaultIDE.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useContext, useState } from "react";
2+
import OptionCard from "../components/OptionCard";
3+
import { SettingsPage } from "../components/SettingsPage";
4+
import { UserContext } from "../user-context";
5+
import settingsMenu from "./settings-menu";
6+
7+
export default function Preferences() {
8+
const { user } = useContext(UserContext);
9+
const [ defaultIde, setDefaultIde ] = useState<string>(user?.additionalData?.ideSettings?.defaultIde || 'code');
10+
11+
return <div>
12+
<SettingsPage title='Preferences' subtitle='Configure your Default IDE for all workspaces.' menuEntries={settingsMenu}>
13+
<h3>Default IDE</h3>
14+
<p className="text-base">Gitpod is using Code as the default IDE.</p>
15+
<div className="mt-4 space-x-4 flex">
16+
<OptionCard className="w-36 h-40" title="VS Code" selected={defaultIde === 'code'} onClick={()=>setDefaultIde('code')}>
17+
<div className="flex-grow flex justify-center align-center">
18+
<img className="w-16" src="/images/vscode.svg"/>
19+
</div>
20+
</OptionCard>
21+
<OptionCard className="w-36 h-40" title="Theia" selected={defaultIde === 'theia'} onClick={()=>setDefaultIde('theia')}>
22+
<div className="flex-grow flex justify-center align-center">
23+
<img className="w-16" src="/images/theia.svg"/>
24+
</div>
25+
</OptionCard>
26+
<OptionCard className="w-36 h-40" title="Custom" selected={!['code', 'theia'].includes(defaultIde)} onClick={()=>setDefaultIde('')}></OptionCard>
27+
</div>
28+
<div className="mt-4">
29+
<label className={['code', 'theia'].includes(defaultIde) ? 'opacity-0' : 'opacity-100'}>
30+
<p className="text-base text-gray-600 font-bold leading-5">Custom IDE image name</p>
31+
<input className="w-80 mt-1" type="text" />
32+
</label>
33+
</div>
34+
</SettingsPage>
35+
</div>;
36+
}

components/dashboard/src/settings/settings-menu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default [
2020
link: '/integrations'
2121
},
2222
{
23-
title: 'Default IDE',
24-
link: '/default-ide'
23+
title: 'Preferences',
24+
link: '/preferences'
2525
},
2626
];

0 commit comments

Comments
 (0)