diff --git a/scm-ui/src/repos/sources/containers/FileHistory.js b/scm-ui/src/repos/sources/containers/FileHistory.js deleted file mode 100644 index 0551ff8239..0000000000 --- a/scm-ui/src/repos/sources/containers/FileHistory.js +++ /dev/null @@ -1,22 +0,0 @@ -//@flow - -import React from "react"; -import { translate } from "react-i18next"; -import { connect } from "react-redux"; - -type Props = { - classes: any, - t: string => string -}; - -class FileHistory extends React.Component { - componentDidMount() {} - - render() { - return "History"; - } -} - -const mapStateToProps = (state: any, ownProps: Props) => {}; - -export default connect(mapStateToProps)(translate("repos")(FileHistory)); diff --git a/scm-ui/src/repos/sources/containers/HistoryView.js b/scm-ui/src/repos/sources/containers/HistoryView.js index e68cbe319b..bdfd8596d2 100644 --- a/scm-ui/src/repos/sources/containers/HistoryView.js +++ b/scm-ui/src/repos/sources/containers/HistoryView.js @@ -1,7 +1,16 @@ // @flow import React from "react"; -import type { File, Changeset, Repository } from "@scm-manager/ui-types"; -import { ErrorNotification, Loading } from "@scm-manager/ui-components"; +import type { + File, + Changeset, + Repository, + PagedCollection +} from "@scm-manager/ui-types"; +import { + ErrorNotification, + Loading, + LinkPaginator +} from "@scm-manager/ui-components"; import { getHistory } from "./history"; import ChangesetList from "../../components/changesets/ChangesetList"; @@ -13,6 +22,8 @@ type Props = { type State = { loaded: boolean, changesets: Changeset[], + page: number, + pageCollection?: PagedCollection, error?: Error }; @@ -22,6 +33,7 @@ class HistoryView extends React.Component { this.state = { loaded: false, + page: 0, changesets: [] }; } @@ -40,7 +52,8 @@ class HistoryView extends React.Component { this.setState({ ...this.state, loaded: true, - changesets: result.changesets + changesets: result.changesets, + pageCollection: result.pageCollection }); } }) @@ -49,8 +62,13 @@ class HistoryView extends React.Component { showHistory() { const { repository } = this.props; - const { changesets } = this.state; - return ; + const { changesets, page, pageCollection } = this.state; + return ( + <> + + + + ); } render() { @@ -70,4 +88,4 @@ class HistoryView extends React.Component { } } -export default (HistoryView); +export default HistoryView; diff --git a/scm-ui/src/repos/sources/containers/history.js b/scm-ui/src/repos/sources/containers/history.js index 7135706f9b..1c58523407 100644 --- a/scm-ui/src/repos/sources/containers/history.js +++ b/scm-ui/src/repos/sources/containers/history.js @@ -7,7 +7,13 @@ export function getHistory(url: string) { .then(response => response.json()) .then(result => { return { - changesets: result._embedded.changesets + changesets: result._embedded.changesets, + pageCollection: { + _embedded: result._embedded, + _links: result._links, + page: result.page, + pageTotal: result.pageTotal + } }; }) .catch(err => { diff --git a/scm-ui/src/repos/sources/containers/history.test.js b/scm-ui/src/repos/sources/containers/history.test.js index f37567cd79..960d59bef6 100644 --- a/scm-ui/src/repos/sources/containers/history.test.js +++ b/scm-ui/src/repos/sources/containers/history.test.js @@ -11,28 +11,31 @@ describe("get content type", () => { }); it("should return history", done => { - let changesets: { - changesets: [ + fetchMock.get("/api/v2" + FILE_URL, { + page: 0, + pageTotal: 1, + _embedded: { + changesets: [ + { + id: "1234" + }, + { + id: "2345" + } + ] + } + }); + + getHistory(FILE_URL).then(content => { + expect(content.changesets).toEqual([ { 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); + ]); + expect(content.pageCollection.page).toEqual(0); done(); }); });