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";
|
2022-03-09 16:42:23 +00:00
|
|
|
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
2022-03-28 20:54:15 +00:00
|
|
|
import type { UseFormMethods } from "react-hook-form";
|
2020-11-02 20:15:09 +00:00
|
|
|
|
|
|
|
export type ClientSecretProps = {
|
|
|
|
secret: string;
|
|
|
|
toggle: () => void;
|
2022-03-28 20:54:15 +00:00
|
|
|
form: UseFormMethods<ClientRepresentation>;
|
2020-11-02 20:15:09 +00:00
|
|
|
};
|
|
|
|
|
2022-03-28 20:54:15 +00:00
|
|
|
export const ClientSecret = ({ secret, toggle, form }: ClientSecretProps) => {
|
2020-11-02 20:15:09 +00:00
|
|
|
const { t } = useTranslation("clients");
|
2022-03-28 20:54:15 +00:00
|
|
|
|
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"
|
2022-03-28 20:54:15 +00:00
|
|
|
isDisabled={form.formState.isDirty}
|
2021-03-17 07:10:30 +00:00
|
|
|
onClick={toggle}
|
|
|
|
>
|
2020-11-02 20:15:09 +00:00
|
|
|
{t("regenerate")}
|
|
|
|
</Button>
|
|
|
|
</SplitItem>
|
|
|
|
</Split>
|
|
|
|
</FormGroup>
|
|
|
|
);
|
|
|
|
};
|