@@ -7,7 +7,11 @@ import { store } from './data/store'
77import { closeApplication } from './windows'
88import { selectEditOnNewTab } from 'shared/data/slices/settings'
99import { selectDownloadPath } from 'shared/data/slices/settings'
10- import { areAllJobsInBatchDone , getCompletedCountInBatch } from 'shared/utils'
10+ import {
11+ areAllJobsInBatchDone ,
12+ getCompletedCountInBatch ,
13+ getIdleCountInBatch ,
14+ } from 'shared/utils'
1115
1216export function buildMenuTemplate ( {
1317 appName,
@@ -23,6 +27,7 @@ export function buildMenuTemplate({
2327 onRemoveJob,
2428 onEditJob,
2529 onShowAbout,
30+ onCancelBatchJob,
2631} ) {
2732 let pipelineStatus = PipelineStatus . UNKNOWN
2833 const instance = getPipelineInstance ( store . getState ( ) )
@@ -58,7 +63,7 @@ export function buildMenuTemplate({
5863 canDelete =
5964 pipelineStatus == PipelineStatus . RUNNING &&
6065 currentJob &&
61- currentJob . state == JobState . SUBMITTED &&
66+ ( currentJob . state == JobState . SUBMITTED || currentJob . state == JobState . ENDED ) &&
6267 currentJob . jobData &&
6368 currentJob . jobData . status != JobStatus . RUNNING &&
6469 currentJob . jobData . status != JobStatus . IDLE
@@ -78,7 +83,10 @@ export function buildMenuTemplate({
7883 if ( currentJob ?. isPrimaryForBatch ) {
7984 canCloseJob = areAllJobsInBatchDone ( currentJob , jobsInBatch )
8085 } else {
81- canCloseJob = currentJob && currentJob . state == JobState . SUBMITTED
86+ canCloseJob =
87+ currentJob &&
88+ ( currentJob . state == JobState . SUBMITTED ||
89+ currentJob . state == JobState . ENDED )
8290 }
8391
8492 let canCreateJob = pipelineStatus == PipelineStatus . RUNNING
@@ -187,11 +195,28 @@ export function buildMenuTemplate({
187195 ]
188196 : [
189197 {
190- label : 'Cancel job' ,
198+ label : currentJob ?. jobRequest ?. batchId
199+ ? 'Cancel scheduled jobs'
200+ : 'Cancel job' ,
191201 click : ( ) => {
192- onRemoveJob ( currentJob )
202+ if ( currentJob ?. jobRequest ?. batchId ) {
203+ if (
204+ getIdleCountInBatch (
205+ currentJob ,
206+ jobsInBatch
207+ ) > 0
208+ ) {
209+ onCancelBatchJob ( jobsInBatch )
210+ }
211+ } else {
212+ onRemoveJob ( currentJob )
213+ }
193214 } ,
194215 accelerator : 'CommandOrControl+D' ,
216+ enabled :
217+ ! currentJob ?. jobRequest ?. batchId ||
218+ getIdleCountInBatch ( currentJob , jobsInBatch ) >
219+ 0 ,
195220 } ,
196221 ] ) ,
197222 { type : 'separator' } ,
@@ -232,7 +257,7 @@ export function buildMenuTemplate({
232257 onEditJob ( currentJob )
233258 } ,
234259 accelerator : 'CommandOrControl+E' ,
235- enabled : canDelete ,
260+ enabled : canDelete && ! currentJob ?. jobRequest ?. batchId ,
236261 } ,
237262 { type : 'separator' } ,
238263 { role : 'copy' } ,
0 commit comments