@@ -3,21 +3,20 @@ import * as vscode from 'vscode';
33
44import { Issue , Transition } from '../api' ;
55import { Command } from '../command' ;
6- import state , { ActiveIssue } from '../state' ;
6+ import { checkEnabled } from '../extension' ;
7+ import state , { ActiveIssue , getActiveIssue } from '../state' ;
78
89export class TransitionIssueCommand implements Command {
910
1011 public id = 'vscode-jira.transitionIssues' ;
1112
1213 @bind
1314 public async run ( withDeactivation = true ) : Promise < void > {
14- if ( ! state . jira ) {
15- vscode . window . showInformationMessage (
16- 'No JIRA client configured. Setup baseUrl, projectNames, username and password' ) ;
15+ if ( ! checkEnabled ( ) ) {
1716 return ;
1817 }
19- const activeIssue = this . getActiveIssue ( ) ;
20- if ( activeIssue && activeIssue . key ) {
18+ const activeIssue = getActiveIssue ( ) ;
19+ if ( activeIssue ) {
2120 const selected = await this . selectTransition ( withDeactivation , activeIssue ) ;
2221 if ( selected === null ) {
2322 await vscode . commands . executeCommand ( 'vscode-jira.activateIssues' , null ) ;
@@ -35,9 +34,6 @@ export class TransitionIssueCommand implements Command {
3534
3635 private async selectTransition ( withActivation : boolean , activeIssue : ActiveIssue ) :
3736 Promise < Transition | null | undefined > {
38- if ( ! state . jira || ! activeIssue . key ) {
39- return ;
40- }
4137 const transitions = await state . jira . getTransitions ( activeIssue . key ) ;
4238 const picks = transitions . transitions . map ( transition => ( {
4339 label : transition . to . name || transition . name ,
@@ -64,16 +60,7 @@ export class TransitionIssueCommand implements Command {
6460 return `Deactivate ${ activeIssue . key } ` ;
6561 }
6662
67- private getActiveIssue ( ) : ActiveIssue | undefined {
68- if ( state . workspaceState ) {
69- return state . workspaceState . get ( 'vscode-jira:active-issue' ) ;
70- }
71- }
72-
7363 private async deactivateWhenDone ( activeIssue : ActiveIssue ) : Promise < void > {
74- if ( ! state . jira || ! activeIssue . key ) {
75- return ;
76- }
7764 const result = await state . jira . search ( { jql : `issue = "${ activeIssue . key } " AND resolution = Resolved` } ) ;
7865 if ( result . issues . length > 0 ) {
7966 vscode . commands . executeCommand ( 'vscode-jira.activateIssues' , null ) ;
0 commit comments