From 62c422fa96d9751903e8eeb8ff6bccc45eb5995a Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Sun, 22 Jul 2018 00:19:38 +0200 Subject: Basic WebUI Based on Material-UI, react-router and react-apollo --- webui/src/Bug.js | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 webui/src/Bug.js (limited to 'webui/src/Bug.js') diff --git a/webui/src/Bug.js b/webui/src/Bug.js new file mode 100644 index 00000000..de61bc8c --- /dev/null +++ b/webui/src/Bug.js @@ -0,0 +1,105 @@ +import React from "react"; +import { Query } from "react-apollo"; +import gql from "graphql-tag"; +import { withStyles } from "@material-ui/core/styles"; + +import Avatar from "@material-ui/core/Avatar"; +import Card from "@material-ui/core/Card"; +import CardContent from "@material-ui/core/CardContent"; +import CardHeader from "@material-ui/core/CardHeader"; +import Chip from "@material-ui/core/Chip"; +import CircularProgress from "@material-ui/core/CircularProgress"; +import Typography from "@material-ui/core/Typography"; + +const styles = theme => ({ + main: { + maxWidth: 600, + margin: "auto", + marginTop: theme.spacing.unit * 4 + }, + labelList: { + display: "flex", + flexWrap: "wrap", + marginTop: theme.spacing.unit + }, + label: { + marginRight: theme.spacing.unit + }, + summary: { + marginBottom: theme.spacing.unit * 2 + }, + comment: { + marginBottom: theme.spacing.unit + } +}); + +const QUERY = gql` + query GetBug($id: BugID!) { + bug(id: $id) { + id + title + status + labels + comments { + message + author { + name + email + } + } + } + } +`; + +const Comment = withStyles(styles)(({ comment, classes }) => ( + + + {comment.author.name[0].toUpperCase()} + + } + title={comment.author.name} + subheader={comment.author.email} + /> + + {comment.message} + + +)); + +const BugView = withStyles(styles)(({ bug, classes }) => ( +
+ + + + {bug.title} + + + #{bug.id.slice(0, 8)} • {bug.status.toUpperCase()} + +
+ {bug.labels.map(label => ( + + ))} +
+
+
+ + {bug.comments.map((comment, index) => ( + + ))} +
+)); + +const Bug = ({ match }) => ( + + {({ loading, error, data }) => { + if (loading) return ; + if (error) return

Error.

; + return ; + }} +
+); + +export default Bug; -- cgit From 4901bdadd3918833fc2cf0ad47d73aeeb061af0d Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Sun, 22 Jul 2018 00:42:19 +0200 Subject: webui: Split into multiple, smaller components --- webui/src/Bug.js | 101 ++++++++++--------------------------------------------- 1 file changed, 17 insertions(+), 84 deletions(-) (limited to 'webui/src/Bug.js') diff --git a/webui/src/Bug.js b/webui/src/Bug.js index de61bc8c..28558a13 100644 --- a/webui/src/Bug.js +++ b/webui/src/Bug.js @@ -1,105 +1,38 @@ import React from "react"; -import { Query } from "react-apollo"; import gql from "graphql-tag"; import { withStyles } from "@material-ui/core/styles"; -import Avatar from "@material-ui/core/Avatar"; -import Card from "@material-ui/core/Card"; -import CardContent from "@material-ui/core/CardContent"; -import CardHeader from "@material-ui/core/CardHeader"; -import Chip from "@material-ui/core/Chip"; -import CircularProgress from "@material-ui/core/CircularProgress"; -import Typography from "@material-ui/core/Typography"; +import Comment from "./Comment"; +import BugSummary from "./BugSummary"; const styles = theme => ({ main: { maxWidth: 600, margin: "auto", marginTop: theme.spacing.unit * 4 - }, - labelList: { - display: "flex", - flexWrap: "wrap", - marginTop: theme.spacing.unit - }, - label: { - marginRight: theme.spacing.unit - }, - summary: { - marginBottom: theme.spacing.unit * 2 - }, - comment: { - marginBottom: theme.spacing.unit } }); -const QUERY = gql` - query GetBug($id: BugID!) { - bug(id: $id) { - id - title - status - labels - comments { - message - author { - name - email - } - } - } - } -`; - -const Comment = withStyles(styles)(({ comment, classes }) => ( - - - {comment.author.name[0].toUpperCase()} - - } - title={comment.author.name} - subheader={comment.author.email} - /> - - {comment.message} - - -)); - -const BugView = withStyles(styles)(({ bug, classes }) => ( +const Bug = ({ bug, classes }) => (
- - - - {bug.title} - - - #{bug.id.slice(0, 8)} • {bug.status.toUpperCase()} - -
- {bug.labels.map(label => ( - - ))} -
-
-
+ {bug.comments.map((comment, index) => ( ))}
-)); - -const Bug = ({ match }) => ( - - {({ loading, error, data }) => { - if (loading) return ; - if (error) return

Error.

; - return ; - }} -
); -export default Bug; +Bug.fragment = gql` + fragment Bug on Bug { + ...BugSummary + comments { + ...Comment + } + } + + ${BugSummary.fragment} + ${Comment.fragment} +`; + +export default withStyles(styles)(Bug); -- cgit