From bef64e9831c4e3ca321de1e6f89733b963ce8b63 Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Mon, 30 Sep 2019 15:29:47 +0200 Subject: [PATCH] add defaultCollapse option to force toggling all DiffFile components by once, remove toggle option and icon for binary files --- .../ui-components/src/repos/DiffFile.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 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 dd48643beb..8dcdf0a640 100644 --- a/scm-ui-components/packages/ui-components/src/repos/DiffFile.js +++ b/scm-ui-components/packages/ui-components/src/repos/DiffFile.js @@ -70,7 +70,7 @@ const styles = { type Props = DiffObjectProps & { file: File, - collapsible: boolean, + defaultCollapse: boolean, // context props classes: any, @@ -84,19 +84,20 @@ type State = { class DiffFile extends React.Component { static defaultProps = { - collapsible: true + defaultCollapse: false }; constructor(props: Props) { super(props); this.state = { - collapsed: false, + collapsed: this.props.defaultCollapse, sideBySide: false }; } toggleCollapse = () => { - if (this.props.collapsible) { + const { file } = this.props; + if(file && !file.isBinaray) { this.setState(state => ({ collapsed: !state.collapsed })); @@ -178,7 +179,8 @@ class DiffFile extends React.Component { ) { return ( <> - {file.oldPath} {file.newPath} + {file.oldPath} {" "} + {file.newPath} ); } else if (file.type === "delete") { @@ -238,7 +240,6 @@ class DiffFile extends React.Component { file, fileControlFactory, fileAnnotationFactory, - collapsible, classes, t } = this.props; @@ -264,7 +265,9 @@ class DiffFile extends React.Component { ); } - const collapseIcon = collapsible ? : null; + const collapseIcon = !file.isBinary ? ( + + ) : null; const fileControls = fileControlFactory ? fileControlFactory(file, this.setCollapse)