# HG changeset patch # User Serhii Ilin # Date 2024-11-06 07:36:08 # Node ID 6da1af211041f8049c4a5d701eeda874fa3661f4 # Parent 06e00555ff2b84f8b693fb36cbc787784cad179e fix: fixed problems on UI in case of long commit messages. Fixes: RCCE-140 diff --git a/rhodecode/templates/changeset/changeset.mako b/rhodecode/templates/changeset/changeset.mako --- a/rhodecode/templates/changeset/changeset.mako +++ b/rhodecode/templates/changeset/changeset.mako @@ -128,7 +128,7 @@
-
+
${_('Show More')}
@@ -416,6 +416,51 @@ var channel = '${c.commit_broadcast_channel}'; new ReviewerPresenceController(channel) + function breakLongCommitMessage() { + const commitElements = document.querySelectorAll(".left-content-message .commit"); + const maxAllowedWidth = window.innerWidth * 0.9; + + commitElements.forEach(commitElement => { + const originalText = commitElement.textContent; + const lines = originalText.split("\n"); + const brokenLines = []; + + commitElement.style.whiteSpace = "nowrap"; + + for (let line of lines) { + let brokenLine = ""; + let words = line.split(" "); + let currentLine = ""; + + words.forEach(word => { + const testLine = currentLine.length > 0 ? currentLine + " " + word : word; + + commitElement.textContent = testLine; + const testLineWidth = commitElement.offsetWidth; + + if (testLineWidth > maxAllowedWidth) { + brokenLine += currentLine + "\n"; + currentLine = word; + } else { + currentLine = testLine; + } + }); + + brokenLine += currentLine; + brokenLines.push(brokenLine.trim()); + } + + commitElement.textContent = brokenLines.join("\n"); + + commitElement.style.whiteSpace = "pre-wrap"; + }); + } + + window.addEventListener("load", function () { + const button = document.getElementById("break-button"); + button.addEventListener("click", breakLongCommitMessage); + + }); })