mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 21:45:43 +01:00
show history table of content
This commit is contained in:
@@ -64,7 +64,7 @@ class Content extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
showHeader() {
|
||||
const { file, classes, t } = this.props;
|
||||
const { file, classes } = this.props;
|
||||
const { showHistory, collapsed } = this.state;
|
||||
const icon = collapsed ? "fa-angle-right" : "fa-angle-down";
|
||||
|
||||
@@ -146,10 +146,12 @@ class Content extends React.Component<Props, State> {
|
||||
|
||||
render() {
|
||||
const { file, revision, repository, path, classes } = this.props;
|
||||
const {showHistory} = this.state;
|
||||
const { showHistory } = this.state;
|
||||
|
||||
const header = this.showHeader();
|
||||
const content = showHistory ? <HistoryView/> : (
|
||||
const content = showHistory ? (
|
||||
<HistoryView file={file} repository={repository} />
|
||||
) : (
|
||||
<SourcesView
|
||||
revision={revision}
|
||||
file={file}
|
||||
|
||||
@@ -2,21 +2,7 @@
|
||||
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import type { File, Repository } from "@scm-manager/ui-types";
|
||||
import {
|
||||
DateFromNow,
|
||||
ErrorNotification,
|
||||
Loading
|
||||
} from "@scm-manager/ui-components";
|
||||
import { connect } from "react-redux";
|
||||
import ImageViewer from "../components/content/ImageViewer";
|
||||
import SourcecodeViewer from "../components/content/SourcecodeViewer";
|
||||
import DownloadViewer from "../components/content/DownloadViewer";
|
||||
import FileSize from "../components/FileSize";
|
||||
import injectSheet from "react-jss";
|
||||
import classNames from "classnames";
|
||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||
import { getContentType } from "./contentType";
|
||||
|
||||
type Props = {
|
||||
classes: any,
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
import { getContentType } from "./contentType";
|
||||
import type { File, Repository } from "@scm-manager/ui-types";
|
||||
import type { File, Changeset, Repository } from "@scm-manager/ui-types";
|
||||
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
|
||||
import { getHistory } from "./history";
|
||||
import ChangesetList from "../../components/changesets/ChangesetList";
|
||||
|
||||
type Props = {
|
||||
repository: Repository,
|
||||
file: File,
|
||||
revision: string,
|
||||
path: string,
|
||||
classes: any,
|
||||
t: string => string
|
||||
repository: Repository
|
||||
};
|
||||
|
||||
type State = {
|
||||
loaded: boolean,
|
||||
changesets: Changeset[],
|
||||
error?: Error
|
||||
};
|
||||
|
||||
@@ -25,13 +21,14 @@ class HistoryView extends React.Component<Props, State> {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
loaded: false
|
||||
loaded: false,
|
||||
changesets: []
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { file } = this.props;
|
||||
/* getContentType(file._links.self.href)
|
||||
getHistory(file._links.history.href)
|
||||
.then(result => {
|
||||
if (result.error) {
|
||||
this.setState({
|
||||
@@ -42,21 +39,22 @@ class HistoryView extends React.Component<Props, State> {
|
||||
} else {
|
||||
this.setState({
|
||||
...this.state,
|
||||
contentType: result.type,
|
||||
language: result.language,
|
||||
loaded: true
|
||||
loaded: true,
|
||||
changesets: result.changesets
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {});*/
|
||||
.catch(err => {});
|
||||
}
|
||||
|
||||
showHistory() {
|
||||
return "Hallo";
|
||||
const { repository } = this.props;
|
||||
const { changesets } = this.state;
|
||||
return <ChangesetList repository={repository} changesets={changesets} />;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes, file } = this.props;
|
||||
const { file } = this.props;
|
||||
const { loaded, error } = this.state;
|
||||
|
||||
if (!file || !loaded) {
|
||||
@@ -72,4 +70,4 @@ class HistoryView extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("repos")(HistoryView);
|
||||
export default (HistoryView);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
import SourcecodeViewer from "../components/content/SourcecodeViewer";
|
||||
import ImageViewer from "../components/content/ImageViewer";
|
||||
@@ -14,9 +13,7 @@ type Props = {
|
||||
repository: Repository,
|
||||
file: File,
|
||||
revision: string,
|
||||
path: string,
|
||||
classes: any,
|
||||
t: string => string
|
||||
path: string
|
||||
};
|
||||
|
||||
type State = {
|
||||
@@ -81,7 +78,7 @@ class SourcesView extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes, file } = this.props;
|
||||
const { file } = this.props;
|
||||
const { loaded, error } = this.state;
|
||||
|
||||
if (!file || !loaded) {
|
||||
@@ -97,4 +94,4 @@ class SourcesView extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("repos")(SourcesView);
|
||||
export default SourcesView;
|
||||
|
||||
16
scm-ui/src/repos/sources/containers/history.js
Normal file
16
scm-ui/src/repos/sources/containers/history.js
Normal file
@@ -0,0 +1,16 @@
|
||||
//@flow
|
||||
import { apiClient } from "@scm-manager/ui-components";
|
||||
|
||||
export function getHistory(url: string) {
|
||||
return apiClient
|
||||
.get(url)
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
return {
|
||||
changesets: result._embedded.changesets
|
||||
};
|
||||
})
|
||||
.catch(err => {
|
||||
return { error: err };
|
||||
});
|
||||
}
|
||||
39
scm-ui/src/repos/sources/containers/history.test.js
Normal file
39
scm-ui/src/repos/sources/containers/history.test.js
Normal file
@@ -0,0 +1,39 @@
|
||||
//@flow
|
||||
import fetchMock from "fetch-mock";
|
||||
import { getHistory } from "./history";
|
||||
|
||||
describe("get content type", () => {
|
||||
const FILE_URL = "/repositories/scmadmin/TestRepo/history/file";
|
||||
|
||||
afterEach(() => {
|
||||
fetchMock.reset();
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
||||
it("should return history", done => {
|
||||
let changesets: {
|
||||
changesets: [
|
||||
{
|
||||
id: "1234"
|
||||
},
|
||||
{
|
||||
id: "2345"
|
||||
}
|
||||
]
|
||||
};
|
||||
let history = {
|
||||
_embedded: {
|
||||
changesets
|
||||
}
|
||||
};
|
||||
|
||||
fetchMock.get("/api/v2" + FILE_URL, {
|
||||
history
|
||||
});
|
||||
|
||||
getHistory(FILE_URL).then(content => {
|
||||
expect(content.changesets).toBe(changesets);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user