mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 02:58:31 -05:00
Migrating other deployment wizards to the generic ResourceTypeWizard (#13132)
* SQL VM wizard migration to ResourceType Wizard * Revert "SQL VM wizard migration to ResourceType Wizard" This reverts commit e58cd47707a7e2812be20d915f1fe638b96b035f. * migrated notebook wizard * SQL VM wizard migration to ResourceType Wizard * Fixed some imports on SQL VM wizard * migrated sqldb wizard to generic ResourceTypeWizard * Added missing import Solving errors from the merge * Moved some common functionality into ResourceTypeWizard * Changed logic of start deployment * fixed some import after changing files.
This commit is contained in:
@@ -7,7 +7,7 @@ import * as nls from 'vscode-nls';
|
||||
|
||||
import { SubFieldInfo, FieldType, FontWeight, LabelPosition, SectionInfo } from '../../interfaces';
|
||||
import { createSection, DefaultInputWidth, DefaultLabelWidth, DefaultFieldAlignItems, DefaultFieldWidth, DefaultFieldHeight } from '../modelViewUtils';
|
||||
import { NotebookWizard } from './notebookWizard';
|
||||
import { NotebookWizardModel } from './notebookWizardModel';
|
||||
import { NotebookWizardPage } from './notebookWizardPage';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -17,11 +17,11 @@ export class NotebookWizardAutoSummaryPage extends NotebookWizardPage {
|
||||
private form!: azdata.FormBuilder;
|
||||
private view!: azdata.ModelView;
|
||||
|
||||
constructor(wizard: NotebookWizard, _pageIndex: number) {
|
||||
super(wizard,
|
||||
constructor(_model: NotebookWizardModel, _pageIndex: number) {
|
||||
super(_model,
|
||||
_pageIndex,
|
||||
wizard.wizardInfo.pages[_pageIndex].title || localize('notebookWizard.autoSummaryPageTitle', "Review your configuration"),
|
||||
wizard.wizardInfo.pages[_pageIndex].description || ''
|
||||
_model.wizardInfo.pages[_pageIndex].title || localize('notebookWizard.autoSummaryPageTitle', "Review your configuration"),
|
||||
_model.wizardInfo.pages[_pageIndex].description || ''
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ export class NotebookWizardAutoSummaryPage extends NotebookWizardPage {
|
||||
});
|
||||
this.formItems = [];
|
||||
|
||||
const fieldWidth = this.pageInfo.fieldWidth || this.wizard.wizardInfo.fieldWidth || DefaultFieldWidth;
|
||||
const fieldHeight = this.pageInfo.fieldHeight || this.wizard.wizardInfo.fieldHeight || DefaultFieldHeight;
|
||||
const fieldAlignItems = this.pageInfo.fieldAlignItems || this.wizard.wizardInfo.fieldAlignItems || DefaultFieldAlignItems;
|
||||
const labelWidth = this.pageInfo.labelWidth || this.wizard.wizardInfo.labelWidth || DefaultLabelWidth;
|
||||
const labelPosition = this.pageInfo.labelPosition || this.wizard.wizardInfo.labelPosition || LabelPosition.Left;
|
||||
const inputWidth = this.pageInfo.inputWidth || this.wizard.wizardInfo.inputWidth || DefaultInputWidth;
|
||||
const fieldWidth = this.pageInfo.fieldWidth || this._model.wizardInfo.fieldWidth || DefaultFieldWidth;
|
||||
const fieldHeight = this.pageInfo.fieldHeight || this._model.wizardInfo.fieldHeight || DefaultFieldHeight;
|
||||
const fieldAlignItems = this.pageInfo.fieldAlignItems || this._model.wizardInfo.fieldAlignItems || DefaultFieldAlignItems;
|
||||
const labelWidth = this.pageInfo.labelWidth || this._model.wizardInfo.labelWidth || DefaultLabelWidth;
|
||||
const labelPosition = this.pageInfo.labelPosition || this._model.wizardInfo.labelPosition || LabelPosition.Left;
|
||||
const inputWidth = this.pageInfo.inputWidth || this._model.wizardInfo.inputWidth || DefaultInputWidth;
|
||||
|
||||
const filteredPages = this.wizard.wizardInfo.pages.filter((undefined, index) => index < this._pageIndex);
|
||||
const filteredPages = this._model.wizardInfo.pages.filter((undefined, index) => index < this._pageIndex);
|
||||
for (const pageInfo of filteredPages) {
|
||||
const summarySectionInfo: SectionInfo = {
|
||||
labelPosition: labelPosition,
|
||||
@@ -80,7 +80,7 @@ export class NotebookWizardAutoSummaryPage extends NotebookWizardPage {
|
||||
component: await createSection({
|
||||
container: this.wizard.wizardObject,
|
||||
toolsService: this.wizard.toolsService,
|
||||
inputComponents: this.wizard.inputComponents,
|
||||
inputComponents: this._model.inputComponents,
|
||||
sectionInfo: summarySectionInfo,
|
||||
view: this.view,
|
||||
onNewDisposableCreated: () => { },
|
||||
|
||||
@@ -5,58 +5,63 @@
|
||||
import * as loc from '../../localizedConstants';
|
||||
import { INotebookService, Notebook } from '../../services/notebookService';
|
||||
import { IToolsService } from '../../services/toolsService';
|
||||
import { Model } from '../model';
|
||||
import { InputComponents, setModelValues } from '../modelViewUtils';
|
||||
import { WizardBase } from '../wizardBase';
|
||||
import { DeploymentType, NotebookWizardInfo } from './../../interfaces';
|
||||
import { IPlatformService } from './../../services/platformService';
|
||||
import { ResourceTypeModel } from '../resourceTypeModel';
|
||||
import { ResourceTypeWizard } from '../resourceTypeWizard';
|
||||
import { DeploymentType, NotebookWizardDeploymentProvider, NotebookWizardInfo } from '../../interfaces';
|
||||
import { IPlatformService } from '../../services/platformService';
|
||||
import { NotebookWizardAutoSummaryPage } from './notebookWizardAutoSummaryPage';
|
||||
import { NotebookWizardPage } from './notebookWizardPage';
|
||||
|
||||
export class NotebookWizard extends WizardBase<NotebookWizard, NotebookWizardPage, Model> {
|
||||
export class NotebookWizardModel extends ResourceTypeModel {
|
||||
private _inputComponents: InputComponents = {};
|
||||
|
||||
public get notebookService(): INotebookService {
|
||||
return this._notebookService;
|
||||
return this.wizard.notebookService;
|
||||
}
|
||||
|
||||
public get platformService(): IPlatformService {
|
||||
return this._platformService;
|
||||
return this.wizard.platformService;
|
||||
}
|
||||
|
||||
public get toolsService(): IToolsService {
|
||||
return this.wizard.toolsService;
|
||||
}
|
||||
|
||||
public get wizardInfo(): NotebookWizardInfo {
|
||||
return this._wizardInfo;
|
||||
return this.notebookProvider.notebookWizard;
|
||||
}
|
||||
|
||||
public get inputComponents(): InputComponents {
|
||||
return this._inputComponents;
|
||||
}
|
||||
|
||||
constructor(private _wizardInfo: NotebookWizardInfo, private _notebookService: INotebookService, private _platformService: IPlatformService, toolsService: IToolsService) {
|
||||
super(_wizardInfo.title, _wizardInfo.name || '', new Model(), toolsService);
|
||||
if (this._wizardInfo.codeCellInsertionPosition === undefined) {
|
||||
this._wizardInfo.codeCellInsertionPosition = 0;
|
||||
constructor(public notebookProvider: NotebookWizardDeploymentProvider, wizard: ResourceTypeWizard) {
|
||||
super(notebookProvider, wizard);
|
||||
if (this.notebookProvider.notebookWizard.codeCellInsertionPosition === undefined) {
|
||||
this.notebookProvider.notebookWizard.codeCellInsertionPosition = 0;
|
||||
}
|
||||
this.wizardObject.doneButton.label = _wizardInfo.doneAction?.label || loc.deployNotebook;
|
||||
this.wizardObject.generateScriptButton.label = _wizardInfo.scriptAction?.label || loc.scriptToNotebook;
|
||||
this.wizard.wizardObject.title = this.notebookProvider.notebookWizard.title;
|
||||
this.wizard.wizardObject.doneButton.label = this.notebookProvider.notebookWizard.doneAction?.label || loc.deployNotebook;
|
||||
this.wizard.wizardObject.generateScriptButton.label = this.notebookProvider.notebookWizard.scriptAction?.label || loc.scriptToNotebook;
|
||||
}
|
||||
|
||||
public get deploymentType(): DeploymentType | undefined {
|
||||
return this._wizardInfo.type;
|
||||
return this.notebookProvider.notebookWizard.type;
|
||||
}
|
||||
|
||||
protected initialize(): void {
|
||||
this.setPages(this.getPages());
|
||||
public initialize(): void {
|
||||
this.wizard.setPages(this.getPages());
|
||||
}
|
||||
|
||||
protected onCancel(): void {
|
||||
public onCancel(): void {
|
||||
}
|
||||
|
||||
protected async onGenerateScript(): Promise<void> {
|
||||
public async onGenerateScript(): Promise<void> {
|
||||
const notebook = await this.prepareNotebookAndEnvironment();
|
||||
await this.openNotebook(notebook);
|
||||
}
|
||||
protected async onOk(): Promise<void> {
|
||||
public async onOk(): Promise<void> {
|
||||
const notebook = await this.prepareNotebookAndEnvironment();
|
||||
const openedNotebook = await this.openNotebook(notebook);
|
||||
openedNotebook.runAllCells();
|
||||
@@ -68,15 +73,15 @@ export class NotebookWizard extends WizardBase<NotebookWizard, NotebookWizardPag
|
||||
}
|
||||
|
||||
private async prepareNotebookAndEnvironment() {
|
||||
await setModelValues(this.inputComponents, this.model);
|
||||
await setModelValues(this.inputComponents, this);
|
||||
const env: NodeJS.ProcessEnv = process.env;
|
||||
this.model.setEnvironmentVariables(env, (varName) => {
|
||||
this.setEnvironmentVariables(env, (varName) => {
|
||||
const isPassword = !!this.inputComponents[varName]?.isPassword;
|
||||
return isPassword;
|
||||
});
|
||||
const notebook: Notebook = await this.notebookService.getNotebook(this.wizardInfo.notebook);
|
||||
// generate python code statements for all variables captured by the wizard
|
||||
const statements = this.model.getCodeCellContentForNotebook(
|
||||
const statements = this.getCodeCellContentForNotebook(
|
||||
this.toolsService.toolsForCurrentProvider,
|
||||
(varName) => {
|
||||
const isPassword = !!this.inputComponents[varName]?.isPassword;
|
||||
@@ -8,28 +8,28 @@ import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { NotebookWizardPageInfo } from '../../interfaces';
|
||||
import { initializeWizardPage, InputComponentInfo, setModelValues, Validator } from '../modelViewUtils';
|
||||
import { WizardPageBase } from '../wizardPageBase';
|
||||
import { ResourceTypePage } from '../resourceTypePage';
|
||||
import { WizardPageInfo } from '../wizardPageInfo';
|
||||
import { NotebookWizard } from './notebookWizard';
|
||||
import { NotebookWizardModel } from './notebookWizardModel';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export class NotebookWizardPage extends WizardPageBase<NotebookWizard> {
|
||||
export class NotebookWizardPage extends ResourceTypePage {
|
||||
|
||||
protected get pageInfo(): NotebookWizardPageInfo {
|
||||
return this.wizard.wizardInfo.pages[this._pageIndex];
|
||||
return this._model.wizardInfo.pages[this._pageIndex];
|
||||
}
|
||||
|
||||
constructor(
|
||||
wizard: NotebookWizard,
|
||||
protected _model: NotebookWizardModel,
|
||||
protected _pageIndex: number,
|
||||
title?: string,
|
||||
description?: string
|
||||
) {
|
||||
super(
|
||||
wizard.wizardInfo.pages[_pageIndex].title || title || '',
|
||||
wizard.wizardInfo.pages[_pageIndex].description || description || '',
|
||||
wizard
|
||||
_model.wizardInfo.pages[_pageIndex].title || title || '',
|
||||
_model.wizardInfo.pages[_pageIndex].description || description || '',
|
||||
_model.wizard
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,21 +37,21 @@ export class NotebookWizardPage extends WizardPageBase<NotebookWizard> {
|
||||
* If the return value is true then done button should be visible to the user
|
||||
*/
|
||||
private get isDoneButtonVisible(): boolean {
|
||||
return !!this.wizard.wizardInfo.doneAction;
|
||||
return !!this._model.wizardInfo.doneAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the return value is true then generateScript button should be visible to the user
|
||||
*/
|
||||
private get isGenerateScriptButtonVisible(): boolean {
|
||||
return !!this.wizard.wizardInfo.scriptAction;
|
||||
return !!this._model.wizardInfo.scriptAction;
|
||||
}
|
||||
|
||||
public initialize(): void {
|
||||
initializeWizardPage({
|
||||
container: this.wizard.wizardObject,
|
||||
inputComponents: this.wizard.inputComponents,
|
||||
wizardInfo: this.wizard.wizardInfo,
|
||||
inputComponents: this._model.inputComponents,
|
||||
wizardInfo: this._model.wizardInfo,
|
||||
pageInfo: this.pageInfo,
|
||||
page: this.pageObject,
|
||||
onNewDisposableCreated: (disposable: vscode.Disposable): void => {
|
||||
@@ -62,7 +62,7 @@ export class NotebookWizardPage extends WizardPageBase<NotebookWizard> {
|
||||
inputComponentInfo: InputComponentInfo
|
||||
): void => {
|
||||
if (name) {
|
||||
this.wizard.inputComponents[name] = inputComponentInfo;
|
||||
this._model.inputComponents[name] = inputComponentInfo;
|
||||
}
|
||||
},
|
||||
onNewValidatorCreated: (validator: Validator): void => {
|
||||
@@ -91,7 +91,7 @@ export class NotebookWizardPage extends WizardPageBase<NotebookWizard> {
|
||||
}
|
||||
|
||||
if (this.pageInfo.isSummaryPage) {
|
||||
await setModelValues(this.wizard.inputComponents, this.wizard.model);
|
||||
await setModelValues(this._model.inputComponents, this.wizard.model);
|
||||
}
|
||||
|
||||
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
||||
|
||||
Reference in New Issue
Block a user