@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
18 lines • 2.46 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { FormGroup, Switch } from "@patternfly/react-core";
import { Controller, FormProvider, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem, TextControl } from "../../ui-shared";
export const SyncSettings = () => {
const { t } = useTranslation();
const form = useFormContext();
const { control, watch } = form;
const watchPeriodicSync = watch("config.fullSyncPeriod", "-1");
const watchChangedSync = watch("config.changedSyncPeriod", "-1");
return (_jsxs(FormProvider, { ...form, children: [_jsx(FormGroup, { label: t("periodicFullSync"), labelIcon: _jsx(HelpItem, { helpText: t("periodicFullSyncHelp"), fieldLabelId: "periodicFullSync" }), fieldId: "kc-periodic-full-sync", hasNoPaddingTop: true, children: _jsx(Controller, { name: "config.fullSyncPeriod", defaultValue: "-1", control: control, render: ({ field }) => (_jsx(Switch, { id: "kc-periodic-full-sync", "data-testid": "periodic-full-sync", onChange: (_event, value) => {
field.onChange(value ? "604800" : "-1");
}, isChecked: field.value !== "-1", label: t("on"), labelOff: t("off"), "aria-label": t("periodicFullSync") })) }) }), watchPeriodicSync !== "-1" && (_jsx(TextControl, { name: "config.fullSyncPeriod", label: t("fullSyncPeriod"), labelIcon: t("fullSyncPeriodHelp"), type: "number", min: -1, defaultValue: "604800" })), _jsx(FormGroup, { label: t("periodicChangedUsersSync"), labelIcon: _jsx(HelpItem, { helpText: t("periodicChangedUsersSyncHelp"), fieldLabelId: "periodicChangedUsersSync" }), fieldId: "kc-periodic-changed-users-sync", hasNoPaddingTop: true, children: _jsx(Controller, { name: "config.changedSyncPeriod", defaultValue: "-1", control: control, render: ({ field }) => (_jsx(Switch, { id: "kc-periodic-changed-users-sync", "data-testid": "periodic-changed-users-sync", onChange: (_event, value) => {
field.onChange(value ? "86400" : "-1");
}, isChecked: field.value !== "-1", label: t("on"), labelOff: t("off"), "aria-label": t("periodicChangedUsersSync") })) }) }), watchChangedSync !== "-1" && (_jsx(TextControl, { name: "config.changedSyncPeriod", label: t("changedUsersSyncPeriod"), labelIcon: t("changedUsersSyncHelp"), type: "number", min: -1, defaultValue: "86400" }))] }));
};
//# sourceMappingURL=SyncSettings.js.map