show text if source is text

This commit is contained in:
Maren Süwer
2018-11-01 10:58:47 +01:00
parent c544b1f90c
commit fba2bc2e80

View File

@@ -34,7 +34,7 @@ type State = {
language: string, language: string,
loaded: boolean, loaded: boolean,
collapsed: boolean, collapsed: boolean,
error?: Error, error?: Error
}; };
const styles = { const styles = {
@@ -129,20 +129,20 @@ class Content extends React.Component<Props, State> {
<table className="table"> <table className="table">
<tbody> <tbody>
<tr> <tr>
<th>Path</th> <td>Path</td>
<th>{file.path}</th> <td>{file.path}</td>
</tr> </tr>
<tr> <tr>
<th>Branch</th> <td>Branch</td>
<th>{revision}</th> <td>{revision}</td>
</tr> </tr>
<tr> <tr>
<th>Last modified</th> <td>Last modified</td>
<th>{date}</th> <td>{date}</td>
</tr> </tr>
<tr> <tr>
<th>Description</th> <td>Description</td>
<th>{description}</th> <td>{description}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -154,12 +154,13 @@ class Content extends React.Component<Props, State> {
showContent() { showContent() {
const { file, revision } = this.props; const { file, revision } = this.props;
const contentType = this.state.contentType; const { contentType, language } = this.state;
const language = this.state.language;
if (contentType.startsWith("image/")) { if (contentType.startsWith("image/")) {
return <ImageViewer file={file} />; return <ImageViewer file={file} />;
} else if (language) { } else if (language) {
return <SourcecodeViewer file={file} language={language} />; return <SourcecodeViewer file={file} language={language} />;
} else if (contentType.startsWith("text/")) {
return <SourcecodeViewer file={file} language="none" />;
} else { } else {
return ( return (
<ExtensionPoint <ExtensionPoint
@@ -174,8 +175,7 @@ class Content extends React.Component<Props, State> {
render() { render() {
const { file, classes } = this.props; const { file, classes } = this.props;
const error = this.state.error; const { loaded, error } = this.state;
const loaded = this.state.loaded;
if (!file || !loaded) { if (!file || !loaded) {
return <Loading />; return <Loading />;
@@ -202,7 +202,6 @@ class Content extends React.Component<Props, State> {
} }
} }
const mapStateToProps = (state: any, ownProps: Props) => { const mapStateToProps = (state: any, ownProps: Props) => {
const { repository, revision, path } = ownProps; const { repository, revision, path } = ownProps;