aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/bug
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-15 15:50:19 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-15 15:50:19 +0200
commit2530cee1eac225924e1119554cf475cdc46ed7dc (patch)
tree4d36ca529a2e25a3fe9f1a881d037215184ec9a1 /webui/src/bug
parent24d862a65c603de4ea77a2688f5c90effc65be2f (diff)
downloadgit-bug-2530cee1eac225924e1119554cf475cdc46ed7dc.tar.gz
webui: reorganize the code
Diffstat (limited to 'webui/src/bug')
-rw-r--r--webui/src/bug/Bug.js39
-rw-r--r--webui/src/bug/BugPage.js30
-rw-r--r--webui/src/bug/Comment.js43
3 files changed, 112 insertions, 0 deletions
diff --git a/webui/src/bug/Bug.js b/webui/src/bug/Bug.js
new file mode 100644
index 00000000..33ecdd79
--- /dev/null
+++ b/webui/src/bug/Bug.js
@@ -0,0 +1,39 @@
+import { withStyles } from '@material-ui/core/styles'
+import gql from 'graphql-tag'
+import React from 'react'
+
+import Comment from './Comment'
+
+const styles = theme => ({
+ main: {
+ maxWidth: 600,
+ margin: 'auto',
+ marginTop: theme.spacing.unit * 4
+ }
+})
+
+const Bug = ({bug, classes}) => (
+ <main className={classes.main}>
+
+ {bug.comments.edges.map(({cursor, node}) => (
+ <Comment key={cursor} comment={node}/>
+ ))}
+ </main>
+)
+
+Bug.fragment = gql`
+ fragment Bug on Bug {
+ comments(first: 10) {
+ edges {
+ cursor
+ node {
+ ...Comment
+ }
+ }
+ }
+ }
+
+ ${Comment.fragment}
+`
+
+export default withStyles(styles)(Bug)
diff --git a/webui/src/bug/BugPage.js b/webui/src/bug/BugPage.js
new file mode 100644
index 00000000..a91030ab
--- /dev/null
+++ b/webui/src/bug/BugPage.js
@@ -0,0 +1,30 @@
+import CircularProgress from '@material-ui/core/CircularProgress'
+import gql from 'graphql-tag'
+import React from 'react'
+import { Query } from 'react-apollo'
+
+import Bug from './Bug'
+
+const QUERY = gql`
+ query GetBug($id: String!) {
+ defaultRepository {
+ bug(prefix: $id) {
+ ...Bug
+ }
+ }
+ }
+
+ ${Bug.fragment}
+`
+
+const BugPage = ({match}) => (
+ <Query query={QUERY} variables={{id: match.params.id}}>
+ {({loading, error, data}) => {
+ if (loading) return <CircularProgress/>
+ if (error) return <p>Error.</p>
+ return <Bug bug={data.defaultRepository.bug}/>
+ }}
+ </Query>
+)
+
+export default BugPage
diff --git a/webui/src/bug/Comment.js b/webui/src/bug/Comment.js
new file mode 100644
index 00000000..bc108083
--- /dev/null
+++ b/webui/src/bug/Comment.js
@@ -0,0 +1,43 @@
+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 { withStyles } from '@material-ui/core/styles'
+import Typography from '@material-ui/core/Typography'
+import gql from 'graphql-tag'
+import React from 'react'
+
+const styles = theme => ({
+ comment: {
+ marginBottom: theme.spacing.unit
+ }
+})
+
+const Comment = withStyles(styles)(({comment, classes}) => (
+ <Card className={classes.comment}>
+ <CardHeader
+ avatar={
+ <Avatar aria-label={comment.author.name}>
+ {comment.author.name[0].toUpperCase()}
+ </Avatar>
+ }
+ title={comment.author.name}
+ subheader={comment.author.email}
+ />
+ <CardContent>
+ <Typography component="p">{comment.message}</Typography>
+ </CardContent>
+ </Card>
+))
+
+Comment.fragment = gql`
+ fragment Comment on Comment {
+ message
+ author {
+ name
+ email
+ }
+ }
+`
+
+export default withStyles(styles)(Comment)