3707 Kusto Icon Fix (#12621)

* 3707 Changed getIconpath in serverTreeRenderer to always set iconPath if iconId is undefined. Changed renderConnection to always renderServerIcon

* 3707 Added default flag to KustoIcon in package.json

* fix caching issue

* 3707 Changed default to optional variable. Updated asyncServerTreeRenderer > getIconPath to check for default

* 3707 Changed logic for setting iconPath in getIconPath

Co-authored-by: chgagnon <chgagnon@microsoft.com>
This commit is contained in:
Justin M
2020-09-25 16:49:33 -07:00
committed by GitHub
parent 037d638927
commit 5396ed855c
5 changed files with 19 additions and 22 deletions

View File

@@ -223,7 +223,8 @@
"path": { "path": {
"light": "resources/light/azureDE.svg", "light": "resources/light/azureDE.svg",
"dark": "resources/dark/azureDE_inverse.svg" "dark": "resources/dark/azureDE_inverse.svg"
} },
"default": true
}, },
{ {
"id": "kusto:cluster", "id": "kusto:cluster",

View File

@@ -22,7 +22,7 @@ export const clientCapabilities = {
export interface ConnectionProviderProperties { export interface ConnectionProviderProperties {
providerId: string; providerId: string;
iconPath?: URI | IconPath | { id: string, path: IconPath }[] iconPath?: URI | IconPath | { id: string, path: IconPath, default?: boolean }[]
displayName: string; displayName: string;
notebookKernelAlias?: string; notebookKernelAlias?: string;
azureResource?: string; azureResource?: string;

View File

@@ -99,7 +99,6 @@ class ConnectionProfileTemplate extends Disposable {
set(element: ConnectionProfile) { set(element: ConnectionProfile) {
if (!this._isCompact) { if (!this._isCompact) {
let iconPath: IconPath | undefined = getIconPath(element, this._connectionManagementService);
if (this._connectionManagementService.isConnected(undefined, element)) { if (this._connectionManagementService.isConnected(undefined, element)) {
this._connectionStatusBadge.classList.remove('disconnected'); this._connectionStatusBadge.classList.remove('disconnected');
this._connectionStatusBadge.classList.add('connected'); this._connectionStatusBadge.classList.add('connected');
@@ -107,9 +106,11 @@ class ConnectionProfileTemplate extends Disposable {
this._connectionStatusBadge.classList.remove('connected'); this._connectionStatusBadge.classList.remove('connected');
this._connectionStatusBadge.classList.add('disconnected'); this._connectionStatusBadge.classList.add('disconnected');
} }
renderServerIcon(this._icon, iconPath);
} }
let iconPath: IconPath | undefined = getIconPath(element, this._connectionManagementService);
renderServerIcon(this._icon, iconPath);
let label = element.title; let label = element.title;
if (!element.isConnectionOptionsValid) { if (!element.isConnectionOptionsValid) {
label = localize('loading', "Loading..."); label = localize('loading', "Loading...");
@@ -259,16 +260,14 @@ function getIconPath(connection: ConnectionProfile, connectionManagementService:
} }
let iconId = connectionManagementService.getConnectionIconId(connection.id); let iconId = connectionManagementService.getConnectionIconId(connection.id);
if (!iconId) { return undefined; }
let providerProperties = connectionManagementService.getProviderProperties(connection.providerName); let providerProperties = connectionManagementService.getProviderProperties(connection.providerName);
if (!providerProperties) { return undefined; } if (!providerProperties) { return undefined; }
let iconPath: IconPath | undefined = undefined; let iconPath: IconPath | undefined = undefined;
let pathConfig: URI | IconPath | { id: string, path: IconPath }[] | undefined = providerProperties['iconPath']; let pathConfig: URI | IconPath | { id: string, path: IconPath, default?: boolean }[] | undefined = providerProperties['iconPath'];
if (Array.isArray(pathConfig)) { if (Array.isArray(pathConfig)) {
for (const e of pathConfig) { for (const e of pathConfig) {
if (!e.id || e.id === iconId) { if (!e.id || e.id === iconId || (!iconId && e.default)) {
iconPath = e.path; iconPath = e.path;
connection['iconPath'] = iconPath; connection['iconPath'] = iconPath;
break; break;

View File

@@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri';
class IconRenderer { class IconRenderer {
private iconRegistered: Set<string> = new Set<string>(); private iconRegistered: Set<string> = new Set<string>();
public registerIcon(path: URI | IconPath): string | undefined { public registerIcon(path: URI | IconPath | undefined): string | undefined {
if (!path) { return undefined; } if (!path) { return undefined; }
let iconPath: IconPath = this.toIconPath(path); let iconPath: IconPath = this.toIconPath(path);
let iconUid: string | undefined = this.getIconUid(iconPath); let iconUid: string | undefined = this.getIconUid(iconPath);
@@ -37,8 +37,7 @@ class IconRenderer {
} }
} }
public putIcon(element: HTMLElement, path: URI | IconPath): void { public putIcon(element: HTMLElement, path: URI | IconPath | undefined): void {
if (!element || !path) { return undefined; }
let iconUid: string | undefined = this.registerIcon(path); let iconUid: string | undefined = this.registerIcon(path);
element.id = iconUid ?? ''; element.id = iconUid ?? '';
} }

View File

@@ -171,16 +171,14 @@ export class ServerTreeRenderer implements IRenderer {
} }
let iconId = this._connectionManagementService.getConnectionIconId(connection.id); let iconId = this._connectionManagementService.getConnectionIconId(connection.id);
if (!iconId) { return undefined; }
let providerProperties = this._connectionManagementService.getProviderProperties(connection.providerName); let providerProperties = this._connectionManagementService.getProviderProperties(connection.providerName);
if (!providerProperties) { return undefined; } if (!providerProperties) { return undefined; }
let iconPath: IconPath | undefined = undefined; let iconPath: IconPath | undefined = undefined;
let pathConfig: URI | IconPath | { id: string, path: IconPath }[] | undefined = providerProperties.iconPath; let pathConfig: URI | IconPath | { id: string, path: IconPath, default?: boolean }[] | undefined = providerProperties.iconPath;
if (Array.isArray(pathConfig)) { if (Array.isArray(pathConfig)) {
for (const e of pathConfig) { for (const e of pathConfig) {
if (!e.id || e.id === iconId) { if (!e.id || e.id === iconId || (!iconId && e.default)) {
iconPath = e.path; iconPath = e.path;
connection['iconPath'] = iconPath; connection['iconPath'] = iconPath;
break; break;
@@ -199,9 +197,7 @@ export class ServerTreeRenderer implements IRenderer {
private renderServerIcon(element: HTMLElement, iconPath: IconPath | undefined, isConnected: boolean): void { private renderServerIcon(element: HTMLElement, iconPath: IconPath | undefined, isConnected: boolean): void {
if (!element) { return; } if (!element) { return; }
if (iconPath) {
iconRenderer.putIcon(element, iconPath); iconRenderer.putIcon(element, iconPath);
}
let badgeToRemove: string = isConnected ? badgeRenderer.serverDisconnected : badgeRenderer.serverConnected; let badgeToRemove: string = isConnected ? badgeRenderer.serverDisconnected : badgeRenderer.serverConnected;
let badgeToAdd: string = isConnected ? badgeRenderer.serverConnected : badgeRenderer.serverDisconnected; let badgeToAdd: string = isConnected ? badgeRenderer.serverConnected : badgeRenderer.serverDisconnected;
badgeRenderer.removeBadge(element, badgeToRemove); badgeRenderer.removeBadge(element, badgeToRemove);
@@ -209,19 +205,21 @@ export class ServerTreeRenderer implements IRenderer {
} }
private renderConnection(connection: ConnectionProfile, templateData: IConnectionTemplateData): void { private renderConnection(connection: ConnectionProfile, templateData: IConnectionTemplateData): void {
let isConnected = this._connectionManagementService.isConnected(undefined, connection);
if (!this._isCompact) { if (!this._isCompact) {
let iconPath = this.getIconPath(connection); if (isConnected) {
if (this._connectionManagementService.isConnected(undefined, connection)) {
templateData.icon.classList.remove('disconnected'); templateData.icon.classList.remove('disconnected');
templateData.icon.classList.add('connected'); templateData.icon.classList.add('connected');
this.renderServerIcon(templateData.icon, iconPath, true);
} else { } else {
templateData.icon.classList.remove('connected'); templateData.icon.classList.remove('connected');
templateData.icon.classList.add('disconnected'); templateData.icon.classList.add('disconnected');
this.renderServerIcon(templateData.icon, iconPath, false);
} }
} }
let iconPath = this.getIconPath(connection);
this.renderServerIcon(templateData.icon, iconPath, isConnected);
let label = connection.title; let label = connection.title;
if (!connection.isConnectionOptionsValid) { if (!connection.isConnectionOptionsValid) {
label = localize('loading', "Loading..."); label = localize('loading', "Loading...");