Skip to content

Commit

Permalink
[dashboard] Re-implement default IDE switch for new dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
jankeromnes committed Mar 17, 2021
1 parent f1b574d commit bee5373
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
15 changes: 15 additions & 0 deletions components/dashboard/src/components/OptionCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface OptionCardProps {
title: string;
selected: boolean;
onClick: () => void;
children?: React.ReactNode;
}

function OptionCard(props: OptionCardProps) {
return <div className={`rounded-xl p-4 border-2 ${props.selected ? 'border-green-500' : 'border-gray-300 hover:border-gray-400'}`}>
<p className={`text-base font-semibold ${props.selected ? 'color-green-600' : 'color-gray-300 hover:color-gray-400'}`}>{props.title}</p>
{props.children}
</div>;
}

export default OptionCard;
19 changes: 16 additions & 3 deletions components/dashboard/src/settings/DefaultIDE.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { useContext, useState } from "react";
import OptionCard from "../components/OptionCard";
import { SettingsPage } from "../components/SettingsPage";
import settingsMenu from './settings-menu';
// import { getGitpodService } from "../service/service";
import { UserContext } from "../user-context";
import settingsMenu from "./settings-menu";

export default function DefaultIDE() {
const { user } = useContext(UserContext);
const [ defaultIde, setDefaultIde ] = useState<string>(user?.additionalData?.ideSettings?.defaultIde || 'code');

return <div>
<SettingsPage title='Default IDE' subtitle='Configure your default IDE' menuEntries={settingsMenu}>
<div className="lg:px-28 px-10 flex pt-10">
Default IDE
<div className="flex flex-col lg:flex-row">
<div className="pb-6">
<div className="pt-6">
<OptionCard title="Code" selected={defaultIde === 'code'} onClick={()=>setDefaultIde('code')}></OptionCard>
<OptionCard title="Theia" selected={defaultIde === 'theia'} onClick={()=>setDefaultIde('theia')}></OptionCard>
<OptionCard title="Custom" selected={!['code', 'theia'].includes(defaultIde)} onClick={()=>setDefaultIde('')}></OptionCard>
</div>
</div>
</div>
</SettingsPage>
</div>;
Expand Down

0 comments on commit bee5373

Please sign in to comment.