diff --git a/extensions/mssql/config.json b/extensions/mssql/config.json index db43334716..e3aa081b31 100644 --- a/extensions/mssql/config.json +++ b/extensions/mssql/config.json @@ -1,6 +1,6 @@ { "downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}", - "version": "4.3.0.10", + "version": "4.3.0.15", "downloadFileNames": { "Windows_86": "win-x86-net6.0.zip", "Windows_64": "win-x64-net6.0.zip", diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 6f36b3afe8..8d18cb9c90 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -1237,6 +1237,14 @@ declare module 'azdata' { * Format (mimeType) of the report */ mimeType: string; + /** + * Whether user confirmation is required, the default value is false. + */ + requireConfirmation?: boolean; + /** + * The confirmation text. + */ + confirmationText?: string; /** * The table schema validation error. */ diff --git a/src/sql/workbench/services/tableDesigner/browser/media/tableDesignerPublishDialog.css b/src/sql/workbench/services/tableDesigner/browser/media/tableDesignerPublishDialog.css index 5d02358cd2..9a14fc8ee1 100644 --- a/src/sql/workbench/services/tableDesigner/browser/media/tableDesignerPublishDialog.css +++ b/src/sql/workbench/services/tableDesigner/browser/media/tableDesignerPublishDialog.css @@ -6,6 +6,12 @@ .table-designer-publish-dialog { height: 350px; padding: 10px; + display: flex; + flex-direction: column; +} + +.table-designer-publish-dialog .report-container { + flex: 1 1 auto; overflow: scroll; user-select: text; } diff --git a/src/sql/workbench/services/tableDesigner/browser/tableDesignerComponentInput.ts b/src/sql/workbench/services/tableDesigner/browser/tableDesignerComponentInput.ts index ccdba64600..e80b028387 100644 --- a/src/sql/workbench/services/tableDesigner/browser/tableDesignerComponentInput.ts +++ b/src/sql/workbench/services/tableDesigner/browser/tableDesignerComponentInput.ts @@ -208,7 +208,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput { return; } const dialog = this._instantiationService.createInstance(TableDesignerPublishDialog); - const result = await dialog.open(previewReportResult.report, previewReportResult.mimeType); + const result = await dialog.open(previewReportResult); if (result === TableDesignerPublishDialogResult.GenerateScript) { await this.generateScript(); } else if (result === TableDesignerPublishDialogResult.UpdateDatabase) { diff --git a/src/sql/workbench/services/tableDesigner/browser/tableDesignerPublishDialog.ts b/src/sql/workbench/services/tableDesigner/browser/tableDesignerPublishDialog.ts index 4a0ef42fa9..4c4b2d44c3 100644 --- a/src/sql/workbench/services/tableDesigner/browser/tableDesignerPublishDialog.ts +++ b/src/sql/workbench/services/tableDesigner/browser/tableDesignerPublishDialog.ts @@ -21,6 +21,9 @@ 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'; +import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox'; +import * as azdata from 'azdata'; +import { attachCheckboxStyler } from 'sql/platform/theme/common/styler'; const OkText: string = localize('tableDesigner.UpdateDatabase', "Update Database"); const CancelText: string = localize('tableDesigner.cancel', "Cancel"); @@ -34,8 +37,7 @@ export enum TableDesignerPublishDialogResult { export class TableDesignerPublishDialog extends Modal { - private _report?: string; - private _mimeType: string = Mimes.text; + private _report?: azdata.designers.GeneratePreviewReportResult; private _okButton?: Button; private _generateScriptButton?: Button; private _cancelButton?: Button; @@ -56,9 +58,8 @@ export class TableDesignerPublishDialog extends Modal { this._markdownRenderer = instantiationService.createInstance(MarkdownRenderer, {}); } - public open(report: string, mimeType: string = Mimes.text): Promise { + public open(report: azdata.designers.GeneratePreviewReportResult): Promise { this._report = report; - this._mimeType = mimeType; this.render(); this.show(); const promise = new Promise((resolve) => { @@ -74,6 +75,9 @@ export class TableDesignerPublishDialog extends Modal { this._okButton = this.addFooterButton(OkText, () => this.handleOkButtonClick()); this._generateScriptButton = this.addFooterButton(GenerateScriptText, () => this.handleGenerateScriptButtonClick(), 'right', true); this._cancelButton = this.addFooterButton(CancelText, () => this.handleCancelButtonClick(), 'right', true); + const requireConfirmation = this._report.requireConfirmation === true; + this._okButton.enabled = !requireConfirmation; + this._generateScriptButton.enabled = !requireConfirmation; this._register(attachButtonStyler(this._okButton, this._themeService)); this._register(attachButtonStyler(this._generateScriptButton, this._themeService)); this._register(attachButtonStyler(this._cancelButton, this._themeService)); @@ -81,12 +85,25 @@ export class TableDesignerPublishDialog extends Modal { protected renderBody(container: HTMLElement) { const body = DOM.append(container, DOM.$('.table-designer-publish-dialog')); - if (this._mimeType === Mimes.markdown) { - const markdownElement = this._markdownRenderer.render({ value: this._report }).element; - DOM.append(body, markdownElement); + const reportContainer = DOM.append(body, DOM.$('.report-container')); + if (this._report.mimeType === Mimes.markdown) { + const markdownElement = this._markdownRenderer.render({ value: this._report.report }).element; + DOM.append(reportContainer, markdownElement); } else { // default to plain text - body.innerText = this._report; + reportContainer.innerText = this._report.report; + } + if (this._report.requireConfirmation && this._report.confirmationText) { + const checkboxContainer = DOM.append(body, DOM.$('div')); + const checkbox = new Checkbox(checkboxContainer, { + label: this._report.confirmationText, + checked: false + }); + this._register(checkbox.onChange((checked) => { + this._okButton.enabled = checked; + this._generateScriptButton.enabled = checked; + })); + this._register(attachCheckboxStyler(checkbox, this._themeService)); } }