@@ -4,10 +4,19 @@ import { withStyles } from 'material-ui/styles';
4
4
5
5
import { ListItem , ListItemText } from 'material-ui/List'
6
6
7
+ import CheckCircle from 'material-ui-icons/CheckCircle'
8
+ import Restore from 'material-ui-icons/Restore'
9
+ import HighlightOff from 'material-ui-icons/HighlightOff'
10
+
7
11
import styles from './styles'
8
12
9
- const LastJobItem = ( { key, job, classes, onClick, children } ) => (
13
+ const SUCCESS = 'SUCCESS'
14
+ const FAILURE = 'FAILURE'
15
+ const PENDING = 'PENDING'
16
+
17
+ const LastJobItem = ( { key, job, classes, jobStatusIcon, onClick, children} ) => (
10
18
< ListItem key = { key } button divider >
19
+ { jobStatusIcon ( job ) }
11
20
< ListItemText
12
21
primary = { `${ job . repoSlug } : ${ job . branchName } # ${ job . commitSha . slice ( 0 , 6 ) } ` }
13
22
onClick = { onClick }
@@ -20,7 +29,47 @@ export default compose(
20
29
withHandlers ( {
21
30
onClick : ( { job, onClick } ) => ( e ) => (
22
31
onClick ( e , job )
23
- )
32
+ ) ,
33
+ jobStatusIcon : ( ) => ( job ) => (
34
+ iconFromStatusCode ( job . exitStatus )
35
+ ) ,
24
36
} ) ,
25
37
withStyles ( styles )
26
38
) ( LastJobItem ) ;
39
+
40
+ function jobHumanStatus ( status ) {
41
+ let humanStatus ;
42
+ switch ( status ) {
43
+ case 0 :
44
+ humanStatus = SUCCESS
45
+ break
46
+
47
+ case null :
48
+ humanStatus = PENDING
49
+ break
50
+
51
+ default :
52
+ humanStatus = FAILURE
53
+ }
54
+ return humanStatus
55
+ }
56
+
57
+ function iconFromStatusCode ( statusCode ) {
58
+ let status = jobHumanStatus ( statusCode )
59
+ let icon = null
60
+
61
+ switch ( status ) {
62
+ case SUCCESS :
63
+ icon = < CheckCircle color = "primary" />
64
+ break
65
+
66
+ case PENDING :
67
+ icon = < Restore color = "disabled" />
68
+ break
69
+
70
+ default :
71
+ icon = < HighlightOff color = "error" />
72
+ }
73
+
74
+ return icon
75
+ }
0 commit comments