@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
28 lines • 1.85 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { HelpItem, TextAreaControl, TextControl, } from "../ui-shared";
import { FormGroup } from "@patternfly/react-core";
import { useEffect } from "react";
import { useFormContext, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { keyValueToArray } from "../components/key-value-form/key-value-convert";
import { MultiLineInput } from "../components/multi-line-input/MultiLineInput";
export const convertToOrg = (org) => {
var _a;
return ({
...org,
domains: (_a = org.domains) === null || _a === void 0 ? void 0 : _a.map((d) => ({ name: d, verified: false })),
attributes: keyValueToArray(org.attributes),
});
};
export const OrganizationForm = ({ readOnly = false, }) => {
const { t } = useTranslation();
const { setValue } = useFormContext();
const name = useWatch({ name: "name" });
useEffect(() => {
if (!readOnly) {
setValue("alias", name);
}
}, [name, readOnly]);
return (_jsxs(_Fragment, { children: [_jsx(TextControl, { label: t("name"), name: "name", rules: { required: t("required") } }), _jsx(TextControl, { label: t("alias"), name: "alias", labelIcon: t("organizationAliasHelp"), isDisabled: readOnly }), _jsx(FormGroup, { label: t("domain"), fieldId: "domain", labelIcon: _jsx(HelpItem, { helpText: t("organizationDomainHelp"), fieldLabelId: "domain" }), children: _jsx(MultiLineInput, { id: "domain", name: "domains", "aria-label": t("domain"), addButtonLabel: "addDomain" }) }), _jsx(TextControl, { label: t("redirectUrl"), name: "redirectUrl", labelIcon: t("organizationRedirectUrlHelp") }), _jsx(TextAreaControl, { name: "description", label: t("description") })] }));
};
//# sourceMappingURL=OrganizationForm.js.map