BugRow.js

 1import { withStyles } from '@material-ui/core/styles'
 2import TableCell from '@material-ui/core/TableCell/TableCell'
 3import TableRow from '@material-ui/core/TableRow/TableRow'
 4import Tooltip from '@material-ui/core/Tooltip/Tooltip'
 5import Typography from '@material-ui/core/Typography'
 6import ErrorOutline from '@material-ui/icons/ErrorOutline'
 7import gql from 'graphql-tag'
 8import React from 'react'
 9import { Link } from 'react-router-dom'
10import Date from '../Date'
11import Label from '../Label'
12
13const Open = ({className}) => <Tooltip title="Open">
14  <ErrorOutline nativeColor='#28a745' className={className}/>
15</Tooltip>
16
17const Closed = ({className}) => <Tooltip title="Closed">
18  <ErrorOutline nativeColor='#cb2431' className={className}/>
19</Tooltip>
20
21const Status = ({status, className}) => {
22  switch (status) {
23    case 'OPEN':
24      return <Open className={className}/>
25    case 'CLOSED':
26      return <Closed className={className}/>
27    default:
28      return 'unknown status ' + status
29  }
30}
31
32const styles = theme => ({
33  cell: {
34    display: 'flex',
35    alignItems: 'center'
36  },
37  status: {
38    margin: 10
39  },
40  expand: {
41    width: '100%'
42  },
43  title: {
44    display: 'inline-block',
45    textDecoration: 'none'
46  },
47  labels: {
48    display: 'inline-block',
49    paddingLeft: theme.spacing.unit,
50  }
51})
52
53const BugRow = ({bug, classes}) => (
54  <TableRow hover>
55    <TableCell className={classes.cell}>
56      <Status status={bug.status} className={classes.status}/>
57      <div className={classes.expand}>
58        <Link to={'bug/' + bug.humanId}>
59          <div className={classes.expand}>
60
61            <Typography variant={'title'} className={classes.title}>
62              {bug.title}
63            </Typography>
64            <span className={classes.labels}>
65              {bug.labels.map(l => (
66                <Label key={l} label={l}/>
67              ))}
68            </span>
69          </div>
70        </Link>
71        <Typography color={'textSecondary'}>
72          {bug.humanId} opened
73          <Date date={bug.createdAt} />
74          by {bug.author.name}
75        </Typography>
76      </div>
77    </TableCell>
78  </TableRow>
79)
80
81BugRow.fragment = gql`
82  fragment BugRow on Bug {
83    id
84    humanId
85    title
86    status
87    createdAt
88    labels
89    author {
90      name
91    }
92  }
93`
94
95export default withStyles(styles)(BugRow)