Skip to content

Commit

Permalink
Fix Vulnerability table width (#2861)
Browse files Browse the repository at this point in the history
### What's done:
* Fix Vulnerability table width
  • Loading branch information
kgevorkyan authored Nov 16, 2023
1 parent d48efe7 commit cc7a66a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ val footer: FC<Props> = FC {
div {
className = ClassName("copyright text-center my-auto")
span {
+"Copyright ${js("String.fromCharCode(169)")} SAVE 2021-2022"
+"Copyright ${js("String.fromCharCode(169)")} SAVE 2021-2023"
br {}
+"Version $SAVE_CLOUD_VERSION"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import web.cssom.rem
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json

private const val MAX_LEN_FOR_TEXT = 40
private const val SPLIT_INDEX = 25

/**
* [FC] for [vulnerabilityTableComponent]
*/
Expand Down Expand Up @@ -131,7 +134,7 @@ val vulnerabilityTableComponent: FC<VulnerabilityTableComponentProps> = FC { pro
Fragment.create {
td {
className = ClassName("align-middle")
+cellContext.row.original.summary
+splitLongWordsInText(cellContext.row.original.summary)
}
}
}
Expand Down Expand Up @@ -387,3 +390,16 @@ private fun pageCount(total: Int, pageSize: Int): Int {
*/
return (total + pageSize - 1) / pageSize
}

private fun splitLongWordsInText(text: String): String {
val words = text.split(' ')
return words.joinToString(" ") { word ->
if (word.length > MAX_LEN_FOR_TEXT) {
val sb = StringBuilder(word)
sb.insert(SPLIT_INDEX, '\n')
sb.toString()
} else {
word
}
}
}

0 comments on commit cc7a66a

Please sign in to comment.