mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-26 17:23:15 -05:00
* controller dropdown field to SQL MIAA and Postgres deployment. (#12217) * saving first draft * throw if no controllers * cleanup * bug fixes * bug fixes and caching controller access * pr comments and bug fixes. * fixes * fixes * comment fix * remove debug prints * comment fixes * remove debug logs * inputValueTransformer returns string|Promise * PR feedback * pr fixes * remove _ from protected fields * anonymous to full methods * small fixes (cherry picked from commit9cf80113fc) * fix option sources (#12387) (cherry picked from commitfca8b85a72) * Remove azdata eula acceptance from arc deployments (#12292) * saving to switch tasks * activate to exports in extApi * working version - cleanup pending * improve messages * apply pr feedback from a different review * remove unneeded strings * redo apiService * remove async from getVersionFromOutput * remove _ prefix from protected fields * error message fix * throw specif errors from azdata extension * arrow methods to regular methods * pr feedback * expand azdata extension api * pr feedback * remove unused var * pr feedback (cherry picked from commitba44a2f02e) Co-authored-by: Arvind Ranasaria <ranasaria@outlook.com>
90 lines
2.7 KiB
TypeScript
90 lines
2.7 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as azdata from 'azdata';
|
|
import * as vscode from 'vscode';
|
|
import * as nls from 'vscode-nls';
|
|
import { WizardPageBase } from './wizardPageBase';
|
|
import { Model } from './model';
|
|
import { IToolsService } from '../services/toolsService';
|
|
const localize = nls.loadMessageBundle();
|
|
|
|
export abstract class WizardBase<T, P extends WizardPageBase<T>, M extends Model> {
|
|
private customButtons: azdata.window.Button[] = [];
|
|
public pages: P[] = [];
|
|
|
|
public wizardObject: azdata.window.Wizard;
|
|
public toDispose: vscode.Disposable[] = [];
|
|
public get model(): M {
|
|
return this._model;
|
|
}
|
|
|
|
constructor(private title: string, private _model: M, public toolsService: IToolsService) {
|
|
this.wizardObject = azdata.window.createWizard(title);
|
|
}
|
|
|
|
public async open(): Promise<void> {
|
|
this.initialize();
|
|
this.wizardObject.customButtons = this.customButtons;
|
|
this.toDispose.push(this.wizardObject.onPageChanged(async (e) => {
|
|
let previousPage = this.pages[e.lastPage];
|
|
let newPage = this.pages[e.newPage];
|
|
await previousPage.onLeave();
|
|
await newPage.onEnter();
|
|
}));
|
|
|
|
this.toDispose.push(this.wizardObject.doneButton.onClick(async () => {
|
|
await this.onOk();
|
|
this.dispose();
|
|
}));
|
|
this.toDispose.push(this.wizardObject.cancelButton.onClick(() => {
|
|
this.onCancel();
|
|
this.dispose();
|
|
}));
|
|
|
|
await this.wizardObject.open();
|
|
if (this.pages && this.pages.length > 0) {
|
|
await this.pages[0].onEnter();
|
|
}
|
|
}
|
|
|
|
protected abstract initialize(): void;
|
|
protected abstract async onOk(): Promise<void>;
|
|
protected abstract onCancel(): void;
|
|
|
|
public addButton(button: azdata.window.Button) {
|
|
this.customButtons.push(button);
|
|
}
|
|
|
|
protected setPages(pages: P[]) {
|
|
this.wizardObject!.pages = pages.map(p => p.pageObject);
|
|
this.pages = pages;
|
|
this.pages.forEach((page) => {
|
|
page.initialize();
|
|
});
|
|
}
|
|
|
|
private dispose() {
|
|
let errorOccurred = false;
|
|
this.toDispose.forEach((disposable: vscode.Disposable) => {
|
|
try {
|
|
disposable.dispose();
|
|
}
|
|
catch (error) {
|
|
errorOccurred = true;
|
|
console.error(error);
|
|
}
|
|
});
|
|
|
|
if (errorOccurred) {
|
|
vscode.window.showErrorMessage(localize('resourceDeployment.DisposableError', "Error occurred while closing the wizard: {0}, open 'Debugger Console' for more information."), this.title);
|
|
}
|
|
}
|
|
|
|
public registerDisposable(disposable: vscode.Disposable): void {
|
|
this.toDispose.push(disposable);
|
|
}
|
|
}
|