Fix other fields being editable in password reprompt for Arc (#14117)

This commit is contained in:
Charles Gagnon
2021-01-29 16:27:20 -08:00
committed by GitHub
parent 667c12abdc
commit f6e39a7211
5 changed files with 10 additions and 65 deletions

View File

@@ -43,16 +43,6 @@ describe('filePicker', function (): void {
it('component getter', () => {
should(filePicker.component()).not.be.undefined();
});
[true, false].forEach(testValue => {
it(`Test readOnly with testValue: ${testValue}`, () => {
filePicker.readOnly = testValue;
filePicker.readOnly!.should.equal(testValue);
});
it(`Test enabled with testValue: ${testValue}`, () => {
filePicker.enabled = testValue;
filePicker.enabled!.should.equal(testValue);
});
});
});
});

View File

@@ -61,17 +61,6 @@ describe('radioOptionsGroup', function (): void {
it(`component getter`, () => {
should(radioOptionsGroup.component()).not.be.undefined();
});
[true, false].forEach(testValue => {
it(`Test readOnly with testValue: ${testValue}`, () => {
radioOptionsGroup.readOnly = testValue;
radioOptionsGroup.readOnly!.should.equal(testValue);
});
it(`Test enabled with testValue: ${testValue}`, () => {
radioOptionsGroup.enabled = testValue;
radioOptionsGroup.enabled!.should.equal(testValue);
});
});
});
});

View File

@@ -6,14 +6,13 @@ import * as azdata from 'azdata';
import * as path from 'path';
import * as vscode from 'vscode';
import * as loc from '../../localizedConstants';
import { IReadOnly } from '../dialogs/connectControllerDialog';
export interface RadioOptionsInfo {
values?: string[],
defaultValue: string
}
export class FilePicker implements IReadOnly {
export class FilePicker {
private _flexContainer: azdata.FlexContainer;
public readonly filePathInputBox: azdata.InputBoxComponent;
public readonly filePickerButton: azdata.ButtonComponent;
@@ -64,21 +63,8 @@ export class FilePicker implements IReadOnly {
return this.filePathInputBox?.value;
}
get readOnly(): boolean {
return this.enabled;
}
set readOnly(value: boolean) {
this.enabled = value;
}
get enabled(): boolean {
return !!this._flexContainer.enabled && this._flexContainer.items.every(r => r.enabled);
}
set enabled(value: boolean) {
this._flexContainer.items.forEach(r => r.enabled = value);
this._flexContainer.enabled = value;
get items(): azdata.Component[] {
return this._flexContainer.items;
}
}

View File

@@ -5,14 +5,13 @@
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import { getErrorMessage } from '../../common/utils';
import { IReadOnly } from '../dialogs/connectControllerDialog';
export interface RadioOptionsInfo {
values?: string[],
defaultValue: string
}
export class RadioOptionsGroup implements IReadOnly {
export class RadioOptionsGroup {
static id: number = 1;
private _divContainer!: azdata.DivContainer;
private _loadingBuilder: azdata.LoadingComponentBuilder;
@@ -68,23 +67,6 @@ export class RadioOptionsGroup implements IReadOnly {
return this._currentRadioOption?.value;
}
get readOnly(): boolean {
return this.enabled;
}
set readOnly(value: boolean) {
this.enabled = value;
}
get enabled(): boolean {
return !!this._divContainer.enabled && this._divContainer.items.every(r => r.enabled);
}
set enabled(value: boolean) {
this._divContainer.items.forEach(r => r.enabled = value);
this._divContainer.enabled = value;
}
get items(): azdata.Component[] {
return this._divContainer.items;
}

View File

@@ -19,9 +19,7 @@ import { getCurrentClusterContext, getDefaultKubeConfigPath, getKubeConfigCluste
import { FilePicker } from '../components/filePicker';
export type ConnectToControllerDialogModel = { controllerModel: ControllerModel, password: string };
export interface IReadOnly {
readOnly?: boolean
}
abstract class ControllerDialogBase extends InitializingComponent {
protected _toDispose: vscode.Disposable[] = [];
protected modelBuilder!: azdata.ModelBuilder;
@@ -70,7 +68,7 @@ abstract class ControllerDialogBase extends InitializingComponent {
}
protected abstract fieldToFocusOn(): azdata.Component;
protected readonlyFields(): IReadOnly[] { return []; }
protected readonlyFields(): azdata.Component[] { return []; }
protected initializeFields(controllerInfo: ControllerInfo | undefined, password: string | undefined) {
this.urlInputBox = this.modelBuilder.inputBox()
@@ -140,7 +138,7 @@ abstract class ControllerDialogBase extends InitializingComponent {
}]).withLayout({ width: '100%' }).component();
await view.initializeModel(formModel);
await this.fieldToFocusOn().focus();
this.readonlyFields().forEach(f => f.readOnly = true);
this.readonlyFields().forEach(f => f.enabled = false);
this.initialized = true;
});
@@ -255,11 +253,11 @@ export class PasswordToControllerDialog extends ControllerDialogBase {
return this.passwordInputBox;
}
protected readonlyFields() {
protected readonlyFields(): azdata.Component[] {
return [
this.urlInputBox,
this.kubeConfigInputBox,
this.clusterContextRadioGroup,
...this.kubeConfigInputBox.items,
...this.clusterContextRadioGroup.items,
this.nameInputBox,
this.usernameInputBox
];