@@ -54,6 +54,14 @@ export class SourceTypeChoice {
5454 }
5555} ;
5656
57+ function createCancelledResult ( stepName : string ) : any {
58+ const cancelledResult :any = new String ( '' ) ;
59+ cancelledResult . properties = {
60+ 'cancelled_step' : stepName
61+ }
62+ return cancelledResult ;
63+ }
64+
5765export class Component extends OpenShiftItem {
5866 private static extensionContext : ExtensionContext ;
5967 private static debugSessions = new Map < string , DebugSession > ( ) ;
@@ -573,9 +581,9 @@ export class Component extends OpenShiftItem {
573581 'Select an Application where you want to create a Component'
574582 )
575583 static async createFromLocal ( application : OpenShiftApplication , selection ?: OpenShiftObject [ ] , componentTypeName ?:string , version ?:string , starterProjectName ?:string ) : Promise < string | null > {
576- if ( ! application ) return null ;
584+ if ( ! application ) return createCancelledResult ( 'applicationName' ) ;
577585 const workspacePath = await selectWorkspaceFolder ( ) ;
578- if ( ! workspacePath ) return null ;
586+ if ( ! workspacePath ) return createCancelledResult ( 'contextFolder' ) ;
579587
580588 return Component . createFromRootWorkspaceFolder ( workspacePath , [ ] , application , componentTypeName , version ? ComponentKind . S2I : ComponentKind . DEVFILE , version , starterProjectName ) ;
581589 }
@@ -590,15 +598,17 @@ export class Component extends OpenShiftItem {
590598 */
591599
592600 @clusterRequired ( ) // request to login to cluster and then execute command
593- static async deployRootWorkspaceFolder ( folder : Uri , componentTypeName : string ) : Promise < void > {
601+ static async deployRootWorkspaceFolder ( folder : Uri , componentTypeName : string ) : Promise < string > {
602+ let result :any ;
594603 let component = Component . odo . getOpenShiftObjectByContext ( folder . fsPath ) ;
595604 if ( ! component ) {
596- await Component . createFromRootWorkspaceFolder ( folder , undefined , undefined , componentTypeName , ComponentKind . DEVFILE , undefined , undefined , false ) ;
605+ result = await Component . createFromRootWorkspaceFolder ( folder , undefined , undefined , componentTypeName , ComponentKind . DEVFILE , undefined , undefined , false ) ;
597606 component = Component . odo . getOpenShiftObjectByContext ( folder . fsPath ) ;
598607 }
599608 if ( component ) {
600609 await Component . push ( component ) ;
601610 }
611+ return result ;
602612 }
603613
604614 /**
@@ -615,12 +625,11 @@ export class Component extends OpenShiftItem {
615625
616626 @vsCommand ( 'openshift.component.createFromRootWorkspaceFolder' )
617627 static async createFromRootWorkspaceFolder ( folder : Uri , selection : Uri [ ] , context : OpenShiftApplication , componentTypeName ?: string , componentKind = ComponentKind . DEVFILE , version ?: string , starterProjectName ?: string , notification = true ) : Promise < string | null > {
618-
619628 const application = await Component . getOpenShiftCmdData ( context ,
620629 'Select an Application where you want to create a Component'
621630 ) ;
622631
623- if ( ! application ) return null ;
632+ if ( ! application ) return createCancelledResult ( 'application' ) ;
624633
625634 let useExistingDevfile = false ;
626635 const devFileLocation = path . join ( folder . fsPath , 'devfile.yaml' ) ;
@@ -646,7 +655,7 @@ export class Component extends OpenShiftItem {
646655 initialNameValue
647656 ) ;
648657
649- if ( ! componentName ) return null ;
658+ if ( ! componentName ) return createCancelledResult ( 'componentName' ) ;
650659
651660 const progressIndicator = window . createQuickPick ( ) ;
652661
@@ -672,7 +681,7 @@ export class Component extends OpenShiftItem {
672681 componentType = await window . showQuickPick ( componentTypes . sort ( ascDevfileFirst ) , { placeHolder : 'Select Component type' , ignoreFocusOut : true } ) ;
673682 }
674683
675- if ( ! componentType ) return null ;
684+ if ( ! componentType ) return createCancelledResult ( 'componentType' ) ;
676685
677686 if ( componentType . kind === ComponentKind . DEVFILE ) {
678687 progressIndicator . placeholder = 'Checking if provided context folder is empty'
@@ -702,11 +711,11 @@ export class Component extends OpenShiftItem {
702711 starterProjects . map ( prj => ( { label : prj . name , description : prj . description } ) ) ,
703712 { placeHolder : 'Select Starter Project to initialize Component' }
704713 ) ;
705- if ( ! selectedStarter ) return null ;
714+ if ( ! selectedStarter ) return createCancelledResult ( 'selectStarterProject' ) ;
706715 createStarter = selectedStarter . label ;
707716 }
708717 } else if ( ! create ) {
709- return null ;
718+ return createCancelledResult ( 'useStaterProjectRequest' ) ; ;
710719 }
711720 }
712721 }
0 commit comments