mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 01:25:37 -05:00
This commit is contained in:
@@ -14,8 +14,6 @@ import * as azdata from 'azdata';
|
||||
import * as nls from 'vs/nls';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import * as ConnectionUtils from 'sql/platform/connection/common/utils';
|
||||
|
||||
export class ConnectionStatusManager {
|
||||
|
||||
@@ -85,23 +83,8 @@ export class ConnectionStatusManager {
|
||||
return connectionInfoForId ? connectionInfoForId.connectionProfile : undefined;
|
||||
}
|
||||
|
||||
private isNonEditorUri(uri: string): boolean {
|
||||
return uri.startsWith(ConnectionUtils.uriPrefixes.connection)
|
||||
|| uri.startsWith(ConnectionUtils.uriPrefixes.dashboard)
|
||||
|| uri.startsWith(ConnectionUtils.uriPrefixes.insights)
|
||||
|| uri.startsWith(ConnectionUtils.uriPrefixes.notebook);
|
||||
}
|
||||
|
||||
public addConnection(connection: IConnectionProfile, id: string): ConnectionManagementInfo {
|
||||
this._logService.info(`Adding connection ${id}`);
|
||||
|
||||
// Newly generated URIs are used in areas where the same connection profile id is expected for callbacks,
|
||||
// This is used for Editor URIs such as Query Editor, which do not have uriPrefixes recognized above.
|
||||
// (This is done to not retrieve the base connection profile, which may be different if a user changes the database).
|
||||
if (!this.isNonEditorUri(id) && this.findConnectionByProfileId(connection.id) !== undefined) {
|
||||
connection.id = generateUuid();
|
||||
}
|
||||
|
||||
// Always create a copy and save that in the list
|
||||
let connectionProfile = new ConnectionProfile(this._capabilitiesService, connection);
|
||||
let connectionInfo: ConnectionManagementInfo = {
|
||||
|
||||
@@ -250,16 +250,13 @@ suite('SQL ConnectionStatusManager tests', () => {
|
||||
newConnection.id = 'test_id';
|
||||
newConnection.serverName = 'new_server_name';
|
||||
newConnection.options['databaseDisplayName'] = newConnection.databaseName;
|
||||
//Duplicate should not be registered if uri is of connection/dashboard type (required for functionality)
|
||||
connections.addConnection(newConnection, 'connection:test_uri_1');
|
||||
connections.addConnection(newConnection, 'dashboard:test_uri_1');
|
||||
//Editor type URIs should generate a new profile id (needed to properly update the connection string)
|
||||
connections.addConnection(newConnection, 'untitled:TestQuery1')
|
||||
connections.addConnection(newConnection, 'test_uri_1');
|
||||
connections.addConnection(newConnection, 'test_uri_2');
|
||||
newConnection = new ConnectionProfile(capabilitiesService, newConnection);
|
||||
|
||||
// Get the connections and verify that the non editor duplicate is only returned once
|
||||
// Get the connections and verify that the duplicate is only returned once
|
||||
let activeConnections = connections.getActiveConnectionProfiles();
|
||||
assert.strictEqual(activeConnections.length, 5);
|
||||
assert.strictEqual(activeConnections.filter(connection => connection.matches(newConnection)).length, 2, 'Did not find newConnection in active connections');
|
||||
assert.strictEqual(activeConnections.length, 4);
|
||||
assert.strictEqual(activeConnections.filter(connection => connection.matches(newConnection)).length, 1, 'Did not find newConnection in active connections');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user