add history and sources button to chose between view

This commit is contained in:
Maren Süwer
2018-11-26 15:20:44 +01:00
parent 6357ec77e2
commit 2f9d0f2793
5 changed files with 296 additions and 90 deletions

View File

@@ -0,0 +1,75 @@
// @flow
import React from "react";
import { translate } from "react-i18next";
import { getContentType } from "./contentType";
import type { File, Repository } from "@scm-manager/ui-types";
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
type Props = {
repository: Repository,
file: File,
revision: string,
path: string,
classes: any,
t: string => string
};
type State = {
loaded: boolean,
error?: Error
};
class HistoryView extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
loaded: false
};
}
componentDidMount() {
const { file } = this.props;
/* getContentType(file._links.self.href)
.then(result => {
if (result.error) {
this.setState({
...this.state,
error: result.error,
loaded: true
});
} else {
this.setState({
...this.state,
contentType: result.type,
language: result.language,
loaded: true
});
}
})
.catch(err => {});*/
}
showHistory() {
return "Hallo";
}
render() {
const { classes, file } = this.props;
const { loaded, error } = this.state;
if (!file || !loaded) {
return <Loading />;
}
if (error) {
return <ErrorNotification error={error} />;
}
const history = this.showHistory();
return <>{history}</>;
}
}
export default translate("repos")(HistoryView);