From 2174db20cd58871e34f25df273e200f532432b61 Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Sun, 26 May 2019 14:10:59 +0200 Subject: [PATCH] fix too long diff file title --- .../ui-components/src/repos/DiffFile.js | 58 ++++++++++++++++--- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/repos/DiffFile.js b/scm-ui-components/packages/ui-components/src/repos/DiffFile.js index ac815511ba..ffe9cbe173 100644 --- a/scm-ui-components/packages/ui-components/src/repos/DiffFile.js +++ b/scm-ui-components/packages/ui-components/src/repos/DiffFile.js @@ -17,13 +17,27 @@ const styles = { panel: { fontSize: "1rem" }, + /* breaks into a second row + * when buttons and title become too long + */ + level: { + flexWrap: "wrap" + }, titleHeader: { + display: "flex", + maxWidth: "100%", cursor: "pointer" }, title: { marginLeft: ".25rem", fontSize: "1rem" }, + /* align child to right + */ + buttonHeader: { + display: "flex", + marginLeft: "auto" + }, hunkDivider: { margin: ".5rem 0" }, @@ -143,14 +157,41 @@ class DiffFile extends React.Component { return file.newPath; }; + hoverFileTitle = (file: any) => { + if ( + file.oldPath !== file.newPath && + (file.type === "copy" || file.type === "rename") + ) { + return ( + <> + {file.oldPath} > {file.newPath} + + ); + } else if (file.type === "delete") { + return file.oldPath; + } + return file.newPath; + }; + renderChangeTag = (file: any) => { - const { t } = this.props; + const { t, classes } = this.props; const key = "diff.changes." + file.type; let value = t(key); if (key === value) { value = file.type; } - return {value}; + return ( + + {value} + + ); }; render() { @@ -187,20 +228,21 @@ class DiffFile extends React.Component { return (
-
+
- + {this.renderFileTitle(file)} - - {this.renderChangeTag(file)} - + {this.renderChangeTag(file)}
-
+