From cc7a66a83b8d2293009e8e3ce16ca2e2efdf9a00 Mon Sep 17 00:00:00 2001 From: Kirill Gevorkyan <26010098+kgevorkyan@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:36:45 +0300 Subject: [PATCH] Fix Vulnerability table width (#2861) ### What's done: * Fix Vulnerability table width --- .../save/frontend/components/Footer.kt | 2 +- .../views/vuln/VulnerabilityTableComponent.kt | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt index 74329ab899..6198d8096f 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt @@ -24,7 +24,7 @@ val footer: FC = 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" } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/VulnerabilityTableComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/VulnerabilityTableComponent.kt index 8b6d4bb100..109af96e46 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/VulnerabilityTableComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/VulnerabilityTableComponent.kt @@ -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] */ @@ -131,7 +134,7 @@ val vulnerabilityTableComponent: FC = FC { pro Fragment.create { td { className = ClassName("align-middle") - +cellContext.row.original.summary + +splitLongWordsInText(cellContext.row.original.summary) } } } @@ -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 + } + } +}