Skip to content

Commit 7515590

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

File tree

2 files changed

+53
-11
lines changed

2 files changed

+53
-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">
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: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ 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

18+
function getLabel(state: WorkspaceInstancePhase) {
19+
return state.substr(0,1).toLocaleUpperCase() + state.substr(1);
20+
}
1721

1822
export function WorkspaceEntry({ desc, model }: { desc: WorkspaceInfo, model: WorkspaceModel }) {
1923
const [isModalVisible, setModalVisible] = useState(false);
@@ -100,20 +104,23 @@ export function WorkspaceEntry({ desc, model }: { desc: WorkspaceInfo, model: Wo
100104
setChangesModalVisible(true);
101105
}
102106
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()}>
107+
<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">
104108
<div className="pr-3 self-center">
105-
<div className={stateClassName}>
106-
&nbsp;
107-
</div>
109+
<Tooltip content={getLabel(state)}>
110+
<div className={stateClassName}>
111+
</div>
112+
</Tooltip>
108113
</div>
109114
<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>
115+
<a href={startUrl.toString()}><div className="font-medium text-gray-800 truncate hover:text-blue-600">{ws.id}</div></a>
116+
<a href={project ? 'https://' + project : undefined}><div className="text-sm overflow-ellipsis truncate text-gray-400 hover:text-blue-600">{project || 'Unknown'}</div></a>
112117
</div>
113118
<div className="flex w-4/12 truncate overflow-ellipsis">
114119
<div className="flex flex-col">
115120
<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>
121+
<a href={ws.contextURL}>
122+
<div className="text-sm text-gray-400 overflow-ellipsis truncate hover:text-blue-600">{ws.contextURL}</div>
123+
</a>
117124
</div>
118125
</div>
119126
<div className="flex w-2/12 truncate" onClick={numberOfChanges > 0 ? showChanges : undefined}>
@@ -127,19 +134,21 @@ export function WorkspaceEntry({ desc, model }: { desc: WorkspaceInfo, model: Wo
127134
}
128135
</div>
129136
</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>
137+
<div className="flex w-2/12 self-center">
138+
<Tooltip content={`Created ${moment(desc.workspace.creationTime).fromNow()}`}>
139+
<div className="text-sm w-full text-gray-400 truncate">{moment(WorkspaceInfo.lastActiveISODate(desc)).fromNow()}</div>
140+
</Tooltip>
132141
</div>
133142
<div className="flex w-8 self-center hover:bg-gray-200 rounded-md cursor-pointer">
134143
<ContextMenu menuEntries={menuEntries}>
135144
<img className="w-8 h-8 p-1" src={ThreeDots} alt="Actions" />
136145
</ContextMenu>
137146
</div>
138-
</a>
147+
</div>
139148
<Modal visible={isChangesModalVisible} onClose={() => setChangesModalVisible(false)}>
140149
{getChangesPopup(pendingChanges)}
141150
</Modal>
142-
<Modal visible={isModalVisible} onClose={() => setModalVisible(false)} onEnter={() => {model.deleteWorkspace(ws.id); return true;}}>
151+
<Modal visible={isModalVisible} onClose={() => setModalVisible(false)} onEnter={() => { model.deleteWorkspace(ws.id); return true; }}>
143152
<div>
144153
<h3 className="pb-2">Delete Workspace</h3>
145154
<div className="border-t border-b border-gray-200 mt-2 -mx-6 px-6 py-2">

0 commit comments

Comments
 (0)