UNPKG

@keycloakify/keycloak-admin-ui

Version:
25 lines 1.51 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useEffect } from "react"; import { Link, useLocation } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Breadcrumb, BreadcrumbItem } from "@patternfly/react-core"; import { useSubGroups } from "../../groups/SubGroupsContext"; import { useRealm } from "../../context/realm-context/RealmContext"; export const GroupBreadCrumbs = () => { const { t } = useTranslation(); const { clear, remove, subGroups } = useSubGroups(); const { realm } = useRealm(); const location = useLocation(); useEffect(() => { const { pathname } = location; if (!pathname.includes("/groups") || pathname.endsWith("/groups")) { clear(); } }, [location]); return subGroups.length !== 0 ? (_jsxs(Breadcrumb, { children: [_jsx(BreadcrumbItem, { children: _jsx(Link, { to: `/${realm}/groups`, children: t("groups") }) }, "home"), subGroups.map((group, i) => { const isLastGroup = i === subGroups.length - 1; return (_jsxs(BreadcrumbItem, { isActive: isLastGroup, children: [!isLastGroup && (_jsx(Link, { to: location.pathname.substring(0, location.pathname.indexOf(group.id) + group.id.length), onClick: () => remove(group), children: group.name })), isLastGroup && (group.id === "search" ? group.name : t("groupDetails"))] }, group.id)); })] })) : null; }; //# sourceMappingURL=GroupBreadCrumbs.js.map