diff --git a/extensions/machine-learning/src/views/dataInfoComponent.ts b/extensions/machine-learning/src/views/dataInfoComponent.ts index 8eff78f085..34a49ef00a 100644 --- a/extensions/machine-learning/src/views/dataInfoComponent.ts +++ b/extensions/machine-learning/src/views/dataInfoComponent.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as azdata from 'azdata'; -import * as vscode from 'vscode'; import { ApiWrapper } from '../common/apiWrapper'; import { ModelViewBase } from './models/modelViewBase'; import { ViewBase } from './viewBase'; @@ -16,7 +15,7 @@ export interface iconSettings { containerWidth?: number, containerHeight?: number, css?: { [key: string]: string }, - path?: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri } + path?: azdata.IconPath; } /** * View to pick model source diff --git a/extensions/machine-learning/src/views/widgets/dashboardWidget.ts b/extensions/machine-learning/src/views/widgets/dashboardWidget.ts index 2553e02ede..02a256399d 100644 --- a/extensions/machine-learning/src/views/widgets/dashboardWidget.ts +++ b/extensions/machine-learning/src/views/widgets/dashboardWidget.ts @@ -14,7 +14,7 @@ interface IActionMetadata { title?: string, description?: string, link?: string, - iconPath?: { light: string | vscode.Uri; dark: string | vscode.Uri }, + iconPath?: azdata.ThemedIconPath, command?: string } diff --git a/extensions/sql-migration/src/dashboard/sqlServerDashboard.ts b/extensions/sql-migration/src/dashboard/sqlServerDashboard.ts index 7018658f46..ce8e81e8c3 100644 --- a/extensions/sql-migration/src/dashboard/sqlServerDashboard.ts +++ b/extensions/sql-migration/src/dashboard/sqlServerDashboard.ts @@ -13,7 +13,7 @@ interface IActionMetadata { title?: string, description?: string, link?: string, - iconPath?: { light: string | vscode.Uri; dark: string | vscode.Uri }, + iconPath?: azdata.ThemedIconPath, command?: string; } diff --git a/src/sql/azdata.d.ts b/src/sql/azdata.d.ts index c5592b778c..0b214c3b55 100644 --- a/src/sql/azdata.d.ts +++ b/src/sql/azdata.d.ts @@ -3180,11 +3180,14 @@ declare module 'azdata' { CSSStyles?: { [key: string]: string }; } + export type ThemedIconPath = { light: string | vscode.Uri; dark: string | vscode.Uri }; + export type IconPath = string | vscode.Uri | ThemedIconPath; + export interface ComponentWithIcon { /** * @deprecated This will be moved to `ComponentWithIconProperties` */ - iconPath?: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri }; + iconPath?: IconPath; /** * @deprecated This will be moved to `ComponentWithIconProperties` */ diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 6cf0e9be24..57dfa52554 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -349,7 +349,7 @@ declare module 'azdata' { export interface RadioCard { id: string; descriptions: RadioCardDescription[]; - icon?: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri }; + icon?: IconPath; } export interface RadioCardDescription { @@ -441,7 +441,7 @@ declare module 'azdata' { /** * The path for the icon with optional dark-theme away alternative */ - iconPath?: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri }; + iconPath?: IconPath; /** * The height of the icon */ @@ -538,7 +538,7 @@ declare module 'azdata' { /** * Icon of the tab */ - icon?: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri }; + icon?: IconPath; } /** @@ -820,7 +820,7 @@ declare module 'azdata' { } export interface ButtonColumnOption { - icon?: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri }; + icon?: IconPath; } export interface ButtonCell extends TableCell { @@ -963,7 +963,7 @@ declare module 'azdata' { /** * The icon to be displayed. */ - icon: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri }; + icon: IconPath; /** * The title of the icon. */ @@ -974,7 +974,7 @@ declare module 'azdata' { /** * The icon to be displayed. */ - icon?: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri }; + icon?: IconPath; /** * The title of the button. */ @@ -985,7 +985,7 @@ declare module 'azdata' { /** * The icon to be displayed. */ - icon?: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri }; + icon?: IconPath; /** * The title of the hyperlink. */ @@ -1013,7 +1013,7 @@ declare module 'azdata' { /** * The icon to use for all the cells in this column. */ - icon?: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri }; + icon?: IconPath; } export interface ButtonColumn extends IconColumnOptions, TableColumn { diff --git a/src/sql/workbench/api/common/extHostModelView.ts b/src/sql/workbench/api/common/extHostModelView.ts index 791c10c1f7..80623f841c 100644 --- a/src/sql/workbench/api/common/extHostModelView.ts +++ b/src/sql/workbench/api/common/extHostModelView.ts @@ -540,7 +540,7 @@ function createFromTabs(items: (azdata.Tab | azdata.TabGroup)[]): InternalItemCo return itemConfigs; } -function toTabItemConfig(content: azdata.Component, title: string, id?: string, group?: string, icon?: string | URI | { light: string | URI; dark: string | URI }): InternalItemConfig { +function toTabItemConfig(content: azdata.Component, title: string, id?: string, group?: string, icon?: azdata.IconPath): InternalItemConfig { return new InternalItemConfig(content as ComponentWrapper, { title: title, group: group, @@ -860,10 +860,10 @@ class ComponentWithIconWrapper extends ComponentWrapper { super(proxy, handle, type, id); } - public get iconPath(): string | URI | { light: string | URI; dark: string | URI } { + public get iconPath(): azdata.IconPath { return this.properties['iconPath']; } - public set iconPath(v: string | URI | { light: string | URI; dark: string | URI }) { + public set iconPath(v: azdata.IconPath) { this.setProperty('iconPath', v); } @@ -927,10 +927,10 @@ class CardWrapper extends ComponentWrapper implements azdata.CardComponent { public set actions(a: azdata.ActionDescriptor[]) { this.setProperty('actions', a); } - public get iconPath(): string | URI | { light: string | URI; dark: string | URI } { + public get iconPath(): azdata.IconPath { return this.properties['iconPath']; } - public set iconPath(v: string | URI | { light: string | URI; dark: string | URI }) { + public set iconPath(v: azdata.IconPath) { this.setProperty('iconPath', v); } diff --git a/src/sql/workbench/browser/modelComponents/componentBase.ts b/src/sql/workbench/browser/modelComponents/componentBase.ts index 09c5e224c3..cfdb650056 100644 --- a/src/sql/workbench/browser/modelComponents/componentBase.ts +++ b/src/sql/workbench/browser/modelComponents/componentBase.ts @@ -14,7 +14,6 @@ import * as azdata from 'azdata'; import { Emitter } from 'vs/base/common/event'; import { IDisposable, Disposable } from 'vs/base/common/lifecycle'; import { ModelComponentWrapper } from 'sql/workbench/browser/modelComponents/modelComponentWrapper.component'; -import { URI } from 'vs/base/common/uri'; import * as nls from 'vs/nls'; import { EventType, addDisposableListener } from 'vs/base/browser/dom'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; @@ -23,8 +22,6 @@ import { convertSize } from 'sql/base/browser/dom'; import { onUnexpectedError } from 'vs/base/common/errors'; import { ILogService } from 'vs/platform/log/common/log'; -export type IUserFriendlyIcon = string | URI | { light: string | URI; dark: string | URI }; - export class ItemDescriptor { constructor(public descriptor: IComponentDescriptor, public config: T) { } } diff --git a/src/sql/workbench/browser/modelComponents/componentWithIconBase.ts b/src/sql/workbench/browser/modelComponents/componentWithIconBase.ts index f50e5161dd..1f8777d19f 100644 --- a/src/sql/workbench/browser/modelComponents/componentWithIconBase.ts +++ b/src/sql/workbench/browser/modelComponents/componentWithIconBase.ts @@ -6,9 +6,8 @@ import { ChangeDetectorRef, ElementRef } from '@angular/core'; import * as azdata from 'azdata'; import { ComponentBase } from 'sql/workbench/browser/modelComponents/componentBase'; -import { createIconCssClass, IUserFriendlyIcon } from 'sql/workbench/browser/modelComponents/iconUtils'; +import { createIconCssClass, IconPath } from 'sql/workbench/browser/modelComponents/iconUtils'; import { removeCSSRulesContainingSelector } from 'vs/base/browser/dom'; -import { URI } from 'vs/base/common/uri'; import { IComponentDescriptor } from 'sql/platform/dashboard/browser/interfaces'; import { convertSize } from 'sql/base/browser/dom'; import { ILogService } from 'vs/platform/log/common/log'; @@ -20,7 +19,7 @@ export class ItemDescriptor { export abstract class ComponentWithIconBase extends ComponentBase { protected _iconClass: string; - protected _iconPath: IUserFriendlyIcon; + protected _iconPath: IconPath; constructor( changeRef: ChangeDetectorRef, el: ElementRef, @@ -58,8 +57,8 @@ export abstract class ComponentWithIconBase((props) => props.iconPath, undefined); + public get iconPath(): IconPath { + return this.getPropertyOrDefault((props) => props.iconPath, undefined); } public get iconHeight(): number | string { diff --git a/src/sql/workbench/browser/modelComponents/iconUtils.ts b/src/sql/workbench/browser/modelComponents/iconUtils.ts index fe985bbe78..0a03960287 100644 --- a/src/sql/workbench/browser/modelComponents/iconUtils.ts +++ b/src/sql/workbench/browser/modelComponents/iconUtils.ts @@ -9,7 +9,7 @@ import { URI } from 'vs/base/common/uri'; const ids = new IdGenerator('model-view-component-icon-'); -export type IUserFriendlyIcon = string | URI | { light: string | URI; dark: string | URI }; +export type IconPath = string | URI | { light: string | URI; dark: string | URI }; /** * Create a CSS class for the specified icon, if a class with the name already exists, it will be deleted first. @@ -17,7 +17,7 @@ export type IUserFriendlyIcon = string | URI | { light: string | URI; dark: stri * @param className optional, the class name you want to reuse. * @returns the CSS class name */ -export function createIconCssClass(iconPath: IUserFriendlyIcon, className?: string): string { +export function createIconCssClass(iconPath: IconPath, className?: string): string { let iconClass = className; if (!iconClass) { iconClass = ids.nextId(); @@ -30,7 +30,7 @@ export function createIconCssClass(iconPath: IUserFriendlyIcon, className?: stri return iconClass; } -function getLightIconUri(iconPath: IUserFriendlyIcon): URI { +function getLightIconUri(iconPath: IconPath): URI { if (iconPath && iconPath['light']) { return getIconUri(iconPath['light']); } else { @@ -38,7 +38,7 @@ function getLightIconUri(iconPath: IUserFriendlyIcon): URI { } } -function getDarkIconUri(iconPath: IUserFriendlyIcon): URI { +function getDarkIconUri(iconPath: IconPath): URI { if (iconPath && iconPath['dark']) { return getIconUri(iconPath['dark']); } @@ -53,6 +53,6 @@ function getIconUri(iconPath: string | URI): URI { } } -export function getIconKey(iconPath: IUserFriendlyIcon): string { +export function getIconKey(iconPath: IconPath): string { return getLightIconUri(iconPath).toString(true) + getDarkIconUri(iconPath)?.toString(true); } diff --git a/src/sql/workbench/browser/modelComponents/tabbedPanel.component.ts b/src/sql/workbench/browser/modelComponents/tabbedPanel.component.ts index b989634e5e..6443b72990 100644 --- a/src/sql/workbench/browser/modelComponents/tabbedPanel.component.ts +++ b/src/sql/workbench/browser/modelComponents/tabbedPanel.component.ts @@ -8,7 +8,7 @@ import { NavigationBarLayout, PanelComponent } from 'sql/base/browser/ui/panel/p import { TabType } from 'sql/base/browser/ui/panel/tab.component'; import { ContainerBase, ItemDescriptor } from 'sql/workbench/browser/modelComponents/componentBase'; import { ComponentEventType, IComponent, IComponentDescriptor, IModelStore, ModelViewAction } from 'sql/platform/dashboard/browser/interfaces'; -import { IUserFriendlyIcon, createIconCssClass } from 'sql/workbench/browser/modelComponents/iconUtils'; +import { IconPath, createIconCssClass } from 'sql/workbench/browser/modelComponents/iconUtils'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { attachTabbedPanelStyler } from 'sql/workbench/common/styler'; import { TabbedPanelLayout } from 'azdata'; @@ -18,7 +18,7 @@ export interface TabConfig { title: string; id?: string; group: string; - icon?: IUserFriendlyIcon; + icon?: IconPath; } interface Tab { diff --git a/src/sql/workbench/browser/modelComponents/table.component.ts b/src/sql/workbench/browser/modelComponents/table.component.ts index cd9c52ddba..e4ee2a9e23 100644 --- a/src/sql/workbench/browser/modelComponents/table.component.ts +++ b/src/sql/workbench/browser/modelComponents/table.component.ts @@ -28,7 +28,7 @@ import { isUndefinedOrNull } from 'vs/base/common/types'; import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType, ModelViewAction } from 'sql/platform/dashboard/browser/interfaces'; import { convertSizeToNumber } from 'sql/base/browser/dom'; import { ButtonCellValue, ButtonColumn } from 'sql/base/browser/ui/table/plugins/buttonColumn.plugin'; -import { IUserFriendlyIcon, createIconCssClass, getIconKey } from 'sql/workbench/browser/modelComponents/iconUtils'; +import { IconPath, createIconCssClass, getIconKey } from 'sql/workbench/browser/modelComponents/iconUtils'; import { HeaderFilter } from 'sql/base/browser/ui/table/plugins/headerFilter.plugin'; import { onUnexpectedError } from 'vs/base/common/errors'; import { ILogService } from 'vs/platform/log/common/log'; @@ -207,7 +207,7 @@ export default class TableComponent extends ComponentBase(col.options ? (col.options).icon : col.icon); + const icon = (col.options ? (col.options).icon : col.icon); this._buttonColumns[col.value] = new ButtonColumn({ title: col.value, iconCssClass: icon ? this.createIconCssClassInternal(icon) : undefined,