-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathBreadCrumbs.tsx
65 lines (59 loc) · 1.87 KB
/
BreadCrumbs.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
import { ChevronRight } from '@osrd-project/ui-icons';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import type { Project, Study, Scenario } from 'common/api/osrdEditoastApi';
type Props = {
project?: Project;
study?: Study;
scenario?: Scenario;
};
export default function BreadCrumbs({ project, study, scenario }: Props) {
const { t } = useTranslation('operationalStudies/project');
return (
<div className="navbar-breadcrumbs">
{!project && !study && !scenario ? (
t('projectsList')
) : (
<>
<div>
<Link to="/operational-studies/projects">{t('projectsList')}</Link>{' '}
</div>
<span className="text-muted">
<ChevronRight />
</span>
</>
)}
{project && !study && !scenario && <div className="text-truncate">{project.name}</div>}
{project && study && (
<>
<div data-testid="project-breadcrumbs" className="text-truncate" title={project.name}>
<Link to={`/operational-studies/projects/${project.id}`}> {project.name}</Link>
</div>
<span className="text-muted">
<ChevronRight />
</span>
</>
)}
{project && study && !scenario && (
<div className="text-truncate" title={study.name}>
{study.name}
</div>
)}
{project && study && scenario && (
<>
<div className="text-truncate" title={study.name}>
<Link to={`/operational-studies/projects/${project.id}/studies/${study.id}`}>
{study.name}
</Link>
</div>
<span className="text-muted">
<ChevronRight />
</span>
<div className="text-truncate" title={scenario.name}>
{scenario.name}
</div>
</>
)}
</div>
);
}