Skip to content

Commit

Permalink
Support editing of new fields on VulnGeneralInfo view (#2744)
Browse files Browse the repository at this point in the history
### What's done:
* Support editing of new fields on VulnGeneralInfo view and show save users credits
  • Loading branch information
kgevorkyan authored Oct 19, 2023
1 parent 8c080be commit 959194b
Showing 1 changed file with 47 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.saveourtool.save.frontend.externals.i18next.useTranslation
import com.saveourtool.save.frontend.utils.*
import com.saveourtool.save.info.UserInfo
import com.saveourtool.save.utils.NO_BREAK_SPACE
import com.saveourtool.save.utils.PRETTY_DELIMITER
import com.saveourtool.save.utils.getRelatedLink
import com.saveourtool.save.utils.shorten
import com.saveourtool.save.utils.toUnixCalendarFormat
Expand Down Expand Up @@ -154,8 +155,22 @@ val vulnerabilityGeneralInfoProps: FC<VulnerabilityGeneralInfoProps> = FC { prop
className = ClassName("font-weight-bold text-primary-blue mb-4")
+"CWE IDs".t()
}
p {
+cosv.cweIds!!.joinToString(", ")

textarea {
className = ClassName("auto_height form-control-plaintext px-2 pt-0 pb-0 text-gray-900")
value = cosv.cweIds!!.joinToString(PRETTY_DELIMITER)
disabled = props.isEditDisabled
rows = 3
if (!props.isEditDisabled) {
style = borderEditStyle()
}
onChange = { event ->
props.setVulnerability { vulnerability ->
vulnerability?.copy(
cosv = cosv.copy(cweIds = event.target.value.split(PRETTY_DELIMITER))
)
}
}
}
}

Expand All @@ -167,10 +182,22 @@ val vulnerabilityGeneralInfoProps: FC<VulnerabilityGeneralInfoProps> = FC { prop
className = ClassName("font-weight-bold text-primary-blue mb-4")
+"CWE Names".t()
}

textarea {
className = ClassName("auto_height form-control-plaintext px-2 pt-0 pb-0 text-gray-900")
value = cosv.cweNames!!.joinToString("\n\n")
disabled = props.isEditDisabled
rows = 8
if (!props.isEditDisabled) {
style = borderEditStyle()
}
onChange = { event ->
props.setVulnerability { vulnerability ->
vulnerability?.copy(
cosv = cosv.copy(cweNames = event.target.value.split("\n\n"))
)
}
}
}
}

Expand All @@ -182,8 +209,22 @@ val vulnerabilityGeneralInfoProps: FC<VulnerabilityGeneralInfoProps> = FC { prop
className = ClassName("font-weight-bold text-primary-blue mb-4")
+"Related Vulnerabilities".t()
}
p {
+cosv.related!!.joinToString(", ")

textarea {
className = ClassName("auto_height form-control-plaintext px-2 pt-0 pb-0 text-gray-900")
value = cosv.related!!.joinToString(PRETTY_DELIMITER)
disabled = props.isEditDisabled
rows = 3
if (!props.isEditDisabled) {
style = borderEditStyle()
}
onChange = { event ->
props.setVulnerability { vulnerability ->
vulnerability?.copy(
cosv = cosv.copy(related = event.target.value.split(PRETTY_DELIMITER))
)
}
}
}
}

Expand Down Expand Up @@ -274,8 +315,9 @@ val vulnerabilityGeneralInfoProps: FC<VulnerabilityGeneralInfoProps> = FC { prop
+"Credits"
}
cosv.credits?.forEach { credit ->
val savePrefix = if (credit.name in saveContributors.map { it.name }) "[SAVE] " else ""
p {
+"${credit.name} <${credit.contact?.joinToString { it }}>"
+"$savePrefix${credit.name} <${credit.contact?.joinToString { it }}>"
}
}
}
Expand Down

0 comments on commit 959194b

Please sign in to comment.