mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 17:23:42 -05:00
Add support for cancelling BDC Add Controller request (#6546)
* Add cancel support * Add comment
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { IEndPoint, IControllerError, getEndPoints } from '../controller/clusterControllerApi';
|
||||
@@ -16,6 +15,9 @@ import { showErrorMessage } from '../utils';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export class AddControllerDialogModel {
|
||||
|
||||
private _canceled = false;
|
||||
|
||||
constructor(
|
||||
public treeDataProvider: ControllerTreeDataProvider,
|
||||
public node?: TreeNode,
|
||||
@@ -33,15 +35,27 @@ export class AddControllerDialogModel {
|
||||
}
|
||||
|
||||
public async onComplete(clusterName: string, url: string, username: string, password: string, rememberPassword: boolean): Promise<void> {
|
||||
let response = await getEndPoints(clusterName, url, username, password, true);
|
||||
if (response && response.endPoints) {
|
||||
let masterInstance: IEndPoint = undefined;
|
||||
if (response.endPoints) {
|
||||
masterInstance = response.endPoints.find(e => e.name && e.name === 'sql-server-master');
|
||||
try {
|
||||
// We pre-fetch the endpoints here to verify that the information entered is correct (the user is able to connect)
|
||||
let response = await getEndPoints(clusterName, url, username, password, true);
|
||||
if (response && response.endPoints) {
|
||||
let masterInstance: IEndPoint = undefined;
|
||||
if (response.endPoints) {
|
||||
masterInstance = response.endPoints.find(e => e.name && e.name === 'sql-server-master');
|
||||
}
|
||||
if (this._canceled) {
|
||||
return;
|
||||
}
|
||||
this.treeDataProvider.addController(clusterName, url, username, password, rememberPassword, masterInstance);
|
||||
await this.treeDataProvider.saveControllers();
|
||||
}
|
||||
} catch (error) {
|
||||
// Ignore the error if we cancelled the request since we can't stop the actual request from completing
|
||||
if (!this._canceled) {
|
||||
throw error;
|
||||
}
|
||||
this.treeDataProvider.addController(clusterName, url, username, password, rememberPassword, masterInstance);
|
||||
await this.treeDataProvider.saveControllers();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async onError(error: IControllerError): Promise<void> {
|
||||
@@ -49,6 +63,7 @@ export class AddControllerDialogModel {
|
||||
}
|
||||
|
||||
public async onCancel(): Promise<void> {
|
||||
this._canceled = true;
|
||||
if (this.node) {
|
||||
this.node.refresh();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user