mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 17:28:26 +00:00
Update rendering on login mappings on hosts table
This commit is contained in:
@@ -94,25 +94,16 @@ export const SshHostsTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
Object.entries(
|
Object.entries(
|
||||||
host.loginMappings.reduce(
|
host.loginMappings.reduce(
|
||||||
(acc, mapping) => {
|
(acc, mapping) => {
|
||||||
const { loginUser, source } = mapping;
|
const key = `${mapping.loginUser}|${mapping.source}|${mapping.allowedPrincipals.usernames.sort().join(",")}`;
|
||||||
const existing = acc[loginUser];
|
acc[key] = mapping;
|
||||||
|
|
||||||
if (!existing) {
|
|
||||||
acc[loginUser] = mapping;
|
|
||||||
} else if (
|
|
||||||
existing.source === LoginMappingSource.HOST_GROUP &&
|
|
||||||
source === LoginMappingSource.HOST
|
|
||||||
) {
|
|
||||||
// Prefer HOST over HOST_GROUP
|
|
||||||
acc[loginUser] = mapping;
|
|
||||||
}
|
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{} as Record<string, (typeof host.loginMappings)[number]>
|
{} as Record<string, (typeof host.loginMappings)[number]>
|
||||||
)
|
)
|
||||||
).map(([loginUser, { allowedPrincipals, source }]) => (
|
)
|
||||||
<div key={`${host.id}-${loginUser}`} className="mb-2">
|
.sort(([a], [b]) => a.localeCompare(b))
|
||||||
|
.map(([key, { loginUser, allowedPrincipals, source }]) => (
|
||||||
|
<div key={`${host.id}-${key}`} className="mb-2">
|
||||||
<div className="text-mineshaft-200">
|
<div className="text-mineshaft-200">
|
||||||
{loginUser}
|
{loginUser}
|
||||||
{source === LoginMappingSource.HOST_GROUP && (
|
{source === LoginMappingSource.HOST_GROUP && (
|
||||||
@@ -122,7 +113,7 @@ export const SshHostsTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{allowedPrincipals.usernames.map((username) => (
|
{allowedPrincipals.usernames.map((username) => (
|
||||||
<div key={`${host.id}-${loginUser}-${username}`} className="ml-4">
|
<div key={`${host.id}-${key}-${username}`} className="ml-4">
|
||||||
└─ {username}
|
└─ {username}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user