2020-10-01 14:25:29 +00:00
|
|
|
import React from "react";
|
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
import useBreadcrumbs from "use-react-router-breadcrumbs";
|
|
|
|
import { useTranslation } from "react-i18next";
|
2020-11-05 14:40:00 +00:00
|
|
|
import { Breadcrumb, BreadcrumbItem } from "@patternfly/react-core";
|
2020-10-01 14:25:29 +00:00
|
|
|
|
|
|
|
import { routes } from "../../route-config";
|
|
|
|
|
|
|
|
export const PageBreadCrumbs = () => {
|
|
|
|
const { t } = useTranslation();
|
2020-11-17 21:28:34 +00:00
|
|
|
const crumbs = useBreadcrumbs(routes(t), { excludePaths: ["/"] });
|
2020-10-01 14:25:29 +00:00
|
|
|
return (
|
2020-11-05 14:40:00 +00:00
|
|
|
<>
|
|
|
|
{crumbs.length > 1 && (
|
|
|
|
<Breadcrumb>
|
|
|
|
{crumbs.map(({ match, breadcrumb: crumb }, i) => (
|
|
|
|
<BreadcrumbItem key={i} isActive={crumbs.length - 1 === i}>
|
|
|
|
{crumbs.length - 1 !== i && <Link to={match.url}>{crumb}</Link>}
|
|
|
|
{crumbs.length - 1 === i && <>{crumb}</>}
|
|
|
|
</BreadcrumbItem>
|
|
|
|
))}
|
|
|
|
</Breadcrumb>
|
|
|
|
)}
|
|
|
|
</>
|
2020-10-01 14:25:29 +00:00
|
|
|
);
|
|
|
|
};
|