Skip to content

Commit 426992b

Browse files
committed
feat(JobMonitor): add clear completed button
1 parent acee5b1 commit 426992b

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

lib/common/components/JobMonitor.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Icon from '@conveyal/woonerf/components/icon'
22
import Pure from '@conveyal/woonerf/components/pure'
33
import React, {PropTypes} from 'react'
44
import {ProgressBar, Button} from 'react-bootstrap'
5-
import truncate from 'truncate'
65

76
import SidebarPopover from './SidebarPopover'
87

@@ -24,6 +23,11 @@ export default class JobMonitor extends Pure {
2423
// this.popover._onResize()
2524
// }
2625
}
26+
27+
removeAll = () => {
28+
this.props.jobMonitor.retired.forEach(job => this.props.removeRetiredJob(job))
29+
}
30+
2731
render () {
2832
const jobContainerStyle = {
2933
marginBottom: 20
@@ -35,25 +39,23 @@ export default class JobMonitor extends Pure {
3539
fontSize: '12px',
3640
color: 'darkGray'
3741
}
38-
const {
39-
jobMonitor,
40-
removeRetiredJob
41-
} = this.props
42+
const {jobMonitor, removeRetiredJob} = this.props
43+
const {jobs, retired} = jobMonitor
4244
return (
4345
<SidebarPopover
4446
ref={(SidebarPopover) => { this.popover = SidebarPopover }}
4547
title='Server Jobs'
4648
{...this.props}>
47-
{jobMonitor.retired.map(job => (
49+
{retired.map(job => (
4850
<RetiredJob
4951
key={`retired-${job.jobId}`}
5052
job={job}
5153
removeRetiredJob={removeRetiredJob}
5254
statusStyle={statusMessageStyle}
5355
style={jobContainerStyle} />
5456
))}
55-
{jobMonitor.jobs.length
56-
? jobMonitor.jobs.map(job => (
57+
{jobs.length
58+
? jobs.map(job => (
5759
<div key={job.jobId} style={jobContainerStyle}>
5860
<div style={{ float: 'left' }}>
5961
<Icon type='spinner' className='fa-pulse' />
@@ -67,7 +69,15 @@ export default class JobMonitor extends Pure {
6769
</div>
6870
</div>
6971
))
70-
: <p>No active jobs.</p>
72+
: <p className='lead text-center'>No active jobs.</p>
73+
}
74+
{retired.length
75+
? <Button
76+
block
77+
onClick={this.removeAll}>
78+
<Icon type='times-circle' /> Clear completed
79+
</Button>
80+
: null
7181
}
7282
</SidebarPopover>
7383
)
@@ -98,7 +108,12 @@ class RetiredJob extends Pure {
98108
}
99109
</div>
100110
<div style={{ marginLeft: 25 }}>
101-
<div>
111+
<div style={{
112+
overflow: 'hidden',
113+
textOverflow: 'ellipsis',
114+
width: '220px',
115+
whiteSpace: 'nowrap'
116+
}}>
102117
<Button
103118
bsStyle='link'
104119
className='pull-right'
@@ -107,7 +122,7 @@ class RetiredJob extends Pure {
107122
</Button>
108123
<strong
109124
title={job.name}>
110-
{truncate(job.name, 25)}
125+
{job.name}
111126
</strong>
112127
</div>
113128
<div

0 commit comments

Comments
 (0)