mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
Hide toggle when there are no hunks to display
This commit is contained in:
@@ -110,7 +110,7 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
|
|
||||||
toggleCollapse = () => {
|
toggleCollapse = () => {
|
||||||
const { file } = this.props;
|
const { file } = this.props;
|
||||||
if (file && !file.isBinary) {
|
if (this.hasContent(file)) {
|
||||||
this.setState(state => ({
|
this.setState(state => ({
|
||||||
collapsed: !state.collapsed
|
collapsed: !state.collapsed
|
||||||
}));
|
}));
|
||||||
@@ -249,6 +249,8 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hasContent = (file: File) => file && !file.isBinary && file.hunks && file.hunks.length > 0;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { file, fileControlFactory, fileAnnotationFactory, t } = this.props;
|
const { file, fileControlFactory, fileAnnotationFactory, t } = this.props;
|
||||||
const { collapsed, sideBySide } = this.state;
|
const { collapsed, sideBySide } = this.state;
|
||||||
@@ -268,7 +270,7 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const collapseIcon = file && !file.isBinary ? <Icon name={icon} color="inherit" /> : null;
|
const collapseIcon = this.hasContent(file) ? <Icon name={icon} color="inherit" /> : null;
|
||||||
|
|
||||||
const fileControls = fileControlFactory ? fileControlFactory(file, this.setCollapse) : null;
|
const fileControls = fileControlFactory ? fileControlFactory(file, this.setCollapse) : null;
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user