@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
31 lines • 2.12 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { AlertVariant, Tab, Tabs, TabTitleText } from "@patternfly/react-core";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useAdminClient } from "../admin-client";
import { useAlerts } from "../ui-shared";
import { RoleMapping } from "../components/role-mapping/RoleMapping";
import { useRealm } from "../context/realm-context/RealmContext";
import { DefaultsGroupsTab } from "../realm-settings/DefaultGroupsTab";
export const UserRegistration = () => {
const { adminClient } = useAdminClient();
const { t } = useTranslation();
const [activeTab, setActiveTab] = useState(10);
const { realmRepresentation: realm } = useRealm();
const [key, setKey] = useState(0);
const { addAlert, addError } = useAlerts();
const { realm: realmName } = useRealm();
const addComposites = async (composites) => {
const compositeArray = composites;
try {
await adminClient.roles.createComposite({ roleId: realm === null || realm === void 0 ? void 0 : realm.defaultRole.id, realm: realmName }, compositeArray);
setKey(key + 1);
addAlert(t("addAssociatedRolesSuccess"), AlertVariant.success);
}
catch (error) {
addError("addAssociatedRolesError", error);
}
};
return (_jsxs(Tabs, { activeKey: activeTab, onSelect: (_, key) => setActiveTab(key), children: [_jsx(Tab, { id: "roles", eventKey: 10, title: _jsx(TabTitleText, { children: t("defaultRoles") }), "data-testid": "default-roles-tab", children: _jsx(RoleMapping, { name: realm === null || realm === void 0 ? void 0 : realm.defaultRole.name, id: realm === null || realm === void 0 ? void 0 : realm.defaultRole.id, type: "roles", isManager: true, save: (rows) => addComposites(rows.map((r) => r.role)) }) }, key), _jsx(Tab, { id: "groups", eventKey: 20, title: _jsx(TabTitleText, { children: t("defaultGroups") }), "data-testid": "default-groups-tab", children: _jsx(DefaultsGroupsTab, {}) })] }));
};
//# sourceMappingURL=UserRegistration.js.map