aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/BugSummary.js
blob: 5ffa8e05730b7cd19ac159e02590f50ee7eb38bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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 * as moment from 'moment'

const Open = ({className}) => <Tooltip title="Open">
  <ErrorOutline nativeColor='#28a745' className={className}/>
</Tooltip>

const Closed = ({className}) => <Tooltip title="Closed">
  <ErrorOutline nativeColor='#cb2431' className={className}/>
</Tooltip>

const Status = ({status, className}) => {
    switch(status) {
      case 'OPEN': return <Open className={className}/>
      case 'CLOSED': return <Closed className={className}/>
      default: return 'unknown status ' + status
    }
}

const styles = theme => ({
  cell: {
    display: 'flex',
    alignItems: 'center'
  },
  status: {
    margin: 10
  },
  title: {
    display: 'inline-block',
    textDecoration: 'none'
  },
  labels: {
    display: 'inline-block',
    paddingLeft: theme.spacing.unit,
    '&>span': {
      padding: '0 4px',
      margin: '0 1px',
      backgroundColor: '#da9898',
      borderRadius: '3px',
    }
  },
})

const BugSummary = ({bug, classes}) => (
  <TableRow hover>
    <TableCell className={classes.cell}>
      <Status status={bug.status} className={classes.status}/>
      <div>
        <Link to={'bug/'+bug.humanId}>
          <Typography variant={'title'} className={classes.title}>
            {bug.title}
          </Typography>
        </Link>
        <span className={classes.labels}>
          {bug.labels.map(l => (
            <span key={l}>{l}</span>)
          )}
        </span>
        <Typography color={'textSecondary'}>
          {bug.humanId} opened
          <Tooltip title={moment(bug.createdAt).format('MMMM D, YYYY, h:mm a')}>
            <span> {moment(bug.createdAt).fromNow()} </span>
          </Tooltip>
          by {bug.author.name}
        </Typography>
      </div>
    </TableCell>
  </TableRow>
)

BugSummary.fragment = gql`
  fragment BugSummary on Bug {
    id
    humanId
    title
    status
    createdAt
    labels
    author {
      name
    }
  }
`

export default withStyles(styles)(BugSummary)