add ability for md + text reports (#18667)

* add ability for md + text reports

* change report type

* re add types for ads

* match fields and add enum for mimetype

* rename preview report

* update type

* rename generate report type

* fix comment
This commit is contained in:
Aditya Bist
2022-03-09 15:48:21 -08:00
committed by GitHub
parent e50bded5d1
commit 822199c9be
8 changed files with 31 additions and 12 deletions

View File

@@ -178,10 +178,10 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
sticky: true
});
let report;
let previewReportResult: azdata.designers.GeneratePreviewReportResult;
try {
this.updateState(this.valid, this.dirty, 'generateReport');
report = await this._provider.generatePreviewReport(this.tableInfo);
previewReportResult = await this._provider.generatePreviewReport(this.tableInfo);
reportNotificationHandle.close();
this.updateState(this.valid, this.dirty);
} catch (error) {
@@ -190,7 +190,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
return;
}
const dialog = this._instantiationService.createInstance(TableDesignerPublishDialog);
const result = await dialog.open(<any>report.report);
const result = await dialog.open(previewReportResult.report, previewReportResult.mimeType);
if (result === TableDesignerPublishDialogResult.GenerateScript) {
await this.generateScript();
} else if (result === TableDesignerPublishDialogResult.UpdateDatabase) {

View File

@@ -20,6 +20,7 @@ import { attachModalDialogStyler } from 'sql/workbench/common/styler';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { MarkdownRenderer } from 'vs/editor/browser/core/markdownRenderer';
import { Mimes } from 'vs/base/common/mime';
const OkText: string = localize('tableDesigner.UpdateDatabase', "Update Database");
const CancelText: string = localize('tableDesigner.cancel', "Cancel");
@@ -34,6 +35,7 @@ export enum TableDesignerPublishDialogResult {
export class TableDesignerPublishDialog extends Modal {
private _report?: string;
private _mimeType: string = Mimes.text;
private _okButton?: Button;
private _generateScriptButton?: Button;
private _cancelButton?: Button;
@@ -54,8 +56,9 @@ export class TableDesignerPublishDialog extends Modal {
this._markdownRenderer = instantiationService.createInstance(MarkdownRenderer, {});
}
public open(report: string): Promise<TableDesignerPublishDialogResult> {
public open(report: string, mimeType: string = Mimes.text): Promise<TableDesignerPublishDialogResult> {
this._report = report;
this._mimeType = mimeType;
this.render();
this.show();
const promise = new Promise<TableDesignerPublishDialogResult>((resolve) => {
@@ -78,8 +81,13 @@ export class TableDesignerPublishDialog extends Modal {
protected renderBody(container: HTMLElement) {
const body = DOM.append(container, DOM.$('.table-designer-publish-dialog'));
const markdownElement = this._markdownRenderer.render({ value: this._report }).element;
DOM.append(body, markdownElement);
if (this._mimeType === Mimes.markdown) {
const markdownElement = this._markdownRenderer.render({ value: this._report }).element;
DOM.append(body, markdownElement);
} else {
// default to plain text
body.innerText = this._report;
}
}
protected layout(height?: number): void {