2022-02-23 14:46:26 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import {
|
|
|
|
CodeBlock,
|
|
|
|
CodeBlockAction,
|
|
|
|
EmptyState,
|
|
|
|
EmptyStateBody,
|
|
|
|
Title,
|
|
|
|
} from "@patternfly/react-core";
|
|
|
|
|
|
|
|
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
|
2022-04-29 12:42:00 +00:00
|
|
|
import { CopyToClipboardButton } from "./CopyToClipboardButton";
|
2022-05-11 09:46:14 +00:00
|
|
|
import { KeycloakTextArea } from "../../components/keycloak-text-area/KeycloakTextArea";
|
2022-02-23 14:46:26 +00:00
|
|
|
|
|
|
|
type GeneratedCodeTabProps = {
|
|
|
|
user?: UserRepresentation;
|
|
|
|
text: string;
|
|
|
|
label: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const GeneratedCodeTab = ({
|
|
|
|
text,
|
|
|
|
user,
|
|
|
|
label,
|
|
|
|
}: GeneratedCodeTabProps) => {
|
|
|
|
const { t } = useTranslation("clients");
|
|
|
|
|
|
|
|
return user ? (
|
|
|
|
<CodeBlock
|
|
|
|
id={label}
|
|
|
|
actions={
|
|
|
|
<CodeBlockAction>
|
2022-05-18 09:22:30 +00:00
|
|
|
<CopyToClipboardButton id="code" text={text} label={label} />
|
2022-02-23 14:46:26 +00:00
|
|
|
</CodeBlockAction>
|
|
|
|
}
|
|
|
|
>
|
2022-05-11 09:46:14 +00:00
|
|
|
<KeycloakTextArea id={`text-area-${label}`} rows={20} value={text} />
|
2022-02-23 14:46:26 +00:00
|
|
|
</CodeBlock>
|
|
|
|
) : (
|
|
|
|
<EmptyState variant="large">
|
|
|
|
<Title headingLevel="h4" size="lg">
|
|
|
|
{t(`${label}No`)}
|
|
|
|
</Title>
|
|
|
|
<EmptyStateBody>{t(`${label}IsDisabled`)}</EmptyStateBody>
|
|
|
|
</EmptyState>
|
|
|
|
);
|
|
|
|
};
|