mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 09:35:37 -05:00
Remove typings and replace missing methods with vscodes (#8217)
* remove typings and replace missing methods with vscodes * fix strict-null-checks * fix tests
This commit is contained in:
@@ -14,6 +14,9 @@ import { join } from 'vs/base/common/path';
|
||||
import * as Utils from 'sql/platform/connection/common/utils';
|
||||
import * as azdata from 'azdata';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { firstIndex, find } from 'vs/base/common/arrays';
|
||||
|
||||
export class ConnectionStatusManager {
|
||||
|
||||
@@ -35,8 +38,8 @@ export class ConnectionStatusManager {
|
||||
}
|
||||
}
|
||||
|
||||
public findConnectionByProfileId(profileId: string): ConnectionManagementInfo {
|
||||
return Object.values(this._connections).find((connection: ConnectionManagementInfo) => connection.connectionProfile.id === profileId);
|
||||
public findConnectionByProfileId(profileId: string): ConnectionManagementInfo | undefined {
|
||||
return find(values(this._connections), connection => connection.connectionProfile.id === profileId);
|
||||
}
|
||||
|
||||
public findConnectionProfile(connectionProfile: IConnectionProfile): ConnectionManagementInfo | undefined {
|
||||
@@ -190,7 +193,7 @@ export class ConnectionStatusManager {
|
||||
}
|
||||
|
||||
private isSharedSession(fileUri: string): boolean {
|
||||
return !!(fileUri && fileUri.startsWith('vsls:'));
|
||||
return !!(fileUri && startsWith(fileUri, 'vsls:'));
|
||||
}
|
||||
|
||||
public isConnected(id: string): boolean {
|
||||
@@ -205,7 +208,7 @@ export class ConnectionStatusManager {
|
||||
}
|
||||
|
||||
public isDefaultTypeUri(uri: string): boolean {
|
||||
return !!(uri && uri.startsWith(Utils.uriPrefixes.default));
|
||||
return !!(uri && startsWith(uri, Utils.uriPrefixes.default));
|
||||
}
|
||||
|
||||
public getProviderIdFromUri(ownerUri: string): string {
|
||||
@@ -225,12 +228,12 @@ export class ConnectionStatusManager {
|
||||
* Get a list of the active connection profiles managed by the status manager
|
||||
*/
|
||||
public getActiveConnectionProfiles(providers?: string[]): ConnectionProfile[] {
|
||||
let profiles = Object.values(this._connections).map((connectionInfo: ConnectionManagementInfo) => connectionInfo.connectionProfile);
|
||||
let profiles = values(this._connections).map((connectionInfo: ConnectionManagementInfo) => connectionInfo.connectionProfile);
|
||||
// Remove duplicate profiles that may be listed multiple times under different URIs by filtering for profiles that don't have the same ID as an earlier profile in the list
|
||||
profiles = profiles.filter((profile, index) => profiles.findIndex(otherProfile => otherProfile.id === profile.id) === index);
|
||||
profiles = profiles.filter((profile, index) => firstIndex(profiles, otherProfile => otherProfile.id === profile.id) === index);
|
||||
|
||||
if (providers) {
|
||||
profiles = profiles.filter(f => providers.includes(f.providerName));
|
||||
profiles = profiles.filter(f => find(providers, x => x === f.providerName));
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user