mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Fixes reset of group name when not saving profile (#24000)
This commit is contained in:
@@ -179,3 +179,7 @@ export function adjustForMssqlAppName(currentAppName: string, suffix?: string):
|
|||||||
? currentAppName + finalSuffix
|
? currentAppName + finalSuffix
|
||||||
: currentAppName ?? appName;
|
: currentAppName ?? appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function delay(time: number): Promise<void> {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, time));
|
||||||
|
}
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
|||||||
}
|
}
|
||||||
let options: IConnectionCompletionOptions = this._options || {
|
let options: IConnectionCompletionOptions = this._options || {
|
||||||
params: params,
|
params: params,
|
||||||
saveTheConnection: !isTemporaryConnection,
|
saveTheConnection: !isTemporaryConnection && !fromEditor,
|
||||||
showDashboard: params?.showDashboard ?? false,
|
showDashboard: params?.showDashboard ?? false,
|
||||||
showConnectionDialogOnError: false,
|
showConnectionDialogOnError: false,
|
||||||
showFirewallRuleOnError: true
|
showFirewallRuleOnError: true
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
|||||||
private _azureAccountList: azdata.Account[];
|
private _azureAccountList: azdata.Account[];
|
||||||
private _callbacks: IConnectionComponentCallbacks;
|
private _callbacks: IConnectionComponentCallbacks;
|
||||||
private _focusedBeforeHandleOnConnection: HTMLElement;
|
private _focusedBeforeHandleOnConnection: HTMLElement;
|
||||||
private _saveProfile: boolean;
|
|
||||||
private _databaseDropdownExpanded: boolean = false;
|
private _databaseDropdownExpanded: boolean = false;
|
||||||
private _defaultDatabaseName: string = localize('defaultDatabaseOption', "<Default>");
|
private _defaultDatabaseName: string = localize('defaultDatabaseOption', "<Default>");
|
||||||
private _loadingDatabaseName: string = localize('loadingDatabaseOption', "Loading...");
|
private _loadingDatabaseName: string = localize('loadingDatabaseOption', "Loading...");
|
||||||
@@ -893,20 +892,15 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
|||||||
this._connectionNameInputBox.value = this.getModelValue(connectionInfo.connectionName);
|
this._connectionNameInputBox.value = this.getModelValue(connectionInfo.connectionName);
|
||||||
this._userNameInputBox.value = this.getModelValue(connectionInfo.userName);
|
this._userNameInputBox.value = this.getModelValue(connectionInfo.userName);
|
||||||
this._passwordInputBox.value = this.getModelValue(connectionInfo.password);
|
this._passwordInputBox.value = this.getModelValue(connectionInfo.password);
|
||||||
this._saveProfile = connectionInfo.saveProfile;
|
|
||||||
this._azureTenantId = connectionInfo.azureTenantId;
|
this._azureTenantId = connectionInfo.azureTenantId;
|
||||||
if (this._databaseNameInputBox) {
|
if (this._databaseNameInputBox) {
|
||||||
this._databaseNameInputBox.value = this.getModelValue(connectionInfo.databaseName);
|
this._databaseNameInputBox.value = this.getModelValue(connectionInfo.databaseName);
|
||||||
}
|
}
|
||||||
let groupName: string;
|
let groupName: string;
|
||||||
if (this._saveProfile) {
|
if (!connectionInfo.groupFullName) {
|
||||||
if (!connectionInfo.groupFullName) {
|
groupName = this.DefaultServerGroup.name;
|
||||||
groupName = this.DefaultServerGroup.name;
|
|
||||||
} else {
|
|
||||||
groupName = connectionInfo.groupFullName.replace('root/', '');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
groupName = this.NoneServerGroup.name;
|
groupName = connectionInfo.groupFullName.replace('root/', '');
|
||||||
}
|
}
|
||||||
if (this._serverGroupSelectBox) {
|
if (this._serverGroupSelectBox) {
|
||||||
this._serverGroupSelectBox.selectWithOptionName(groupName);
|
this._serverGroupSelectBox.selectWithOptionName(groupName);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { ConnectionManagementService } from 'sql/workbench/services/connection/browser/connectionManagementService';
|
import { ConnectionManagementService } from 'sql/workbench/services/connection/browser/connectionManagementService';
|
||||||
import { ConnectionType, IConnectableInput, IConnectionResult, INewConnectionParams, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
import { ConnectionType, IConnectableInput, IConnectionResult, INewConnectionParams, IConnectionManagementService, IConnectionCallbacks } from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { TestErrorMessageService } from 'sql/platform/errorMessage/test/common/testErrorMessageService';
|
import { TestErrorMessageService } from 'sql/platform/errorMessage/test/common/testErrorMessageService';
|
||||||
|
|
||||||
import * as TypeMoq from 'typemoq';
|
import * as TypeMoq from 'typemoq';
|
||||||
@@ -54,6 +54,8 @@ import { ConnectionBrowserView } from 'sql/workbench/services/connection/browser
|
|||||||
import { ConnectionProviderProperties, ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ConnectionProviderProperties, ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
import { Emitter } from 'vs/base/common/event';
|
import { Emitter } from 'vs/base/common/event';
|
||||||
import { NullCommandService } from 'vs/platform/commands/test/common/nullCommandService';
|
import { NullCommandService } from 'vs/platform/commands/test/common/nullCommandService';
|
||||||
|
import { delay } from 'sql/platform/connection/common/utils';
|
||||||
|
import { IConnectionCompletionOptions } from 'azdata';
|
||||||
|
|
||||||
suite('ConnectionDialogService tests', () => {
|
suite('ConnectionDialogService tests', () => {
|
||||||
const testTreeViewId = 'testTreeView';
|
const testTreeViewId = 'testTreeView';
|
||||||
@@ -322,7 +324,8 @@ suite('ConnectionDialogService tests', () => {
|
|||||||
assert(!!returnedModel);
|
assert(!!returnedModel);
|
||||||
|
|
||||||
assert.strictEqual(returnedModel._groupName, 'testGroup');
|
assert.strictEqual(returnedModel._groupName, 'testGroup');
|
||||||
assert(called);
|
await delay(200);
|
||||||
|
assert(called, 'fillInConnectionInputs was not called as expected.');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handleOnConnect calls connectAndSaveProfile when called with profile', async () => {
|
test('handleOnConnect calls connectAndSaveProfile when called with profile', async () => {
|
||||||
@@ -339,8 +342,32 @@ suite('ConnectionDialogService tests', () => {
|
|||||||
(connectionDialogService as any)._connectionDialog.connectButtonState = true;
|
(connectionDialogService as any)._connectionDialog.connectButtonState = true;
|
||||||
((connectionDialogService as any)._connectionDialog as any).connect(connectionProfile);
|
((connectionDialogService as any)._connectionDialog as any).connect(connectionProfile);
|
||||||
});
|
});
|
||||||
|
await delay(200);
|
||||||
|
assert(called, 'connectAndSaveProfile was not called as expected.');
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(() => { assert(called); }, 200);
|
test('handleOnConnect does not save connection for editor type connection', async () => {
|
||||||
|
let called = false;
|
||||||
|
let saveConnection = true;
|
||||||
|
mockConnectionManagementService.setup(x => x.connectAndSaveProfile(TypeMoq.It.isAny(), TypeMoq.It.isAnyString(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
||||||
|
.callback((connection: IConnectionProfile, uri: string, options: IConnectionCompletionOptions, callbacks: IConnectionCallbacks) => {
|
||||||
|
saveConnection = options.saveConnection;
|
||||||
|
})
|
||||||
|
.returns(() => {
|
||||||
|
called = true;
|
||||||
|
return Promise.resolve(<IConnectionResult>{ connected: true, errorMessage: undefined, errorCode: undefined });
|
||||||
|
});
|
||||||
|
testConnectionParams.connectionType = ConnectionType.editor;
|
||||||
|
(connectionDialogService as any)._connectionDialog = undefined;
|
||||||
|
(connectionDialogService as any)._dialogDeferredPromise = new Deferred<IConnectionProfile>();
|
||||||
|
await connectionDialogService.showDialog(mockConnectionManagementService.object, testConnectionParams, connectionProfile);
|
||||||
|
((connectionDialogService as any)._connectionControllerMap['MSSQL'] as any)._model = connectionProfile;
|
||||||
|
(connectionDialogService as any)._connectionDialog.connectButtonState = true;
|
||||||
|
((connectionDialogService as any)._connectionDialog as any).connect(connectionProfile);
|
||||||
|
|
||||||
|
await delay(200);
|
||||||
|
assert(called, 'connectAndSaveProfile was not called as expected.');
|
||||||
|
assert(!saveConnection, 'Must not save connection for editor connection type');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handleOnConnect calls connectAndSaveProfile when called without profile', async () => {
|
test('handleOnConnect calls connectAndSaveProfile when called without profile', async () => {
|
||||||
@@ -356,7 +383,8 @@ suite('ConnectionDialogService tests', () => {
|
|||||||
((connectionDialogService as any)._connectionControllerMap['MSSQL'] as any)._model = connectionProfile;
|
((connectionDialogService as any)._connectionControllerMap['MSSQL'] as any)._model = connectionProfile;
|
||||||
(connectionDialogService as any)._connectionDialog.connectButtonState = true;
|
(connectionDialogService as any)._connectionDialog.connectButtonState = true;
|
||||||
((connectionDialogService as any)._connectionDialog as any).connect();
|
((connectionDialogService as any)._connectionDialog as any).connect();
|
||||||
setTimeout(() => { assert(called); }, 200);
|
await delay(200);
|
||||||
|
assert(called, 'connectAndSaveProfile was not called as expected.');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handleOnCancel calls cancelEditorConnection', async () => {
|
test('handleOnCancel calls cancelEditorConnection', async () => {
|
||||||
@@ -373,6 +401,7 @@ suite('ConnectionDialogService tests', () => {
|
|||||||
((connectionDialogService as any)._connectionDialog as any).cancel();
|
((connectionDialogService as any)._connectionDialog as any).cancel();
|
||||||
});
|
});
|
||||||
mockWidget.verify(x => x.databaseDropdownExpanded = false, TypeMoq.Times.atLeastOnce());
|
mockWidget.verify(x => x.databaseDropdownExpanded = false, TypeMoq.Times.atLeastOnce());
|
||||||
assert(called);
|
await delay(200);
|
||||||
|
assert(called, 'cancelEditorConnection was not called as expected.');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user