Skip to content

Commit

Permalink
Created Clean Jobs Button
Browse files Browse the repository at this point in the history
- Created button for UI
- Added route for logic
  • Loading branch information
Alex Ross authored and Alex Ross committed Sep 13, 2019
1 parent 12177e4 commit 6e2cfc6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
static/
yarn-error.log
yarn-error.log
*.rdb
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function UI() {
router.get('/queues', require('./routes/queues'))
router.put('/queues/:queueName/retry', require('./routes/retryAll'))
router.put('/queues/:queueName/:id/retry', require('./routes/retryJob'))
router.put('/queues/:queueName/clean', require('./routes/cleanAll'))
router.get('/', require('./routes/index'))

app.use(bodyParser.json())
Expand Down
Empty file added routes/cleanAll.js
Empty file.
2 changes: 2 additions & 0 deletions ui/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function App({ basePath }) {
setSelectedStatuses,
retryJob,
retryAll,
cleanAll,
} = useStore(basePath)

return (
Expand All @@ -30,6 +31,7 @@ export default function App({ basePath }) {
selectStatus={setSelectedStatuses}
retryJob={retryJob(queue.name)}
retryAll={retryAll(queue.name)}
cleanAll={cleanAll(queue.name)}
/>
))}
</>
Expand Down
5 changes: 5 additions & 0 deletions ui/components/Queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ const actions = {
failed: ({ retryAll }) => {
return <button onClick={retryAll}>Retry all</button>
},
delayed: ({ cleanAll }) => {
return <button onClick={cleanAll}>Clean all</button>
},
}

function QueueActions(props) {
Expand All @@ -269,6 +272,7 @@ function QueueActions(props) {
export default function Queue({
retryAll,
retryJob,
cleanAll,
queue,
selectStatus,
selectedStatus,
Expand All @@ -291,6 +295,7 @@ export default function Queue({
<>
<QueueActions
retryAll={retryAll}
cleanAll={cleanAll}
queue={queue}
status={selectedStatus}
/>
Expand Down
14 changes: 13 additions & 1 deletion ui/components/hooks/useStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,17 @@ export default function useStore(basePath) {
update,
)

return { state, retryJob, retryAll, selectedStatuses, setSelectedStatuses }
const cleanAll = queueName => () =>
fetch(`${basePath}/queues/${queueName}/clean`, { method: 'put' }).then(
update,
)

return {
state,
retryJob,
retryAll,
cleanAll,
selectedStatuses,
setSelectedStatuses,
}
}

0 comments on commit 6e2cfc6

Please sign in to comment.