Skip to content

Commit 73b0c13

Browse files
authored
Distinct user in Contributors and Credits on vulnerability page (#2857)
Distinct user in Contributors and Credits on vulnerability page ### What's done: * Distinct user in Contributors and Credits on vulnerability page
1 parent 838ee31 commit 73b0c13

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/VulnerabilityGeneralInfoProps.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ val vulnerabilityGeneralInfoProps: FC<VulnerabilityGeneralInfoProps> = FC { prop
335335
+"Contributors".t()
336336
}
337337
userBoard {
338-
users = saveContributors
338+
users = saveContributors.distinctBy { it.name }
339339
avatarOuterClasses = "col-2"
340340
}
341341
}
@@ -348,8 +348,8 @@ val vulnerabilityGeneralInfoProps: FC<VulnerabilityGeneralInfoProps> = FC { prop
348348
className = ClassName("font-weight-bold text-primary-blue mb-4")
349349
+"Credits"
350350
}
351-
cosv.credits!!.forEachIndexed { creditInd, credit ->
352-
val userPrefix = if (credit.name in saveContributors.map { it.name }) "[SAVE] user" else "External user"
351+
cosv.credits!!.mergeContactsForOneUser().forEachIndexed { creditInd, credit ->
352+
val userPrefix = if (credit.name in saveContributors.map { it.name }) "[SAVE user]" else "[External user]"
353353
if (props.isEditDisabled) {
354354
div {
355355
className = ClassName("row ml-1")
@@ -514,6 +514,14 @@ external interface VulnerabilityGeneralInfoProps : Props {
514514
var setSelectedMenu: StateSetter<VulnerabilityTab>
515515
}
516516

517+
private fun List<Credit>.mergeContactsForOneUser() = this
518+
.groupBy { it.name }.map { entry ->
519+
val name = entry.key
520+
val contacts = entry.value.mapNotNull { it.contact }.flatten()
521+
// suppose, that `credit type` is the same for credits with same name
522+
Credit(name, contacts, entry.value.first().type)
523+
}
524+
517525
/**
518526
* @param currentUserInfo
519527
* @param vulnerability

0 commit comments

Comments
 (0)