Added clickable more info links to designer validation issues (#19365)

* added clickable more info links to designer validation issues

* fix selection issue

* remove more info if none

* change quote style

* clear the dom node
This commit is contained in:
Aditya Bist
2022-05-13 13:35:22 -07:00
committed by GitHub
parent 8352c7631c
commit 128767c713
4 changed files with 33 additions and 5 deletions

View File

@@ -983,7 +983,6 @@ export class Designer extends Disposable implements IThemable {
table.onBlur((e) => { table.onBlur((e) => {
currentTableActions.forEach(a => a.updateState()); currentTableActions.forEach(a => a.updateState());
table.grid.setSelectedRows([]); table.grid.setSelectedRows([]);
table.grid.resetActiveCell();
}); });
component = table; component = table;
break; break;

View File

@@ -15,6 +15,8 @@ import { IColorTheme, ICssStyleCollector, IThemeService, registerThemingParticip
import { attachListStyler } from 'vs/platform/theme/common/styler'; import { attachListStyler } from 'vs/platform/theme/common/styler';
import { problemsErrorIconForeground, problemsInfoIconForeground, problemsWarningIconForeground } from 'vs/platform/theme/common/colorRegistry'; import { problemsErrorIconForeground, problemsInfoIconForeground, problemsWarningIconForeground } from 'vs/platform/theme/common/colorRegistry';
import { Codicon } from 'vs/base/common/codicons'; import { Codicon } from 'vs/base/common/codicons';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Link } from 'vs/platform/opener/browser/link';
export class DesignerIssuesTabPanelView extends Disposable implements IPanelView { export class DesignerIssuesTabPanelView extends Disposable implements IPanelView {
private _container: HTMLElement; private _container: HTMLElement;
@@ -23,13 +25,16 @@ export class DesignerIssuesTabPanelView extends Disposable implements IPanelView
public readonly onIssueSelected: Event<DesignerPropertyPath> = this._onIssueSelected.event; public readonly onIssueSelected: Event<DesignerPropertyPath> = this._onIssueSelected.event;
constructor(@IThemeService private _themeService: IThemeService) { constructor(
@IThemeService private _themeService: IThemeService,
@IInstantiationService private _instantiationService: IInstantiationService
) {
super(); super();
} }
render(container: HTMLElement): void { render(container: HTMLElement): void {
this._container = container.appendChild(DOM.$('.issues-container')); this._container = container.appendChild(DOM.$('.issues-container'));
this._issueList = new List<DesignerIssue>('designerIssueList', this._container, new DesignerIssueListDelegate(), [new TableFilterListRenderer()], { this._issueList = new List<DesignerIssue>('designerIssueList', this._container, new DesignerIssueListDelegate(), [this._instantiationService.createInstance(TableFilterListRenderer)], {
multipleSelectionSupport: false, multipleSelectionSupport: false,
keyboardSupport: true, keyboardSupport: true,
mouseSupport: true, mouseSupport: true,
@@ -87,14 +92,21 @@ class DesignerIssueListDelegate implements IListVirtualDelegate<DesignerIssue> {
interface DesignerIssueListItemTemplate { interface DesignerIssueListItemTemplate {
issueText: HTMLDivElement; issueText: HTMLDivElement;
issueIcon: HTMLDivElement; issueIcon: HTMLDivElement;
issueMoreInfoLink: HTMLDivElement;
} }
class TableFilterListRenderer implements IListRenderer<DesignerIssue, DesignerIssueListItemTemplate> { class TableFilterListRenderer implements IListRenderer<DesignerIssue, DesignerIssueListItemTemplate> {
constructor(
@IInstantiationService private _instantiationService: IInstantiationService
) { }
renderTemplate(container: HTMLElement): DesignerIssueListItemTemplate { renderTemplate(container: HTMLElement): DesignerIssueListItemTemplate {
const data: DesignerIssueListItemTemplate = Object.create(null); const data: DesignerIssueListItemTemplate = Object.create(null);
const issueItem = container.appendChild(DOM.$('.issue-item')); const issueItem = container.appendChild(DOM.$('.issue-item'));
data.issueIcon = issueItem.appendChild(DOM.$('')); data.issueIcon = issueItem.appendChild(DOM.$(''));
data.issueText = issueItem.appendChild(DOM.$('.issue-text')); data.issueText = issueItem.appendChild(DOM.$('.issue-text'));
data.issueMoreInfoLink = issueItem.appendChild(DOM.$('.issue-more-info'));
return data; return data;
} }
@@ -114,6 +126,15 @@ class TableFilterListRenderer implements IListRenderer<DesignerIssue, DesignerIs
break; break;
} }
templateData.issueIcon.className = `issue-icon ${iconClass}`; templateData.issueIcon.className = `issue-icon ${iconClass}`;
if (element.moreInfoLink) {
const linkElement = this._instantiationService.createInstance(Link, {
label: localize('designer.moreInfoLink', "More information"),
href: element.moreInfoLink
}, undefined);
templateData.issueMoreInfoLink.appendChild(linkElement.el);
} else {
DOM.clearNode(templateData.issueMoreInfoLink);
}
} }
public disposeTemplate(templateData: DesignerIssueListItemTemplate): void { public disposeTemplate(templateData: DesignerIssueListItemTemplate): void {

View File

@@ -239,7 +239,12 @@ export type DesignerPropertyPath = (string | number)[];
export const DesignerRootObjectPath: DesignerPropertyPath = []; export const DesignerRootObjectPath: DesignerPropertyPath = [];
export type DesignerIssueSeverity = 'error' | 'warning' | 'information'; export type DesignerIssueSeverity = 'error' | 'warning' | 'information';
export type DesignerIssue = { description: string, propertyPath?: DesignerPropertyPath, severity: DesignerIssueSeverity }; export type DesignerIssue = {
description: string,
propertyPath?: DesignerPropertyPath,
severity: DesignerIssueSeverity,
moreInfoLink?: string;
};
export interface DesignerEditResult { export interface DesignerEditResult {
isValid: boolean; isValid: boolean;

View File

@@ -46,12 +46,15 @@
} }
.designer-component .issues-container .issue-item .issue-text { .designer-component .issues-container .issue-item .issue-text {
flex: 1 1 auto;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
user-select: text; user-select: text;
} }
.designer-component .issues-container .issue-item .issue-more-info {
padding-left: 10px;
}
.designer-component .tabbed-panel-container { .designer-component .tabbed-panel-container {
flex: 1 1 auto; flex: 1 1 auto;
overflow: hidden; overflow: hidden;