mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
show history table of content
This commit is contained in:
@@ -19,7 +19,6 @@ import SingleGroup from "../groups/containers/SingleGroup";
|
|||||||
import AddGroup from "../groups/containers/AddGroup";
|
import AddGroup from "../groups/containers/AddGroup";
|
||||||
|
|
||||||
import Config from "../config/containers/Config";
|
import Config from "../config/containers/Config";
|
||||||
import ChangeUserPassword from "./ChangeUserPassword";
|
|
||||||
import Profile from "./Profile";
|
import Profile from "./Profile";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class Content extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showHeader() {
|
showHeader() {
|
||||||
const { file, classes, t } = this.props;
|
const { file, classes } = this.props;
|
||||||
const { showHistory, collapsed } = this.state;
|
const { showHistory, collapsed } = this.state;
|
||||||
const icon = collapsed ? "fa-angle-right" : "fa-angle-down";
|
const icon = collapsed ? "fa-angle-right" : "fa-angle-down";
|
||||||
|
|
||||||
@@ -146,10 +146,12 @@ class Content extends React.Component<Props, State> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { file, revision, repository, path, classes } = this.props;
|
const { file, revision, repository, path, classes } = this.props;
|
||||||
const {showHistory} = this.state;
|
const { showHistory } = this.state;
|
||||||
|
|
||||||
const header = this.showHeader();
|
const header = this.showHeader();
|
||||||
const content = showHistory ? <HistoryView/> : (
|
const content = showHistory ? (
|
||||||
|
<HistoryView file={file} repository={repository} />
|
||||||
|
) : (
|
||||||
<SourcesView
|
<SourcesView
|
||||||
revision={revision}
|
revision={revision}
|
||||||
file={file}
|
file={file}
|
||||||
|
|||||||
@@ -2,21 +2,7 @@
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
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 { 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 = {
|
type Props = {
|
||||||
classes: any,
|
classes: any,
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
import type { File, Changeset, Repository } from "@scm-manager/ui-types";
|
||||||
|
|
||||||
import { getContentType } from "./contentType";
|
|
||||||
import type { File, Repository } from "@scm-manager/ui-types";
|
|
||||||
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
|
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
|
||||||
|
import { getHistory } from "./history";
|
||||||
|
import ChangesetList from "../../components/changesets/ChangesetList";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
repository: Repository,
|
|
||||||
file: File,
|
file: File,
|
||||||
revision: string,
|
repository: Repository
|
||||||
path: string,
|
|
||||||
classes: any,
|
|
||||||
t: string => string
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
loaded: boolean,
|
loaded: boolean,
|
||||||
|
changesets: Changeset[],
|
||||||
error?: Error
|
error?: Error
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -25,13 +21,14 @@ class HistoryView extends React.Component<Props, State> {
|
|||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
loaded: false
|
loaded: false,
|
||||||
|
changesets: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { file } = this.props;
|
const { file } = this.props;
|
||||||
/* getContentType(file._links.self.href)
|
getHistory(file._links.history.href)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -42,21 +39,22 @@ class HistoryView extends React.Component<Props, State> {
|
|||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
...this.state,
|
...this.state,
|
||||||
contentType: result.type,
|
loaded: true,
|
||||||
language: result.language,
|
changesets: result.changesets
|
||||||
loaded: true
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {});*/
|
.catch(err => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
showHistory() {
|
showHistory() {
|
||||||
return "Hallo";
|
const { repository } = this.props;
|
||||||
|
const { changesets } = this.state;
|
||||||
|
return <ChangesetList repository={repository} changesets={changesets} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { classes, file } = this.props;
|
const { file } = this.props;
|
||||||
const { loaded, error } = this.state;
|
const { loaded, error } = this.state;
|
||||||
|
|
||||||
if (!file || !loaded) {
|
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
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
|
||||||
|
|
||||||
import SourcecodeViewer from "../components/content/SourcecodeViewer";
|
import SourcecodeViewer from "../components/content/SourcecodeViewer";
|
||||||
import ImageViewer from "../components/content/ImageViewer";
|
import ImageViewer from "../components/content/ImageViewer";
|
||||||
@@ -14,9 +13,7 @@ type Props = {
|
|||||||
repository: Repository,
|
repository: Repository,
|
||||||
file: File,
|
file: File,
|
||||||
revision: string,
|
revision: string,
|
||||||
path: string,
|
path: string
|
||||||
classes: any,
|
|
||||||
t: string => string
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
@@ -81,7 +78,7 @@ class SourcesView extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { classes, file } = this.props;
|
const { file } = this.props;
|
||||||
const { loaded, error } = this.state;
|
const { loaded, error } = this.state;
|
||||||
|
|
||||||
if (!file || !loaded) {
|
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