Differentiated server icons by server type: box, big data cluster, cloud... (#5241)

This commit is contained in:
Gene Lee
2019-05-13 14:52:56 -07:00
committed by GitHub
parent 7da0dddaa9
commit 99d00e2057
25 changed files with 693 additions and 19 deletions

View File

@@ -11,6 +11,8 @@ import { Event, Emitter } from 'vs/base/common/event';
import { deepClone } from 'vs/base/common/objects';
import * as azdata from 'azdata';
import * as path from 'path';
import { URI } from 'vs/base/common/uri';
export interface ConnectionProviderProperties {
providerId: string;
@@ -66,6 +68,47 @@ const ConnectionProviderContrib: IJSONSchema = {
type: 'string',
description: localize('schema.displayName', "Display Name for the provider")
},
iconPath: {
description: localize('schema.iconPath', 'Icon path for the server type'),
oneOf: [
{
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
},
path: {
type: 'object',
properties: {
light: {
type: 'string',
},
dark: {
type: 'string',
}
}
}
}
}
},
{
type: 'object',
properties: {
light: {
type: 'string',
},
dark: {
type: 'string',
}
}
},
{
type: 'string'
}
]
},
connectionOptions: {
type: 'array',
description: localize('schema.connectionOptions', "Options for connection"),
@@ -123,6 +166,7 @@ ExtensionsRegistry.registerExtensionPoint<ConnectionProviderProperties | Connect
for (let extension of extensions) {
const { value } = extension;
resolveIconPath(extension);
if (Array.isArray<ConnectionProviderProperties>(value)) {
for (let command of value) {
handleCommand(command, extension);
@@ -132,3 +176,39 @@ ExtensionsRegistry.registerExtensionPoint<ConnectionProviderProperties | Connect
}
}
});
function resolveIconPath(extension: IExtensionPointUser<any>): void {
if (!extension || !extension.value) { return undefined; }
let toAbsolutePath = (iconPath: any, baseDir: string) => {
if (!iconPath || !baseDir) { return; }
if (Array.isArray(iconPath)) {
for (let e of iconPath) {
e.path = {
light: URI.file(path.join(baseDir, e.path.light)),
dark: URI.file(path.join(baseDir, e.path.dark))
};
}
} else if (typeof iconPath === 'string') {
iconPath = {
light: URI.file(path.join(baseDir, iconPath)),
dark: URI.file(path.join(baseDir, iconPath))
};
} else {
iconPath = {
light: URI.file(path.join(baseDir, iconPath.light)),
dark: URI.file(path.join(baseDir, iconPath.dark))
};
}
};
let baseDir = extension.description.extensionLocation.fsPath;
let properties: ConnectionProviderProperties = extension.value;
if (Array.isArray<ConnectionProviderProperties>(properties)) {
for (let p of properties) {
toAbsolutePath(p['iconPath'], baseDir);
}
} else {
toAbsolutePath(properties['iconPath'], baseDir);
}
}

View File

@@ -10,25 +10,35 @@ export class ServerInfoContextKey implements IContextKey<ServerInfo> {
static ServerInfo = new RawContextKey<ServerInfo>('serverInfo', undefined);
static ServerMajorVersion = new RawContextKey<string>('serverMajorVersion', undefined);
static IsCloud = new RawContextKey<boolean>('isCloud', undefined);
static IsBigDataCluster = new RawContextKey<boolean>('isBigDataCluster', undefined);
private _serverInfo: IContextKey<ServerInfo>;
private _serverMajorVersion: IContextKey<string>;
private _isCloud: IContextKey<boolean>;
private _isBigDataCluster: IContextKey<boolean>;
constructor(
@IContextKeyService contextKeyService: IContextKeyService
) {
this._serverInfo = ServerInfoContextKey.ServerInfo.bindTo(contextKeyService);
this._serverMajorVersion = ServerInfoContextKey.ServerMajorVersion.bindTo(contextKeyService);
this._isCloud = ServerInfoContextKey.IsCloud.bindTo(contextKeyService);
this._isBigDataCluster = ServerInfoContextKey.IsBigDataCluster.bindTo(contextKeyService);
}
set(value: ServerInfo) {
this._serverInfo.set(value);
let majorVersion = value && value.serverMajorVersion;
this._serverMajorVersion.set(majorVersion && `${majorVersion}`);
this._isCloud.set(value && value.isCloud);
this._isBigDataCluster.set(value && value.options && value.options['isBigDataCluster']);
}
reset(): void {
this._serverMajorVersion.reset();
this._isCloud.reset();
this._isBigDataCluster.reset();
}
public get(): ServerInfo {