mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
Make Diff collapsible optional and render type only if present
This commit is contained in:
@@ -46,6 +46,7 @@ const styles = {
|
|||||||
|
|
||||||
type Props = DiffObjectProps & {
|
type Props = DiffObjectProps & {
|
||||||
file: File,
|
file: File,
|
||||||
|
collapsible: true,
|
||||||
// context props
|
// context props
|
||||||
classes: any,
|
classes: any,
|
||||||
t: string => string
|
t: string => string
|
||||||
@@ -66,9 +67,11 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleCollapse = () => {
|
toggleCollapse = () => {
|
||||||
|
if (this.props.collapsable) {
|
||||||
this.setState(state => ({
|
this.setState(state => ({
|
||||||
collapsed: !state.collapsed
|
collapsed: !state.collapsed
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
toggleSideBySide = () => {
|
toggleSideBySide = () => {
|
||||||
@@ -173,6 +176,9 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
|
|
||||||
renderChangeTag = (file: any) => {
|
renderChangeTag = (file: any) => {
|
||||||
const { t, classes } = this.props;
|
const { t, classes } = this.props;
|
||||||
|
if (!file.type) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const key = "diff.changes." + file.type;
|
const key = "diff.changes." + file.type;
|
||||||
let value = t(key);
|
let value = t(key);
|
||||||
if (key === value) {
|
if (key === value) {
|
||||||
@@ -205,6 +211,7 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
file,
|
file,
|
||||||
fileControlFactory,
|
fileControlFactory,
|
||||||
fileAnnotationFactory,
|
fileAnnotationFactory,
|
||||||
|
collapsible,
|
||||||
classes,
|
classes,
|
||||||
t
|
t
|
||||||
} = this.props;
|
} = this.props;
|
||||||
@@ -227,6 +234,7 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const collapseIcon = collapsible? <i className={icon} />: null;
|
||||||
|
|
||||||
const fileControls = fileControlFactory
|
const fileControls = fileControlFactory
|
||||||
? fileControlFactory(file, this.setCollapse)
|
? fileControlFactory(file, this.setCollapse)
|
||||||
@@ -240,7 +248,7 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
onClick={this.toggleCollapse}
|
onClick={this.toggleCollapse}
|
||||||
title={this.hoverFileTitle(file)}
|
title={this.hoverFileTitle(file)}
|
||||||
>
|
>
|
||||||
<i className={icon} />
|
{collapseIcon}
|
||||||
<span
|
<span
|
||||||
className={classNames("is-ellipsis-overflow", classes.title)}
|
className={classNames("is-ellipsis-overflow", classes.title)}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user