-
Notifications
You must be signed in to change notification settings - Fork 3
/
pagination.tsx
77 lines (71 loc) · 2.09 KB
/
pagination.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { text2color } from 'idea-react';
import { computed } from 'mobx';
import { GitRepository } from 'mobx-github';
import { observer } from 'mobx-react';
import { Column, RestTable } from 'mobx-restful-table';
import { compose, translator } from 'next-ssr-middleware';
import { PureComponent } from 'react';
import { Badge, Container } from 'react-bootstrap';
import { PageHead } from '../components/PageHead';
import { repositoryStore } from '../models/Base';
import { i18n } from '../models/Translation';
export const getServerSideProps = compose(translator(i18n));
const { t } = i18n;
@observer
export default class PaginationPage extends PureComponent {
@computed
get columns(): Column<GitRepository>[] {
return [
{
key: 'full_name',
renderHead: t('repository_name'),
renderBody: ({ html_url, full_name }) => (
<a target="_blank" href={html_url} rel="noreferrer">
{full_name}
</a>
),
},
{ key: 'homepage', type: 'url', renderHead: t('home_page') },
{ key: 'language', renderHead: t('programming_language') },
{
key: 'topics',
renderHead: t('topic'),
renderBody: ({ topics }) => (
<>
{topics?.map(topic => (
<Badge
key={topic}
className="me-2"
bg={text2color(topic, ['light'])}
as="a"
target="_blank"
href={`https://github.com/topics/${topic}`}
>
{topic}
</Badge>
))}
</>
),
},
{ key: 'stargazers_count', type: 'number', renderHead: t('star_count') },
];
}
render() {
return (
<Container style={{ height: '91vh' }}>
<PageHead title={t('pagination')} />
<RestTable
className="h-100 text-center"
striped
hover
editable
deletable
columns={this.columns}
store={repositoryStore}
translator={i18n}
onCheck={console.log}
/>
</Container>
);
}
}