From bf85df7e3606ad8bdfa240c641d60a376e4b599f Mon Sep 17 00:00:00 2001 From: carlosmonastyrski Date: Tue, 6 May 2025 08:37:19 -0300 Subject: [PATCH] Fix SSH table UI user groups issues --- .../components/SshHostGroupModal.tsx | 160 +++++++++--------- .../SshHostsPage/components/SshHostsTable.tsx | 3 +- 2 files changed, 81 insertions(+), 82 deletions(-) diff --git a/frontend/src/pages/ssh/SshHostsPage/components/SshHostGroupModal.tsx b/frontend/src/pages/ssh/SshHostsPage/components/SshHostGroupModal.tsx index 6cd99c796..081af4cbf 100644 --- a/frontend/src/pages/ssh/SshHostsPage/components/SshHostGroupModal.tsx +++ b/frontend/src/pages/ssh/SshHostsPage/components/SshHostGroupModal.tsx @@ -351,88 +351,86 @@ export const SshHostGroupModal = ({ popUp, handlePopUpToggle }: Props) => { name={`loginMappings.${i}.allowedPrincipals`} render={({ field: { value = [], onChange }, fieldState: { error } }) => (
- {(value.length === 0 ? [{ type: "user", value: "" }] : value).map( - (principal, principalIndex) => ( -
-
- -
-
- -
-
- { - const newPrincipals = value.filter( - (_, idx) => idx !== principalIndex - ); - onChange(newPrincipals.length ? newPrincipals : []); - }} - > - - -
+ {value.map((principal, principalIndex) => ( +
+
+
- ) - )} +
+ +
+
+ { + const newPrincipals = value.filter( + (_, idx) => idx !== principalIndex + ); + onChange(newPrincipals.length ? newPrincipals : []); + }} + > + + +
+
+ ))} {error && {error.message}}
)} diff --git a/frontend/src/pages/ssh/SshHostsPage/components/SshHostsTable.tsx b/frontend/src/pages/ssh/SshHostsPage/components/SshHostsTable.tsx index fd43697ec..e3c53860e 100644 --- a/frontend/src/pages/ssh/SshHostsPage/components/SshHostsTable.tsx +++ b/frontend/src/pages/ssh/SshHostsPage/components/SshHostsTable.tsx @@ -131,7 +131,8 @@ export const SshHostsTable = ({ handlePopUpOpen }: Props) => { const filteredGroups = allowedPrincipals.groups?.filter( (g) => !existing.groups?.has(g) ); - return (filteredGroups?.length ?? 0) > 0 + return ((filteredGroups?.length || filteredUsernames?.length) ?? 0) > + 0 ? { loginUser, source: LoginMappingSource.HOST_GROUP,