Skip to content

Commit cc7a66a

Browse files
authored
Fix Vulnerability table width (#2861)
### What's done: * Fix Vulnerability table width
1 parent d48efe7 commit cc7a66a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ val footer: FC<Props> = FC {
2424
div {
2525
className = ClassName("copyright text-center my-auto")
2626
span {
27-
+"Copyright ${js("String.fromCharCode(169)")} SAVE 2021-2022"
27+
+"Copyright ${js("String.fromCharCode(169)")} SAVE 2021-2023"
2828
br {}
2929
+"Version $SAVE_CLOUD_VERSION"
3030
}

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ import web.cssom.rem
3535
import kotlinx.serialization.encodeToString
3636
import kotlinx.serialization.json.Json
3737

38+
private const val MAX_LEN_FOR_TEXT = 40
39+
private const val SPLIT_INDEX = 25
40+
3841
/**
3942
* [FC] for [vulnerabilityTableComponent]
4043
*/
@@ -131,7 +134,7 @@ val vulnerabilityTableComponent: FC<VulnerabilityTableComponentProps> = FC { pro
131134
Fragment.create {
132135
td {
133136
className = ClassName("align-middle")
134-
+cellContext.row.original.summary
137+
+splitLongWordsInText(cellContext.row.original.summary)
135138
}
136139
}
137140
}
@@ -387,3 +390,16 @@ private fun pageCount(total: Int, pageSize: Int): Int {
387390
*/
388391
return (total + pageSize - 1) / pageSize
389392
}
393+
394+
private fun splitLongWordsInText(text: String): String {
395+
val words = text.split(' ')
396+
return words.joinToString(" ") { word ->
397+
if (word.length > MAX_LEN_FOR_TEXT) {
398+
val sb = StringBuilder(word)
399+
sb.insert(SPLIT_INDEX, '\n')
400+
sb.toString()
401+
} else {
402+
word
403+
}
404+
}
405+
}

0 commit comments

Comments
 (0)