From cf9e83e74dc5f91b0e13fbdb79848925e68809a3 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Wed, 15 Aug 2018 21:49:31 +0200 Subject: webui: display label changes in the timeline + cleaning evrywhere --- webui/src/Author.js | 24 +++++++++++++++++++++++ webui/src/Date.js | 11 +++++++++++ webui/src/Label.js | 15 ++++++++++++++ webui/src/bug/Bug.js | 13 ++++++------- webui/src/bug/LabelChange.js | 44 ++++++++++++++++++++++++++++++++++++++++++ webui/src/bug/Message.js | 23 ++++++++-------------- webui/src/bug/Timeline.js | 7 +++++-- webui/src/bug/TimelineQuery.js | 5 ++++- webui/src/list/BugRow.js | 17 +++++----------- 9 files changed, 122 insertions(+), 37 deletions(-) create mode 100644 webui/src/Author.js create mode 100644 webui/src/Date.js create mode 100644 webui/src/Label.js create mode 100644 webui/src/bug/LabelChange.js (limited to 'webui/src') diff --git a/webui/src/Author.js b/webui/src/Author.js new file mode 100644 index 00000000..37de7aa7 --- /dev/null +++ b/webui/src/Author.js @@ -0,0 +1,24 @@ +import Tooltip from '@material-ui/core/Tooltip/Tooltip' +import React from 'react' +import { withStyles } from '@material-ui/core/styles' + +const styles = theme => ({ + author: { + ...theme.typography.body2, + }, + bold: { + fontWeight: 'bold' + } +}) + +const Author = ({author, bold, classes}) => { + const klass = bold ? [classes.author, classes.bold] : [classes.author] + + return ( + + {author.name} + + ) +} + +export default withStyles(styles)(Author) diff --git a/webui/src/Date.js b/webui/src/Date.js new file mode 100644 index 00000000..b20fd274 --- /dev/null +++ b/webui/src/Date.js @@ -0,0 +1,11 @@ +import Tooltip from '@material-ui/core/Tooltip/Tooltip' +import * as moment from 'moment' +import React from 'react' + +const Date = ({date}) => ( + + {moment(date).fromNow()} + +) + +export default Date diff --git a/webui/src/Label.js b/webui/src/Label.js new file mode 100644 index 00000000..93a9a358 --- /dev/null +++ b/webui/src/Label.js @@ -0,0 +1,15 @@ +import React from 'react' +import { withStyles } from '@material-ui/core/styles' + +const styles = theme => ({ + label: { + padding: '0 4px', + margin: '0 1px', + backgroundColor: '#da9898', + borderRadius: '3px' + }, +}) + +const Label = ({label, classes}) => {label} + +export default withStyles(styles)(Label) diff --git a/webui/src/bug/Bug.js b/webui/src/bug/Bug.js index 3847c755..34fc3ad4 100644 --- a/webui/src/bug/Bug.js +++ b/webui/src/bug/Bug.js @@ -1,9 +1,9 @@ import { withStyles } from '@material-ui/core/styles' -import Tooltip from '@material-ui/core/Tooltip/Tooltip' import Typography from '@material-ui/core/Typography/Typography' import gql from 'graphql-tag' -import * as moment from 'moment' import React from 'react' +import Author from '../Author' +import Date from '../Date' import TimelineQuery from './TimelineQuery' const styles = theme => ({ @@ -21,7 +21,8 @@ const styles = theme => ({ marginLeft: 15, }, container: { - display: 'flex' + display: 'flex', + marginBottom: 30 }, timeline: { width: '70%', @@ -47,11 +48,9 @@ const Bug = ({bug, classes}) => ( {bug.humanId} - {bug.author.name} + opened this bug - - {moment(bug.createdAt).fromNow()} - + diff --git a/webui/src/bug/LabelChange.js b/webui/src/bug/LabelChange.js new file mode 100644 index 00000000..f954372a --- /dev/null +++ b/webui/src/bug/LabelChange.js @@ -0,0 +1,44 @@ +import { withStyles } from '@material-ui/core/styles' +import gql from 'graphql-tag' +import React from 'react' +import Author from '../Author' +import Date from '../Date' +import Label from '../Label' + +const styles = theme => ({ + main: { + ...theme.typography.body2 + }, +}) + +const LabelChange = ({op, classes}) => { + const {added, removed} = op + return ( +
+ + { added.length > 0 && added the } + { added.map((label, index) =>
+ ) +} + +LabelChange.fragment = gql` + fragment LabelChange on Operation { + ... on LabelChangeOperation { + date + author { + name + email + } + added + removed + } + } +` + +export default withStyles(styles)(LabelChange) diff --git a/webui/src/bug/Message.js b/webui/src/bug/Message.js index 04c7dfab..612a9563 100644 --- a/webui/src/bug/Message.js +++ b/webui/src/bug/Message.js @@ -1,9 +1,9 @@ import { withStyles } from '@material-ui/core/styles' -import Tooltip from '@material-ui/core/Tooltip/Tooltip' import Typography from '@material-ui/core/Typography' import gql from 'graphql-tag' -import * as moment from 'moment' import React from 'react' +import Author from '../Author' +import Date from '../Date' const styles = theme => ({ header: { @@ -14,10 +14,6 @@ const styles = theme => ({ borderTopLeftRadius: 3, borderTopRightRadius: 3, }, - author: { - ...theme.typography.body2, - fontWeight: 'bold' - }, message: { borderLeft: '1px solid #d1d5da', borderRight: '1px solid #d1d5da', @@ -25,23 +21,20 @@ const styles = theme => ({ borderBottomLeftRadius: 3, borderBottomRightRadius: 3, backgroundColor: '#fff', - minHeight: 50 + minHeight: 50, + padding: 5, } }) -const Message = ({message, classes}) => ( +const Message = ({op, classes}) => (
- - {message.author.name} - + commented - - {moment(message.date).fromNow()} - +
- {message.message} + {op.message}
) diff --git a/webui/src/bug/Timeline.js b/webui/src/bug/Timeline.js index 0c4100ec..72c07121 100644 --- a/webui/src/bug/Timeline.js +++ b/webui/src/bug/Timeline.js @@ -1,5 +1,6 @@ import { withStyles } from '@material-ui/core/styles' import React from 'react' +import LabelChange from './LabelChange' import Message from './Message' const styles = theme => ({ @@ -26,9 +27,11 @@ class Timeline extends React.Component { { ops.map((op, index) => { switch (op.__typename) { case 'CreateOperation': - return + return case 'AddCommentOperation': - return + return + case 'LabelChangeOperation': + return default: console.log('unsupported operation type ' + op.__typename) diff --git a/webui/src/bug/TimelineQuery.js b/webui/src/bug/TimelineQuery.js index e773aac0..ad4d00b0 100644 --- a/webui/src/bug/TimelineQuery.js +++ b/webui/src/bug/TimelineQuery.js @@ -2,6 +2,7 @@ import CircularProgress from '@material-ui/core/CircularProgress' import gql from 'graphql-tag' import React from 'react' import { Query } from 'react-apollo' +import LabelChange from './LabelChange' import Timeline from './Timeline' import Message from './Message' @@ -13,6 +14,7 @@ const QUERY = gql` nodes { ...Create ...Comment + ...LabelChange } pageInfo { hasNextPage @@ -24,10 +26,11 @@ const QUERY = gql` } ${Message.createFragment} ${Message.commentFragment} + ${LabelChange.fragment} ` const TimelineQuery = ({id}) => ( - + {({loading, error, data, fetchMore}) => { if (loading) return if (error) return

Error: {error}

diff --git a/webui/src/list/BugRow.js b/webui/src/list/BugRow.js index 1ce5ea06..dba498d2 100644 --- a/webui/src/list/BugRow.js +++ b/webui/src/list/BugRow.js @@ -5,9 +5,10 @@ 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 * as moment from 'moment' import React from 'react' import { Link } from 'react-router-dom' +import Date from '../Date' +import Label from '../Label' const Open = ({className}) => @@ -46,12 +47,6 @@ const styles = theme => ({ labels: { display: 'inline-block', paddingLeft: theme.spacing.unit, - '&>span': { - padding: '0 4px', - margin: '0 1px', - backgroundColor: '#da9898', - borderRadius: '3px' - } } }) @@ -68,16 +63,14 @@ const BugRow = ({bug, classes}) => ( {bug.labels.map(l => ( - {l}) - )} + {bug.humanId} opened - - {moment(bug.createdAt).fromNow()} - + by {bug.author.name} -- cgit