Fixed small layout issue and set default label of password (#2286)
This commit is contained in:
parent
74ecc18be0
commit
de32d5d163
6 changed files with 29 additions and 8 deletions
|
@ -24,11 +24,12 @@ import type CredentialRepresentation from "@keycloak/keycloak-admin-client/lib/d
|
||||||
import { ResetPasswordDialog } from "./user-credentials/ResetPasswordDialog";
|
import { ResetPasswordDialog } from "./user-credentials/ResetPasswordDialog";
|
||||||
import { ResetCredentialDialog } from "./user-credentials/ResetCredentialDialog";
|
import { ResetCredentialDialog } from "./user-credentials/ResetCredentialDialog";
|
||||||
import { InlineLabelEdit } from "./user-credentials/InlineLabelEdit";
|
import { InlineLabelEdit } from "./user-credentials/InlineLabelEdit";
|
||||||
import "./user-credentials.css";
|
|
||||||
import styles from "@patternfly/react-styles/css/components/Table/table";
|
import styles from "@patternfly/react-styles/css/components/Table/table";
|
||||||
import { CredentialRow } from "./user-credentials/CredentialRow";
|
import { CredentialRow } from "./user-credentials/CredentialRow";
|
||||||
import { toUpperCase } from "../util";
|
import { toUpperCase } from "../util";
|
||||||
|
|
||||||
|
import "./user-credentials.css";
|
||||||
|
|
||||||
type UserCredentialsProps = {
|
type UserCredentialsProps = {
|
||||||
user: UserRepresentation;
|
user: UserRepresentation;
|
||||||
};
|
};
|
||||||
|
@ -394,12 +395,15 @@ export const UserCredentials = ({ user }: UserCredentialsProps) => {
|
||||||
<Fragment key={groupedCredential.key}>
|
<Fragment key={groupedCredential.key}>
|
||||||
<Tr
|
<Tr
|
||||||
id={groupedCredential.value.map(({ id }) => id).toString()}
|
id={groupedCredential.value.map(({ id }) => id).toString()}
|
||||||
draggable
|
draggable={groupedUserCredentials.length > 1}
|
||||||
onDrop={onDrop}
|
onDrop={onDrop}
|
||||||
onDragEnd={onDragEnd}
|
onDragEnd={onDragEnd}
|
||||||
onDragStart={onDragStart}
|
onDragStart={onDragStart}
|
||||||
>
|
>
|
||||||
<Td
|
<Td
|
||||||
|
className={
|
||||||
|
groupedUserCredentials.length === 1 ? "one-row" : ""
|
||||||
|
}
|
||||||
draggableRow={{
|
draggableRow={{
|
||||||
id: `draggable-row-${groupedCredential.value.map(
|
id: `draggable-row-${groupedCredential.value.map(
|
||||||
({ id }) => id
|
({ id }) => id
|
||||||
|
|
|
@ -124,6 +124,7 @@ export default {
|
||||||
"This user does not have any credentials. You can set password for this user.",
|
"This user does not have any credentials. You can set password for this user.",
|
||||||
setPassword: "Set password",
|
setPassword: "Set password",
|
||||||
setPasswordFor: "Set password for {{username}}",
|
setPasswordFor: "Set password for {{username}}",
|
||||||
|
defaultPasswordLabel: "My password",
|
||||||
save: "Save",
|
save: "Save",
|
||||||
cancel: "Cancel",
|
cancel: "Cancel",
|
||||||
savePasswordSuccess: "The password has been set successfully.",
|
savePasswordSuccess: "The password has been set successfully.",
|
||||||
|
|
|
@ -76,3 +76,7 @@
|
||||||
tr.kc-table-header th {
|
tr.kc-table-header th {
|
||||||
padding-top: 0px !important;
|
padding-top: 0px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td.one-row button svg {
|
||||||
|
color: var(--pf-c-button--disabled--Color);
|
||||||
|
}
|
|
@ -77,7 +77,7 @@ export const CredentialRow = ({
|
||||||
</Button>
|
</Button>
|
||||||
</Td>
|
</Td>
|
||||||
{credential.type === "password" ? (
|
{credential.type === "password" ? (
|
||||||
<Td>
|
<Td isActionCell>
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
data-testid="resetPasswordBtn"
|
data-testid="resetPasswordBtn"
|
||||||
|
@ -89,7 +89,7 @@ export const CredentialRow = ({
|
||||||
) : (
|
) : (
|
||||||
<Td />
|
<Td />
|
||||||
)}
|
)}
|
||||||
<Td>
|
<Td isActionCell>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
isPlain
|
isPlain
|
||||||
position={DropdownPosition.right}
|
position={DropdownPosition.right}
|
||||||
|
|
|
@ -54,7 +54,11 @@ export const InlineLabelEdit = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form isHorizontal className="kc-form-userLabel">
|
<Form
|
||||||
|
isHorizontal
|
||||||
|
className="kc-form-userLabel"
|
||||||
|
onSubmit={handleSubmit(saveUserLabel)}
|
||||||
|
>
|
||||||
<FormGroup fieldId="kc-userLabel" className="kc-userLabel-row">
|
<FormGroup fieldId="kc-userLabel" className="kc-userLabel-row">
|
||||||
<div className="kc-form-group-userLabel">
|
<div className="kc-form-group-userLabel">
|
||||||
{isEditable ? (
|
{isEditable ? (
|
||||||
|
@ -73,9 +77,7 @@ export const InlineLabelEdit = ({
|
||||||
data-testid="editUserLabelAcceptBtn"
|
data-testid="editUserLabelAcceptBtn"
|
||||||
variant="link"
|
variant="link"
|
||||||
className="kc-editUserLabelAcceptBtn"
|
className="kc-editUserLabelAcceptBtn"
|
||||||
onClick={() => {
|
type="submit"
|
||||||
handleSubmit(saveUserLabel)();
|
|
||||||
}}
|
|
||||||
icon={<CheckIcon />}
|
icon={<CheckIcon />}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -93,6 +93,16 @@ export const ResetPasswordDialog = ({
|
||||||
value: password,
|
value: password,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const { id } = (
|
||||||
|
await adminClient.users.getCredentials({ id: user.id! })
|
||||||
|
).find((c) => c.type === "password")!;
|
||||||
|
await adminClient.users.updateCredentialLabel(
|
||||||
|
{
|
||||||
|
id: user.id!,
|
||||||
|
credentialId: id!,
|
||||||
|
},
|
||||||
|
t("defaultPasswordLabel")
|
||||||
|
);
|
||||||
addAlert(
|
addAlert(
|
||||||
isResetPassword
|
isResetPassword
|
||||||
? t("resetCredentialsSuccess")
|
? t("resetCredentialsSuccess")
|
||||||
|
|
Loading…
Reference in a new issue