Skip to content

Commit 1977dc7

Browse files
tallysmartinsPragTob
authored andcommitted
Adds job status icon to repos page (#10)
* Adds job status icon to repos page Signed-off-by: Tallys Martins <[email protected]> * Apply review changes Signed-off-by: Tallys Martins <[email protected]>
1 parent 5055b42 commit 1977dc7

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

src/containers/blocks/JobsList/JobListItem/index.js

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ import { withStyles } from 'material-ui/styles';
44

55
import { ListItem, ListItemText } from 'material-ui/List'
66

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+
711
import styles from './styles'
812

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}) => (
1018
<ListItem key={ key } button divider>
19+
{ jobStatusIcon(job) }
1120
<ListItemText
1221
primary={ `${job.repoSlug} : ${job.branchName} # ${job.commitSha.slice(0, 6)}` }
1322
onClick={ onClick }
@@ -20,7 +29,47 @@ export default compose(
2029
withHandlers({
2130
onClick: ({ job, onClick }) => (e) => (
2231
onClick(e, job)
23-
)
32+
),
33+
jobStatusIcon: () => (job) => (
34+
iconFromStatusCode(job.exitStatus)
35+
),
2436
}),
2537
withStyles(styles)
2638
)(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+
}

src/containers/pages/ReposListPage/index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ import styles from './styles'
1818

1919
const ReposListPage = ({ classes, data, children, onSubmit }) => (
2020
<Page>
21-
<Typography variant="display2" align="center">
22-
What is ElixirBench?
23-
</Typography>
24-
<Typography variant="headline" align="center">
25-
Long Running Benchmarks for Elixir Projects
26-
</Typography>
2721
<div className={ classes.repos }>
2822
<Grid container spacing={ 24 }>
2923
<Grid item xs={ 12 } sm={ 12 } md={ 4 }>

src/graphql/queries/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const getJobs = gql`
8686
commitSha
8787
completedAt
8888
claimedAt
89+
exitStatus
8990
}
9091
}
9192
`

0 commit comments

Comments
 (0)