mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
add mockup for content classes
This commit is contained in:
39
scm-ui/src/repos/content/components/Content.js
Normal file
39
scm-ui/src/repos/content/components/Content.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
// @flow
|
||||||
|
import React from "react";
|
||||||
|
import { translate } from "react-i18next";
|
||||||
|
import { apiClient } from "@scm-manager/ui-components";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
t: string => string
|
||||||
|
};
|
||||||
|
|
||||||
|
type State = {
|
||||||
|
contentType: string
|
||||||
|
};
|
||||||
|
|
||||||
|
class Content extends React.Component<Props, State> {
|
||||||
|
constructor(props: Props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
contentType: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getContentType(url: string) {
|
||||||
|
return apiClient
|
||||||
|
.head(url)
|
||||||
|
.then(response => response)
|
||||||
|
.catch(err => {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translate("repos")(Content);
|
||||||
23
scm-ui/src/repos/content/components/Content.test.js
Normal file
23
scm-ui/src/repos/content/components/Content.test.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
//@flow
|
||||||
|
import fetchMock from "fetch-mock";
|
||||||
|
import { getContentType } from "./Content";
|
||||||
|
|
||||||
|
describe("get content type", () => {
|
||||||
|
const CONTENT_URL = "/repositories/scmadmin/TestRepo/content/testContent";
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
fetchMock.reset();
|
||||||
|
fetchMock.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
xit("should return content", done => {
|
||||||
|
fetchMock.head("/api/v2" + CONTENT_URL, {
|
||||||
|
"Content-Type": "text/plain"
|
||||||
|
});
|
||||||
|
|
||||||
|
getContentType(CONTENT_URL).then(content => {
|
||||||
|
expect(content).toBe("This is a testContent");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
29
scm-ui/src/repos/content/components/DownloadViewer.js
Normal file
29
scm-ui/src/repos/content/components/DownloadViewer.js
Normal 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 null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translate("repos")(DownloadViewer);
|
||||||
29
scm-ui/src/repos/content/components/ImageViewer.js
Normal file
29
scm-ui/src/repos/content/components/ImageViewer.js
Normal 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 null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translate("repos")(ImageViewer);
|
||||||
39
scm-ui/src/repos/content/components/SourcecodeViewer.js
Normal file
39
scm-ui/src/repos/content/components/SourcecodeViewer.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
// @flow
|
||||||
|
import React from "react";
|
||||||
|
import { translate } from "react-i18next";
|
||||||
|
import { apiClient } from "@scm-manager/ui-components";
|
||||||
|
|
||||||
|
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 null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getContent(url: string) {
|
||||||
|
return apiClient
|
||||||
|
.get(url)
|
||||||
|
.then(response => response.text())
|
||||||
|
.catch(err => {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translate("repos")(SourcecodeViewer);
|
||||||
22
scm-ui/src/repos/content/components/SourcecodeViewer.test.js
Normal file
22
scm-ui/src/repos/content/components/SourcecodeViewer.test.js
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user