Add 'copy to clipboard' button for user id (#33491)

Closes #33496

Signed-off-by: Tim Koch <me@timkoch.dev>
This commit is contained in:
Tim 2024-10-09 18:23:59 +02:00 committed by GitHub
parent 1ef845b31d
commit ff44d8dd98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 9 deletions

View file

@ -17,7 +17,7 @@ import { useAlerts } from "@keycloak/keycloak-ui-shared";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog"; import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { useAccess } from "../../context/access/Access"; import { useAccess } from "../../context/access/Access";
import useFormatDate from "../../utils/useFormatDate"; import useFormatDate from "../../utils/useFormatDate";
import { CopyToClipboardButton } from "../scopes/CopyToClipboardButton"; import { CopyToClipboardButton } from "../../components/copy-to-clipboard-button/CopyToClipboardButton";
export type ClientSecretProps = { export type ClientSecretProps = {
client: ClientRepresentation; client: ClientRepresentation;

View file

@ -8,7 +8,7 @@ import {
TextArea, TextArea,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { CopyToClipboardButton } from "./CopyToClipboardButton"; import { CopyToClipboardButton } from "../../components/copy-to-clipboard-button/CopyToClipboardButton";
type GeneratedCodeTabProps = { type GeneratedCodeTabProps = {
user?: UserRepresentation; user?: UserRepresentation;

View file

@ -56,7 +56,7 @@ export * as DetailProvider from "./clients/registration/DetailProvider";
export * as CreateClientRole from "./clients/roles/CreateClientRole"; export * as CreateClientRole from "./clients/roles/CreateClientRole";
export { AddScopeDialog } from "./clients/scopes/AddScopeDialog"; export { AddScopeDialog } from "./clients/scopes/AddScopeDialog";
export { ClientScopes } from "./clients/scopes/ClientScopes"; export { ClientScopes } from "./clients/scopes/ClientScopes";
export { CopyToClipboardButton } from "./clients/scopes/CopyToClipboardButton"; export { CopyToClipboardButton } from "./components/copy-to-clipboard-button/CopyToClipboardButton";
export { DedicatedScope } from "./clients/scopes/DedicatedScope"; export { DedicatedScope } from "./clients/scopes/DedicatedScope";
export * as DedicatedScopes from "./clients/scopes/DedicatedScopes"; export * as DedicatedScopes from "./clients/scopes/DedicatedScopes";
export { EvaluateScopes } from "./clients/scopes/EvaluateScopes"; export { EvaluateScopes } from "./clients/scopes/EvaluateScopes";

View file

@ -39,6 +39,7 @@ import { toUsers } from "./routes/Users";
import { FixedButtonsGroup } from "../components/form/FixedButtonGroup"; import { FixedButtonsGroup } from "../components/form/FixedButtonGroup";
import { RequiredActionMultiSelect } from "./user-credentials/RequiredActionMultiSelect"; import { RequiredActionMultiSelect } from "./user-credentials/RequiredActionMultiSelect";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { CopyToClipboardButton } from "../components/copy-to-clipboard-button/CopyToClipboardButton";
export type BruteForced = { export type BruteForced = {
isBruteForceProtected?: boolean; isBruteForceProtected?: boolean;
@ -183,12 +184,24 @@ export const UserForm = ({
{user?.id && ( {user?.id && (
<> <>
<FormGroup label={t("id")} fieldId="kc-id" isRequired> <FormGroup label={t("id")} fieldId="kc-id" isRequired>
<TextInput <InputGroup>
id={user.id} <InputGroupItem isFill>
aria-label={t("userID")} <TextInput
value={user.id} id={user.id}
readOnly aria-label={t("userID")}
/> value={user.id}
readOnly
/>
</InputGroupItem>
<InputGroupItem>
<CopyToClipboardButton
id={`user-${user.id}`}
text={user.id}
label={t("userID")}
variant="control"
/>
</InputGroupItem>
</InputGroup>
</FormGroup> </FormGroup>
<FormGroup <FormGroup
label={t("createdAt")} label={t("createdAt")}