mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
add link area support for text component (#4103)
* add link area support for text component * add comment for localizable resources * address comments
This commit is contained in:
@@ -32,15 +32,26 @@ export class SettingsPage extends WizardPageBase<CreateClusterModel> {
|
|||||||
let dockerSettingsGroup = view.modelBuilder.groupContainer().withItems([]).withLayout({ header: localize('bdc-create.DockerSettingsText', 'Docker Settings'), collapsible: true }).component();
|
let dockerSettingsGroup = view.modelBuilder.groupContainer().withItems([]).withLayout({ header: localize('bdc-create.DockerSettingsText', 'Docker Settings'), collapsible: true }).component();
|
||||||
|
|
||||||
let acceptEulaCheckbox = view.modelBuilder.checkBox().component();
|
let acceptEulaCheckbox = view.modelBuilder.checkBox().component();
|
||||||
acceptEulaCheckbox.label = localize('bdc-create.AcceptEulaText', 'I accept the SQL Server EULA');
|
|
||||||
acceptEulaCheckbox.checked = false;
|
acceptEulaCheckbox.checked = false;
|
||||||
|
|
||||||
let eulaHyperlink = view.modelBuilder.hyperlink().withProperties({
|
let eulaLink: sqlops.LinkArea = {
|
||||||
label: localize('bdc-create.ViewEulaText', 'View Eula'),
|
text: localize('bdc-create.LicenseAgreementText', 'License Agreement'),
|
||||||
url: 'https://docs.microsoft.com/en-us/sql/getting-started/about-the-sql-server-license-terms?view=sql-server-2014'
|
url: 'https://docs.microsoft.com/en-us/sql/getting-started/about-the-sql-server-license-terms?view=sql-server-2014'
|
||||||
|
};
|
||||||
|
let privacyPolicyLink: sqlops.LinkArea = {
|
||||||
|
text: localize('bdc-create.PrivacyPolicyText', 'Privacy Policy'),
|
||||||
|
url: 'https://privacy.microsoft.com/en-us/privacystatement'
|
||||||
|
};
|
||||||
|
|
||||||
|
let checkboxText = view.modelBuilder.text().withProperties<sqlops.TextComponentProperties>({
|
||||||
|
value: localize({
|
||||||
|
key: 'bdc-create.AcceptTermsText',
|
||||||
|
comment: ['{0} is the place holder for License Agreement, {1} is the place holder for Privacy Policy']
|
||||||
|
}, 'I accept the {0} and {1}.'),
|
||||||
|
links: [eulaLink, privacyPolicyLink]
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
let eulaContainer = this.createRow(view, [acceptEulaCheckbox, eulaHyperlink]);
|
let eulaContainer = this.createRow(view, [acceptEulaCheckbox, checkboxText]);
|
||||||
|
|
||||||
let form = formBuilder.withFormItems([
|
let form = formBuilder.withFormItems([
|
||||||
{
|
{
|
||||||
@@ -71,6 +82,6 @@ export class SettingsPage extends WizardPageBase<CreateClusterModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private createRow(view: sqlops.ModelView, items: sqlops.Component[]): sqlops.FlexContainer {
|
private createRow(view: sqlops.ModelView, items: sqlops.Component[]): sqlops.FlexContainer {
|
||||||
return view.modelBuilder.flexContainer().withItems(items, { CSSStyles: { 'margin-right': '10px' } }).withLayout({ flexFlow: 'row', alignItems: 'baseline' }).component();
|
return view.modelBuilder.flexContainer().withItems(items, { CSSStyles: { 'margin-right': '5px' } }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import 'vs/css!./radioButton';
|
import 'vs/css!./radioButton';
|
||||||
import {
|
import {
|
||||||
Component, Input, Inject, ChangeDetectorRef, forwardRef,
|
Component, Input, Inject, ChangeDetectorRef, forwardRef,
|
||||||
OnDestroy, AfterViewInit, ElementRef
|
OnDestroy, AfterViewInit, ElementRef, SecurityContext
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import * as sqlops from 'sqlops';
|
import * as sqlops from 'sqlops';
|
||||||
@@ -14,11 +14,12 @@ import * as sqlops from 'sqlops';
|
|||||||
import { ComponentBase } from 'sql/parts/modelComponents/componentBase';
|
import { ComponentBase } from 'sql/parts/modelComponents/componentBase';
|
||||||
import { IComponent, IComponentDescriptor, IModelStore } from 'sql/parts/modelComponents/interfaces';
|
import { IComponent, IComponentDescriptor, IModelStore } from 'sql/parts/modelComponents/interfaces';
|
||||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||||
|
import { SafeHtml, DomSanitizer } from '@angular/platform-browser';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'modelview-text',
|
selector: 'modelview-text',
|
||||||
template: `
|
template: `
|
||||||
<p [style.width]="getWidth()">{{getValue()}}</p>`
|
<p [style.width]="getWidth()" [innerHTML]="getValue()"></p>`
|
||||||
})
|
})
|
||||||
export default class TextComponent extends ComponentBase implements IComponent, OnDestroy, AfterViewInit {
|
export default class TextComponent extends ComponentBase implements IComponent, OnDestroy, AfterViewInit {
|
||||||
@Input() descriptor: IComponentDescriptor;
|
@Input() descriptor: IComponentDescriptor;
|
||||||
@@ -27,7 +28,8 @@ export default class TextComponent extends ComponentBase implements IComponent,
|
|||||||
constructor(
|
constructor(
|
||||||
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
|
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
|
||||||
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
|
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
|
||||||
@Inject(forwardRef(() => ElementRef)) el: ElementRef) {
|
@Inject(forwardRef(() => ElementRef)) el: ElementRef,
|
||||||
|
@Inject(forwardRef(() => DomSanitizer)) private _domSanitizer: DomSanitizer) {
|
||||||
super(changeRef, el);
|
super(changeRef, el);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +59,16 @@ export default class TextComponent extends ComponentBase implements IComponent,
|
|||||||
return this.getPropertyOrDefault<sqlops.TextComponentProperties, string>((props) => props.value, '');
|
return this.getPropertyOrDefault<sqlops.TextComponentProperties, string>((props) => props.value, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public getValue(): string {
|
public getValue(): SafeHtml {
|
||||||
return this.value;
|
let links = this.getPropertyOrDefault<sqlops.TextComponentProperties, sqlops.LinkArea[]>((props) => props.links, []);
|
||||||
|
let text = this._domSanitizer.sanitize(SecurityContext.HTML, this.value);
|
||||||
|
if (links.length !== 0) {
|
||||||
|
for (let i: number = 0; i < links.length; i++) {
|
||||||
|
let link = links[i];
|
||||||
|
let linkTag = `<a href="${this._domSanitizer.sanitize(SecurityContext.URL, link.url)}" tabIndex="0" target="blank">${this._domSanitizer.sanitize(SecurityContext.HTML, link.text)}</a>`;
|
||||||
|
text = text.replace(`{${i}}`, linkTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
src/sql/sqlops.proposed.d.ts
vendored
6
src/sql/sqlops.proposed.d.ts
vendored
@@ -543,6 +543,12 @@ declare module 'sqlops' {
|
|||||||
|
|
||||||
export interface TextComponentProperties {
|
export interface TextComponentProperties {
|
||||||
value?: string;
|
value?: string;
|
||||||
|
links?: LinkArea[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LinkArea {
|
||||||
|
text: string;
|
||||||
|
url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HyperlinkComponentProperties extends ComponentProperties {
|
export interface HyperlinkComponentProperties extends ComponentProperties {
|
||||||
|
|||||||
@@ -433,7 +433,6 @@ export function createApiFactory(
|
|||||||
return extHostModelViewDialog.createWizardPage(title);
|
return extHostModelViewDialog.createWizardPage(title);
|
||||||
},
|
},
|
||||||
createWizard(title: string): sqlops.window.Wizard {
|
createWizard(title: string): sqlops.window.Wizard {
|
||||||
console.warn('deprecated method');
|
|
||||||
return extHostModelViewDialog.createWizard(title);
|
return extHostModelViewDialog.createWizard(title);
|
||||||
},
|
},
|
||||||
MessageLevel: sqlExtHostTypes.MessageLevel
|
MessageLevel: sqlExtHostTypes.MessageLevel
|
||||||
|
|||||||
Reference in New Issue
Block a user