Skip to content

Commit 6e82249

Browse files
committed
[dashboard] Simplify SettingsPage component by folding the SubMenu back into it
1 parent 32f59f1 commit 6e82249

12 files changed

+52
-68
lines changed

components/dashboard/src/components/SettingsPage.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

components/dashboard/src/components/SubMenu.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

components/dashboard/src/settings/Account.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { User } from "@gitpod/gitpod-protocol";
22
import { useContext, useState } from "react";
33
import Modal from "../components/Modal";
4-
import { SettingsPage } from "../components/SettingsPage";
54
import { UserContext } from "../user-context";
6-
import settingsMenu from "./settings-menu";
5+
import { SettingsPage } from "./SettingsPage";
76

87
export default function Account() {
98
const { user } = useContext(UserContext);
@@ -20,7 +19,7 @@ export default function Account() {
2019
</div>
2120
</Modal>
2221

23-
<SettingsPage title='Account' subtitle='Profile details' menuEntries={settingsMenu}>
22+
<SettingsPage title='Account' subtitle='Profile details'>
2423
<h3>Profile</h3>
2524
<div className="flex flex-col lg:flex-row">
2625
<div>

components/dashboard/src/settings/EnvironmentVariables.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { SettingsPage } from "../components/SettingsPage";
2-
import settingsMenu from './settings-menu';
1+
import { SettingsPage } from "./SettingsPage";
32

43
export default function EnvVars() {
54
return <div>
6-
<SettingsPage title='Environment Variables' subtitle='Configure environment variables for your workspaces' menuEntries={settingsMenu}>
5+
<SettingsPage title='Environment Variables' subtitle='Configure environment variables for your workspaces'>
76
<h3>Environment Variables</h3>
87
</SettingsPage>
98
</div>;

components/dashboard/src/settings/GitIntegrations.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { SettingsPage } from "../components/SettingsPage";
2-
import settingsMenu from './settings-menu';
1+
import { SettingsPage } from "./SettingsPage";
32

43
export default function GitIntegrations() {
54
return <div>
6-
<SettingsPage title='Git Integrations' subtitle='Manage integration with your Git hosters' menuEntries={settingsMenu}>
5+
<SettingsPage title='Git Integrations' subtitle='Manage integration with your Git hosters'>
76
<h3>Git Hoster Access Control</h3>
87
</SettingsPage>
98
</div>;

components/dashboard/src/settings/Notifications.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { SettingsPage } from "../components/SettingsPage";
2-
import settingsMenu from "./settings-menu";
1+
import { SettingsPage } from "./SettingsPage";
32

43
export default function Notifications() {
54
return <div>
6-
<SettingsPage title='Notifications' subtitle='Email notification preferences' menuEntries={settingsMenu}>
5+
<SettingsPage title='Notifications' subtitle='Email notification preferences'>
76
<h3>Notifications</h3>
87
</SettingsPage>
98
</div>;

components/dashboard/src/settings/Plans.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { SettingsPage } from "../components/SettingsPage";
2-
import settingsMenu from "./settings-menu";
1+
import { SettingsPage } from "./SettingsPage";
32

43
export default function Plans() {
54
return <div>
6-
<SettingsPage title='Plans' subtitle='Plans and Usage' menuEntries={settingsMenu} >
5+
<SettingsPage title='Plans' subtitle='Plans and Usage'>
76
<h3>Plans</h3>
87
</SettingsPage>
98
</div>;

components/dashboard/src/settings/Preferences.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { useContext, useState } from "react";
22
import OptionCard from "../components/OptionCard";
3-
import { SettingsPage } from "../components/SettingsPage";
43
import { UserContext } from "../user-context";
5-
import settingsMenu from "./settings-menu";
4+
import { SettingsPage } from "./SettingsPage";
65

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

1110
return <div>
12-
<SettingsPage title='Preferences' subtitle='Configure your Default IDE for all workspaces.' menuEntries={settingsMenu}>
11+
<SettingsPage title='Preferences' subtitle='Configure your Default IDE for all workspaces.'>
1312
<h3>Default IDE</h3>
1413
<p className="text-base">Gitpod is using Code as the default IDE.</p>
1514
<div className="mt-4 space-x-4 flex">
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Link } from "react-router-dom";
2+
import Header from '../components/Header';
3+
import settingsMenu from "./settings-menu";
4+
5+
export interface Props {
6+
title: string;
7+
subtitle: string;
8+
children: React.ReactNode;
9+
}
10+
11+
export function SettingsPage(p: Props) {
12+
return <div>
13+
<Header title={p.title} subtitle={p.subtitle}/>
14+
<div className='lg:px-28 px-10 flex pt-9'>
15+
<div>
16+
<ul className="flex flex-col text-sm text-gray-500 pt-4 lg:pt-0 w-48 space-y-2">
17+
{settingsMenu.map(e => {
18+
let classes = "flex block py-2 font-sm px-4 rounded-md";
19+
if (e.link.toLowerCase() === window.location.pathname) {
20+
classes += " bg-gray-800 text-gray-50";
21+
} else {
22+
classes += " hover:bg-gray-100";
23+
}
24+
return <Link to={e.link} key={e.title}>
25+
<li className={classes}>
26+
{e.title}
27+
</li>
28+
</Link>;
29+
})}
30+
</ul>
31+
</div>
32+
<div className='ml-32 w-full pt-1'>
33+
{p.children}
34+
</div>
35+
</div>
36+
</div>;
37+
}

components/dashboard/src/start/CreateWorkspace.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React, { Suspense } from "react";
22
import { CreateWorkspaceMode, WorkspaceCreationResult } from "@gitpod/gitpod-protocol";
33
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
44
import Modal from "../components/Modal";
5-
import { StartPage, StartPhase } from "../components/StartPage";
6-
import StartWorkspace from "./StartWorkspace";
75
import { getGitpodService } from "../service/service";
6+
import { StartPage, StartPhase } from "./StartPage";
7+
import StartWorkspace from "./StartWorkspace";
88

99
const WorkspaceLogs = React.lazy(() => import('./WorkspaceLogs'));
1010

components/dashboard/src/start/StartWorkspace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from "react";
22
import { DisposableCollection, WorkspaceInstance } from "@gitpod/gitpod-protocol";
33
import { GitpodHostUrl } from "@gitpod/gitpod-protocol/lib/util/gitpod-host-url";
4-
import { StartPage, StartPhase } from "../components/StartPage";
54
import { getGitpodService } from "../service/service";
5+
import { StartPage, StartPhase } from "./StartPage";
66

77
export interface StartWorkspaceProps {
88
workspaceId: string;

0 commit comments

Comments
 (0)