mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 21:45:43 +01:00
add dummy paginator
This commit is contained in:
@@ -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<Props> {
|
||||
componentDidMount() {}
|
||||
|
||||
render() {
|
||||
return "History";
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: any, ownProps: Props) => {};
|
||||
|
||||
export default connect(mapStateToProps)(translate("repos")(FileHistory));
|
||||
@@ -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<Props, State> {
|
||||
|
||||
this.state = {
|
||||
loaded: false,
|
||||
page: 0,
|
||||
changesets: []
|
||||
};
|
||||
}
|
||||
@@ -40,7 +52,8 @@ class HistoryView extends React.Component<Props, State> {
|
||||
this.setState({
|
||||
...this.state,
|
||||
loaded: true,
|
||||
changesets: result.changesets
|
||||
changesets: result.changesets,
|
||||
pageCollection: result.pageCollection
|
||||
});
|
||||
}
|
||||
})
|
||||
@@ -49,8 +62,13 @@ class HistoryView extends React.Component<Props, State> {
|
||||
|
||||
showHistory() {
|
||||
const { repository } = this.props;
|
||||
const { changesets } = this.state;
|
||||
return <ChangesetList repository={repository} changesets={changesets} />;
|
||||
const { changesets, page, pageCollection } = this.state;
|
||||
return (
|
||||
<>
|
||||
<ChangesetList repository={repository} changesets={changesets} />
|
||||
<LinkPaginator page={page} collection={pageCollection} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -70,4 +88,4 @@ class HistoryView extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default (HistoryView);
|
||||
export default HistoryView;
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user