Skip to content

Commit

Permalink
feat(promote): adding Promote Jobs button
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Apr 11, 2021
1 parent 3c5d0cb commit c0e0d59
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ package-lock.json
.idea
*.tern-port
*.sublime-workspace
dump.rdb
4 changes: 3 additions & 1 deletion public/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ $(document).ready(() => {
method: action === 'remove' ? 'POST' : 'PATCH',
url: `${basePath}/api/queue/${encodeURIComponent(
queueHost
)}/${encodeURIComponent(queueName)}/job/bulk`,
)}/${encodeURIComponent(queueName)}/${
action === 'promote' ? 'delayed/' : ''
}job/bulk`,
data: JSON.stringify(data),
contentType: 'application/json',
})
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/api/bulkAction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const _ = require('lodash');

const ACTIONS = ['remove', 'retry'];
const ACTIONS = ['remove', 'retry', 'promote'];

function bulkAction(action) {
return async function handler(req, res) {
Expand Down
3 changes: 3 additions & 0 deletions src/server/views/api/bulkJobsPromote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const bulkAction = require('./bulkAction');

module.exports = bulkAction('promote');
2 changes: 2 additions & 0 deletions src/server/views/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ const jobAdd = require('./jobAdd');
const jobPromote = require('./jobPromote');
const jobRetry = require('./jobRetry');
const jobRemove = require('./jobRemove');
const bulkJobsPromote = require('./bulkJobsPromote');
const bulkJobsRemove = require('./bulkJobsRemove');
const bulkJobsRetry = require('./bulkJobsRetry');

router.post('/queue/:queueHost/:queueName/job', jobAdd);
router.post('/queue/:queueHost/:queueName/job/bulk', bulkJobsRemove);
router.patch('/queue/:queueHost/:queueName/job/bulk', bulkJobsRetry);
router.patch('/queue/:queueHost/:queueName/delayed/job/bulk', bulkJobsPromote);
router.patch('/queue/:queueHost/:queueName/delayed/job/:id', jobPromote);
router.patch('/queue/:queueHost/:queueName/job/:id', jobRetry);
router.delete('/queue/:queueHost/:queueName/job/:id', jobRemove);
Expand Down
2 changes: 2 additions & 0 deletions src/server/views/dashboard/queueJobsByState.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ async function _html(req, res) {
pages.push(_.last(pages) + 1);
}
pages = pages.filter((page) => page <= _.ceil(jobCounts[state] / pageSize));
const disablePromote = !(state === 'delayed' && !queue.IS_BEE);
const disableRetry = !(
state === 'failed' ||
(state === 'delayed' && !queue.IS_BEE)
Expand All @@ -136,6 +137,7 @@ async function _html(req, res) {
disablePagination:
queue.IS_BEE && (state === 'succeeded' || state === 'failed'),
disableOrdering: queue.IS_BEE,
disablePromote,
disableRetry,
currentPage: page,
pages,
Expand Down
6 changes: 6 additions & 0 deletions src/server/views/dashboard/templates/queueJobsByState.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
Retry Jobs
</button>
{{/unless}}
{{#unless disablePromote}}
<button type="button" data-action="promote" data-queue-name="{{ queueName }}" data-queue-host="{{ queueHost }}"
data-queue-state="{{ state }}" class="js-bulk-action btn btn-success">
Promote Jobs
</button>
{{/unless}}

<div class="btn-group">
<div class="btn-group">
Expand Down

0 comments on commit c0e0d59

Please sign in to comment.