mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Add TextType property (#16421)
This commit is contained in:
@@ -68,7 +68,7 @@ export class RadioGroupLoadingComponentBuilder implements azdata.ComponentBuilde
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
const errorLoadingRadioOptionsLabel = this._view!.modelBuilder.text().withProps({ value: getErrorMessage(e), CSSStyles: { 'color': 'Red' } }).component();
|
const errorLoadingRadioOptionsLabel = this._view!.modelBuilder.text().withProps({ value: getErrorMessage(e), textType: azdata.TextType.Error }).component();
|
||||||
this._optionsDivContainer.addItem(errorLoadingRadioOptionsLabel);
|
this._optionsDivContainer.addItem(errorLoadingRadioOptionsLabel);
|
||||||
}
|
}
|
||||||
this.component().loading = false;
|
this.component().loading = false;
|
||||||
|
|||||||
12
src/sql/azdata.proposed.d.ts
vendored
12
src/sql/azdata.proposed.d.ts
vendored
@@ -580,12 +580,24 @@ declare module 'azdata' {
|
|||||||
*/
|
*/
|
||||||
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of text this is - used to determine display color.
|
||||||
|
*/
|
||||||
|
export enum TextType {
|
||||||
|
Normal = 'Normal',
|
||||||
|
Error = 'Error'
|
||||||
|
}
|
||||||
|
|
||||||
export interface TextComponentProperties {
|
export interface TextComponentProperties {
|
||||||
/**
|
/**
|
||||||
* The heading level for this component - if set the text component will be created as an h#
|
* The heading level for this component - if set the text component will be created as an h#
|
||||||
* HTML element with this value being the #.
|
* HTML element with this value being the #.
|
||||||
*/
|
*/
|
||||||
headingLevel?: HeadingLevel;
|
headingLevel?: HeadingLevel;
|
||||||
|
/**
|
||||||
|
* The type to display the text as - used to determine the color of the text. Default is Normal.
|
||||||
|
*/
|
||||||
|
textType?: TextType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace nb {
|
export namespace nb {
|
||||||
|
|||||||
@@ -1377,6 +1377,13 @@ class TextComponentWrapper extends ComponentWrapper implements azdata.TextCompon
|
|||||||
public set headingLevel(headingLevel: azdata.HeadingLevel | undefined) {
|
public set headingLevel(headingLevel: azdata.HeadingLevel | undefined) {
|
||||||
this.setProperty('headingLevel', headingLevel);
|
this.setProperty('headingLevel', headingLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get textType(): azdata.TextType | undefined {
|
||||||
|
return this.properties['textType'];
|
||||||
|
}
|
||||||
|
public set textType(type: azdata.TextType | undefined) {
|
||||||
|
this.setProperty('textType', type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageComponentWrapper extends ComponentWithIconWrapper implements azdata.ImageComponentProperties {
|
class ImageComponentWrapper extends ComponentWithIconWrapper implements azdata.ImageComponentProperties {
|
||||||
|
|||||||
@@ -610,7 +610,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
|||||||
ColumnSizingMode: sqlExtHostTypes.ColumnSizingMode,
|
ColumnSizingMode: sqlExtHostTypes.ColumnSizingMode,
|
||||||
DatabaseEngineEdition: sqlExtHostTypes.DatabaseEngineEdition,
|
DatabaseEngineEdition: sqlExtHostTypes.DatabaseEngineEdition,
|
||||||
TabOrientation: sqlExtHostTypes.TabOrientation,
|
TabOrientation: sqlExtHostTypes.TabOrientation,
|
||||||
sqlAssessment
|
sqlAssessment,
|
||||||
|
TextType: sqlExtHostTypes.TextType
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -887,3 +887,8 @@ export enum ButtonType {
|
|||||||
Normal = 'Normal',
|
Normal = 'Normal',
|
||||||
Informational = 'Informational'
|
Informational = 'Informational'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum TextType {
|
||||||
|
Normal = 'Normal',
|
||||||
|
Error = 'Error'
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,7 +18,15 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||||||
import * as DOM from 'vs/base/browser/dom';
|
import * as DOM from 'vs/base/browser/dom';
|
||||||
import { ILogService } from 'vs/platform/log/common/log';
|
import { ILogService } from 'vs/platform/log/common/log';
|
||||||
import { attachLinkStyler } from 'vs/platform/theme/common/styler';
|
import { attachLinkStyler } from 'vs/platform/theme/common/styler';
|
||||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
import { IColorTheme, ICssStyleCollector, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||||
|
import { errorForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||||
|
|
||||||
|
export enum TextType {
|
||||||
|
Normal = 'Normal',
|
||||||
|
Error = 'Error'
|
||||||
|
}
|
||||||
|
|
||||||
|
const errorTextClass = 'error-text';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'modelview-text',
|
selector: 'modelview-text',
|
||||||
@@ -97,9 +105,22 @@ export default class TextComponent extends TitledComponent<azdata.TextComponentP
|
|||||||
this.setPropertyFromUI<azdata.HeadingLevel | undefined>((properties, value) => { properties.headingLevel = value; }, newValue);
|
this.setPropertyFromUI<azdata.HeadingLevel | undefined>((properties, value) => { properties.headingLevel = value; }, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get textType(): azdata.TextType | undefined {
|
||||||
|
return this.getPropertyOrDefault<azdata.TextType | undefined>(props => props.textType, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
public set textType(newValue: azdata.TextType | undefined) {
|
||||||
|
this.setPropertyFromUI<azdata.TextType | undefined>((properties, value) => { properties.textType = value; }, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
public override setProperties(properties: { [key: string]: any; }): void {
|
public override setProperties(properties: { [key: string]: any; }): void {
|
||||||
super.setProperties(properties);
|
super.setProperties(properties);
|
||||||
this.updateText();
|
this.updateText();
|
||||||
|
if (this.textType === TextType.Error) {
|
||||||
|
(this._el.nativeElement as HTMLElement).classList.add(errorTextClass);
|
||||||
|
} else {
|
||||||
|
(this._el.nativeElement as HTMLElement).classList.remove(errorTextClass);
|
||||||
|
}
|
||||||
this._changeRef.detectChanges();
|
this._changeRef.detectChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,3 +195,14 @@ export default class TextComponent extends TitledComponent<azdata.TextComponentP
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {
|
||||||
|
const errorForegroundColor = theme.getColor(errorForeground);
|
||||||
|
if (errorForegroundColor) {
|
||||||
|
collector.addRule(`
|
||||||
|
modelview-text.${errorTextClass} {
|
||||||
|
color: ${errorForegroundColor};
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user