Skip to content

Commit 3f6a5dd

Browse files
committed
[dashboard] avatar menu
1 parent d644c6b commit 3f6a5dd

File tree

4 files changed

+47
-21
lines changed

4 files changed

+47
-21
lines changed

components/dashboard/src/components/ContextMenu.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ function ContextMenu(props: ContextMenuProps) {
3434
const enhancedEntries = props.menuEntries.map(e => {
3535
return {
3636
... e,
37-
onClick: () => {
37+
onClick: e.onClick ? () => {
3838
e.onClick && e.onClick();
3939
toggleExpanded();
40-
}
40+
}: undefined
4141
}
4242
})
43-
const font = "text-gray-400 hover:text-gray-800"
43+
44+
const font = "text-gray-600 hover:text-gray-800"
4445
return (
4546
<div className="relative cursor-pointer">
4647
<div onClick={(e) => {
@@ -50,12 +51,16 @@ function ContextMenu(props: ContextMenuProps) {
5051
{props.children}
5152
</div>
5253
{expanded?
53-
<div className={`z-50 ${props.width || 'w-40'} bg-white absolute py-2 right-0 flex flex-col border border-gray-200 rounded-lg space-y-2`}>
54+
<div className={`mt-2 z-50 ${props.width || 'w-40'} bg-white absolute right-0 flex flex-col border border-gray-200 rounded-lg`}>
5455
{enhancedEntries.map(e => {
55-
const entry = <div key={e.title} className={`px-4 flex py-2 text-gray-600 hover:bg-gray-200 text-sm leading-1 ${e.customFontStyle || font} ${e.separator? ' border-b border-gray-200':''}`} >
56+
const clickable = e.href || e.onClick;
57+
const entry = <div key={e.title} className={`px-4 flex py-3 ${clickable?'hover:bg-gray-200':''} text-sm leading-1 ${e.customFontStyle || font} ${e.separator? ' border-b border-gray-200':''}`} >
5658
<div>{e.title}</div><div className="flex-1"></div>{e.active ? <div className="pl-1 font-semibold">&#x2713;</div>: null}
5759
</div>
58-
return <a href={e.href} onClick={e.onClick}>
60+
if (!clickable) {
61+
return entry;
62+
}
63+
return <a key={e.title} href={e.href} onClick={e.onClick}>
5964
{entry}
6065
</a>
6166
})}

components/dashboard/src/components/Menu.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { User } from "@gitpod/gitpod-protocol";
12
import { useContext } from "react";
23
import { Link } from "react-router-dom";
4+
import { gitpodHostUrl } from "../service/service";
35
import { UserContext } from "../user-context";
6+
import ContextMenu from "./ContextMenu";
47

58
interface Entry {
69
title: string, link: string
@@ -57,10 +60,27 @@ function Menu(props: { left: Entry[], right: Entry[] }) {
5760
{props.right.map(MenuItem)}
5861
</ul>
5962
</nav>
60-
<Link className="lg:ml-3 flex items-center justify-start lg:mb-0 mb-4 pointer-cursor m-l-auto rounded-full border-2 border-white hover:border-gray-200 p-0.5" to="/account">
61-
<img className="rounded-full w-6 h-6"
62-
src={user?.avatarUrl || ''} alt={user?.name || 'Anonymous'} />
63-
</Link>
63+
<div className="lg:ml-3 flex items-center justify-start lg:mb-0 mb-4 pointer-cursor m-l-auto rounded-full border-2 border-white hover:border-gray-200 p-0.5">
64+
<ContextMenu menuEntries={[
65+
{
66+
title: (user && User.getPrimaryEmail(user)) || '',
67+
customFontStyle: 'text-gray-400',
68+
separator: true
69+
},
70+
{
71+
title: 'Settings',
72+
href: '/settings',
73+
separator: true
74+
},
75+
{
76+
title: 'Logout',
77+
href: gitpodHostUrl.asApiLogout().toString()
78+
},
79+
]}>
80+
<img className="rounded-full w-6 h-6"
81+
src={user?.avatarUrl || ''} alt={user?.name || 'Anonymous'} />
82+
</ContextMenu>
83+
</div>
6484
</div>
6585
</header>
6686
);

components/dashboard/src/components/StartPage.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ function ProgressBar(props: { phase: number, error: boolean }) {
2323
// This phase is currently running
2424
classes += ' bg-green-400 animate-pulse';
2525
}
26-
return <div key={'phase-'+i} className={classes}/>;
26+
return <div key={'phase-' + i} className={classes} />;
2727
})}
2828
</div>;
2929
}
3030

3131
export interface StartPageProps {
32-
phase: number;
33-
error?: boolean;
34-
children?: React.ReactNode;
32+
phase: number;
33+
error?: boolean;
34+
children?: React.ReactNode;
3535
}
3636

3737
export function StartPage(props: StartPageProps) {
@@ -56,11 +56,12 @@ export function StartPage(props: StartPageProps) {
5656
title = "Starting";
5757
break;
5858
}
59-
return <div className="h-screen flex bg-white">
60-
<div className="w-full mt-40 md:mt-60 flex flex-col items-center">
59+
return <div className="w-screen h-screen bg-white align-middle">
60+
<div className="flex flex-col mx-auto items-center h-screen">
61+
<div className="h-1/3"></div>
6162
<img src="/gitpod.svg" className="h-16 flex-shrink-0" />
6263
<h3 className="mt-8 text-xl">{title}</h3>
63-
<ProgressBar phase={props.phase} error={!!props.error}/>
64+
<ProgressBar phase={props.phase} error={!!props.error} />
6465
{props.children}
6566
</div>
6667
</div>;

components/dashboard/src/workspaces/WorkspaceEntry.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,19 @@ export function WorkspaceEntry({desc, model}: {desc: WorkspaceInfo, model: Works
9999
<a href={project ? 'https://'+ project : undefined}><div className="text-sm overflow-ellipsis truncate text-gray-400 truncate">{project || 'Unknown'}</div></a>
100100
</div>
101101
<div className="flex w-4/12 truncate overflow-ellipsis" onClick={startWsOnClick}>
102-
<div className="flex flex-col">
102+
<div className="flex flex-col truncate">
103103
<div className="font-medium text-gray-500 truncate">{ws.description}</div>
104104
<div className="text-sm text-gray-400 truncate">{ws.contextURL}</div>
105105
</div>
106106
</div>
107107
<div className="flex w-2/12" onClick={numberOfChanges > 0 ? showChanges: startWsOnClick}>
108-
<div className="flex flex-col">
108+
<div className="flex flex-col truncate">
109109
<div className="font-medium text-gray-500 truncate">{currentBranch}</div>
110110
{
111111
numberOfChanges > 0 ?
112-
<div className={"text-sm text-red truncate cursor-pointer hover:underline"} onClick={showChanges}>{changesLabel}</div>
112+
<div className={"text-sm text-red cursor-pointer hover:underline"} onClick={showChanges}>{changesLabel}</div>
113113
:
114-
<div className="text-sm text-gray-400 truncate">No Changes</div>
114+
<div className="text-sm text-gray-400">No Changes</div>
115115
}
116116
<Modal visible={isChangesModalVisible} onClose={() => setChangesModalVisible(false)}>
117117
{getChangesPopup(pendingChanges)}

0 commit comments

Comments
 (0)