@girder/jobs 3.2.15 → 3.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@girder/jobs",
3
- "version": "3.2.15",
3
+ "version": "3.2.16",
4
4
  "description": "A general purpose plugin for managing offline jobs.",
5
5
  "homepage": "http://girder.readthedocs.io/en/latest/plugins.html#jobs",
6
6
  "bugs": {
@@ -311,24 +311,22 @@ var JobListWidget = View.extend({
311
311
  },
312
312
 
313
313
  _cancelJobs: function () {
314
- _whenAll(
315
- Object.keys(this.jobCheckedStates)
316
- .filter((jobId) => {
317
- var jobModel = this.collection.find((job) => job.id === jobId);
318
- return JobStatus.isCancelable(jobModel);
319
- })
320
- .map((jobId) => restRequest({
321
- url: `job/${jobId}/cancel`,
322
- method: 'PUT',
323
- error: null
324
- }))
325
- ).done((results) => {
326
- if (!results.length) {
327
- return;
328
- }
314
+ const cancelableJobIds = Object.keys(this.jobCheckedStates).filter((jobId) => {
315
+ var jobModel = this.collection.find((job) => job.id === jobId);
316
+ return JobStatus.isCancelable(jobModel);
317
+ });
318
+ const numJobs = cancelableJobIds.length;
319
+ if (numJobs === 0) {
320
+ return;
321
+ }
322
+ _whenAll(cancelableJobIds.map((jobId) => restRequest({
323
+ url: `job/${jobId}/cancel`,
324
+ method: 'PUT',
325
+ error: null
326
+ }))).done(() => {
329
327
  events.trigger('g:alert', {
330
328
  icon: 'ok',
331
- text: `Cancel ${results.length === 1 ? 'request' : 'requests'} sent for ${results.length} ${results.length === 1 ? 'job' : 'jobs'}`,
329
+ text: `Cancel ${numJobs === 1 ? 'request' : 'requests'} sent for ${numJobs} ${numJobs === 1 ? 'job' : 'jobs'}`,
332
330
  type: 'info',
333
331
  timeout: 4000
334
332
  });