diff --git a/js/apps/admin-ui/src/user/UserCredentials.tsx b/js/apps/admin-ui/src/user/UserCredentials.tsx
index 68801aea85..66234d45de 100644
--- a/js/apps/admin-ui/src/user/UserCredentials.tsx
+++ b/js/apps/admin-ui/src/user/UserCredentials.tsx
@@ -53,6 +53,56 @@ type ExpandableCredentialRepresentation = {
isExpanded: boolean;
};
+type UserLabelEdit = {
+ status: boolean;
+ rowKey: string;
+};
+
+type UserCredentialsRowProps = {
+ credential: CredentialRepresentation;
+ userId: string;
+ toggleDelete: (credential: CredentialRepresentation) => void;
+ resetPassword: () => void;
+ isUserLabelEdit?: UserLabelEdit;
+ setIsUserLabelEdit: (isUserLabelEdit: UserLabelEdit) => void;
+ refresh: () => void;
+};
+
+const UserCredentialsRow = ({
+ credential,
+ userId,
+ toggleDelete,
+ resetPassword,
+ isUserLabelEdit,
+ setIsUserLabelEdit,
+ refresh,
+}: UserCredentialsRowProps) => (
+ toggleDelete(credential)}
+ resetPassword={resetPassword}
+ >
+ {
+ setIsUserLabelEdit({
+ status: !isUserLabelEdit?.status,
+ rowKey: credential.id!,
+ });
+ if (isUserLabelEdit?.status) {
+ refresh();
+ }
+ }}
+ />
+
+);
+
export const UserCredentials = ({ user, setUser }: UserCredentialsProps) => {
const { t } = useTranslation();
const { addAlert, addError } = useAlerts();
@@ -69,10 +119,7 @@ export const UserCredentials = ({ user, setUser }: UserCredentialsProps) => {
const [selectedCredential, setSelectedCredential] =
useState({});
const [isResetPassword, setIsResetPassword] = useState(false);
- const [isUserLabelEdit, setIsUserLabelEdit] = useState<{
- status: boolean;
- rowKey: string;
- }>();
+ const [isUserLabelEdit, setIsUserLabelEdit] = useState();
const bodyRef = useRef(null);
const [state, setState] = useState({
@@ -141,37 +188,6 @@ export const UserCredentials = ({ user, setUser }: UserCredentialsProps) => {
},
});
- const Row = ({ credential }: { credential: CredentialRepresentation }) => (
- {
- setSelectedCredential(credential);
- toggleDeleteDialog();
- }}
- resetPassword={resetPassword}
- >
- {
- setIsUserLabelEdit({
- status: !isUserLabelEdit?.status,
- rowKey: credential.id!,
- });
- if (isUserLabelEdit?.status) {
- refresh();
- }
- }}
- />
-
- );
-
const itemOrder = useMemo(
() =>
groupedUserCredentials.flatMap((groupedCredential) => [
@@ -339,6 +355,11 @@ export const UserCredentials = ({ user, setUser }: UserCredentialsProps) => {
}
};
+ const onToggleDelete = (credential: CredentialRepresentation) => {
+ setSelectedCredential(credential);
+ toggleDeleteDialog();
+ };
+
const useFederatedCredentials = user.federationLink || user.origin;
const [credentialTypes, setCredentialTypes] = useState([]);
@@ -480,7 +501,16 @@ export const UserCredentials = ({ user, setUser }: UserCredentialsProps) => {
{groupedCredential.value.length <= 1 &&
groupedCredential.value.map((credential) => (
-
+
))}
{groupedCredential.isExpanded &&
@@ -508,7 +538,15 @@ export const UserCredentials = ({ user, setUser }: UserCredentialsProps) => {
>
{toUpperCase(credential.type!)}
-
+
))}