add custom width support for dialogs (#10641)

* add custom width support for dialogs

* comments

* fix test
This commit is contained in:
Alan Ren
2020-06-03 13:08:48 -07:00
committed by GitHub
parent 2e4aee944c
commit c4be667567
12 changed files with 123 additions and 33 deletions

View File

@@ -10,12 +10,13 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { MainThreadModelViewDialogShape, SqlMainContext, ExtHostModelViewDialogShape, SqlExtHostContext } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { Dialog, DialogTab, DialogButton, WizardPage, Wizard } from 'sql/workbench/services/dialog/common/dialogTypes';
import { CustomDialogService } from 'sql/workbench/services/dialog/browser/customDialogService';
import { CustomDialogService, DefaultWizardOptions, DefaultDialogOptions } from 'sql/workbench/services/dialog/browser/customDialogService';
import { IModelViewDialogDetails, IModelViewTabDetails, IModelViewButtonDetails, IModelViewWizardPageDetails, IModelViewWizardDetails } from 'sql/workbench/api/common/sqlExtHostTypes';
import { ModelViewInput, ModelViewInputModel, ModeViewSaveHandler } from 'sql/workbench/browser/modelComponents/modelViewInput';
import * as vscode from 'vscode';
import * as azdata from 'azdata';
import { assign } from 'vs/base/common/objects';
@extHostNamedCustomer(SqlMainContext.MainThreadModelViewDialog)
export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape {
@@ -67,7 +68,9 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
public $openDialog(handle: number, dialogName?: string): Thenable<void> {
let dialog = this.getDialog(handle);
this._dialogService.showDialog(dialog, dialogName, { hasBackButton: false, isWide: dialog.isWide, hasErrors: true });
const options = assign({}, DefaultDialogOptions);
options.width = dialog.width;
this._dialogService.showDialog(dialog, dialogName, options);
return Promise.resolve();
}
@@ -91,7 +94,7 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
}
dialog.title = details.title;
dialog.isWide = details.isWide;
dialog.width = details.width;
if (details.content && typeof details.content !== 'string') {
dialog.content = details.content.map(tabHandle => this.getTab(tabHandle));
} else {
@@ -163,6 +166,7 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
let wizard = this._wizards.get(handle);
if (!wizard) {
wizard = new Wizard(details.title);
wizard.width = details.width;
wizard.backButton = this.getButton(details.backButton);
wizard.cancelButton = this.getButton(details.cancelButton);
wizard.generateScriptButton = this.getButton(details.generateScriptButton);
@@ -213,7 +217,9 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
public $openWizard(handle: number): Thenable<void> {
let wizard = this.getWizard(handle);
this._dialogService.showWizard(wizard);
const options = assign({}, DefaultWizardOptions);
options.width = wizard.width;
this._dialogService.showWizard(wizard, options);
return Promise.resolve();
}