@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
48 lines • 2.82 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { ActionGroup, AlertVariant, Button, PageSection, } from "@patternfly/react-core";
import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { useAdminClient } from "../../admin-client";
import { useAlerts } from "../../ui-shared";
import { FormAccess } from "../../components/form/FormAccess";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toIdentityProvider } from "../../identity-providers/routes/IdentityProvider";
import { toIdentityProviders } from "../../identity-providers/routes/IdentityProviders";
import { SamlConnectSettings } from "../../identity-providers/add/SamlConnectSettings";
import { SamlGeneralSettings } from "../../identity-providers/add/SamlGeneralSettings";
export default function AddSamlConnect() {
const { adminClient } = useAdminClient();
const { t } = useTranslation();
const navigate = useNavigate();
const id = "saml";
const form = useForm({
defaultValues: { alias: id, config: { allowCreate: "true" } },
mode: "onChange",
});
const { handleSubmit, formState: { isDirty }, } = form;
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();
const onSubmit = async (provider) => {
delete provider.discoveryEndpoint;
try {
await adminClient.identityProviders.create({
...provider,
providerId: id,
});
addAlert(t("createIdentityProviderSuccess"), AlertVariant.success);
navigate(toIdentityProvider({
realm,
providerId: id,
alias: provider.alias,
tab: "settings",
}));
}
catch (error) {
addError("createIdentityProviderError", error);
}
};
return (_jsxs(_Fragment, { children: [_jsx(ViewHeader, { titleKey: t("addSamlProvider") }), _jsx(PageSection, { variant: "light", children: _jsx(FormProvider, { ...form, children: _jsxs(FormAccess, { role: "manage-identity-providers", isHorizontal: true, onSubmit: handleSubmit(onSubmit), children: [_jsx(SamlGeneralSettings, {}), _jsx(SamlConnectSettings, {}), _jsxs(ActionGroup, { children: [_jsx(Button, { isDisabled: !isDirty, variant: "primary", type: "submit", "data-testid": "createProvider", children: t("add") }), _jsx(Button, { variant: "link", "data-testid": "cancel", component: (props) => (_jsx(Link, { ...props, to: toIdentityProviders({ realm }) })), children: t("cancel") })] })] }) }) })] }));
}
//# sourceMappingURL=AddSamlConnect.js.map