mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 01:25:36 -05:00
fix the input box validation (#15634)
* fix the input box validation * fix one more place
This commit is contained in:
@@ -116,7 +116,7 @@ export function validateInputs(optionsMap: { [optionName: string]: IOptionElemen
|
||||
optionElement.option.valueType === ServiceOptionType.number);
|
||||
|
||||
if (isInputBox) {
|
||||
if (!widget.validate()) {
|
||||
if (widget.validate() !== undefined) {
|
||||
isValid = false;
|
||||
if (!isFocused) {
|
||||
isFocused = true;
|
||||
|
||||
@@ -159,7 +159,7 @@ export default class InputBoxComponent extends ComponentBase<azdata.InputBoxProp
|
||||
public async validate(): Promise<boolean> {
|
||||
await super.validate();
|
||||
// Let the input validate handle showing/hiding the error message
|
||||
const valid = this.inputElement.validate();
|
||||
const valid = this.inputElement.validate() === undefined;
|
||||
|
||||
// set aria label based on validity of input
|
||||
if (valid) {
|
||||
|
||||
@@ -826,7 +826,7 @@ export class BackupComponent extends AngularDisposable {
|
||||
|
||||
private enableBackupButton(): void {
|
||||
if (!this.backupButton!.enabled) {
|
||||
if (this.pathListBox!.count > 0 && (!this.isFormatChecked || this.mediaNameBox!.value) && this.backupRetainDaysBox!.validate()) {
|
||||
if (this.pathListBox!.count > 0 && (!this.isFormatChecked || this.mediaNameBox!.value) && this.backupRetainDaysBox!.validate() === undefined) {
|
||||
this.backupEnabled = true;
|
||||
}
|
||||
}
|
||||
@@ -851,7 +851,7 @@ export class BackupComponent extends AngularDisposable {
|
||||
}
|
||||
|
||||
private backupRetainDaysChanged(days: string): void {
|
||||
if (!this.backupRetainDaysBox!.validate()) {
|
||||
if (this.backupRetainDaysBox!.validate() !== undefined) {
|
||||
this.backupEnabled = false;
|
||||
} else {
|
||||
this.enableBackupButton();
|
||||
|
||||
@@ -887,27 +887,27 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
|
||||
private validateInputs(): boolean {
|
||||
let isFocused = false;
|
||||
let validateServerName = this._serverNameInputBox.validate();
|
||||
if (!validateServerName) {
|
||||
const isServerNameValid = this._serverNameInputBox.validate() === undefined;
|
||||
if (!isServerNameValid) {
|
||||
this._serverNameInputBox.focus();
|
||||
isFocused = true;
|
||||
}
|
||||
let validateUserName = this._userNameInputBox.validate();
|
||||
if (!validateUserName && !isFocused) {
|
||||
const isUserNameValid = this._userNameInputBox.validate() === undefined;
|
||||
if (!isUserNameValid && !isFocused) {
|
||||
this._userNameInputBox.focus();
|
||||
isFocused = true;
|
||||
}
|
||||
let validatePassword = this._passwordInputBox.validate();
|
||||
if (!validatePassword && !isFocused) {
|
||||
const isPasswordValid = this._passwordInputBox.validate() === undefined;
|
||||
if (!isPasswordValid && !isFocused) {
|
||||
this._passwordInputBox.focus();
|
||||
isFocused = true;
|
||||
}
|
||||
let validateAzureAccount = this.validateAzureAccountSelection();
|
||||
if (!validateAzureAccount && !isFocused) {
|
||||
const isAzureAccountValid = this.validateAzureAccountSelection();
|
||||
if (!isAzureAccountValid && !isFocused) {
|
||||
this._azureAccountDropdown.focus();
|
||||
isFocused = true;
|
||||
}
|
||||
return validateServerName && validateUserName && validatePassword && validateAzureAccount;
|
||||
return isServerNameValid && isUserNameValid && isPasswordValid && isAzureAccountValid;
|
||||
}
|
||||
|
||||
public connect(model: IConnectionProfile): boolean {
|
||||
|
||||
@@ -307,11 +307,11 @@ export class ServerGroupDialog extends Modal {
|
||||
|
||||
private validateInputs(): boolean {
|
||||
const renderedDialog = this.withRenderedDialog;
|
||||
let validate = renderedDialog.groupNameInputBox.validate();
|
||||
if (!validate) {
|
||||
const isNameValid = renderedDialog.groupNameInputBox.validate() === undefined;
|
||||
if (!isNameValid) {
|
||||
renderedDialog.groupNameInputBox.focus();
|
||||
}
|
||||
return validate;
|
||||
return isNameValid;
|
||||
}
|
||||
|
||||
// initialize the view based on the current state of the view model
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as OptionsDialogHelper from 'sql/workbench/browser/modal/optionsDialogHelper';
|
||||
import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import { InputBox, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import * as azdata from 'azdata';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as assert from 'assert';
|
||||
@@ -100,7 +100,7 @@ suite('Advanced options helper tests', () => {
|
||||
|
||||
inputBox = TypeMoq.Mock.ofType(InputBox, TypeMoq.MockBehavior.Loose, $('div'), null, null);
|
||||
inputBox.callBase = true;
|
||||
inputBox.setup(x => x.validate()).returns(() => isValid);
|
||||
inputBox.setup(x => x.validate()).returns(() => isValid ? undefined : MessageType.ERROR);
|
||||
inputBox.setup(x => x.value).returns(() => inputValue);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user