keycloak-scim/src/components/bread-crumb/PageBreadCrumbs.tsx
Erik Jan de Wit 7ebe695921
removed "Home" from navigation (#209)
* only show breadcrumb when there are 2 levels
* renamed the list clients and client scopes
2020-11-05 15:40:00 +01:00

26 lines
845 B
TypeScript

import React from "react";
import { Link } from "react-router-dom";
import useBreadcrumbs from "use-react-router-breadcrumbs";
import { useTranslation } from "react-i18next";
import { Breadcrumb, BreadcrumbItem } from "@patternfly/react-core";
import { routes } from "../../route-config";
export const PageBreadCrumbs = () => {
const { t } = useTranslation();
const crumbs = useBreadcrumbs(routes(t)).slice(1);
return (
<>
{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>
)}
</>
);
};