Files
azuredatastudio/extensions/resource-deployment/src/ui/wizardBase.ts
Arvind Ranasaria 4dd6db57ee Feat/tool install master merge back to master (#7819)
* add install tools button (#7454)

* add install tools button

* address comments

* remove description for install tools hint message

* First working version of AutoDeployment of tools (#7647)

First working version of AutoDeployment of tools.

This pull request adds feature to install the tools needed for doing BDC/TINA deployments.

This has been tested so far only on win32 and testing on other platforms is in progress.

* removing TODO and redundant code

* Not localizing azuredatastudio product name

* convert methods returning Promises to async-await

* changing from null to undefined

* Localize all the command labels

* using existing sudo-prompt typings

* progres/error status in ModalDialogue && PR fixes

* review feedback to change warning to information

* revert settings.json changes

* fix resource-Deployment Extension Unit Test

* ensuring platform service's working directory

* incorporate review feedback

* review feedback

* addressing PR feedback

* PR fixes

* PR Feedback

* remove debug logs

* disable UI deployment containers when installing

* addding data type to stdout/stderr messaging

* remove commented code

* revert accidental change

* addressing review feedback

* fix failed install with zero exit code

* fixing bug due to typo

* fixes for linux

* Misc fixes during mac testing

* PR fixes
2019-10-18 23:17:21 -07:00

91 lines
2.6 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';
const localize = nls.loadMessageBundle();
export abstract class WizardBase<T, M extends Model> {
private customButtons: azdata.window.Button[] = [];
private pages: WizardPageBase<T>[] = [];
public wizardObject: azdata.window.Wizard;
public toDispose: vscode.Disposable[] = [];
public get model(): M {
return this._model;
}
constructor(private title: string, private _model: M) {
this.wizardObject = azdata.window.createWizard(title);
}
public open(): Thenable<void> {
this.initialize();
this.wizardObject.customButtons = this.customButtons;
this.toDispose.push(this.wizardObject.onPageChanged((e) => {
let previousPage = this.pages[e.lastPage];
let newPage = this.pages[e.newPage];
previousPage.onLeave();
newPage.onEnter();
}));
this.toDispose.push(this.wizardObject.doneButton.onClick(() => {
this.onOk();
this.dispose();
}));
this.toDispose.push(this.wizardObject.cancelButton.onClick(() => {
this.onCancel();
this.dispose();
}));
return this.wizardObject.open().then(() => {
if (this.pages && this.pages.length > 0) {
this.pages[0].onEnter();
}
});
}
protected abstract initialize(): void;
protected abstract onOk(): void;
protected abstract onCancel(): void;
public addButton(button: azdata.window.Button) {
this.customButtons.push(button);
}
protected setPages(pages: WizardPageBase<T>[]) {
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);
}
}