mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Features to resource deployment to add arc control create in ARC extension (#10088)
* save not yet tested work * Merge from master. * Screeens Shared for Feeedback * Code complete * remove unneeded changes * remove unnecessary comma * remov wss * remove dead code * PR feedback * checkpoint fixes * PR & minor fixes * minor fix for feature of resourceType options being optional. * reverting experimental change * separating out changes for future featurework. * revert unneeded change * review feedback fixes * review feedback * rename InputFieldComponent to InputComponent
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { INotebookService } from '../../services/notebookService';
|
||||
import { Model } from '../model';
|
||||
import { WizardBase } from '../wizardBase';
|
||||
import { WizardPageBase } from '../wizardPageBase';
|
||||
import { DeploymentType, NotebookWizardInfo } from './../../interfaces';
|
||||
import { IPlatformService } from './../../services/platformService';
|
||||
import { NotebookWizardPage } from './notebookWizardPage';
|
||||
import { NotebookWizardSummaryPage } from './notebookWizardSummaryPage';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export class NotebookWizard extends WizardBase<NotebookWizard, Model> {
|
||||
|
||||
public get notebookService(): INotebookService {
|
||||
return this._notebookService;
|
||||
}
|
||||
|
||||
public get platformService(): IPlatformService {
|
||||
return this._platformService;
|
||||
}
|
||||
|
||||
public get wizardInfo(): NotebookWizardInfo {
|
||||
return this._wizardInfo;
|
||||
}
|
||||
|
||||
constructor(private _wizardInfo: NotebookWizardInfo, private _notebookService: INotebookService, private _platformService: IPlatformService) {
|
||||
super(_wizardInfo.title, new Model());
|
||||
this.wizardObject.doneButton.label = _wizardInfo.actionText || this.wizardObject.doneButton.label;
|
||||
}
|
||||
|
||||
public get deploymentType(): DeploymentType | undefined {
|
||||
return this._wizardInfo.type;
|
||||
}
|
||||
|
||||
protected initialize(): void {
|
||||
this.setPages(this.getPages());
|
||||
this.wizardObject.generateScriptButton.hidden = true;
|
||||
this.wizardInfo.actionText = this.wizardInfo.actionText || localize('deployCluster.ScriptToNotebook', "Script to Notebook");
|
||||
this.wizardObject.doneButton.label = this.wizardInfo.actionText;
|
||||
}
|
||||
|
||||
protected onCancel(): void {
|
||||
}
|
||||
|
||||
protected onOk(): void {
|
||||
this.model.setEnvironmentVariables();
|
||||
if (this.wizardInfo.runNotebook) {
|
||||
this.notebookService.backgroundExecuteNotebook(this.wizardInfo.taskName, this.wizardInfo.notebook, 'deploy', this.platformService);
|
||||
} else {
|
||||
this.notebookService.launchNotebook(this.wizardInfo.notebook).then(() => { }, (error) => {
|
||||
vscode.window.showErrorMessage(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private getPages(): WizardPageBase<NotebookWizard>[] {
|
||||
const pages: WizardPageBase<NotebookWizard>[] = [];
|
||||
for (let pageIndex: number = 0; pageIndex < this.wizardInfo.pages.length; pageIndex++) {
|
||||
pages.push(new NotebookWizardPage(this, pageIndex));
|
||||
}
|
||||
if (this.wizardInfo.generateSummaryPage) {
|
||||
pages.push(new NotebookWizardSummaryPage(this));
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { EOL } from 'os';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { NotebookWizardPageInfo } from '../../interfaces';
|
||||
import { initializeWizardPage, InputComponents, InputComponent, setModelValues, Validator } from '../modelViewUtils';
|
||||
import { WizardPageBase } from '../wizardPageBase';
|
||||
import { NotebookWizard } from './notebookWizard';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export class NotebookWizardPage extends WizardPageBase<NotebookWizard> {
|
||||
private inputComponents: InputComponents = {};
|
||||
|
||||
protected get pageInfo(): NotebookWizardPageInfo {
|
||||
return this.wizard.wizardInfo.pages[this._pageIndex];
|
||||
}
|
||||
|
||||
constructor(wizard: NotebookWizard, private _pageIndex: number) {
|
||||
super(wizard.wizardInfo.pages[_pageIndex].title, wizard.wizardInfo.pages[_pageIndex].description || '', wizard);
|
||||
}
|
||||
|
||||
public initialize(): void {
|
||||
const self = this;
|
||||
initializeWizardPage({
|
||||
container: this.wizard.wizardObject,
|
||||
wizardInfo: this.wizard.wizardInfo,
|
||||
pageInfo: this.pageInfo,
|
||||
page: this.pageObject,
|
||||
onNewDisposableCreated: (disposable: vscode.Disposable): void => {
|
||||
self.wizard.registerDisposable(disposable);
|
||||
},
|
||||
onNewInputComponentCreated: (name: string, component: InputComponent): void => {
|
||||
self.inputComponents[name] = { component: component };
|
||||
},
|
||||
onNewValidatorCreated: (validator: Validator): void => {
|
||||
self.validators.push(validator);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public onLeave() {
|
||||
setModelValues(this.inputComponents, this.wizard.model);
|
||||
// The following callback registration clears previous navigation validators.
|
||||
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public onEnter() {
|
||||
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
||||
this.wizard.wizardObject.message = { text: '' };
|
||||
if (pcInfo.newPage > pcInfo.lastPage) {
|
||||
const messages: string[] = [];
|
||||
|
||||
this.validators.forEach(validator => {
|
||||
const result = validator();
|
||||
if (!result.valid) {
|
||||
messages.push(result.message);
|
||||
}
|
||||
});
|
||||
|
||||
if (messages.length > 0) {
|
||||
this.wizard.wizardObject.message = {
|
||||
text: messages.length === 1 ? messages[0] : localize('wizardPage.ValidationError', "There are some errors on this page, click 'Show Details' to view the errors."),
|
||||
description: messages.length === 1 ? undefined : messages.join(EOL),
|
||||
level: azdata.window.MessageLevel.Error
|
||||
};
|
||||
}
|
||||
return messages.length === 0;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 nls from 'vscode-nls';
|
||||
|
||||
import { SubFieldInfo, FieldType, FontWeight, LabelPosition, SectionInfo } from '../../interfaces';
|
||||
import { createSection, DefaultInputComponentWidth, DefaultLabelComponentWidth } from '../modelViewUtils';
|
||||
import { WizardPageBase } from '../wizardPageBase';
|
||||
import { NotebookWizard } from './notebookWizard';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export class NotebookWizardSummaryPage extends WizardPageBase<NotebookWizard> {
|
||||
private formItems: azdata.FormComponent[] = [];
|
||||
private form!: azdata.FormBuilder;
|
||||
private view!: azdata.ModelView;
|
||||
|
||||
constructor(wizard: NotebookWizard) {
|
||||
super(localize('notebookWizard.summaryPageTitle', "Review your configuration"), '', wizard);
|
||||
}
|
||||
|
||||
public initialize(): void {
|
||||
this.pageObject.registerContent((view: azdata.ModelView) => {
|
||||
this.view = view;
|
||||
this.form = view.modelBuilder.formContainer();
|
||||
return view.initializeModel(this.form!.withLayout({ width: '100%' }).component());
|
||||
});
|
||||
}
|
||||
|
||||
public onLeave() {
|
||||
this.wizard.wizardObject.message = { text: '' };
|
||||
}
|
||||
|
||||
public onEnter() {
|
||||
this.formItems.forEach(item => {
|
||||
this.form!.removeFormItem(item);
|
||||
});
|
||||
this.formItems = [];
|
||||
|
||||
const inputWidth = this.wizard.wizardInfo.inputWidth || (this.wizard.wizardInfo.summaryPage && this.wizard.wizardInfo.summaryPage.inputWidth) || DefaultInputComponentWidth;
|
||||
const labelWidth = this.wizard.wizardInfo.labelWidth || (this.wizard.wizardInfo.summaryPage && this.wizard.wizardInfo.summaryPage.labelWidth) || DefaultLabelComponentWidth;
|
||||
const labelPosition = this.wizard.wizardInfo.labelPosition || (this.wizard.wizardInfo.summaryPage && this.wizard.wizardInfo.summaryPage.labelPosition) || LabelPosition.Left;
|
||||
|
||||
this.wizard.wizardInfo.pages.forEach(pageInfo => {
|
||||
const summarySectionInfo: SectionInfo = {
|
||||
labelPosition: labelPosition,
|
||||
labelWidth: labelWidth,
|
||||
inputWidth: inputWidth,
|
||||
title: '',
|
||||
rows: []
|
||||
};
|
||||
pageInfo.sections.forEach(sectionInfo => {
|
||||
sectionInfo.fields!.forEach(fieldInfo => {
|
||||
if (fieldInfo.variableName) {
|
||||
this.addSummaryForVariable(summarySectionInfo, fieldInfo);
|
||||
}
|
||||
if (fieldInfo.subFields) {
|
||||
fieldInfo.subFields.forEach(subFieldInfo => {
|
||||
this.addSummaryForVariable(summarySectionInfo, subFieldInfo);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
if (summarySectionInfo!.rows!.length > 0) {
|
||||
const formComponent: azdata.FormComponent = {
|
||||
title: pageInfo.title,
|
||||
component: createSection({
|
||||
container: this.wizard.wizardObject,
|
||||
sectionInfo: summarySectionInfo,
|
||||
view: this.view,
|
||||
onNewDisposableCreated: () => { },
|
||||
onNewInputComponentCreated: () => { },
|
||||
onNewValidatorCreated: () => { }
|
||||
})
|
||||
};
|
||||
this.formItems.push(formComponent);
|
||||
}
|
||||
});
|
||||
this.form.addFormItems(this.formItems);
|
||||
|
||||
}
|
||||
|
||||
private addSummaryForVariable(summarySectionInfo: SectionInfo, fieldInfo: SubFieldInfo) {
|
||||
summarySectionInfo!.rows!.push({
|
||||
fields: [{
|
||||
type: FieldType.ReadonlyText,
|
||||
label: fieldInfo.label,
|
||||
defaultValue: this.wizard.model.getStringValue(fieldInfo.variableName!),
|
||||
labelFontWeight: FontWeight.Bold
|
||||
}]
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user