@@ -97,13 +97,24 @@ export class Component extends OpenShiftItem {
9797 }
9898 }
9999
100+ static async getLinkPort ( component : OpenShiftObject , compName : string ) {
101+ const compData = await Component . odo . execute ( Command . describeComponentJson ( component . getParent ( ) . getParent ( ) . getName ( ) , component . getParent ( ) . getName ( ) , compName ) , component . contextPath ? component . contextPath . fsPath : Platform . getUserHomePath ( ) ) ;
102+ return JSON . parse ( compData . stdout ) ;
103+ }
104+
100105 static async unlinkAllComponents ( component : OpenShiftObject ) {
101106 const linkComponent = await Component . getLinkData ( component ) ;
102107 const getLinkComponent = linkComponent [ 'status' ] . linkedComponents ;
103108 if ( getLinkComponent ) {
104- Object . keys ( getLinkComponent ) . forEach ( async key => {
105- await Component . odo . execute ( Command . unlinkComponents ( component . getParent ( ) . getParent ( ) . getName ( ) , component . getParent ( ) . getName ( ) , key , component . getName ( ) ) , component . contextPath . fsPath ) ;
106- } ) ;
109+ for ( const key of Object . keys ( getLinkComponent ) ) {
110+ const getLinkPort = await Component . getLinkPort ( component , key ) ;
111+ const getPort = getLinkPort [ 'status' ] . linkedComponents [ component . getName ( ) ] ;
112+ if ( getPort ) {
113+ for ( const port of getPort ) {
114+ await Component . odo . execute ( Command . unlinkComponents ( component . getParent ( ) . getParent ( ) . getName ( ) , component . getParent ( ) . getName ( ) , key , component . getName ( ) , port ) , component . contextPath . fsPath ) ;
115+ }
116+ }
117+ }
107118 }
108119 }
109120
@@ -177,8 +188,11 @@ export class Component extends OpenShiftItem {
177188 } ) ;
178189 const compName = await window . showQuickPick ( linkCompName , { placeHolder : "Select a Component to unlink" , ignoreFocusOut : true } ) ;
179190 if ( ! compName ) return null ;
191+ const getLinkPort = linkComponent [ 'status' ] . linkedComponents [ compName ] ;
192+ const port = await window . showQuickPick ( getLinkPort , { placeHolder : "Select a Port" } ) ;
193+ if ( ! port ) return null ;
180194 return Progress . execFunctionWithProgress ( `Unlinking Component` ,
181- ( ) => Component . odo . execute ( Command . unlinkComponents ( component . getParent ( ) . getParent ( ) . getName ( ) , component . getParent ( ) . getName ( ) , component . getName ( ) , compName ) , component . contextPath . fsPath )
195+ ( ) => Component . odo . execute ( Command . unlinkComponents ( component . getParent ( ) . getParent ( ) . getName ( ) , component . getParent ( ) . getName ( ) , component . getName ( ) , compName , port ) , component . contextPath . fsPath )
182196 . then ( ( ) => `Component '${ compName } ' has been successfully unlinked from the Component '${ component . getName ( ) } '` )
183197 . catch ( ( err ) => Promise . reject ( `Failed to unlink Component with error '${ err } '` ) )
184198 ) ;
0 commit comments