mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Differentiated server icons by server type: box, big data cluster, cloud... (#5241)
This commit is contained in:
@@ -11,6 +11,7 @@ import { ConnectionProfile } from 'sql/platform/connection/common/connectionProf
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
|
||||
import { IServerGroupDialogCallbacks } from 'sql/platform/serverGroup/common/serverGroupController';
|
||||
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||
|
||||
export const VIEWLET_ID = 'workbench.view.connections';
|
||||
|
||||
@@ -182,6 +183,8 @@ export interface IConnectionManagementService {
|
||||
*/
|
||||
registerProvider(providerId: string, provider: azdata.ConnectionProvider): void;
|
||||
|
||||
registerIconProvider(providerId: string, provider: azdata.IconProvider): void;
|
||||
|
||||
editGroup(group: ConnectionProfileGroup): Promise<void>;
|
||||
|
||||
getConnectionProfile(fileUri: string): IConnectionProfile;
|
||||
@@ -273,6 +276,10 @@ export interface IConnectionManagementService {
|
||||
* Get connection profile by id
|
||||
*/
|
||||
getConnectionProfileById(profileId: string): IConnectionProfile;
|
||||
|
||||
getProviderProperties(providerName: string): ConnectionProviderProperties;
|
||||
|
||||
getConnectionIconId(connectionId: string): string;
|
||||
}
|
||||
|
||||
export enum RunQueryOnConnectionMode {
|
||||
|
||||
@@ -52,12 +52,15 @@ import { IConnectionDialogService } from 'sql/workbench/services/connection/comm
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import * as interfaces from './interfaces';
|
||||
|
||||
export class ConnectionManagementService extends Disposable implements IConnectionManagementService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private _providers = new Map<string, { onReady: Thenable<azdata.ConnectionProvider>, properties: ConnectionProviderProperties }>();
|
||||
private _iconProviders = new Map<string, azdata.IconProvider>();
|
||||
private _connectionIconIdCache = new Map<string, string>();
|
||||
|
||||
private _uriToProvider: { [uri: string]: string; } = Object.create(null);
|
||||
|
||||
@@ -176,6 +179,10 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
(this._providers.get(providerId).onReady as Deferred<azdata.ConnectionProvider>).resolve(provider);
|
||||
}
|
||||
|
||||
public registerIconProvider(providerId: string, iconProvider: azdata.IconProvider): void {
|
||||
this._iconProviders.set(providerId, iconProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the connection dialog
|
||||
* @param params Include the uri, type of connection
|
||||
@@ -543,10 +550,27 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
if (options.showDashboard) {
|
||||
this.showDashboardForConnectionManagementInfo(connectionManagementInfo.connectionProfile);
|
||||
}
|
||||
|
||||
let connectionProfile = connectionManagementInfo.connectionProfile;
|
||||
this._onConnect.fire(<IConnectionParams>{
|
||||
connectionUri: uri,
|
||||
connectionProfile: connectionManagementInfo.connectionProfile
|
||||
connectionProfile: connectionProfile
|
||||
});
|
||||
|
||||
let iconProvider = this._iconProviders.get(connectionManagementInfo.providerId);
|
||||
if (iconProvider) {
|
||||
let serverInfo: azdata.ServerInfo = this.getServerInfo(connectionProfile.id);
|
||||
let profile: interfaces.IConnectionProfile = connectionProfile.toIConnectionProfile();
|
||||
iconProvider.getConnectionIconId(profile, serverInfo).then(iconId => {
|
||||
if (iconId) {
|
||||
this._connectionIconIdCache.set(connectionProfile.id, iconId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public getConnectionIconId(connectionId: string): string {
|
||||
return this._connectionIconIdCache.get(connectionId);
|
||||
}
|
||||
|
||||
public showDashboard(connection: IConnectionProfile): Thenable<boolean> {
|
||||
@@ -1392,4 +1416,9 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public getProviderProperties(providerName: string): ConnectionProviderProperties {
|
||||
let connectionProvider = this._providers.get(providerName);
|
||||
return connectionProvider && connectionProvider.properties;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user