mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add ability to pass in initial variable values to deployment wizards (#14224)
This commit is contained in:
@@ -11,7 +11,7 @@ import { IOptionsSourceProvider } from 'resource-deployment';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { getDateTimeString, getErrorMessage, isUserCancelledError, throwUnless } from '../common/utils';
|
||||
import { AzureAccountFieldInfo, AzureLocationsFieldInfo, ComponentCSSStyles, DialogInfoBase, FieldInfo, FieldType, FilePickerFieldInfo, instanceOfDynamicEnablementInfo, IOptionsSource, KubeClusterContextFieldInfo, LabelPosition, NoteBookEnvironmentVariablePrefix, OptionsInfo, OptionsType, PageInfoBase, RowInfo, SectionInfo, TextCSSStyles } from '../interfaces';
|
||||
import { AzureAccountFieldInfo, AzureLocationsFieldInfo, ComponentCSSStyles, DialogInfoBase, FieldInfo, FieldType, FilePickerFieldInfo, InitialVariableValues, instanceOfDynamicEnablementInfo, IOptionsSource, KubeClusterContextFieldInfo, LabelPosition, NoteBookEnvironmentVariablePrefix, OptionsInfo, OptionsType, PageInfoBase, RowInfo, SectionInfo, TextCSSStyles } from '../interfaces';
|
||||
import * as loc from '../localizedConstants';
|
||||
import { apiService } from '../services/apiService';
|
||||
import { valueProviderService } from '../services/valueProviderService';
|
||||
@@ -126,6 +126,7 @@ interface ContextBase {
|
||||
container: azdata.window.Dialog | azdata.window.Wizard;
|
||||
toolsService: IToolsService,
|
||||
inputComponents: InputComponents;
|
||||
initialVariableValues?: InitialVariableValues;
|
||||
onNewValidatorCreated: (validator: Validator) => void;
|
||||
onNewDisposableCreated: (disposable: vscode.Disposable) => void;
|
||||
onNewInputComponentCreated: (name: string, inputComponentInfo: InputComponentInfo<InputComponent>) => void;
|
||||
@@ -170,9 +171,10 @@ interface InputBoxInfo {
|
||||
*/
|
||||
function createInputBoxField({ context, inputBoxType = 'text' }: { context: FieldContext; inputBoxType?: azdata.InputBoxInputType; }) {
|
||||
const label = createLabel(context.view, { text: context.fieldInfo.label, description: context.fieldInfo.description, required: context.fieldInfo.required, width: context.fieldInfo.labelWidth, cssStyles: context.fieldInfo.labelCSSStyles });
|
||||
const defaultValue = context.initialVariableValues?.[context.fieldInfo.variableName || '']?.toString() || context.fieldInfo.defaultValue;
|
||||
const input = createInputBoxInputInfo(context.view, {
|
||||
type: inputBoxType,
|
||||
defaultValue: context.fieldInfo.defaultValue,
|
||||
defaultValue: defaultValue,
|
||||
ariaLabel: context.fieldInfo.label,
|
||||
required: context.fieldInfo.required,
|
||||
min: context.fieldInfo.min,
|
||||
@@ -329,6 +331,7 @@ export function initializeWizardPage(context: WizardPageContext): void {
|
||||
container: context.container,
|
||||
toolsService: context.toolsService,
|
||||
inputComponents: context.inputComponents,
|
||||
initialVariableValues: context.initialVariableValues,
|
||||
onNewDisposableCreated: context.onNewDisposableCreated,
|
||||
onNewInputComponentCreated: context.onNewInputComponentCreated,
|
||||
onNewValidatorCreated: context.onNewValidatorCreated,
|
||||
@@ -483,6 +486,7 @@ async function processFields(fieldInfoArray: FieldInfo[], components: azdata.Com
|
||||
fieldInfo: fieldInfo,
|
||||
container: context.container,
|
||||
inputComponents: context.inputComponents,
|
||||
initialVariableValues: context.initialVariableValues,
|
||||
components: components,
|
||||
toolsService: context.toolsService
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ 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 { InitialVariableValues, NotebookWizardPageInfo } from '../../interfaces';
|
||||
import { initializeWizardPage, InputComponent, InputComponentInfo, setModelValues, Validator } from '../modelViewUtils';
|
||||
import { ResourceTypePage } from '../resourceTypePage';
|
||||
import { WizardPageInfo } from '../wizardPageInfo';
|
||||
@@ -47,13 +47,14 @@ export class NotebookWizardPage extends ResourceTypePage {
|
||||
return !!this._model.wizardInfo.scriptAction;
|
||||
}
|
||||
|
||||
public initialize(): void {
|
||||
public initialize(initialParamValues?: InitialVariableValues): void {
|
||||
initializeWizardPage({
|
||||
container: this.wizard.wizardObject,
|
||||
inputComponents: this._model.inputComponents,
|
||||
wizardInfo: this._model.wizardInfo,
|
||||
pageInfo: this.pageInfo,
|
||||
page: this.pageObject,
|
||||
initialVariableValues: initialParamValues,
|
||||
onNewDisposableCreated: (disposable: vscode.Disposable): void => {
|
||||
this.wizard.registerDisposable(disposable);
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { DeploymentProvider } from '../interfaces';
|
||||
import { DeploymentProvider, InitialVariableValues } from '../interfaces';
|
||||
import { Model } from './model';
|
||||
import { ResourceTypeWizard } from './resourceTypeWizard';
|
||||
|
||||
@@ -13,7 +13,7 @@ export abstract class ResourceTypeModel extends Model {
|
||||
super();
|
||||
}
|
||||
|
||||
abstract initialize(): void;
|
||||
abstract initialize(initialParams?: InitialVariableValues): void;
|
||||
abstract onOk(): Promise<void>;
|
||||
abstract onCancel(): void;
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,4 @@
|
||||
import { ResourceTypeWizard } from './resourceTypeWizard';
|
||||
import { WizardPageBase } from './wizardPageBase';
|
||||
|
||||
export abstract class ResourceTypePage extends WizardPageBase<ResourceTypeWizard>{
|
||||
abstract initialize(): void;
|
||||
}
|
||||
export abstract class ResourceTypePage extends WizardPageBase<ResourceTypeWizard>{ }
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { DeploymentProvider, instanceOfAzureSQLDBDeploymentProvider, instanceOfAzureSQLVMDeploymentProvider, instanceOfNotebookWizardDeploymentProvider, instanceOfWizardDeploymentProvider, ResourceType, ResourceTypeOptionValue } from '../interfaces';
|
||||
import { DeploymentProvider, InitialVariableValues, instanceOfAzureSQLDBDeploymentProvider, instanceOfAzureSQLVMDeploymentProvider, instanceOfNotebookWizardDeploymentProvider, instanceOfWizardDeploymentProvider, ResourceType, ResourceTypeOptionValue } from '../interfaces';
|
||||
import { DeployClusterWizardModel } from './deployClusterWizard/deployClusterWizardModel';
|
||||
import { DeployAzureSQLVMWizardModel } from './deployAzureSQLVMWizard/deployAzureSQLVMWizardModel';
|
||||
import { WizardPageInfo } from './wizardPageInfo';
|
||||
@@ -59,7 +59,8 @@ export class ResourceTypeWizard {
|
||||
public toolsService: IToolsService,
|
||||
public platformService: IPlatformService,
|
||||
public resourceTypeService: ResourceTypeService,
|
||||
private _optionValuesFilter?: OptionValuesFilter) {
|
||||
private _optionValuesFilter?: OptionValuesFilter,
|
||||
private _initialVariableValues?: InitialVariableValues) {
|
||||
/**
|
||||
* Setting the first provider from the first value of the dropdowns.
|
||||
* If there are no options (dropdowns) then the resource type has only one provider which is set as default here.
|
||||
@@ -164,7 +165,7 @@ export class ResourceTypeWizard {
|
||||
// generateScriptButton is enabled only when the page is valid.
|
||||
this.wizardObject.generateScriptButton.enabled = isValid;
|
||||
});
|
||||
page.initialize();
|
||||
page.initialize(this._initialVariableValues);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { InitialVariableValues } from '../interfaces';
|
||||
import { Validator } from './modelViewUtils';
|
||||
import { WizardPageInfo } from './wizardPageInfo';
|
||||
|
||||
@@ -29,7 +30,7 @@ export abstract class WizardPageBase<T> {
|
||||
|
||||
public async onLeave(_pageInfo?: WizardPageInfo): Promise<void> { }
|
||||
|
||||
public abstract initialize(): void;
|
||||
public abstract initialize(initialVariableValues?: InitialVariableValues): void;
|
||||
|
||||
protected get validators(): Validator[] {
|
||||
return this._validators;
|
||||
|
||||
Reference in New Issue
Block a user