mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-12 03:51:37 -04:00
new component - infobox (#14027)
* new component: infobox * comments * new option * add comments
This commit is contained in:
@@ -271,6 +271,14 @@ class ModelBuilderImpl implements azdata.ModelBuilder {
|
||||
return builder;
|
||||
}
|
||||
|
||||
infoBox(): azdata.ComponentBuilder<azdata.InfoBoxComponent, azdata.InfoBoxComponentProperties> {
|
||||
let id = this.getNextComponentId();
|
||||
let builder: ComponentBuilderImpl<azdata.InfoBoxComponent, azdata.InfoBoxComponentProperties> = this.getComponentBuilder(new InfoBoxComponentWrapper(this._proxy, this._handle, id), id);
|
||||
|
||||
this._componentBuilders.set(id, builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
getComponentBuilder<T extends azdata.Component, TPropertyBag extends azdata.ComponentProperties>(component: ComponentWrapper, id: string): ComponentBuilderImpl<T, TPropertyBag> {
|
||||
let componentBuilder: ComponentBuilderImpl<T, TPropertyBag> = new ComponentBuilderImpl<T, TPropertyBag>(component);
|
||||
this._componentBuilders.set(id, componentBuilder);
|
||||
@@ -1984,6 +1992,37 @@ class PropertiesContainerComponentWrapper extends ComponentWrapper implements az
|
||||
}
|
||||
}
|
||||
|
||||
class InfoBoxComponentWrapper extends ComponentWrapper implements azdata.InfoBoxComponent {
|
||||
constructor(proxy: MainThreadModelViewShape, handle: number, id: string) {
|
||||
super(proxy, handle, ModelComponentTypes.InfoBox, id);
|
||||
this.properties = {};
|
||||
}
|
||||
|
||||
public get style(): azdata.InfoBoxStyle {
|
||||
return this.properties['style'];
|
||||
}
|
||||
|
||||
public set style(v: azdata.InfoBoxStyle) {
|
||||
this.setProperty('style', v);
|
||||
}
|
||||
|
||||
public get text(): string {
|
||||
return this.properties['text'];
|
||||
}
|
||||
|
||||
public set text(v: string) {
|
||||
this.setProperty('text', v);
|
||||
}
|
||||
|
||||
public get announceText(): boolean {
|
||||
return this.properties['announceText'];
|
||||
}
|
||||
|
||||
public set announceText(v: boolean) {
|
||||
this.setProperty('announceText', v);
|
||||
}
|
||||
}
|
||||
|
||||
class GroupContainerComponentWrapper extends ComponentWrapper implements azdata.GroupContainer {
|
||||
constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string) {
|
||||
super(proxy, handle, type, id);
|
||||
|
||||
@@ -177,7 +177,8 @@ export enum ModelComponentTypes {
|
||||
ListView,
|
||||
TabbedPanel,
|
||||
Separator,
|
||||
PropertiesContainer
|
||||
PropertiesContainer,
|
||||
InfoBox
|
||||
}
|
||||
|
||||
export enum ModelViewAction {
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import {
|
||||
Component, Input, Inject, ChangeDetectorRef, forwardRef,
|
||||
OnDestroy, AfterViewInit, ElementRef, ViewChild
|
||||
} from '@angular/core';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { IComponent, IComponentDescriptor, IModelStore } from 'sql/platform/dashboard/browser/interfaces';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ComponentBase } from 'sql/workbench/browser/modelComponents/componentBase';
|
||||
import { InfoBox, InfoBoxStyle } from 'sql/base/browser/ui/infoBox/infoBox';
|
||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import { attachInfoBoxStyler } from 'sql/platform/theme/common/styler';
|
||||
|
||||
@Component({
|
||||
selector: 'modelview-infobox',
|
||||
template: `
|
||||
<div #container>
|
||||
</div>`
|
||||
})
|
||||
export default class InfoBoxComponent extends ComponentBase<azdata.InfoBoxComponentProperties> implements IComponent, OnDestroy, AfterViewInit {
|
||||
@Input() descriptor: IComponentDescriptor;
|
||||
@Input() modelStore: IModelStore;
|
||||
@ViewChild('container', { read: ElementRef }) private _container: ElementRef;
|
||||
|
||||
private _infoBox: InfoBox;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => ElementRef)) el: ElementRef,
|
||||
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
|
||||
@Inject(ILogService) logService: ILogService) {
|
||||
super(changeRef, el, logService);
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.baseInit();
|
||||
if (this._container) {
|
||||
this._infoBox = new InfoBox(this._container.nativeElement);
|
||||
this._register(attachInfoBoxStyler(this._infoBox, this.themeService));
|
||||
this.updateInfoBox();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.baseDestroy();
|
||||
}
|
||||
|
||||
public setLayout(layout: any): void {
|
||||
this.layout();
|
||||
}
|
||||
|
||||
public setProperties(properties: { [key: string]: any; }): void {
|
||||
super.setProperties(properties);
|
||||
this.updateInfoBox();
|
||||
}
|
||||
|
||||
private updateInfoBox(): void {
|
||||
if (this._infoBox) {
|
||||
this._container.nativeElement.style.width = this.getWidth();
|
||||
this._container.nativeElement.style.height = this.getHeight();
|
||||
this._infoBox.announceText = this.announceText;
|
||||
this._infoBox.infoBoxStyle = this.style;
|
||||
this._infoBox.text = this.text;
|
||||
}
|
||||
}
|
||||
|
||||
public get style(): InfoBoxStyle {
|
||||
return this.getPropertyOrDefault<InfoBoxStyle>((props) => props.style, 'information');
|
||||
}
|
||||
|
||||
public get text(): string {
|
||||
return this.getPropertyOrDefault<string>((props) => props.text, '');
|
||||
}
|
||||
|
||||
public get announceText(): boolean {
|
||||
return this.getPropertyOrDefault<boolean>((props) => props.announceText, false);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import SeparatorComponent from 'sql/workbench/browser/modelComponents/separator.
|
||||
import { ModelComponentTypes } from 'sql/platform/dashboard/browser/interfaces';
|
||||
import PropertiesContainerComponent from 'sql/workbench/browser/modelComponents/propertiesContainer.component';
|
||||
import ListViewComponent from 'sql/workbench/browser/modelComponents/listView.component';
|
||||
import InfoBoxComponent from 'sql/workbench/browser/modelComponents/infoBox.component';
|
||||
|
||||
export const DIV_CONTAINER = 'div-container';
|
||||
registerComponentType(DIV_CONTAINER, ModelComponentTypes.DivContainer, DivContainer);
|
||||
@@ -126,3 +127,6 @@ registerComponentType(SEPARATOR_COMPONENT, ModelComponentTypes.Separator, Separa
|
||||
|
||||
export const PROPERTIESCONTAINER_COMPONENT = 'propertiescontainer-component';
|
||||
registerComponentType(PROPERTIESCONTAINER_COMPONENT, ModelComponentTypes.PropertiesContainer, PropertiesContainerComponent);
|
||||
|
||||
export const INFOBOX_COMPONENT = 'infobox-component';
|
||||
registerComponentType(INFOBOX_COMPONENT, ModelComponentTypes.InfoBox, InfoBoxComponent);
|
||||
|
||||
Reference in New Issue
Block a user