mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -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';
|
'use strict';
|
||||||
|
|
||||||
import * as vscode from 'vscode';
|
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { IEndPoint, IControllerError, getEndPoints } from '../controller/clusterControllerApi';
|
import { IEndPoint, IControllerError, getEndPoints } from '../controller/clusterControllerApi';
|
||||||
@@ -16,6 +15,9 @@ import { showErrorMessage } from '../utils';
|
|||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
export class AddControllerDialogModel {
|
export class AddControllerDialogModel {
|
||||||
|
|
||||||
|
private _canceled = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public treeDataProvider: ControllerTreeDataProvider,
|
public treeDataProvider: ControllerTreeDataProvider,
|
||||||
public node?: TreeNode,
|
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> {
|
public async onComplete(clusterName: string, url: string, username: string, password: string, rememberPassword: boolean): Promise<void> {
|
||||||
let response = await getEndPoints(clusterName, url, username, password, true);
|
try {
|
||||||
if (response && response.endPoints) {
|
// We pre-fetch the endpoints here to verify that the information entered is correct (the user is able to connect)
|
||||||
let masterInstance: IEndPoint = undefined;
|
let response = await getEndPoints(clusterName, url, username, password, true);
|
||||||
if (response.endPoints) {
|
if (response && response.endPoints) {
|
||||||
masterInstance = response.endPoints.find(e => e.name && e.name === 'sql-server-master');
|
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> {
|
public async onError(error: IControllerError): Promise<void> {
|
||||||
@@ -49,6 +63,7 @@ export class AddControllerDialogModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async onCancel(): Promise<void> {
|
public async onCancel(): Promise<void> {
|
||||||
|
this._canceled = true;
|
||||||
if (this.node) {
|
if (this.node) {
|
||||||
this.node.refresh();
|
this.node.refresh();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user