* Connect method that calls parent connect method and handles
* connection errors unique to this route
* @param {TargetModel} target
* @param {HostModel} host
*/
@action
asyncconnect(target,host){
try{
awaitthis.targets.connect(target,host);
}catch(error){
this.isConnectionError=true;
this.confirm
.confirm(error.message,{isConnectError:true})
// Retry
.then(()=>this.connect(target,host))
.catch(()=>{
// Reset the flag as this was user initiated and we're not
// in a transition or have a host modal open
this.isConnectionError=false;
});
}
}
/**
* Establish a session to current target.
* @param {TargetModel} target
* @param {HostModel} host
* hostConnect is only called when making a connection with a host and ensures that the host modal is automatically closed in the case of a connection error.
*/
@action
asynchostConnect(target,host){
awaitthis.connect(target,host);
if(this.isConnectionError){
this.toggleModal(false);
this.isConnectionError=false;
}
}
/**
* Determine if we show host modal or quick connect based on target attributes.
* @param {TargetModel} model
* @param {function} toggleModal
*/
@action
asyncpreConnect(model){
/**
* if hosts length is 1 or less we will try to
* connect, even if there is no address on the target and
* rely on the CLI to give the user the proper error or if
* there are 2 or more hosts we show the modal for host selection