Stop OE connection spinner when user closes connection dialog (#2777)

This commit is contained in:
Matt Irvine
2018-10-05 14:14:19 -07:00
committed by GitHub
parent 48b899b5d0
commit 8a8745701b
8 changed files with 27 additions and 7 deletions

View File

@@ -67,6 +67,7 @@ export interface IConnectionCallbacks {
onConnectReject(error?: string): void; onConnectReject(error?: string): void;
onConnectSuccess(params?: INewConnectionParams): void; onConnectSuccess(params?: INewConnectionParams): void;
onDisconnect(): void; onDisconnect(): void;
onConnectCanceled(): void;
} }
export const SERVICE_ID = 'connectionManagementService'; export const SERVICE_ID = 'connectionManagementService';
@@ -336,6 +337,7 @@ export interface IConnectableInput {
onConnectReject(error?: string): void; onConnectReject(error?: string): void;
onConnectSuccess(params?: INewConnectionParams): void; onConnectSuccess(params?: INewConnectionParams): void;
onDisconnect(): void; onDisconnect(): void;
onConnectCanceled(): void;
} }
export enum ConnectionType { export enum ConnectionType {

View File

@@ -366,6 +366,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
onConnectStart: callbacks ? callbacks.onConnectStart : undefined, onConnectStart: callbacks ? callbacks.onConnectStart : undefined,
onConnectSuccess: callbacks ? callbacks.onConnectSuccess : undefined, onConnectSuccess: callbacks ? callbacks.onConnectSuccess : undefined,
onDisconnect: callbacks ? callbacks.onDisconnect : undefined, onDisconnect: callbacks ? callbacks.onDisconnect : undefined,
onConnectCanceled: callbacks ? callbacks.onConnectCanceled : undefined,
uri: uri uri: uri
}; };
} }
@@ -438,7 +439,8 @@ export class ConnectionManagementService extends Disposable implements IConnecti
onConnectReject: () => { }, onConnectReject: () => { },
onConnectStart: () => { }, onConnectStart: () => { },
onConnectSuccess: () => { }, onConnectSuccess: () => { },
onDisconnect: () => { } onDisconnect: () => { },
onConnectCanceled: () => { }
}; };
} }
if (!options) { if (!options) {

View File

@@ -153,6 +153,9 @@ export class ConnectionDialogService implements IConnectionDialogService {
} else { } else {
this._connectionManagementService.cancelConnection(this._model); this._connectionManagementService.cancelConnection(this._model);
} }
if (params && params.input && params.input.onConnectCanceled) {
params.input.onConnectCanceled();
}
this._connectionDialog.resetConnection(); this._connectionDialog.resetConnection();
this._connecting = false; this._connecting = false;
} }

View File

@@ -175,6 +175,9 @@ export class EditDataInput extends EditorInput implements IConnectableInput {
} }
} }
public onConnectCanceled(): void {
}
public onConnectSuccess(params?: INewConnectionParams): void { public onConnectSuccess(params?: INewConnectionParams): void {
let rowLimit: number = undefined; let rowLimit: number = undefined;
let queryString: string = undefined; let queryString: string = undefined;

View File

@@ -130,14 +130,16 @@ export class TreeUpdateUtils {
if (tree) { if (tree) {
// Show the spinner in OE by adding the 'loading' trait to the connection, and set up callbacks to hide the spinner // Show the spinner in OE by adding the 'loading' trait to the connection, and set up callbacks to hide the spinner
tree.addTraits('loading', [connection]); tree.addTraits('loading', [connection]);
callbacks = { let rejectOrCancelCallback = () => {
onConnectStart: undefined,
onConnectReject: () => {
tree.collapse(connection); tree.collapse(connection);
tree.removeTraits('loading', [connection]); tree.removeTraits('loading', [connection]);
}, };
callbacks = {
onConnectStart: undefined,
onConnectReject: rejectOrCancelCallback,
onConnectSuccess: () => tree.removeTraits('loading', [connection]), onConnectSuccess: () => tree.removeTraits('loading', [connection]),
onDisconnect: undefined onDisconnect: undefined,
onConnectCanceled: rejectOrCancelCallback,
}; };
} }
connectionManagementService.connect(connection, undefined, options, callbacks).then(result => { connectionManagementService.connect(connection, undefined, options, callbacks).then(result => {

View File

@@ -225,6 +225,9 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
this._updateTaskbar.fire(); this._updateTaskbar.fire();
} }
public onConnectCanceled(): void {
}
public onConnectSuccess(params?: INewConnectionParams): void { public onConnectSuccess(params?: INewConnectionParams): void {
this._runQueryEnabled = true; this._runQueryEnabled = true;
this._connectEnabled = false; this._connectEnabled = false;

View File

@@ -56,7 +56,8 @@ suite('ConnectionDialogService tests', () => {
onConnectStart: undefined, onConnectStart: undefined,
onConnectSuccess: undefined, onConnectSuccess: undefined,
onConnectReject: undefined, onConnectReject: undefined,
onDisconnect: undefined onDisconnect: undefined,
onConnectCanceled: undefined
}, },
runQueryOnCompletion: undefined, runQueryOnCompletion: undefined,
querySelection: undefined querySelection: undefined

View File

@@ -259,6 +259,7 @@ suite('SQL ConnectionManagementService tests', () => {
onConnectStart: undefined, onConnectStart: undefined,
onDisconnect: undefined, onDisconnect: undefined,
onConnectSuccess: undefined, onConnectSuccess: undefined,
onConnectCanceled: undefined,
uri: 'Editor Uri' uri: 'Editor Uri'
}, },
runQueryOnCompletion: RunQueryOnConnectionMode.executeQuery runQueryOnCompletion: RunQueryOnConnectionMode.executeQuery
@@ -279,6 +280,7 @@ suite('SQL ConnectionManagementService tests', () => {
onConnectStart: undefined, onConnectStart: undefined,
onDisconnect: undefined, onDisconnect: undefined,
onConnectSuccess: undefined, onConnectSuccess: undefined,
onConnectCanceled: undefined,
uri: 'Editor Uri' uri: 'Editor Uri'
}, },
runQueryOnCompletion: RunQueryOnConnectionMode.executeQuery runQueryOnCompletion: RunQueryOnConnectionMode.executeQuery
@@ -348,6 +350,7 @@ suite('SQL ConnectionManagementService tests', () => {
onConnectReject: undefined, onConnectReject: undefined,
onConnectStart: undefined, onConnectStart: undefined,
onDisconnect: undefined, onDisconnect: undefined,
onConnectCanceled: undefined,
uri: uri uri: uri
}, },
querySelection: undefined, querySelection: undefined,
@@ -661,6 +664,7 @@ suite('SQL ConnectionManagementService tests', () => {
onConnectReject: undefined, onConnectReject: undefined,
onConnectStart: undefined, onConnectStart: undefined,
onDisconnect: undefined, onDisconnect: undefined,
onConnectCanceled: undefined,
uri: uri uri: uri
}, },
querySelection: undefined, querySelection: undefined,