Fixed dynamic enablement (#19742)

* Fixed dynamic enablement

* Set to false or original logic in constructor

* Changed boolean to also undefined

* Moved comment to constructor

Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
Candice Ye
2022-06-16 15:03:51 -07:00
committed by GitHub
parent d4509a6528
commit adafdd489f

View File

@@ -12,9 +12,12 @@ export class RadioGroupLoadingComponentBuilder implements azdata.ComponentBuilde
private _optionsLoadingBuilder: azdata.LoadingComponentBuilder; private _optionsLoadingBuilder: azdata.LoadingComponentBuilder;
private _onValueChangedEmitter: vscode.EventEmitter<void> = new vscode.EventEmitter(); private _onValueChangedEmitter: vscode.EventEmitter<void> = new vscode.EventEmitter();
private _currentRadioOption!: azdata.RadioButtonComponent; private _currentRadioOption!: azdata.RadioButtonComponent;
private _enabled: boolean | undefined;
constructor(private _view: azdata.ModelView, private _onNewDisposableCreated: (disposable: vscode.Disposable) => void, private _fieldInfo: FieldInfo) { constructor(private _view: azdata.ModelView, private _onNewDisposableCreated: (disposable: vscode.Disposable) => void, private _fieldInfo: FieldInfo) {
this._optionsDivContainer = this._view!.modelBuilder.divContainer().withProps({ clickable: false }).component(); this._optionsDivContainer = this._view!.modelBuilder.divContainer().withProps({ clickable: false }).component();
this._optionsLoadingBuilder = this._view!.modelBuilder.loadingComponent().withItem(this._optionsDivContainer); this._optionsLoadingBuilder = this._view!.modelBuilder.loadingComponent().withItem(this._optionsDivContainer);
// Dynamic enablement fields will default to false since they're calculated later
this._enabled = instanceOfDynamicEnablementInfo(this._fieldInfo.enabled) ? false : this._fieldInfo.enabled;
} }
component(): azdata.LoadingComponent { component(): azdata.LoadingComponent {
@@ -51,7 +54,7 @@ export class RadioGroupLoadingComponentBuilder implements azdata.ComponentBuilde
label: option.displayName, label: option.displayName,
value: option.name, value: option.name,
checked: option.displayName === defaultValue, checked: option.displayName === defaultValue,
enabled: instanceOfDynamicEnablementInfo(this._fieldInfo.enabled) ? false : this._fieldInfo.enabled // Dynamic enablement is initially set to false enabled: this._enabled
}).component(); }).component();
if (radioOption.checked) { if (radioOption.checked) {
this._currentRadioOption = radioOption; this._currentRadioOption = radioOption;
@@ -90,6 +93,7 @@ export class RadioGroupLoadingComponentBuilder implements azdata.ComponentBuilde
this._optionsDivContainer.items.forEach(radioButton => { this._optionsDivContainer.items.forEach(radioButton => {
radioButton.enabled = enabled; radioButton.enabled = enabled;
}); });
this._enabled = enabled;
} }
get onValueChanged(): vscode.Event<void> { get onValueChanged(): vscode.Event<void> {