mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +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
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import type { File, Changeset, Repository } from "@scm-manager/ui-types";
|
import type {
|
||||||
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
|
File,
|
||||||
|
Changeset,
|
||||||
|
Repository,
|
||||||
|
PagedCollection
|
||||||
|
} from "@scm-manager/ui-types";
|
||||||
|
import {
|
||||||
|
ErrorNotification,
|
||||||
|
Loading,
|
||||||
|
LinkPaginator
|
||||||
|
} from "@scm-manager/ui-components";
|
||||||
import { getHistory } from "./history";
|
import { getHistory } from "./history";
|
||||||
import ChangesetList from "../../components/changesets/ChangesetList";
|
import ChangesetList from "../../components/changesets/ChangesetList";
|
||||||
|
|
||||||
@@ -13,6 +22,8 @@ type Props = {
|
|||||||
type State = {
|
type State = {
|
||||||
loaded: boolean,
|
loaded: boolean,
|
||||||
changesets: Changeset[],
|
changesets: Changeset[],
|
||||||
|
page: number,
|
||||||
|
pageCollection?: PagedCollection,
|
||||||
error?: Error
|
error?: Error
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -22,6 +33,7 @@ class HistoryView extends React.Component<Props, State> {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
loaded: false,
|
loaded: false,
|
||||||
|
page: 0,
|
||||||
changesets: []
|
changesets: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -40,7 +52,8 @@ class HistoryView extends React.Component<Props, State> {
|
|||||||
this.setState({
|
this.setState({
|
||||||
...this.state,
|
...this.state,
|
||||||
loaded: true,
|
loaded: true,
|
||||||
changesets: result.changesets
|
changesets: result.changesets,
|
||||||
|
pageCollection: result.pageCollection
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -49,8 +62,13 @@ class HistoryView extends React.Component<Props, State> {
|
|||||||
|
|
||||||
showHistory() {
|
showHistory() {
|
||||||
const { repository } = this.props;
|
const { repository } = this.props;
|
||||||
const { changesets } = this.state;
|
const { changesets, page, pageCollection } = this.state;
|
||||||
return <ChangesetList repository={repository} changesets={changesets} />;
|
return (
|
||||||
|
<>
|
||||||
|
<ChangesetList repository={repository} changesets={changesets} />
|
||||||
|
<LinkPaginator page={page} collection={pageCollection} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
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(response => response.json())
|
||||||
.then(result => {
|
.then(result => {
|
||||||
return {
|
return {
|
||||||
changesets: result._embedded.changesets
|
changesets: result._embedded.changesets,
|
||||||
|
pageCollection: {
|
||||||
|
_embedded: result._embedded,
|
||||||
|
_links: result._links,
|
||||||
|
page: result.page,
|
||||||
|
pageTotal: result.pageTotal
|
||||||
|
}
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ describe("get content type", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return history", done => {
|
it("should return history", done => {
|
||||||
let changesets: {
|
fetchMock.get("/api/v2" + FILE_URL, {
|
||||||
|
page: 0,
|
||||||
|
pageTotal: 1,
|
||||||
|
_embedded: {
|
||||||
changesets: [
|
changesets: [
|
||||||
{
|
{
|
||||||
id: "1234"
|
id: "1234"
|
||||||
@@ -20,19 +23,19 @@ describe("get content type", () => {
|
|||||||
id: "2345"
|
id: "2345"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
|
||||||
let history = {
|
|
||||||
_embedded: {
|
|
||||||
changesets
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
fetchMock.get("/api/v2" + FILE_URL, {
|
|
||||||
history
|
|
||||||
});
|
});
|
||||||
|
|
||||||
getHistory(FILE_URL).then(content => {
|
getHistory(FILE_URL).then(content => {
|
||||||
expect(content.changesets).toBe(changesets);
|
expect(content.changesets).toEqual([
|
||||||
|
{
|
||||||
|
id: "1234"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "2345"
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
expect(content.pageCollection.page).toEqual(0);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user