2020-11-02 20:15:09 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import {
|
|
|
|
Button,
|
|
|
|
ClipboardCopy,
|
|
|
|
FormGroup,
|
|
|
|
Split,
|
|
|
|
SplitItem,
|
|
|
|
} from "@patternfly/react-core";
|
2021-03-17 07:10:30 +00:00
|
|
|
import { useFormContext } from "react-hook-form";
|
2021-05-04 17:58:18 +00:00
|
|
|
import type { ClientForm } from "../ClientDetails";
|
2020-11-02 20:15:09 +00:00
|
|
|
|
|
|
|
export type ClientSecretProps = {
|
|
|
|
secret: string;
|
|
|
|
toggle: () => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ClientSecret = ({ secret, toggle }: ClientSecretProps) => {
|
|
|
|
const { t } = useTranslation("clients");
|
2021-03-17 07:10:30 +00:00
|
|
|
const { formState } = useFormContext<ClientForm>();
|
2020-11-02 20:15:09 +00:00
|
|
|
return (
|
|
|
|
<FormGroup label={t("clientSecret")} fieldId="kc-client-secret">
|
|
|
|
<Split hasGutter>
|
|
|
|
<SplitItem isFilled>
|
|
|
|
<ClipboardCopy id="kc-client-secret" isReadOnly>
|
|
|
|
{secret}
|
|
|
|
</ClipboardCopy>
|
|
|
|
</SplitItem>
|
|
|
|
<SplitItem>
|
2021-03-17 07:10:30 +00:00
|
|
|
<Button
|
|
|
|
variant="secondary"
|
|
|
|
onClick={toggle}
|
|
|
|
isDisabled={formState.isDirty}
|
|
|
|
>
|
2020-11-02 20:15:09 +00:00
|
|
|
{t("regenerate")}
|
|
|
|
</Button>
|
|
|
|
</SplitItem>
|
|
|
|
</Split>
|
|
|
|
</FormGroup>
|
|
|
|
);
|
|
|
|
};
|