aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/list/ListPage.js
blob: b7de735f1e890c78aaf08684e73ccdc346d553ed (plain) (blame)
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
// @flow
import CircularProgress from '@material-ui/core/CircularProgress'
import gql from 'graphql-tag'
import React from 'react'
import { Query } from 'react-apollo'

import BugRow from './BugRow'
import List from './List'

const QUERY = gql`
  query($first: Int = 10, $last: Int, $after: String, $before: String) {
    defaultRepository {
      bugs: allBugs(first: $first, last: $last, after: $after, before: $before) {
        totalCount
        edges {
          cursor
          node {
            ...BugRow
          }
        }
        pageInfo{
          hasNextPage
          hasPreviousPage
          startCursor
          endCursor
        }
      }
    }
  }


  ${BugRow.fragment}
`

const ListPage = () => (
  <Query query={QUERY}>
    {({loading, error, data, fetchMore}) => {
      if (loading) return <CircularProgress/>
      if (error) return <p>Error.</p>
      return <List bugs={data.defaultRepository.bugs} fetchMore={fetchMore}/>
    }}
  </Query>
)

export default ListPage