mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 01:25:38 -05:00
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:
@@ -99,7 +99,6 @@ class ConnectionProfileTemplate extends Disposable {
|
||||
|
||||
set(element: ConnectionProfile) {
|
||||
if (!this._isCompact) {
|
||||
let iconPath: IconPath | undefined = getIconPath(element, this._connectionManagementService);
|
||||
if (this._connectionManagementService.isConnected(undefined, element)) {
|
||||
this._connectionStatusBadge.classList.remove('disconnected');
|
||||
this._connectionStatusBadge.classList.add('connected');
|
||||
@@ -107,9 +106,11 @@ class ConnectionProfileTemplate extends Disposable {
|
||||
this._connectionStatusBadge.classList.remove('connected');
|
||||
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;
|
||||
if (!element.isConnectionOptionsValid) {
|
||||
label = localize('loading', "Loading...");
|
||||
@@ -259,16 +260,14 @@ function getIconPath(connection: ConnectionProfile, connectionManagementService:
|
||||
}
|
||||
|
||||
let iconId = connectionManagementService.getConnectionIconId(connection.id);
|
||||
if (!iconId) { return undefined; }
|
||||
|
||||
let providerProperties = connectionManagementService.getProviderProperties(connection.providerName);
|
||||
if (!providerProperties) { return 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)) {
|
||||
for (const e of pathConfig) {
|
||||
if (!e.id || e.id === iconId) {
|
||||
if (!e.id || e.id === iconId || (!iconId && e.default)) {
|
||||
iconPath = e.path;
|
||||
connection['iconPath'] = iconPath;
|
||||
break;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
class IconRenderer {
|
||||
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; }
|
||||
let iconPath: IconPath = this.toIconPath(path);
|
||||
let iconUid: string | undefined = this.getIconUid(iconPath);
|
||||
@@ -37,8 +37,7 @@ class IconRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
public putIcon(element: HTMLElement, path: URI | IconPath): void {
|
||||
if (!element || !path) { return undefined; }
|
||||
public putIcon(element: HTMLElement, path: URI | IconPath | undefined): void {
|
||||
let iconUid: string | undefined = this.registerIcon(path);
|
||||
element.id = iconUid ?? '';
|
||||
}
|
||||
|
||||
@@ -171,16 +171,14 @@ export class ServerTreeRenderer implements IRenderer {
|
||||
}
|
||||
|
||||
let iconId = this._connectionManagementService.getConnectionIconId(connection.id);
|
||||
if (!iconId) { return undefined; }
|
||||
|
||||
let providerProperties = this._connectionManagementService.getProviderProperties(connection.providerName);
|
||||
if (!providerProperties) { return 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)) {
|
||||
for (const e of pathConfig) {
|
||||
if (!e.id || e.id === iconId) {
|
||||
if (!e.id || e.id === iconId || (!iconId && e.default)) {
|
||||
iconPath = e.path;
|
||||
connection['iconPath'] = iconPath;
|
||||
break;
|
||||
@@ -199,9 +197,7 @@ export class ServerTreeRenderer implements IRenderer {
|
||||
|
||||
private renderServerIcon(element: HTMLElement, iconPath: IconPath | undefined, isConnected: boolean): void {
|
||||
if (!element) { return; }
|
||||
if (iconPath) {
|
||||
iconRenderer.putIcon(element, iconPath);
|
||||
}
|
||||
iconRenderer.putIcon(element, iconPath);
|
||||
let badgeToRemove: string = isConnected ? badgeRenderer.serverDisconnected : badgeRenderer.serverConnected;
|
||||
let badgeToAdd: string = isConnected ? badgeRenderer.serverConnected : badgeRenderer.serverDisconnected;
|
||||
badgeRenderer.removeBadge(element, badgeToRemove);
|
||||
@@ -209,19 +205,21 @@ export class ServerTreeRenderer implements IRenderer {
|
||||
}
|
||||
|
||||
private renderConnection(connection: ConnectionProfile, templateData: IConnectionTemplateData): void {
|
||||
|
||||
let isConnected = this._connectionManagementService.isConnected(undefined, connection);
|
||||
if (!this._isCompact) {
|
||||
let iconPath = this.getIconPath(connection);
|
||||
if (this._connectionManagementService.isConnected(undefined, connection)) {
|
||||
if (isConnected) {
|
||||
templateData.icon.classList.remove('disconnected');
|
||||
templateData.icon.classList.add('connected');
|
||||
this.renderServerIcon(templateData.icon, iconPath, true);
|
||||
} else {
|
||||
templateData.icon.classList.remove('connected');
|
||||
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;
|
||||
if (!connection.isConnectionOptionsValid) {
|
||||
label = localize('loading', "Loading...");
|
||||
|
||||
Reference in New Issue
Block a user