bf236cb7f3
* add create client policy form; WIP add client policy tests checkout realm settings test from master RealmSettingsPage.ts master remove comment and add missing translation fix tests PR feedback from Jon and Erik rebase editClientPolicy edit client policy add client policy conditions form fix bug in create form remove comment update help text fixes breadcrumbs add support for adding multiple conditions, deleting conditions, and list conditions in data table clean up names add delete functionality to conditions form PR feedback from Jon useMemo for conditions remove comments and logs remove unused hook PR feedback from Jon messages rename message rebase remove duplicate value fixed multi select bug conditionConfigs wip add all config fields, labels, and help text for condition types wip config POST config post is working fix bug in multiline string POST fix any client empty config client scopes config wip fix config settings for client-updater-context fix client access type config clean up configuration conditionals add aria label to resolve critical axe issue Apply suggestions from code review Co-authored-by: Jon Koops <jonkoops@gmail.com> address PR feedback from Jon fix undef error PR feedback from Stan add util function * fix import stmt * revert change to route * fix profile create values * fix paths
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import React from "react";
|
|
import { Controller, useFormContext } from "react-hook-form";
|
|
import { useTranslation } from "react-i18next";
|
|
import { FormGroup, Switch } from "@patternfly/react-core";
|
|
|
|
import type { ComponentProps } from "./components";
|
|
import { HelpItem } from "../../../components/help-enabler/HelpItem";
|
|
import { convertToHyphens } from "../../../util";
|
|
|
|
export const BooleanComponent = ({
|
|
name,
|
|
label,
|
|
helpText,
|
|
defaultValue,
|
|
}: ComponentProps) => {
|
|
const { t } = useTranslation("client-scopes");
|
|
const { control } = useFormContext();
|
|
|
|
return (
|
|
<FormGroup
|
|
hasNoPaddingTop
|
|
label={t(label!)}
|
|
fieldId={name!}
|
|
labelIcon={
|
|
<HelpItem helpText={t(helpText!)} forLabel={t(label!)} forID={name!} />
|
|
}
|
|
>
|
|
<Controller
|
|
name={`config.${convertToHyphens(name!)}`}
|
|
data-testid={name}
|
|
defaultValue={defaultValue}
|
|
control={control}
|
|
render={({ onChange, value }) => (
|
|
<Switch
|
|
id={name!}
|
|
label={t("common:on")}
|
|
labelOff={t("common:off")}
|
|
isChecked={value === "true" || value === true}
|
|
onChange={(value) => onChange("" + value)}
|
|
/>
|
|
)}
|
|
/>
|
|
</FormGroup>
|
|
);
|
|
};
|