aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/list
diff options
context:
space:
mode:
authorQuentin Gliech <quentingliech@gmail.com>2018-08-18 17:00:53 -0400
committerSandhose <quentingliech@gmail.com>2018-08-19 23:14:45 +0200
commitbb4ebed08c3f1b1a7ba9968ede75a07f1705d2df (patch)
treedd6998679330f1814001011c339ba7ee1da876d9 /webui/src/list
parent8575abf285d1dd71990b619fbdf3cd44dbc48e75 (diff)
downloadgit-bug-bb4ebed08c3f1b1a7ba9968ede75a07f1705d2df.tar.gz
webui: Format everything with prettier
Diffstat (limited to 'webui/src/list')
-rw-r--r--webui/src/list/BugRow.js54
-rw-r--r--webui/src/list/List.js103
-rw-r--r--webui/src/list/ListQuery.js36
3 files changed, 98 insertions, 95 deletions
diff --git a/webui/src/list/BugRow.js b/webui/src/list/BugRow.js
index 05eafe92..9253cc88 100644
--- a/webui/src/list/BugRow.js
+++ b/webui/src/list/BugRow.js
@@ -1,14 +1,14 @@
-import { withStyles } from "@material-ui/core/styles";
-import TableCell from "@material-ui/core/TableCell/TableCell";
-import TableRow from "@material-ui/core/TableRow/TableRow";
-import Tooltip from "@material-ui/core/Tooltip/Tooltip";
-import Typography from "@material-ui/core/Typography";
-import ErrorOutline from "@material-ui/icons/ErrorOutline";
-import gql from "graphql-tag";
-import React from "react";
-import { Link } from "react-router-dom";
-import Date from "../Date";
-import Label from "../Label";
+import { withStyles } from '@material-ui/core/styles';
+import TableCell from '@material-ui/core/TableCell/TableCell';
+import TableRow from '@material-ui/core/TableRow/TableRow';
+import Tooltip from '@material-ui/core/Tooltip/Tooltip';
+import Typography from '@material-ui/core/Typography';
+import ErrorOutline from '@material-ui/icons/ErrorOutline';
+import gql from 'graphql-tag';
+import React from 'react';
+import { Link } from 'react-router-dom';
+import Date from '../Date';
+import Label from '../Label';
const Open = ({ className }) => (
<Tooltip title="Open">
@@ -24,35 +24,35 @@ const Closed = ({ className }) => (
const Status = ({ status, className }) => {
switch (status) {
- case "OPEN":
+ case 'OPEN':
return <Open className={className} />;
- case "CLOSED":
+ case 'CLOSED':
return <Closed className={className} />;
default:
- return "unknown status " + status;
+ return 'unknown status ' + status;
}
};
const styles = theme => ({
cell: {
- display: "flex",
- alignItems: "center",
- "& a": {
- textDecoration: "none"
- }
+ display: 'flex',
+ alignItems: 'center',
+ '& a': {
+ textDecoration: 'none',
+ },
},
status: {
- margin: 10
+ margin: 10,
},
expand: {
- width: "100%"
+ width: '100%',
},
title: {
- display: "inline"
+ display: 'inline',
},
labels: {
- paddingLeft: theme.spacing.unit
- }
+ paddingLeft: theme.spacing.unit,
+ },
});
const BugRow = ({ bug, classes }) => (
@@ -60,9 +60,9 @@ const BugRow = ({ bug, classes }) => (
<TableCell className={classes.cell}>
<Status status={bug.status} className={classes.status} />
<div className={classes.expand}>
- <Link to={"bug/" + bug.humanId}>
+ <Link to={'bug/' + bug.humanId}>
<div className={classes.expand}>
- <Typography variant={"title"} className={classes.title}>
+ <Typography variant={'title'} className={classes.title}>
{bug.title}
</Typography>
{bug.labels.length > 0 && (
@@ -74,7 +74,7 @@ const BugRow = ({ bug, classes }) => (
)}
</div>
</Link>
- <Typography color={"textSecondary"}>
+ <Typography color={'textSecondary'}>
{bug.humanId} opened
<Date date={bug.createdAt} />
by {bug.author.name}
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);
diff --git a/webui/src/list/ListQuery.js b/webui/src/list/ListQuery.js
index 3b57fcc2..9dbe4e53 100644
--- a/webui/src/list/ListQuery.js
+++ b/webui/src/list/ListQuery.js
@@ -1,15 +1,20 @@
// @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'
+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) {
+ bugs: allBugs(
+ first: $first
+ last: $last
+ after: $after
+ before: $before
+ ) {
totalCount
edges {
cursor
@@ -17,7 +22,7 @@ const QUERY = gql`
...BugRow
}
}
- pageInfo{
+ pageInfo {
hasNextPage
hasPreviousPage
startCursor
@@ -27,18 +32,17 @@ const QUERY = gql`
}
}
-
${BugRow.fragment}
-`
+`;
const ListQuery = () => (
<Query query={QUERY}>
- {({loading, error, data, fetchMore}) => {
- if (loading) return <CircularProgress/>
- if (error) return <p>Error: {error}</p>
- return <List bugs={data.defaultRepository.bugs} fetchMore={fetchMore}/>
+ {({ loading, error, data, fetchMore }) => {
+ if (loading) return <CircularProgress />;
+ if (error) return <p>Error: {error}</p>;
+ return <List bugs={data.defaultRepository.bugs} fetchMore={fetchMore} />;
}}
</Query>
-)
+);
-export default ListQuery
+export default ListQuery;