Skip to content

Commit c237195

Browse files
committed
[dashboard] Improved Workspace entry
- added tooltips - removed <a/> around entire element - aded links and hover effects on individual elements
1 parent f49abb1 commit c237195

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { useState } from 'react';
8+
9+
export interface TooltipProps {
10+
children: React.ReactChild[] | React.ReactChild;
11+
content: string;
12+
}
13+
14+
function Tooltip(props: TooltipProps) {
15+
const [expanded, setExpanded] = useState(false);
16+
17+
return (
18+
<div onMouseLeave={() => setExpanded(false)} onMouseEnter={() => setExpanded(true)} className="relative cursor-pointer">
19+
<div>
20+
{props.children}
21+
</div>
22+
{expanded ?
23+
<div style={{top: '-100%', left: '50%', transform: 'translate(-50%, -100%)'}} className={`mt-2 z-50 py-1 px-2 bg-gray-900 text-gray-100 text-sm absolute flex flex-col border rounded-md truncated`}>
24+
{props.content}
25+
</div>
26+
:
27+
null
28+
}
29+
</div>
30+
);
31+
}
32+
33+
export default Tooltip;

components/dashboard/src/workspaces/WorkspaceEntry.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { getGitpodService } from '../service/service';
1313
import Modal from '../components/Modal';
1414
import { MouseEvent, useState } from 'react';
1515
import { WorkspaceModel } from './workspace-model';
16+
import Tooltip from '../components/Tooltip';
1617

1718

1819
export function WorkspaceEntry({ desc, model }: { desc: WorkspaceInfo, model: WorkspaceModel }) {
@@ -100,20 +101,23 @@ export function WorkspaceEntry({ desc, model }: { desc: WorkspaceInfo, model: Wo
100101
setChangesModalVisible(true);
101102
}
102103
return <div>
103-
<a className="rounded-xl whitespace-nowrap flex space-x-2 py-6 px-6 w-full justify-between hover:bg-gray-100 focus:bg-gitpod-kumquat-light cursor-pointer group" href={startUrl.toString()}>
104+
<div className="rounded-xl whitespace-nowrap flex space-x-2 py-6 px-6 w-full justify-between hover:bg-gray-100 focus:bg-gitpod-kumquat-light group">
104105
<div className="pr-3 self-center">
105-
<div className={stateClassName}>
106-
&nbsp;
107-
</div>
106+
<Tooltip content={state}>
107+
<div className={stateClassName}>
108+
</div>
109+
</Tooltip>
108110
</div>
109111
<div className="flex flex-col w-3/12">
110-
<div className="font-medium text-gray-800 truncate">{ws.id}</div>
111-
<a href={project ? 'https://' + project : undefined}><div className="text-sm overflow-ellipsis truncate text-gray-400">{project || 'Unknown'}</div></a>
112+
<a href={startUrl.toString()}><div className="font-medium text-gray-800 truncate hover:text-blue-500">{ws.id}</div></a>
113+
<a href={project ? 'https://' + project : undefined}><div className="text-sm overflow-ellipsis truncate text-gray-400 hover:text-blue-400">{project || 'Unknown'}</div></a>
112114
</div>
113115
<div className="flex w-4/12 truncate overflow-ellipsis">
114116
<div className="flex flex-col">
115117
<div className="font-medium text-gray-500 overflow-ellipsis truncate">{ws.description}</div>
116-
<div className="text-sm text-gray-400 overflow-ellipsis truncate">{ws.contextURL}</div>
118+
<a href={ws.contextURL}>
119+
<div className="text-sm text-gray-400 overflow-ellipsis truncate hover:text-blue-400">{ws.contextURL}</div>
120+
</a>
117121
</div>
118122
</div>
119123
<div className="flex w-2/12 truncate" onClick={numberOfChanges > 0 ? showChanges : undefined}>
@@ -127,19 +131,21 @@ export function WorkspaceEntry({ desc, model }: { desc: WorkspaceInfo, model: Wo
127131
}
128132
</div>
129133
</div>
130-
<div className="flex w-2/12 self-center space-x-2 truncate">
131-
<div className="text-sm text-gray-400 truncate">{moment(WorkspaceInfo.lastActiveISODate(desc)).fromNow()}</div>
134+
<div className="flex w-2/12 self-center">
135+
<Tooltip content={`Created ${moment(desc.workspace.creationTime).fromNow()}`}>
136+
<div className="text-sm w-full text-gray-400 truncate">{moment(WorkspaceInfo.lastActiveISODate(desc)).fromNow()}</div>
137+
</Tooltip>
132138
</div>
133139
<div className="flex w-8 self-center hover:bg-gray-200 rounded-md cursor-pointer">
134140
<ContextMenu menuEntries={menuEntries}>
135141
<img className="w-8 h-8 p-1" src={ThreeDots} alt="Actions" />
136142
</ContextMenu>
137143
</div>
138-
</a>
144+
</div>
139145
<Modal visible={isChangesModalVisible} onClose={() => setChangesModalVisible(false)}>
140146
{getChangesPopup(pendingChanges)}
141147
</Modal>
142-
<Modal visible={isModalVisible} onClose={() => setModalVisible(false)} onEnter={() => {model.deleteWorkspace(ws.id); return true;}}>
148+
<Modal visible={isModalVisible} onClose={() => setModalVisible(false)} onEnter={() => { model.deleteWorkspace(ws.id); return true; }}>
143149
<div>
144150
<h3 className="pb-2">Delete Workspace</h3>
145151
<div className="border-t border-b border-gray-200 mt-2 -mx-6 px-6 py-2">

0 commit comments

Comments
 (0)