564441899b
* merge all namespaces into one added fallback namespace to the configuration to minimize changes to the keys * small fix * Fix the broken `OverridesBackend` * remove stray console log * restore ns argument * PR review * merge main --------- Co-authored-by: Jon Koops <jonkoops@gmail.com>
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { useTranslation } from "react-i18next";
|
|
import { ActionGroup, ActionGroupProps, Button } from "@patternfly/react-core";
|
|
import { PropsWithChildren } from "react";
|
|
|
|
import style from "./fixed-buttons.module.css";
|
|
|
|
type FixedButtonGroupProps = ActionGroupProps & {
|
|
name: string;
|
|
save?: () => void;
|
|
reset?: () => void;
|
|
isSubmit?: boolean;
|
|
isActive?: boolean;
|
|
};
|
|
|
|
export const FixedButtonsGroup = ({
|
|
name,
|
|
save,
|
|
reset,
|
|
isSubmit = false,
|
|
isActive = true,
|
|
children,
|
|
...rest
|
|
}: PropsWithChildren<FixedButtonGroupProps>) => {
|
|
const { t } = useTranslation();
|
|
return (
|
|
<ActionGroup className={style.buttonGroup} {...rest}>
|
|
{(save || isSubmit) && (
|
|
<Button
|
|
isDisabled={!isActive}
|
|
data-testid={`${name}-save`}
|
|
onClick={() => save?.()}
|
|
type={isSubmit ? "submit" : "button"}
|
|
>
|
|
{t("save")}
|
|
</Button>
|
|
)}
|
|
{reset && (
|
|
<Button
|
|
isDisabled={!isActive}
|
|
data-testid={`${name}-revert`}
|
|
variant="link"
|
|
onClick={() => reset()}
|
|
>
|
|
{t("revert")}
|
|
</Button>
|
|
)}
|
|
{children}
|
|
</ActionGroup>
|
|
);
|
|
};
|