Fix SSH table UI user groups issues

This commit is contained in:
carlosmonastyrski
2025-05-06 08:37:19 -03:00
parent b9070a8fa3
commit bf85df7e36
2 changed files with 81 additions and 82 deletions
@@ -351,8 +351,7 @@ export const SshHostGroupModal = ({ popUp, handlePopUpToggle }: Props) => {
name={`loginMappings.${i}.allowedPrincipals`} name={`loginMappings.${i}.allowedPrincipals`}
render={({ field: { value = [], onChange }, fieldState: { error } }) => ( render={({ field: { value = [], onChange }, fieldState: { error } }) => (
<div className="flex flex-col space-y-2"> <div className="flex flex-col space-y-2">
{(value.length === 0 ? [{ type: "user", value: "" }] : value).map( {value.map((principal, principalIndex) => (
(principal, principalIndex) => (
<div <div
key={`principal-${i + 1}-${principalIndex + 1}-${principal.type}`} key={`principal-${i + 1}-${principalIndex + 1}-${principal.type}`}
className="flex items-center space-x-2" className="flex items-center space-x-2"
@@ -431,8 +430,7 @@ export const SshHostGroupModal = ({ popUp, handlePopUpToggle }: Props) => {
</IconButton> </IconButton>
</div> </div>
</div> </div>
) ))}
)}
{error && <span className="text-sm text-red-500">{error.message}</span>} {error && <span className="text-sm text-red-500">{error.message}</span>}
</div> </div>
)} )}
@@ -131,7 +131,8 @@ export const SshHostsTable = ({ handlePopUpOpen }: Props) => {
const filteredGroups = allowedPrincipals.groups?.filter( const filteredGroups = allowedPrincipals.groups?.filter(
(g) => !existing.groups?.has(g) (g) => !existing.groups?.has(g)
); );
return (filteredGroups?.length ?? 0) > 0 return ((filteredGroups?.length || filteredUsernames?.length) ?? 0) >
0
? { ? {
loginUser, loginUser,
source: LoginMappingSource.HOST_GROUP, source: LoginMappingSource.HOST_GROUP,