open correct viewer for each type and reorder the structure

This commit is contained in:
Maren Süwer
2018-10-25 14:03:45 +02:00
parent bfdb58797b
commit 36f289a153
7 changed files with 26 additions and 10 deletions

View File

@@ -0,0 +1,29 @@
// @flow
import React from "react";
import { translate } from "react-i18next";
type Props = {
t: string => string
};
type State = {
content: string
};
class DownloadViewer extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
content: ""
};
}
componentDidMount() {}
render() {
return "DownloadViewer";
}
}
export default translate("repos")(DownloadViewer);

View File

@@ -0,0 +1,29 @@
// @flow
import React from "react";
import { translate } from "react-i18next";
type Props = {
t: string => string
};
type State = {
content: string
};
class ImageViewer extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
content: ""
};
}
componentDidMount() {}
render() {
return "ImageViewer";
}
}
export default translate("repos")(ImageViewer);

View File

@@ -0,0 +1,39 @@
// @flow
import React from "react";
import { translate } from "react-i18next";
import { apiClient } from "../../../../../../scm-ui-components/packages/ui-components/src/index";
type Props = {
t: string => string
};
type State = {
content: string
};
class SourcecodeViewer extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
content: ""
};
}
componentDidMount() {}
render() {
return "sourceCodeViewer";
}
}
export function getContent(url: string) {
return apiClient
.get(url)
.then(response => response.text())
.catch(err => {
return null;
});
}
export default translate("repos")(SourcecodeViewer);

View File

@@ -0,0 +1,22 @@
//@flow
import fetchMock from "fetch-mock";
import { getContent } from "./SourcecodeViewer";
describe("get content", () => {
const CONTENT_URL =
"/repositories/scmadmin/TestRepo/content/testContent";
afterEach(() => {
fetchMock.reset();
fetchMock.restore();
});
it("should return content", done => {
fetchMock.getOnce("/api/v2" + CONTENT_URL, "This is a testContent");
getContent(CONTENT_URL).then(content => {
expect(content).toBe("This is a testContent");
done();
});
});
});