Skip to content
This repository was archived by the owner on Dec 2, 2022. It is now read-only.

Commit bfd979f

Browse files
committed
Pagination for commits
1 parent c7e2714 commit bfd979f

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/ui/components/argit/cloneButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const CloneButton = connector(
3232
target="Popover1"
3333
>
3434
<PopoverHeader>Clone with argit</PopoverHeader>
35-
<PopoverBody>dgit clone "{url}"</PopoverBody>
35+
<PopoverBody>{url}</PopoverBody>
3636
</UncontrolledPopover>
3737
</>
3838
)

src/ui/components/argit/commits.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as React from "react"
1+
import React, { useState } from "react"
22
import { connector } from "../../actionCreators/index"
33
import { ReadCommitResult } from "../../../domain/types"
44
import Widget from "./Widget/Widget"
5-
import { Table } from "reactstrap"
5+
import { Button, Table } from "reactstrap"
66
import format from "date-fns/format"
77

88
type CommitsProps = {
@@ -17,7 +17,10 @@ export const Commits = connector(
1717
}),
1818
actions => ({})
1919
)(function CommitsImpl(props: CommitsProps) {
20-
console.log(props.history)
20+
const [offset, setOffset] = useState(0)
21+
const numCommits = 15
22+
const commits = props.history.slice(offset, offset + numCommits)
23+
2124
return (
2225
<Widget
2326
title={
@@ -29,7 +32,7 @@ export const Commits = connector(
2932
<div className="table-responsive">
3033
<Table>
3134
<tbody>
32-
{props.history.map(description => (
35+
{commits.map(description => (
3336
<tr key={description.oid}>
3437
<td>{description.oid}</td>
3538
<td>
@@ -45,6 +48,20 @@ export const Commits = connector(
4548
</tbody>
4649
</Table>
4750
</div>
51+
{offset - numCommits >= 0 && (
52+
<Button color="primary" onClick={() => setOffset(offset - numCommits)}>
53+
Newer
54+
</Button>
55+
)}
56+
{offset + numCommits < props.history.length && (
57+
<Button
58+
className="float-right"
59+
color="primary"
60+
onClick={() => setOffset(offset + numCommits)}
61+
>
62+
Older
63+
</Button>
64+
)}
4865
</Widget>
4966
)
5067
})

0 commit comments

Comments
 (0)