/
project-node-tooltip.tsx
90 lines (83 loc) · 2.4 KB
/
project-node-tooltip.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { getProjectGraphService } from '../machines/get-services';
import { FlagIcon, MapPinIcon } from '@heroicons/react/24/solid';
import Tag from '../ui-components/tag';
import { TooltipButton, TooltipLinkButton } from './tooltip-button';
import { useRouteConstructor } from '../util';
import { useNavigate } from 'react-router-dom';
export interface ProjectNodeToolTipProps {
type: 'app' | 'lib' | 'e2e';
id: string;
tags: string[];
}
export function ProjectNodeToolTip({
type,
id,
tags,
}: ProjectNodeToolTipProps) {
const projectGraphService = getProjectGraphService();
const { start, end, algorithm } =
projectGraphService.getSnapshot().context.tracing;
const routeConstructor = useRouteConstructor();
const navigate = useNavigate();
function onExclude() {
projectGraphService.send({
type: 'deselectProject',
projectName: id,
});
navigate(routeConstructor('/projects', true));
}
function onStartTrace() {
navigate(
routeConstructor(`/projects/trace/${encodeURIComponent(id)}`, true)
);
}
function onEndTrace() {
navigate(
routeConstructor(
`/projects/trace/${encodeURIComponent(start)}/${encodeURIComponent(
id
)}`,
true
)
);
}
return (
<div className="text-sm text-slate-700 dark:text-slate-400">
<h4>
<Tag className="mr-3">{type}</Tag>
<span className="font-mono">{id}</span>
</h4>
{tags.length > 0 ? (
<p className="my-2">
<strong>tags</strong>
<br></br>
{tags.join(', ')}
</p>
) : null}
<div className="grid grid-cols-3 gap-4">
<TooltipLinkButton to={routeConstructor(`/projects/${id}`, true)}>
Focus
</TooltipLinkButton>
<TooltipButton onClick={onExclude}>Exclude</TooltipButton>
{!start ? (
<TooltipButton
className="flex flex-row items-center"
onClick={onStartTrace}
>
<MapPinIcon className="mr-2 h-5 w-5 text-slate-500"></MapPinIcon>
Start
</TooltipButton>
) : (
<TooltipButton
className="flex flex-row items-center"
onClick={onEndTrace}
>
<FlagIcon className="mr-2 h-5 w-5 text-slate-500"></FlagIcon>
End
</TooltipButton>
)}
</div>
</div>
);
}
export default ProjectNodeToolTip;