mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Cleanup Resource Deployment ModelView (#13510)
This commit is contained in:
@@ -210,7 +210,6 @@
|
|||||||
"type": "azure_account",
|
"type": "azure_account",
|
||||||
"required": true,
|
"required": true,
|
||||||
"subscriptionVariableName": "AZDATA_NB_VAR_ARC_SUBSCRIPTION",
|
"subscriptionVariableName": "AZDATA_NB_VAR_ARC_SUBSCRIPTION",
|
||||||
"displaySubscriptionVariableName": "AZDATA_NB_VAR_ARC_DISPLAY_SUBSCRIPTION",
|
|
||||||
"resourceGroupVariableName": "AZDATA_NB_VAR_ARC_RESOURCE_GROUP"
|
"resourceGroupVariableName": "AZDATA_NB_VAR_ARC_RESOURCE_GROUP"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -219,7 +218,6 @@
|
|||||||
"defaultValue": "eastus",
|
"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",
|
|
||||||
"locations": [
|
"locations": [
|
||||||
"australiaeast",
|
"australiaeast",
|
||||||
"centralus",
|
"centralus",
|
||||||
@@ -273,7 +271,7 @@
|
|||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
|
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
|
||||||
"value": "%arc.data.controller.direct%"
|
"value": "direct"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -284,7 +282,7 @@
|
|||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
|
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
|
||||||
"value": "%arc.data.controller.direct%"
|
"value": "direct"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -295,7 +293,7 @@
|
|||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
|
"target": "AZDATA_NB_VAR_ARC_DATA_CONTROLLER_CONNECTIVITY_MODE",
|
||||||
"value": "%arc.data.controller.direct%"
|
"value": "direct"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -542,7 +540,7 @@
|
|||||||
"label": "%arc.data.controller.summary.subscription%",
|
"label": "%arc.data.controller.summary.subscription%",
|
||||||
"type": "readonly_text",
|
"type": "readonly_text",
|
||||||
"isEvaluated": true,
|
"isEvaluated": true,
|
||||||
"defaultValue": "$(AZDATA_NB_VAR_ARC_DISPLAY_SUBSCRIPTION)",
|
"defaultValue": "$(AZDATA_NB_VAR_ARC_SUBSCRIPTION)",
|
||||||
"inputWidth": "600"
|
"inputWidth": "600"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -555,7 +553,7 @@
|
|||||||
"label": "%arc.data.controller.summary.location%",
|
"label": "%arc.data.controller.summary.location%",
|
||||||
"type": "readonly_text",
|
"type": "readonly_text",
|
||||||
"isEvaluated": true,
|
"isEvaluated": true,
|
||||||
"defaultValue": "$(AZDATA_NB_VAR_ARC_DATA_CONTROLLER_DISPLAY_LOCATION)"
|
"defaultValue": "$(AZDATA_NB_VAR_ARC_DATA_CONTROLLER_LOCATION)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -296,7 +296,6 @@
|
|||||||
"defaultValue": "westus",
|
"defaultValue": "westus",
|
||||||
"required": true,
|
"required": true,
|
||||||
"locationVariableName": "AZDATA_NB_VAR_ASDE_AZURE_LOCATION",
|
"locationVariableName": "AZDATA_NB_VAR_ASDE_AZURE_LOCATION",
|
||||||
"displayLocationVariableName": "AZDATA_NB_VAR_ASDE_AZURE_LOCATION_TEXT",
|
|
||||||
"locations": [
|
"locations": [
|
||||||
"australiaeast",
|
"australiaeast",
|
||||||
"australiasoutheast",
|
"australiasoutheast",
|
||||||
|
|||||||
@@ -316,7 +316,6 @@ export interface KubeClusterContextFieldInfo extends FieldInfo {
|
|||||||
configFileVariableName?: string;
|
configFileVariableName?: string;
|
||||||
}
|
}
|
||||||
export interface AzureAccountFieldInfo extends AzureLocationsFieldInfo {
|
export interface AzureAccountFieldInfo extends AzureLocationsFieldInfo {
|
||||||
displaySubscriptionVariableName?: string;
|
|
||||||
subscriptionVariableName?: string;
|
subscriptionVariableName?: string;
|
||||||
resourceGroupVariableName?: string;
|
resourceGroupVariableName?: string;
|
||||||
allowNewResourceGroup?: boolean;
|
allowNewResourceGroup?: boolean;
|
||||||
@@ -326,7 +325,6 @@ export interface AzureAccountFieldInfo extends AzureLocationsFieldInfo {
|
|||||||
|
|
||||||
export interface AzureLocationsFieldInfo extends FieldInfo {
|
export interface AzureLocationsFieldInfo extends FieldInfo {
|
||||||
locationVariableName?: string;
|
locationVariableName?: string;
|
||||||
displayLocationVariableName?: string;
|
|
||||||
locations?: string[]
|
locations?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export type InputComponent = azdata.TextComponent | azdata.InputBoxComponent | a
|
|||||||
export type InputComponentInfo<T extends InputComponent> = {
|
export type InputComponentInfo<T extends InputComponent> = {
|
||||||
component: T;
|
component: T;
|
||||||
getValue: () => Promise<InputValueType>;
|
getValue: () => Promise<InputValueType>;
|
||||||
|
getDisplayValue?: () => Promise<string>;
|
||||||
onValueChanged: vscode.Event<void>;
|
onValueChanged: vscode.Event<void>;
|
||||||
isPassword?: boolean
|
isPassword?: boolean
|
||||||
};
|
};
|
||||||
@@ -262,6 +263,7 @@ export function createDropdownInputInfo(view: azdata.ModelView, info: { defaultV
|
|||||||
return {
|
return {
|
||||||
component: dropdown,
|
component: dropdown,
|
||||||
getValue: async (): Promise<InputValueType> => typeof dropdown.value === 'string' ? dropdown.value : dropdown.value?.name,
|
getValue: async (): Promise<InputValueType> => typeof dropdown.value === 'string' ? dropdown.value : dropdown.value?.name,
|
||||||
|
getDisplayValue: async (): Promise<string> => (typeof dropdown.value === 'string' ? dropdown.value : dropdown.value?.displayName) || '',
|
||||||
onValueChanged: dropdown.onValueChanged,
|
onValueChanged: dropdown.onValueChanged,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -753,7 +755,7 @@ function processEvaluatedTextField(context: FieldContext): ReadOnlyFieldInputs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string that interpolates all variable names in the {@param inputValue} string de-marked as $(VariableName)
|
* Returns a string that interpolates all variable names in the {@param inputValue} string de-marked as $(VariableName)
|
||||||
* substituted with their corresponding values.
|
* substituted with their corresponding values. Will use the display value of the target input values if possible.
|
||||||
*
|
*
|
||||||
* Only variables in the current model starting with {@see NoteBookEnvironmentVariablePrefix} are replaced.
|
* Only variables in the current model starting with {@see NoteBookEnvironmentVariablePrefix} are replaced.
|
||||||
*
|
*
|
||||||
@@ -764,7 +766,7 @@ async function substituteVariableValues(inputComponents: InputComponents, inputV
|
|||||||
await Promise.all(Object.keys(inputComponents)
|
await Promise.all(Object.keys(inputComponents)
|
||||||
.filter(key => key.startsWith(NoteBookEnvironmentVariablePrefix))
|
.filter(key => key.startsWith(NoteBookEnvironmentVariablePrefix))
|
||||||
.map(async key => {
|
.map(async key => {
|
||||||
const value = (await inputComponents[key].getValue()) ?? '<undefined>';
|
const value = (await (inputComponents[key].getDisplayValue ? inputComponents[key].getDisplayValue!() : inputComponents[key].getValue())) ?? '<undefined>';
|
||||||
const re: RegExp = new RegExp(`\\\$\\\(${key}\\\)`, 'gi');
|
const re: RegExp = new RegExp(`\\\$\\\(${key}\\\)`, 'gi');
|
||||||
inputValue = inputValue?.replace(re, value.toString());
|
inputValue = inputValue?.replace(re, value.toString());
|
||||||
})
|
})
|
||||||
@@ -927,6 +929,7 @@ async function createRadioOptions(context: FieldContext, getRadioButtonInfo?: ((
|
|||||||
context.onNewInputComponentCreated(context.fieldInfo.variableName || context.fieldInfo.label, {
|
context.onNewInputComponentCreated(context.fieldInfo.variableName || context.fieldInfo.label, {
|
||||||
component: radioGroupLoadingComponentBuilder,
|
component: radioGroupLoadingComponentBuilder,
|
||||||
getValue: async (): Promise<InputValueType> => radioGroupLoadingComponentBuilder.value,
|
getValue: async (): Promise<InputValueType> => radioGroupLoadingComponentBuilder.value,
|
||||||
|
getDisplayValue: async (): Promise<string> => radioGroupLoadingComponentBuilder.displayValue,
|
||||||
onValueChanged: radioGroupLoadingComponentBuilder.onValueChanged,
|
onValueChanged: radioGroupLoadingComponentBuilder.onValueChanged,
|
||||||
});
|
});
|
||||||
addLabelInputPairToContainer(context.view, context.components, label, radioGroupLoadingComponentBuilder.component(), context.fieldInfo);
|
addLabelInputPairToContainer(context.view, context.components, label, radioGroupLoadingComponentBuilder.component(), context.fieldInfo);
|
||||||
@@ -1118,15 +1121,9 @@ function createAzureSubscriptionDropdown(
|
|||||||
const inputValue = (await subscriptionDropdown.getValue())?.toString() || '';
|
const inputValue = (await subscriptionDropdown.getValue())?.toString() || '';
|
||||||
return subscriptionValueToSubscriptionMap.get(inputValue)?.id || inputValue;
|
return subscriptionValueToSubscriptionMap.get(inputValue)?.id || inputValue;
|
||||||
},
|
},
|
||||||
|
getDisplayValue: subscriptionDropdown.getDisplayValue,
|
||||||
onValueChanged: subscriptionDropdown.onValueChanged
|
onValueChanged: subscriptionDropdown.onValueChanged
|
||||||
});
|
});
|
||||||
if (context.fieldInfo.displaySubscriptionVariableName) {
|
|
||||||
context.fieldInfo.subFields!.push({
|
|
||||||
label: label.value!,
|
|
||||||
variableName: context.fieldInfo.displaySubscriptionVariableName
|
|
||||||
});
|
|
||||||
context.onNewInputComponentCreated(context.fieldInfo.displaySubscriptionVariableName!, subscriptionDropdown);
|
|
||||||
}
|
|
||||||
addLabelInputPairToContainer(context.view, context.components, label, subscriptionDropdown.component, context.fieldInfo);
|
addLabelInputPairToContainer(context.view, context.components, label, subscriptionDropdown.component, context.fieldInfo);
|
||||||
return subscriptionDropdown.component;
|
return subscriptionDropdown.component;
|
||||||
}
|
}
|
||||||
@@ -1341,22 +1338,6 @@ async function processAzureLocationsField(context: AzureLocationsFieldContext):
|
|||||||
});
|
});
|
||||||
context.onNewInputComponentCreated(context.fieldInfo.locationVariableName, locationDropdown);
|
context.onNewInputComponentCreated(context.fieldInfo.locationVariableName, locationDropdown);
|
||||||
}
|
}
|
||||||
if (context.fieldInfo.displayLocationVariableName) {
|
|
||||||
context.fieldInfo.subFields!.push({
|
|
||||||
label: label.value!,
|
|
||||||
variableName: context.fieldInfo.displayLocationVariableName
|
|
||||||
});
|
|
||||||
// Create a special input component that maps the dropdown to the display name for the location
|
|
||||||
// so that we have two variables - one for the value and one for the display name
|
|
||||||
context.onNewInputComponentCreated(context.fieldInfo.displayLocationVariableName, {
|
|
||||||
component: locationDropdown.component,
|
|
||||||
getValue: async (): Promise<InputValueType> => {
|
|
||||||
const inputValue = (await locationDropdown.getValue())?.toString();
|
|
||||||
return apiService.azurecoreApi.getRegionDisplayName(inputValue);
|
|
||||||
},
|
|
||||||
onValueChanged: locationDropdown.onValueChanged,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
addLabelInputPairToContainer(context.view, context.components, label, locationDropdown.component, context.fieldInfo);
|
addLabelInputPairToContainer(context.view, context.components, label, locationDropdown.component, context.fieldInfo);
|
||||||
return locationDropdown.component;
|
return locationDropdown.component;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ export class RadioGroupLoadingComponentBuilder implements azdata.ComponentBuilde
|
|||||||
: op as azdata.CategoryValue;
|
: op as azdata.CategoryValue;
|
||||||
const radioOption = this._view!.modelBuilder.radioButton().withProperties<azdata.RadioButtonProperties>({
|
const radioOption = this._view!.modelBuilder.radioButton().withProperties<azdata.RadioButtonProperties>({
|
||||||
label: option.displayName,
|
label: option.displayName,
|
||||||
|
value: option.name,
|
||||||
checked: option.displayName === defaultValue,
|
checked: option.displayName === defaultValue,
|
||||||
name: option.name,
|
|
||||||
enabled: instanceOfDynamicEnablementInfo(this._fieldInfo.enabled) ? false : this._fieldInfo.enabled // Dynamic enablement is initially set to false
|
enabled: instanceOfDynamicEnablementInfo(this._fieldInfo.enabled) ? false : this._fieldInfo.enabled // Dynamic enablement is initially set to false
|
||||||
}).component();
|
}).component();
|
||||||
if (radioOption.checked) {
|
if (radioOption.checked) {
|
||||||
@@ -75,7 +75,11 @@ export class RadioGroupLoadingComponentBuilder implements azdata.ComponentBuilde
|
|||||||
}
|
}
|
||||||
|
|
||||||
get value(): string | undefined {
|
get value(): string | undefined {
|
||||||
return this._currentRadioOption?.label;
|
return this._currentRadioOption?.value || this._currentRadioOption?.label;
|
||||||
|
}
|
||||||
|
|
||||||
|
get displayValue(): string {
|
||||||
|
return this._currentRadioOption.label || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
get checked(): azdata.RadioButtonComponent {
|
get checked(): azdata.RadioButtonComponent {
|
||||||
|
|||||||
Reference in New Issue
Block a user