only show history if link is present

This commit is contained in:
Maren Süwer
2018-11-28 09:28:45 +01:00
parent 71636e3e07
commit 1b41fe8d93
2 changed files with 22 additions and 19 deletions

View File

@@ -68,6 +68,16 @@ class Content extends React.Component<Props, State> {
const { showHistory, collapsed } = this.state; const { showHistory, collapsed } = this.state;
const icon = collapsed ? "fa-angle-right" : "fa-angle-down"; const icon = collapsed ? "fa-angle-right" : "fa-angle-down";
const selector = file._links.history ? (
<ButtonGroup
file={file}
historyIsSelected={showHistory}
showHistory={(changeShowHistory: boolean) =>
this.setShowHistoryState(changeShowHistory)
}
/>
) : null;
return ( return (
<span className={classes.pointer}> <span className={classes.pointer}>
<article className="media"> <article className="media">
@@ -81,14 +91,7 @@ class Content extends React.Component<Props, State> {
/> />
<span>{file.name}</span> <span>{file.name}</span>
</div> </div>
<div className="media-right"> <div className="media-right">{selector}</div>
<ButtonGroup
historyIsSelected={showHistory}
showHistory={(changeShowHistory: boolean) =>
this.setShowHistoryState(changeShowHistory)
}
/>
</div>
</article> </article>
</span> </span>
); );
@@ -149,7 +152,8 @@ class Content extends React.Component<Props, State> {
const { showHistory } = this.state; const { showHistory } = this.state;
const header = this.showHeader(); const header = this.showHeader();
const content = showHistory ? ( const content =
showHistory && file._links.history ? (
<HistoryView file={file} repository={repository} /> <HistoryView file={file} repository={repository} />
) : ( ) : (
<SourcesView <SourcesView

View File

@@ -87,7 +87,6 @@ class HistoryView extends React.Component<Props, State> {
} }
render() { render() {
console.log(this.state);
const { file } = this.props; const { file } = this.props;
const { loaded, error } = this.state; const { loaded, error } = this.state;