mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Change Azure region dropdown to use azurecore API (#11131)
* Change Azure region dropdown to use azurecore API for getting display name * Fix compile errors * Adding a few things to the vscodeignore * and another
This commit is contained in:
@@ -4,3 +4,6 @@ out/**
|
|||||||
extension.webpack.config.js
|
extension.webpack.config.js
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
coverConfig.json
|
||||||
|
*.vsix
|
||||||
|
coverage
|
||||||
|
|||||||
@@ -286,17 +286,17 @@
|
|||||||
{
|
{
|
||||||
"type": "azure_locations",
|
"type": "azure_locations",
|
||||||
"label": "%arc.control.plane.arc.data.controller.location%",
|
"label": "%arc.control.plane.arc.data.controller.location%",
|
||||||
"defaultValue": "East US",
|
"defaultValue": "eastus",
|
||||||
"required": true,
|
"required": true,
|
||||||
"locationVariableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_LOCATION",
|
"locationVariableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_LOCATION",
|
||||||
"displayLocationVariableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_DISPLAY_LOCATION",
|
"displayLocationVariableName": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_DISPLAY_LOCATION",
|
||||||
"locations": [
|
"locations": [
|
||||||
"East US",
|
"eastus",
|
||||||
"East US 2",
|
"eastus2",
|
||||||
"Central US",
|
"centralus",
|
||||||
"West Europe",
|
"westus2",
|
||||||
"Southeast Asia",
|
"southeastasia",
|
||||||
"West US 2"
|
"westeurope"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ export class AzureSettingsPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
this.pageObject.registerContent((view: azdata.ModelView) => {
|
this.pageObject.registerContent(async (view: azdata.ModelView) => {
|
||||||
const azureGroup = createSection({
|
const azureGroup = await createSection({
|
||||||
sectionInfo: azureSection,
|
sectionInfo: azureSection,
|
||||||
view: view,
|
view: view,
|
||||||
onNewDisposableCreated: (disposable: vscode.Disposable): void => {
|
onNewDisposableCreated: (disposable: vscode.Disposable): void => {
|
||||||
@@ -157,7 +157,7 @@ export class AzureSettingsPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onEnter(): void {
|
public async onEnter(): Promise<void> {
|
||||||
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
||||||
this.wizard.wizardObject.message = { text: '' };
|
this.wizard.wizardObject.message = { text: '' };
|
||||||
if (pcInfo.newPage > pcInfo.lastPage) {
|
if (pcInfo.newPage > pcInfo.lastPage) {
|
||||||
|
|||||||
@@ -201,8 +201,8 @@ export class ClusterSettingsPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
this.pageObject.registerContent((view: azdata.ModelView) => {
|
this.pageObject.registerContent(async (view: azdata.ModelView) => {
|
||||||
const basicSettingsGroup = createSection({
|
const basicSettingsGroup = await createSection({
|
||||||
view: view,
|
view: view,
|
||||||
container: self.wizard.wizardObject,
|
container: self.wizard.wizardObject,
|
||||||
inputComponents: this.wizard.inputComponents,
|
inputComponents: this.wizard.inputComponents,
|
||||||
@@ -217,7 +217,7 @@ export class ClusterSettingsPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
self.validators.push(validator);
|
self.validators.push(validator);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const activeDirectorySettingsGroup = createSection({
|
const activeDirectorySettingsGroup = await createSection({
|
||||||
view: view,
|
view: view,
|
||||||
container: self.wizard.wizardObject,
|
container: self.wizard.wizardObject,
|
||||||
inputComponents: this.wizard.inputComponents,
|
inputComponents: this.wizard.inputComponents,
|
||||||
@@ -232,7 +232,7 @@ export class ClusterSettingsPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
self.validators.push(validator);
|
self.validators.push(validator);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const dockerSettingsGroup = createSection({
|
const dockerSettingsGroup = await createSection({
|
||||||
view: view,
|
view: view,
|
||||||
container: self.wizard.wizardObject,
|
container: self.wizard.wizardObject,
|
||||||
inputComponents: this.wizard.inputComponents,
|
inputComponents: this.wizard.inputComponents,
|
||||||
@@ -301,7 +301,7 @@ export class ClusterSettingsPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onEnter() {
|
public async onEnter(): Promise<void> {
|
||||||
getInputBoxComponent(VariableNames.DockerRegistry_VariableName, this.inputComponents).value = this.wizard.model.getStringValue(VariableNames.DockerRegistry_VariableName);
|
getInputBoxComponent(VariableNames.DockerRegistry_VariableName, this.inputComponents).value = this.wizard.model.getStringValue(VariableNames.DockerRegistry_VariableName);
|
||||||
getInputBoxComponent(VariableNames.DockerRepository_VariableName, this.inputComponents).value = this.wizard.model.getStringValue(VariableNames.DockerRepository_VariableName);
|
getInputBoxComponent(VariableNames.DockerRepository_VariableName, this.inputComponents).value = this.wizard.model.getStringValue(VariableNames.DockerRepository_VariableName);
|
||||||
getInputBoxComponent(VariableNames.DockerImageTag_VariableName, this.inputComponents).value = this.wizard.model.getStringValue(VariableNames.DockerImageTag_VariableName);
|
getInputBoxComponent(VariableNames.DockerImageTag_VariableName, this.inputComponents).value = this.wizard.model.getStringValue(VariableNames.DockerImageTag_VariableName);
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ export class DeploymentProfilePage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
.component();
|
.component();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onEnter() {
|
public async onEnter(): Promise<void> {
|
||||||
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
||||||
this.wizard.wizardObject.message = { text: '' };
|
this.wizard.wizardObject.message = { text: '' };
|
||||||
if (pcInfo.newPage > pcInfo.lastPage) {
|
if (pcInfo.newPage > pcInfo.lastPage) {
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ export class ServiceSettingsPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.pageObject.registerContent((view: azdata.ModelView) => {
|
this.pageObject.registerContent(async (view: azdata.ModelView) => {
|
||||||
const createSectionFunc = (sectionInfo: SectionInfo): azdata.GroupContainer => {
|
const createSectionFunc = async (sectionInfo: SectionInfo): Promise<azdata.GroupContainer> => {
|
||||||
return createSection({
|
return await createSection({
|
||||||
view: view,
|
view: view,
|
||||||
container: this.wizard.wizardObject,
|
container: this.wizard.wizardObject,
|
||||||
inputComponents: this.inputComponents,
|
inputComponents: this.inputComponents,
|
||||||
@@ -131,7 +131,7 @@ export class ServiceSettingsPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const scaleSection = createSectionFunc(scaleSectionInfo);
|
const scaleSection = await createSectionFunc(scaleSectionInfo);
|
||||||
this.endpointSection = this.createEndpointSection(view);
|
this.endpointSection = this.createEndpointSection(view);
|
||||||
const storageSection = this.createStorageSection(view);
|
const storageSection = this.createStorageSection(view);
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ export class ServiceSettingsPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public onEnter(): void {
|
public async onEnter(): Promise<void> {
|
||||||
this.setInputBoxValue(VariableNames.ComputePoolScale_VariableName);
|
this.setInputBoxValue(VariableNames.ComputePoolScale_VariableName);
|
||||||
this.setInputBoxValue(VariableNames.DataPoolScale_VariableName);
|
this.setInputBoxValue(VariableNames.DataPoolScale_VariableName);
|
||||||
this.setInputBoxValue(VariableNames.HDFSPoolScale_VariableName);
|
this.setInputBoxValue(VariableNames.HDFSPoolScale_VariableName);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export class SummaryPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onEnter() {
|
public async onEnter(): Promise<void> {
|
||||||
this.wizard.showCustomButtons();
|
this.wizard.showCustomButtons();
|
||||||
this.formItems.forEach(item => {
|
this.formItems.forEach(item => {
|
||||||
this.form!.removeFormItem(item);
|
this.form!.removeFormItem(item);
|
||||||
@@ -279,10 +279,10 @@ export class SummaryPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
const createSectionFunc = (sectionInfo: SectionInfo): azdata.FormComponent => {
|
const createSectionFunc = async (sectionInfo: SectionInfo): Promise<azdata.FormComponent> => {
|
||||||
return {
|
return {
|
||||||
title: '',
|
title: '',
|
||||||
component: createSection({
|
component: await createSection({
|
||||||
container: this.wizard.wizardObject,
|
container: this.wizard.wizardObject,
|
||||||
inputComponents: this.wizard.inputComponents,
|
inputComponents: this.wizard.inputComponents,
|
||||||
sectionInfo: sectionInfo,
|
sectionInfo: sectionInfo,
|
||||||
@@ -295,12 +295,12 @@ export class SummaryPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (this.wizard.deploymentType === BdcDeploymentType.ExistingAKS || this.wizard.deploymentType === BdcDeploymentType.ExistingKubeAdm) {
|
if (this.wizard.deploymentType === BdcDeploymentType.ExistingAKS || this.wizard.deploymentType === BdcDeploymentType.ExistingKubeAdm) {
|
||||||
const deploymentTargetSection = createSectionFunc(deploymentTargetSectionInfo);
|
const deploymentTargetSection = await createSectionFunc(deploymentTargetSectionInfo);
|
||||||
this.formItems.push(deploymentTargetSection);
|
this.formItems.push(deploymentTargetSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
const clusterSection = createSectionFunc(clusterSectionInfo);
|
const clusterSection = await createSectionFunc(clusterSectionInfo);
|
||||||
const scaleSection = createSectionFunc(scaleSectionInfo);
|
const scaleSection = await createSectionFunc(scaleSectionInfo);
|
||||||
const endpointSection = {
|
const endpointSection = {
|
||||||
title: '',
|
title: '',
|
||||||
component: this.createEndpointSection()
|
component: this.createEndpointSection()
|
||||||
@@ -310,7 +310,7 @@ export class SummaryPage extends WizardPageBase<DeployClusterWizard> {
|
|||||||
component: this.createStorageSection()
|
component: this.createStorageSection()
|
||||||
};
|
};
|
||||||
if (this.wizard.model.getStringValue(VariableNames.AksName_VariableName)) {
|
if (this.wizard.model.getStringValue(VariableNames.AksName_VariableName)) {
|
||||||
const azureSection = createSectionFunc(azureSectionInfo);
|
const azureSection = await createSectionFunc(azureSectionInfo);
|
||||||
this.formItems.push(azureSection);
|
this.formItems.push(azureSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export class TargetClusterContextPage extends WizardPageBase<DeployClusterWizard
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onEnter() {
|
public async onEnter(): Promise<void> {
|
||||||
if (this.loadDefaultKubeConfigFile) {
|
if (this.loadDefaultKubeConfigFile) {
|
||||||
let defaultKubeConfigPath = this.wizard.kubeService.getDefaultConfigPath();
|
let defaultKubeConfigPath = this.wizard.kubeService.getDefaultConfigPath();
|
||||||
this.loadClusterContexts(defaultKubeConfigPath);
|
this.loadClusterContexts(defaultKubeConfigPath);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { EOL, homedir as os_homedir } from 'os';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import * as azurecore from '../../../azurecore/src/azurecore';
|
|
||||||
import { azureResource } from '../../../azurecore/src/azureResource/azure-resource';
|
import { azureResource } from '../../../azurecore/src/azureResource/azure-resource';
|
||||||
import { AzureAccountFieldInfo, AzureLocationsFieldInfo, ComponentCSSStyles, DialogInfoBase, FieldInfo, FieldType, KubeClusterContextFieldInfo, LabelPosition, NoteBookEnvironmentVariablePrefix, OptionsInfo, OptionsType, PageInfoBase, RowInfo, SectionInfo, TextCSSStyles } from '../interfaces';
|
import { AzureAccountFieldInfo, AzureLocationsFieldInfo, ComponentCSSStyles, DialogInfoBase, FieldInfo, FieldType, KubeClusterContextFieldInfo, LabelPosition, NoteBookEnvironmentVariablePrefix, OptionsInfo, OptionsType, PageInfoBase, RowInfo, SectionInfo, TextCSSStyles } from '../interfaces';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
@@ -176,8 +175,8 @@ export function initializeDialog(dialogContext: DialogContext): void {
|
|||||||
const tabs: azdata.window.DialogTab[] = [];
|
const tabs: azdata.window.DialogTab[] = [];
|
||||||
dialogContext.dialogInfo.tabs.forEach(tabInfo => {
|
dialogContext.dialogInfo.tabs.forEach(tabInfo => {
|
||||||
const tab = azdata.window.createTab(tabInfo.title);
|
const tab = azdata.window.createTab(tabInfo.title);
|
||||||
tab.registerContent((view: azdata.ModelView) => {
|
tab.registerContent(async (view: azdata.ModelView) => {
|
||||||
const sections = tabInfo.sections.map(sectionInfo => {
|
const sections = await Promise.all(tabInfo.sections.map(sectionInfo => {
|
||||||
sectionInfo.inputWidth = sectionInfo.inputWidth || tabInfo.inputWidth || DefaultInputWidth;
|
sectionInfo.inputWidth = sectionInfo.inputWidth || tabInfo.inputWidth || DefaultInputWidth;
|
||||||
sectionInfo.labelWidth = sectionInfo.labelWidth || tabInfo.labelWidth || DefaultLabelWidth;
|
sectionInfo.labelWidth = sectionInfo.labelWidth || tabInfo.labelWidth || DefaultLabelWidth;
|
||||||
sectionInfo.fieldAlignItems = sectionInfo.fieldAlignItems || tabInfo.fieldAlignItems || DefaultFieldAlignItems;
|
sectionInfo.fieldAlignItems = sectionInfo.fieldAlignItems || tabInfo.fieldAlignItems || DefaultFieldAlignItems;
|
||||||
@@ -193,7 +192,7 @@ export function initializeDialog(dialogContext: DialogContext): void {
|
|||||||
container: dialogContext.container,
|
container: dialogContext.container,
|
||||||
inputComponents: dialogContext.inputComponents
|
inputComponents: dialogContext.inputComponents
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
const formBuilder = view.modelBuilder.formContainer().withFormItems(
|
const formBuilder = view.modelBuilder.formContainer().withFormItems(
|
||||||
sections.map(section => {
|
sections.map(section => {
|
||||||
return { title: '', component: section };
|
return { title: '', component: section };
|
||||||
@@ -212,8 +211,8 @@ export function initializeDialog(dialogContext: DialogContext): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function initializeWizardPage(context: WizardPageContext): void {
|
export function initializeWizardPage(context: WizardPageContext): void {
|
||||||
context.page.registerContent((view: azdata.ModelView) => {
|
context.page.registerContent(async (view: azdata.ModelView) => {
|
||||||
const sections = context.pageInfo.sections.map(sectionInfo => {
|
const sections = await Promise.all(context.pageInfo.sections.map(sectionInfo => {
|
||||||
sectionInfo.inputWidth = sectionInfo.inputWidth || context.pageInfo.inputWidth || context.wizardInfo.inputWidth || DefaultInputWidth;
|
sectionInfo.inputWidth = sectionInfo.inputWidth || context.pageInfo.inputWidth || context.wizardInfo.inputWidth || DefaultInputWidth;
|
||||||
sectionInfo.labelWidth = sectionInfo.labelWidth || context.pageInfo.labelWidth || context.wizardInfo.labelWidth || DefaultLabelWidth;
|
sectionInfo.labelWidth = sectionInfo.labelWidth || context.pageInfo.labelWidth || context.wizardInfo.labelWidth || DefaultLabelWidth;
|
||||||
sectionInfo.fieldAlignItems = sectionInfo.fieldAlignItems || context.pageInfo.fieldAlignItems || DefaultFieldAlignItems;
|
sectionInfo.fieldAlignItems = sectionInfo.fieldAlignItems || context.pageInfo.fieldAlignItems || DefaultFieldAlignItems;
|
||||||
@@ -229,7 +228,7 @@ export function initializeWizardPage(context: WizardPageContext): void {
|
|||||||
onNewValidatorCreated: context.onNewValidatorCreated,
|
onNewValidatorCreated: context.onNewValidatorCreated,
|
||||||
sectionInfo: sectionInfo
|
sectionInfo: sectionInfo
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
const formBuilder = view.modelBuilder.formContainer().withFormItems(
|
const formBuilder = view.modelBuilder.formContainer().withFormItems(
|
||||||
sections.map(section => { return { title: '', component: section }; }),
|
sections.map(section => { return { title: '', component: section }; }),
|
||||||
{
|
{
|
||||||
@@ -242,7 +241,7 @@ export function initializeWizardPage(context: WizardPageContext): void {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createSection(context: SectionContext): azdata.GroupContainer {
|
export async function createSection(context: SectionContext): Promise<azdata.GroupContainer> {
|
||||||
const components: azdata.Component[] = [];
|
const components: azdata.Component[] = [];
|
||||||
context.sectionInfo.inputWidth = context.sectionInfo.inputWidth || DefaultInputWidth;
|
context.sectionInfo.inputWidth = context.sectionInfo.inputWidth || DefaultInputWidth;
|
||||||
context.sectionInfo.labelWidth = context.sectionInfo.labelWidth || DefaultLabelWidth;
|
context.sectionInfo.labelWidth = context.sectionInfo.labelWidth || DefaultLabelWidth;
|
||||||
@@ -250,11 +249,11 @@ export function createSection(context: SectionContext): azdata.GroupContainer {
|
|||||||
context.sectionInfo.fieldWidth = context.sectionInfo.fieldWidth || DefaultFieldWidth;
|
context.sectionInfo.fieldWidth = context.sectionInfo.fieldWidth || DefaultFieldWidth;
|
||||||
context.sectionInfo.fieldHeight = context.sectionInfo.fieldHeight || DefaultFieldHeight;
|
context.sectionInfo.fieldHeight = context.sectionInfo.fieldHeight || DefaultFieldHeight;
|
||||||
if (context.sectionInfo.fields) {
|
if (context.sectionInfo.fields) {
|
||||||
processFields(context.sectionInfo.fields, components, context);
|
await processFields(context.sectionInfo.fields, components, context);
|
||||||
} else if (context.sectionInfo.rows) {
|
} else if (context.sectionInfo.rows) {
|
||||||
context.sectionInfo.rows.forEach(rowInfo => {
|
for (const rowInfo of context.sectionInfo.rows) {
|
||||||
components.push(processRow(rowInfo, context));
|
components.push(await processRow(rowInfo, context));
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return createGroupContainer(context.view, components, {
|
return createGroupContainer(context.view, components, {
|
||||||
@@ -264,19 +263,19 @@ export function createSection(context: SectionContext): azdata.GroupContainer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function processRow(rowInfo: RowInfo, context: SectionContext): azdata.Component {
|
async function processRow(rowInfo: RowInfo, context: SectionContext): Promise<azdata.Component> {
|
||||||
const items: azdata.Component[] = [];
|
const items: azdata.Component[] = [];
|
||||||
if ('items' in rowInfo.items[0]) { // rowInfo.items is RowInfo[]
|
if ('items' in rowInfo.items[0]) { // rowInfo.items is RowInfo[]
|
||||||
const rowItems = rowInfo.items as RowInfo[];
|
const rowItems = rowInfo.items as RowInfo[];
|
||||||
items.push(...rowItems.map(rowInfo => processRow(rowInfo, context)));
|
items.push(...(await Promise.all(rowItems.map(rowInfo => processRow(rowInfo, context)))));
|
||||||
} else { // rowInfo.items is FieldInfo[]
|
} else { // rowInfo.items is FieldInfo[]
|
||||||
const fieldItems = rowInfo.items as FieldInfo[];
|
const fieldItems = rowInfo.items as FieldInfo[];
|
||||||
processFields(fieldItems, items, context, context.sectionInfo.spaceBetweenFields === undefined ? '50px' : context.sectionInfo.spaceBetweenFields);
|
await processFields(fieldItems, items, context, context.sectionInfo.spaceBetweenFields === undefined ? '50px' : context.sectionInfo.spaceBetweenFields);
|
||||||
}
|
}
|
||||||
return createFlexContainer(context.view, items, true, context.sectionInfo.fieldWidth, context.sectionInfo.fieldHeight, context.sectionInfo.fieldAlignItems, rowInfo.cssStyles);
|
return createFlexContainer(context.view, items, true, context.sectionInfo.fieldWidth, context.sectionInfo.fieldHeight, context.sectionInfo.fieldAlignItems, rowInfo.cssStyles);
|
||||||
}
|
}
|
||||||
|
|
||||||
function processFields(fieldInfoArray: FieldInfo[], components: azdata.Component[], context: SectionContext, spaceBetweenFields?: string): void {
|
async function processFields(fieldInfoArray: FieldInfo[], components: azdata.Component[], context: SectionContext, spaceBetweenFields?: string): Promise<void> {
|
||||||
for (let i = 0; i < fieldInfoArray.length; i++) {
|
for (let i = 0; i < fieldInfoArray.length; i++) {
|
||||||
const fieldInfo = fieldInfoArray[i];
|
const fieldInfo = fieldInfoArray[i];
|
||||||
fieldInfo.labelWidth = fieldInfo.labelWidth || context.sectionInfo.labelWidth;
|
fieldInfo.labelWidth = fieldInfo.labelWidth || context.sectionInfo.labelWidth;
|
||||||
@@ -285,7 +284,7 @@ function processFields(fieldInfoArray: FieldInfo[], components: azdata.Component
|
|||||||
fieldInfo.fieldWidth = fieldInfo.fieldWidth || context.sectionInfo.fieldWidth;
|
fieldInfo.fieldWidth = fieldInfo.fieldWidth || context.sectionInfo.fieldWidth;
|
||||||
fieldInfo.fieldHeight = fieldInfo.fieldHeight || context.sectionInfo.fieldHeight;
|
fieldInfo.fieldHeight = fieldInfo.fieldHeight || context.sectionInfo.fieldHeight;
|
||||||
fieldInfo.labelPosition = fieldInfo.labelPosition === undefined ? context.sectionInfo.labelPosition : fieldInfo.labelPosition;
|
fieldInfo.labelPosition = fieldInfo.labelPosition === undefined ? context.sectionInfo.labelPosition : fieldInfo.labelPosition;
|
||||||
processField({
|
await processField({
|
||||||
view: context.view,
|
view: context.view,
|
||||||
onNewDisposableCreated: context.onNewDisposableCreated,
|
onNewDisposableCreated: context.onNewDisposableCreated,
|
||||||
onNewInputComponentCreated: context.onNewInputComponentCreated,
|
onNewInputComponentCreated: context.onNewInputComponentCreated,
|
||||||
@@ -338,7 +337,7 @@ function addLabelInputPairToContainer(view: azdata.ModelView, components: azdata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function processField(context: FieldContext): void {
|
async function processField(context: FieldContext): Promise<void> {
|
||||||
switch (context.fieldInfo.type) {
|
switch (context.fieldInfo.type) {
|
||||||
case FieldType.Options:
|
case FieldType.Options:
|
||||||
processOptionsTypeField(context);
|
processOptionsTypeField(context);
|
||||||
@@ -366,7 +365,7 @@ function processField(context: FieldContext): void {
|
|||||||
processAzureAccountField(context);
|
processAzureAccountField(context);
|
||||||
break;
|
break;
|
||||||
case FieldType.AzureLocations:
|
case FieldType.AzureLocations:
|
||||||
processAzureLocationsField(context);
|
await processAzureLocationsField(context);
|
||||||
break;
|
break;
|
||||||
case FieldType.FilePicker:
|
case FieldType.FilePicker:
|
||||||
processFilePickerField(context);
|
processFilePickerField(context);
|
||||||
@@ -735,7 +734,7 @@ async function processAzureAccountField(context: AzureAccountFieldContext): Prom
|
|||||||
const accountDropdown = createAzureAccountDropdown(context);
|
const accountDropdown = createAzureAccountDropdown(context);
|
||||||
const subscriptionDropdown = createAzureSubscriptionDropdown(context, subscriptionValueToSubscriptionMap);
|
const subscriptionDropdown = createAzureSubscriptionDropdown(context, subscriptionValueToSubscriptionMap);
|
||||||
const resourceGroupDropdown = createAzureResourceGroupsDropdown(context, accountDropdown, accountValueToAccountMap, subscriptionDropdown, subscriptionValueToSubscriptionMap);
|
const resourceGroupDropdown = createAzureResourceGroupsDropdown(context, accountDropdown, accountValueToAccountMap, subscriptionDropdown, subscriptionValueToSubscriptionMap);
|
||||||
const locationDropdown = context.fieldInfo.locations && processAzureLocationsField(context);
|
const locationDropdown = context.fieldInfo.locations && await processAzureLocationsField(context);
|
||||||
accountDropdown.onValueChanged(async selectedItem => {
|
accountDropdown.onValueChanged(async selectedItem => {
|
||||||
const selectedAccount = accountValueToAccountMap.get(selectedItem.selected)!;
|
const selectedAccount = accountValueToAccountMap.get(selectedItem.selected)!;
|
||||||
await handleSelectedAccountChanged(context, selectedAccount, subscriptionDropdown, subscriptionValueToSubscriptionMap, resourceGroupDropdown, locationDropdown);
|
await handleSelectedAccountChanged(context, selectedAccount, subscriptionDropdown, subscriptionValueToSubscriptionMap, resourceGroupDropdown, locationDropdown);
|
||||||
@@ -942,35 +941,26 @@ async function handleSelectedSubscriptionChanged(context: AzureAccountFieldConte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Map of known Azure location friendly names to their internal names
|
|
||||||
*/
|
|
||||||
const knownAzureLocationNameMappings = new Map<string, string>([
|
|
||||||
['East US', azurecore.AzureRegion.eastus],
|
|
||||||
['East US 2', azurecore.AzureRegion.eastus2],
|
|
||||||
['Central US', azurecore.AzureRegion.centralus],
|
|
||||||
['West Europe', azurecore.AzureRegion.westeurope],
|
|
||||||
['Southeast Asia', azurecore.AzureRegion.southeastasia],
|
|
||||||
['West US 2', azurecore.AzureRegion.westus2]
|
|
||||||
]);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Azure Locations field consists of a dropdown field for azure locations
|
* An Azure Locations field consists of a dropdown field for azure locations
|
||||||
* @param context The context to use to create the field
|
* @param context The context to use to create the field
|
||||||
*/
|
*/
|
||||||
function processAzureLocationsField(context: AzureLocationsFieldContext): azdata.DropDownComponent {
|
async function processAzureLocationsField(context: AzureLocationsFieldContext): Promise<azdata.DropDownComponent> {
|
||||||
const label = createLabel(context.view, {
|
const label = createLabel(context.view, {
|
||||||
text: context.fieldInfo.label || loc.location,
|
text: context.fieldInfo.label || loc.location,
|
||||||
required: context.fieldInfo.required,
|
required: context.fieldInfo.required,
|
||||||
width: context.fieldInfo.labelWidth,
|
width: context.fieldInfo.labelWidth,
|
||||||
cssStyles: context.fieldInfo.labelCSSStyles
|
cssStyles: context.fieldInfo.labelCSSStyles
|
||||||
});
|
});
|
||||||
|
const azurecoreApi = await apiService.getAzurecoreApi();
|
||||||
|
const locationValues = context.fieldInfo.locations?.map(l => { return { name: l, displayName: azurecoreApi.getRegionDisplayName(l) }; });
|
||||||
const locationDropdown = createDropdown(context.view, {
|
const locationDropdown = createDropdown(context.view, {
|
||||||
|
defaultValue: locationValues?.find(l => l.name === context.fieldInfo.defaultValue),
|
||||||
width: context.fieldInfo.inputWidth,
|
width: context.fieldInfo.inputWidth,
|
||||||
editable: false,
|
editable: false,
|
||||||
required: context.fieldInfo.required,
|
required: context.fieldInfo.required,
|
||||||
label: loc.location,
|
label: loc.location,
|
||||||
values: context.fieldInfo.locations
|
values: locationValues
|
||||||
});
|
});
|
||||||
locationDropdown.fireOnTextChange = true;
|
locationDropdown.fireOnTextChange = true;
|
||||||
context.fieldInfo.subFields = context.fieldInfo.subFields || [];
|
context.fieldInfo.subFields = context.fieldInfo.subFields || [];
|
||||||
@@ -979,12 +969,6 @@ function processAzureLocationsField(context: AzureLocationsFieldContext): azdata
|
|||||||
label: label.value!,
|
label: label.value!,
|
||||||
variableName: context.fieldInfo.locationVariableName
|
variableName: context.fieldInfo.locationVariableName
|
||||||
});
|
});
|
||||||
context.onNewInputComponentCreated(context.fieldInfo.locationVariableName, {
|
|
||||||
component: locationDropdown,
|
|
||||||
inputValueTransformer: (inputValue: string) => {
|
|
||||||
return knownAzureLocationNameMappings.get(inputValue) || inputValue;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (context.fieldInfo.displayLocationVariableName) {
|
if (context.fieldInfo.displayLocationVariableName) {
|
||||||
context.fieldInfo.subFields!.push({
|
context.fieldInfo.subFields!.push({
|
||||||
@@ -993,12 +977,6 @@ function processAzureLocationsField(context: AzureLocationsFieldContext): azdata
|
|||||||
});
|
});
|
||||||
context.onNewInputComponentCreated(context.fieldInfo.displayLocationVariableName, { component: locationDropdown });
|
context.onNewInputComponentCreated(context.fieldInfo.displayLocationVariableName, { component: locationDropdown });
|
||||||
}
|
}
|
||||||
context.onNewInputComponentCreated(context.fieldInfo.variableName!, {
|
|
||||||
component: locationDropdown,
|
|
||||||
inputValueTransformer: (inputValue: string) => {
|
|
||||||
return knownAzureLocationNameMappings.get(inputValue) || inputValue;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addLabelInputPairToContainer(context.view, context.components, label, locationDropdown, context.fieldInfo);
|
addLabelInputPairToContainer(context.view, context.components, label, locationDropdown, context.fieldInfo);
|
||||||
return locationDropdown;
|
return locationDropdown;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export class NotebookWizardAutoSummaryPage extends NotebookWizardPage {
|
|||||||
this.wizard.wizardObject.message = { text: '' };
|
this.wizard.wizardObject.message = { text: '' };
|
||||||
}
|
}
|
||||||
|
|
||||||
public onEnter(): void {
|
public async onEnter(): Promise<void> {
|
||||||
this.formItems.forEach(item => {
|
this.formItems.forEach(item => {
|
||||||
this.form!.removeFormItem(item);
|
this.form!.removeFormItem(item);
|
||||||
});
|
});
|
||||||
@@ -50,7 +50,8 @@ export class NotebookWizardAutoSummaryPage extends NotebookWizardPage {
|
|||||||
const labelPosition = this.pageInfo.labelPosition || this.wizard.wizardInfo.labelPosition || LabelPosition.Left;
|
const labelPosition = this.pageInfo.labelPosition || this.wizard.wizardInfo.labelPosition || LabelPosition.Left;
|
||||||
const inputWidth = this.pageInfo.inputWidth || this.wizard.wizardInfo.inputWidth || DefaultInputWidth;
|
const inputWidth = this.pageInfo.inputWidth || this.wizard.wizardInfo.inputWidth || DefaultInputWidth;
|
||||||
|
|
||||||
this.wizard.wizardInfo.pages.filter((undefined, index) => index < this._pageIndex).forEach(pageInfo => {
|
const filteredPages = this.wizard.wizardInfo.pages.filter((undefined, index) => index < this._pageIndex);
|
||||||
|
for (const pageInfo of filteredPages) {
|
||||||
const summarySectionInfo: SectionInfo = {
|
const summarySectionInfo: SectionInfo = {
|
||||||
labelPosition: labelPosition,
|
labelPosition: labelPosition,
|
||||||
labelWidth: labelWidth,
|
labelWidth: labelWidth,
|
||||||
@@ -76,7 +77,7 @@ export class NotebookWizardAutoSummaryPage extends NotebookWizardPage {
|
|||||||
if (summarySectionInfo!.rows!.length > 0) {
|
if (summarySectionInfo!.rows!.length > 0) {
|
||||||
const formComponent: azdata.FormComponent = {
|
const formComponent: azdata.FormComponent = {
|
||||||
title: pageInfo.title,
|
title: pageInfo.title,
|
||||||
component: createSection({
|
component: await createSection({
|
||||||
container: this.wizard.wizardObject,
|
container: this.wizard.wizardObject,
|
||||||
inputComponents: this.wizard.inputComponents,
|
inputComponents: this.wizard.inputComponents,
|
||||||
sectionInfo: summarySectionInfo,
|
sectionInfo: summarySectionInfo,
|
||||||
@@ -88,7 +89,7 @@ export class NotebookWizardAutoSummaryPage extends NotebookWizardPage {
|
|||||||
};
|
};
|
||||||
this.formItems.push(formComponent);
|
this.formItems.push(formComponent);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
this.form.addFormItems(this.formItems);
|
this.form.addFormItems(this.formItems);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export class NotebookWizardPage extends WizardPageBase<NotebookWizard> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onEnter(): void {
|
public async onEnter(): Promise<void> {
|
||||||
if (this.pageInfo.isSummaryPage) {
|
if (this.pageInfo.isSummaryPage) {
|
||||||
setModelValues(this.wizard.inputComponents, this.wizard.model);
|
setModelValues(this.wizard.inputComponents, this.wizard.model);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ export abstract class WizardBase<T, P extends WizardPageBase<T>, M extends Model
|
|||||||
this.wizardObject = azdata.window.createWizard(title);
|
this.wizardObject = azdata.window.createWizard(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public open(): Thenable<void> {
|
public async open(): Promise<void> {
|
||||||
this.initialize();
|
this.initialize();
|
||||||
this.wizardObject.customButtons = this.customButtons;
|
this.wizardObject.customButtons = this.customButtons;
|
||||||
this.toDispose.push(this.wizardObject.onPageChanged((e) => {
|
this.toDispose.push(this.wizardObject.onPageChanged(async (e) => {
|
||||||
let previousPage = this.pages[e.lastPage];
|
let previousPage = this.pages[e.lastPage];
|
||||||
let newPage = this.pages[e.newPage];
|
let newPage = this.pages[e.newPage];
|
||||||
previousPage.onLeave();
|
previousPage.onLeave();
|
||||||
newPage.onEnter();
|
await newPage.onEnter();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.toDispose.push(this.wizardObject.doneButton.onClick(async () => {
|
this.toDispose.push(this.wizardObject.doneButton.onClick(async () => {
|
||||||
@@ -43,12 +43,10 @@ export abstract class WizardBase<T, P extends WizardPageBase<T>, M extends Model
|
|||||||
this.dispose();
|
this.dispose();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return this.wizardObject.open().then(() => {
|
await this.wizardObject.open();
|
||||||
if (this.pages && this.pages.length > 0) {
|
if (this.pages && this.pages.length > 0) {
|
||||||
this.pages[0].onEnter();
|
await this.pages[0].onEnter();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract initialize(): void;
|
protected abstract initialize(): void;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export abstract class WizardPageBase<T> {
|
|||||||
return this._wizard;
|
return this._wizard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public onEnter(): void { }
|
public async onEnter(): Promise<void> { }
|
||||||
|
|
||||||
public onLeave(): void { }
|
public onLeave(): void { }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user