1import { withStyles } from '@material-ui/core/styles';
 2import React from 'react';
 3import LabelChange from './LabelChange';
 4import Message from './Message';
 5import SetStatus from './SetStatus';
 6import SetTitle from './SetTitle';
 7
 8const styles = theme => ({
 9  main: {
10    '& > *:not(:last-child)': {
11      marginBottom: theme.spacing.unit * 2,
12    },
13  },
14});
15
16class Timeline extends React.Component {
17  props: {
18    ops: Array,
19    fetchMore: any => any,
20    classes: any,
21  };
22
23  render() {
24    const { ops, classes } = this.props;
25
26    return (
27      <div className={classes.main}>
28        {ops.map((op, index) => {
29          switch (op.__typename) {
30            case 'CreateTimelineItem':
31              return <Message key={index} op={op} />;
32            case 'AddCommentTimelineItem':
33              return <Message key={index} op={op} />;
34            case 'LabelChangeTimelineItem':
35              return <LabelChange key={index} op={op} />;
36            case 'SetTitleTimelineItem':
37              return <SetTitle key={index} op={op} />;
38            case 'SetStatusTimelineItem':
39              return <SetStatus key={index} op={op} />;
40
41            default:
42              console.log('unsupported operation type ' + op.__typename);
43              return null;
44          }
45        })}
46      </div>
47    );
48  }
49}
50
51export default withStyles(styles)(Timeline);