2021-05-06 18:59:00 +00:00
|
|
|
import { FormGroup } from "@patternfly/react-core";
|
2023-01-20 14:28:32 +00:00
|
|
|
import { PropsWithChildren } from "react";
|
|
|
|
import { useTranslation } from "react-i18next";
|
2021-05-06 18:59:00 +00:00
|
|
|
|
2023-03-07 09:29:40 +00:00
|
|
|
import { HelpItem } from "ui-shared";
|
2021-05-06 18:59:00 +00:00
|
|
|
|
|
|
|
export type FieldProps = { label: string; field: string; isReadOnly?: boolean };
|
2021-08-10 11:18:48 +00:00
|
|
|
export type FormGroupFieldProps = { label: string };
|
2021-05-06 18:59:00 +00:00
|
|
|
|
2023-01-20 14:28:32 +00:00
|
|
|
export const FormGroupField = ({
|
2021-08-10 11:18:48 +00:00
|
|
|
label,
|
|
|
|
children,
|
2023-01-20 14:28:32 +00:00
|
|
|
}: PropsWithChildren<FormGroupFieldProps>) => {
|
2023-09-08 13:17:17 +00:00
|
|
|
const { t } = useTranslation();
|
2021-05-06 18:59:00 +00:00
|
|
|
return (
|
|
|
|
<FormGroup
|
|
|
|
label={t(label)}
|
|
|
|
fieldId={label}
|
2023-09-08 13:17:17 +00:00
|
|
|
labelIcon={<HelpItem helpText={t(`${label}Help`)} fieldLabelId={label} />}
|
2021-05-06 18:59:00 +00:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</FormGroup>
|
|
|
|
);
|
|
|
|
};
|