Add enabled property and make default account option empty (#9036)

* Add enabled property and make default account option empty

* Rmove unused loc string

* Add descriptive comment and support required azure dropdowns.
This commit is contained in:
Charles Gagnon
2020-02-04 08:06:14 -08:00
committed by GitHub
parent 62df5359e2
commit 86ad477c77
3 changed files with 10 additions and 6 deletions

View File

@@ -66,14 +66,15 @@ interface CreateContext {
onNewInputComponentCreated: (name: string, component: azdata.InputBoxComponent | azdata.DropDownComponent | azdata.CheckBoxComponent, inputValueTransformer?: InputValueTransformer) => void;
}
export function createTextInput(view: azdata.ModelView, inputInfo: { defaultValue?: string, ariaLabel: string, required?: boolean, placeHolder?: string, width?: string }): azdata.InputBoxComponent {
export function createTextInput(view: azdata.ModelView, inputInfo: { defaultValue?: string, ariaLabel: string, required?: boolean, placeHolder?: string, width?: string, enabled?: boolean }): azdata.InputBoxComponent {
return view.modelBuilder.inputBox().withProperties<azdata.InputBoxProperties>({
value: inputInfo.defaultValue,
ariaLabel: inputInfo.ariaLabel,
inputType: 'text',
required: inputInfo.required,
placeHolder: inputInfo.placeHolder,
width: inputInfo.width
width: inputInfo.width,
enabled: inputInfo.enabled
}).component();
}
@@ -326,7 +327,8 @@ function processTextField(context: FieldContext): void {
ariaLabel: context.fieldInfo.label,
required: context.fieldInfo.required,
placeHolder: context.fieldInfo.placeHolder,
width: context.fieldInfo.inputWidth
width: context.fieldInfo.inputWidth,
enabled: context.fieldInfo.enabled
});
context.onNewInputComponentCreated(context.fieldInfo.variableName!, input);
addLabelInputPairToContainer(context.view, context.components, label, input, context.fieldInfo.labelPosition);
@@ -437,7 +439,9 @@ function processAzureAccountField(context: AzureAccountFieldContext): void {
handleSelectedAccountChanged(context, selectedAccount, subscriptionDropdown, subscriptionValueToSubscriptionMap, resourceGroupDropdown, locationDropdown);
});
azdata.accounts.getAllAccounts().then((accounts: azdata.Account[]) => {
accountDropdown.values = [loc.localDeploy].concat(accounts.map(account => {
// Append a blank value for the "default" option if the field isn't required, this will clear all the dropdowns when selected
const dropdownValues = context.fieldInfo.required ? [] : [''];
accountDropdown.values = dropdownValues.concat(accounts.map(account => {
const displayName = `${account.displayInfo.displayName} (${account.displayInfo.userId})`;
accountValueToAccountMap.set(displayName, account);
return displayName;