@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
32 lines • 1.41 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useFetch } from "../ui-shared";
import { Button } from "@patternfly/react-core";
import { useState } from "react";
import { Link } from "react-router-dom";
import { useAdminClient } from "../admin-client";
import { useAccess } from "../context/access/Access";
import { useRealm } from "../context/realm-context/RealmContext";
import { toCustomUserFederation } from "../user-federation/routes/CustomUserFederation";
export const FederatedUserLink = ({ user }) => {
const { adminClient } = useAdminClient();
const access = useAccess();
const { realm } = useRealm();
const [component, setComponent] = useState();
useFetch(() => access.hasAccess("view-realm")
? adminClient.components.findOne({
id: user.federationLink,
})
: adminClient.userStorageProvider.name({
id: user.federationLink,
}), setComponent, []);
if (!component)
return null;
if (!access.hasAccess("view-realm"))
return _jsx("span", { children: component.name });
return (_jsx(Button, { variant: "link", component: (props) => (_jsx(Link, { ...props, to: toCustomUserFederation({
id: component.id,
providerId: component.providerId,
realm,
}) })), children: component.name }));
};
//# sourceMappingURL=FederatedUserLink.js.map