@@ -313,7 +313,6 @@ export class EngagementRules {
313
313
314
314
async getAvailableTransitions (
315
315
engagementId : ID ,
316
- currentUserRoles ?: readonly Role [ ] ,
317
316
changeset ?: ID ,
318
317
) : Promise < EngagementStatusTransition [ ] > {
319
318
const session = this . identity . current ;
@@ -329,7 +328,7 @@ export class EngagementRules {
329
328
) ;
330
329
331
330
// If current user is not an approver (based on roles) then don't allow any transitions
332
- currentUserRoles ?? = session . roles ;
331
+ const currentUserRoles = session . roles ;
333
332
if ( intersection ( approvers , currentUserRoles ) . length === 0 ) {
334
333
return [ ] ;
335
334
}
@@ -355,9 +354,8 @@ export class EngagementRules {
355
354
return availableTransitionsAccordingToProject ;
356
355
}
357
356
358
- async canBypassWorkflow ( ) {
359
- const session = this . identity . current ;
360
- const roles = session . roles ;
357
+ canBypassWorkflow ( ) {
358
+ const { roles } = this . identity . current ;
361
359
return intersection ( rolesThatCanBypassWorkflow , roles ) . length > 0 ;
362
360
}
363
361
@@ -366,17 +364,12 @@ export class EngagementRules {
366
364
nextStatus : EngagementStatus ,
367
365
changeset ?: ID ,
368
366
) {
369
- // If current user's roles include a role that can bypass workflow
370
- // stop the check here.
371
- const session = this . identity . current ;
372
- const currentUserRoles = session . roles ;
373
- if ( intersection ( rolesThatCanBypassWorkflow , currentUserRoles ) . length > 0 ) {
367
+ if ( this . canBypassWorkflow ( ) ) {
374
368
return ;
375
369
}
376
370
377
371
const transitions = await this . getAvailableTransitions (
378
372
engagementId ,
379
- currentUserRoles ,
380
373
changeset ,
381
374
) ;
382
375
0 commit comments