UNPKG

@keycloakify/keycloak-admin-ui

Version:
23 lines 2.34 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { DataList, DataListCell, DataListItem, DataListItemCells, DataListItemRow, Modal, ModalVariant, } from "@patternfly/react-core"; import { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { useServerInfo } from "../../context/server-info/ServerInfoProvider"; import useLocaleSort, { mapByKey } from "../../utils/useLocaleSort"; export const AddProviderDialog = ({ onConfirm, toggleDialog, }) => { var _a, _b; const { t } = useTranslation(); const serverInfo = useServerInfo(); const providers = Object.keys(((_a = serverInfo.providers) === null || _a === void 0 ? void 0 : _a["client-registration-policy"].providers) || []); const descriptions = (_b = serverInfo.componentTypes) === null || _b === void 0 ? void 0 : _b["org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy"]; const localeSort = useLocaleSort(); const rows = useMemo(() => localeSort((descriptions === null || descriptions === void 0 ? void 0 : descriptions.filter((d) => providers.includes(d.id))) || [], mapByKey("id")), [providers, descriptions]); return (_jsx(Modal, { variant: ModalVariant.medium, title: t("chooseAPolicyProvider"), isOpen: true, onClose: toggleDialog, children: _jsxs(DataList, { onSelectDataListItem: (_event, id) => { onConfirm(id); toggleDialog(); }, "aria-label": t("addPredefinedMappers"), isCompact: true, children: [_jsx(DataListItem, { "aria-label": t("headerName"), id: "header", children: _jsx(DataListItemRow, { children: _jsx(DataListItemCells, { dataListCells: [t("name"), t("description")].map((name) => (_jsx(DataListCell, { style: { fontWeight: 700 }, children: name }, name))) }) }) }), rows.map((provider) => (_jsx(DataListItem, { "aria-label": provider.id, "data-testid": provider.id, id: provider.id, children: _jsx(DataListItemRow, { children: _jsx(DataListItemCells, { dataListCells: [ _jsx(DataListCell, { width: 2, children: provider.id }, `name-${provider.id}`), _jsx(DataListCell, { width: 4, children: provider.helpText }, `description-${provider.id}`), ] }) }) }, provider.id)))] }) })); }; //# sourceMappingURL=AddProviderDialog.js.map