diff options
author | Quentin Gliech <quentingliech@gmail.com> | 2018-08-18 17:00:53 -0400 |
---|---|---|
committer | Sandhose <quentingliech@gmail.com> | 2018-08-19 23:14:45 +0200 |
commit | bb4ebed08c3f1b1a7ba9968ede75a07f1705d2df (patch) | |
tree | dd6998679330f1814001011c339ba7ee1da876d9 /webui/src/list/List.js | |
parent | 8575abf285d1dd71990b619fbdf3cd44dbc48e75 (diff) | |
download | git-bug-bb4ebed08c3f1b1a7ba9968ede75a07f1705d2df.tar.gz |
webui: Format everything with prettier
Diffstat (limited to 'webui/src/list/List.js')
-rw-r--r-- | webui/src/list/List.js | 103 |
1 files changed, 51 insertions, 52 deletions
diff --git a/webui/src/list/List.js b/webui/src/list/List.js index 880782c7..d36be8a1 100644 --- a/webui/src/list/List.js +++ b/webui/src/list/List.js @@ -1,115 +1,114 @@ -import { withStyles } from '@material-ui/core/styles' -import Table from '@material-ui/core/Table/Table' -import TableBody from '@material-ui/core/TableBody/TableBody' -import TablePagination from '@material-ui/core/TablePagination/TablePagination' -import React from 'react' -import BugRow from './BugRow' +import { withStyles } from '@material-ui/core/styles'; +import Table from '@material-ui/core/Table/Table'; +import TableBody from '@material-ui/core/TableBody/TableBody'; +import TablePagination from '@material-ui/core/TablePagination/TablePagination'; +import React from 'react'; +import BugRow from './BugRow'; const styles = theme => ({ main: { maxWidth: 600, margin: 'auto', - marginTop: theme.spacing.unit * 4 - } -}) + marginTop: theme.spacing.unit * 4, + }, +}); class List extends React.Component { - props: { bugs: Array, - fetchMore: (any) => any, + fetchMore: any => any, classes: any, - } + }; state = { page: 0, rowsPerPage: 10, - lastQuery: {} - } + lastQuery: {}, + }; handleChangePage = (event, page) => { - const {bugs, fetchMore} = this.props - const {rowsPerPage} = this.state - const pageInfo = bugs.pageInfo + const { bugs, fetchMore } = this.props; + const { rowsPerPage } = this.state; + const pageInfo = bugs.pageInfo; if (page === this.state.page + 1) { if (!pageInfo.hasNextPage) { - return + return; } const variables = { after: pageInfo.endCursor, - first: rowsPerPage - } + first: rowsPerPage, + }; fetchMore({ variables, updateQuery: this.updateQuery, - }) + }); - this.setState({page, lastQuery: variables}) - return + this.setState({ page, lastQuery: variables }); + return; } if (page === this.state.page - 1) { if (!pageInfo.hasPreviousPage) { - return + return; } const variables = { before: pageInfo.startCursor, - last: rowsPerPage - } + last: rowsPerPage, + }; fetchMore({ variables, updateQuery: this.updateQuery, - }) + }); - this.setState({page, lastQuery: variables}) - return + this.setState({ page, lastQuery: variables }); + return; } - throw new Error('non neighbour page pagination is not supported') - } + throw new Error('non neighbour page pagination is not supported'); + }; handleChangeRowsPerPage = event => { - const {fetchMore} = this.props - const {lastQuery} = this.state - const rowsPerPage = event.target.value + const { fetchMore } = this.props; + const { lastQuery } = this.state; + const rowsPerPage = event.target.value; - const variables = lastQuery + const variables = lastQuery; if (lastQuery.first) { - variables.first = rowsPerPage + variables.first = rowsPerPage; } else if (lastQuery.last) { - variables.last = rowsPerPage + variables.last = rowsPerPage; } else { - variables.first = rowsPerPage + variables.first = rowsPerPage; } fetchMore({ variables, updateQuery: this.updateQuery, - }) + }); - this.setState({rowsPerPage, lastQuery: variables}) - } + this.setState({ rowsPerPage, lastQuery: variables }); + }; - updateQuery = (previousResult, {fetchMoreResult}) => { - return fetchMoreResult ? fetchMoreResult : previousResult - } + updateQuery = (previousResult, { fetchMoreResult }) => { + return fetchMoreResult ? fetchMoreResult : previousResult; + }; render() { - const {classes, bugs} = this.props - const {page, rowsPerPage} = this.state + const { classes, bugs } = this.props; + const { page, rowsPerPage } = this.state; return ( <main className={classes.main}> <Table className={classes.table}> <TableBody> - {bugs.edges.map(({cursor, node}) => ( - <BugRow bug={node} key={cursor}/> + {bugs.edges.map(({ cursor, node }) => ( + <BugRow bug={node} key={cursor} /> ))} </TableBody> </Table> @@ -119,17 +118,17 @@ class List extends React.Component { rowsPerPage={rowsPerPage} page={page} backIconButtonProps={{ - 'aria-label': 'Previous Page' + 'aria-label': 'Previous Page', }} nextIconButtonProps={{ - 'aria-label': 'Next Page' + 'aria-label': 'Next Page', }} onChangePage={this.handleChangePage} onChangeRowsPerPage={this.handleChangeRowsPerPage} /> </main> - ) + ); } } -export default withStyles(styles)(List) +export default withStyles(styles)(List); |