Skip to content

Commit

Permalink
Distinct user in Contributors and Credits on vulnerability page (#2857)
Browse files Browse the repository at this point in the history
Distinct user in Contributors and Credits on vulnerability page
### What's done:
* Distinct user in Contributors and Credits on vulnerability page
  • Loading branch information
kgevorkyan authored Nov 10, 2023
1 parent 838ee31 commit 73b0c13
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ val vulnerabilityGeneralInfoProps: FC<VulnerabilityGeneralInfoProps> = FC { prop
+"Contributors".t()
}
userBoard {
users = saveContributors
users = saveContributors.distinctBy { it.name }
avatarOuterClasses = "col-2"
}
}
Expand All @@ -348,8 +348,8 @@ val vulnerabilityGeneralInfoProps: FC<VulnerabilityGeneralInfoProps> = FC { prop
className = ClassName("font-weight-bold text-primary-blue mb-4")
+"Credits"
}
cosv.credits!!.forEachIndexed { creditInd, credit ->
val userPrefix = if (credit.name in saveContributors.map { it.name }) "[SAVE] user" else "External user"
cosv.credits!!.mergeContactsForOneUser().forEachIndexed { creditInd, credit ->
val userPrefix = if (credit.name in saveContributors.map { it.name }) "[SAVE user]" else "[External user]"
if (props.isEditDisabled) {
div {
className = ClassName("row ml-1")
Expand Down Expand Up @@ -514,6 +514,14 @@ external interface VulnerabilityGeneralInfoProps : Props {
var setSelectedMenu: StateSetter<VulnerabilityTab>
}

private fun List<Credit>.mergeContactsForOneUser() = this
.groupBy { it.name }.map { entry ->
val name = entry.key
val contacts = entry.value.mapNotNull { it.contact }.flatten()
// suppose, that `credit type` is the same for credits with same name
Credit(name, contacts, entry.value.first().type)
}

/**
* @param currentUserInfo
* @param vulnerability
Expand Down

0 comments on commit 73b0c13

Please sign in to comment.