Fix for switching active queries using file explorer (#17024)

* debug messages to figure out what is calling this

* added existing connection handling.

* added timeout for isConnected

* restored connectionStatusManager

* added timeout for updating the connection state

* added existing profile check in queryInputFactory

* moved existing profile check to outer

* added to nonSync

* added mock getConnectionProfile

* added push instead of assign

* added additional tests

* removed getConnectionProfile

* added test message for getConnectionProfile

* fixed tests, need to add more

* added working tests

* moved connect to helper method

* rearranged test order and added sync

* changed wording

* small capitalization change
This commit is contained in:
Alex Ma
2021-09-10 10:23:35 -07:00
committed by GitHub
parent 6ceb489a7d
commit 175464107c
2 changed files with 205 additions and 38 deletions

View File

@@ -56,18 +56,8 @@ export class QueryEditorLanguageAssociation implements ILanguageAssociation {
open: false, initalContent: content
}) as UntitledQueryEditorInput;
}
const profile = getCurrentGlobalConnection(this.objectExplorerService, this.connectionManagementService, this.editorService);
if (profile) {
const options: IConnectionCompletionOptions = {
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: undefined, input: queryEditorInput },
saveTheConnection: false,
showDashboard: false,
showConnectionDialogOnError: true,
showFirewallRuleOnError: true
};
this.connectionManagementService.connect(profile, queryEditorInput.uri, options).catch(err => onUnexpectedError(err));
}
this.connectInput(queryEditorInput);
return queryEditorInput;
}
@@ -82,21 +72,28 @@ export class QueryEditorLanguageAssociation implements ILanguageAssociation {
return undefined;
}
const profile = getCurrentGlobalConnection(this.objectExplorerService, this.connectionManagementService, this.editorService);
if (profile) {
const options: IConnectionCompletionOptions = {
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: undefined, input: queryEditorInput },
saveTheConnection: false,
showDashboard: false,
showConnectionDialogOnError: true,
showFirewallRuleOnError: true
};
this.connectionManagementService.connect(profile, queryEditorInput.uri, options).catch(err => onUnexpectedError(err));
}
this.connectInput(queryEditorInput);
return queryEditorInput;
}
private connectInput(queryEditorInput: QueryEditorInput): void {
const existingProfile = this.connectionManagementService.getConnectionProfile(queryEditorInput.uri);
// Create new connection if only there is no existing connectionProfile with the uri.
if (!existingProfile) {
const profile = getCurrentGlobalConnection(this.objectExplorerService, this.connectionManagementService, this.editorService);
if (profile) {
const options: IConnectionCompletionOptions = {
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: undefined, input: queryEditorInput },
saveTheConnection: false,
showDashboard: false,
showConnectionDialogOnError: true,
showFirewallRuleOnError: true
};
this.connectionManagementService.connect(profile, queryEditorInput.uri, options).catch(err => onUnexpectedError(err));
}
}
}
createBase(activeEditor: QueryEditorInput): IEditorInput {
return activeEditor.text;
}