fix findDropDownItemIndex bug (#15642)

This commit is contained in:
brian-harris
2021-06-09 12:11:19 -07:00
committed by GitHub
parent 95704dc45e
commit 7256bff094
2 changed files with 18 additions and 15 deletions

View File

@@ -130,7 +130,10 @@ export function selectDropDownIndex(dropDown: DropDownComponent, index: number):
} }
export function findDropDownItemIndex(dropDown: DropDownComponent, value: string): number { export function findDropDownItemIndex(dropDown: DropDownComponent, value: string): number {
return dropDown.values && if (dropDown.values) {
dropDown.values.findIndex((v: any) => ((v as CategoryValue)?.displayName?.toLowerCase() === value?.toLowerCase())) || return dropDown.values.findIndex((v: any) =>
-1; (v as CategoryValue)?.displayName?.toLowerCase() === value?.toLowerCase());
}
return -1;
} }

View File

@@ -13,6 +13,8 @@ import { IconPathHelper } from '../constants/iconPathHelper';
import { WIZARD_INPUT_COMPONENT_WIDTH } from './wizardController'; import { WIZARD_INPUT_COMPONENT_WIDTH } from './wizardController';
import { findDropDownItemIndex, selectDropDownIndex } from '../api/utils'; import { findDropDownItemIndex, selectDropDownIndex } from '../api/utils';
const WIZARD_TABLE_COLUMN_WIDTH = '200px';
export class DatabaseBackupPage extends MigrationWizardPage { export class DatabaseBackupPage extends MigrationWizardPage {
private _view!: azdata.ModelView; private _view!: azdata.ModelView;
@@ -394,7 +396,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
private createTargetDatabaseContainer(): azdata.FlexContainer { private createTargetDatabaseContainer(): azdata.FlexContainer {
const WIZARD_INPUT_COMPONENT_WIDTH = '200px';
const headerCssStyles: azdata.CssStyles = { const headerCssStyles: azdata.CssStyles = {
'border': 'none', 'border': 'none',
'font-size': '13px', 'font-size': '13px',
@@ -436,7 +437,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
rowCssStyles: rowCssStyle, rowCssStyles: rowCssStyle,
headerCssStyles: headerCssStyles, headerCssStyles: headerCssStyles,
isReadOnly: true, isReadOnly: true,
width: WIZARD_INPUT_COMPONENT_WIDTH width: WIZARD_TABLE_COLUMN_WIDTH,
}, },
{ {
displayName: constants.TARGET_DATABASE_NAME, displayName: constants.TARGET_DATABASE_NAME,
@@ -444,7 +445,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
rowCssStyles: rowCssStyle, rowCssStyles: rowCssStyle,
headerCssStyles: headerCssStyles, headerCssStyles: headerCssStyles,
isReadOnly: true, isReadOnly: true,
width: WIZARD_INPUT_COMPONENT_WIDTH width: WIZARD_TABLE_COLUMN_WIDTH
}, },
{ {
displayName: constants.RESOURCE_GROUP, displayName: constants.RESOURCE_GROUP,
@@ -452,7 +453,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
rowCssStyles: rowCssStyle, rowCssStyles: rowCssStyle,
headerCssStyles: headerCssStyles, headerCssStyles: headerCssStyles,
isReadOnly: true, isReadOnly: true,
width: WIZARD_INPUT_COMPONENT_WIDTH width: WIZARD_TABLE_COLUMN_WIDTH
}, },
{ {
displayName: constants.STORAGE_ACCOUNT, displayName: constants.STORAGE_ACCOUNT,
@@ -460,7 +461,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
rowCssStyles: rowCssStyle, rowCssStyles: rowCssStyle,
headerCssStyles: headerCssStyles, headerCssStyles: headerCssStyles,
isReadOnly: true, isReadOnly: true,
width: WIZARD_INPUT_COMPONENT_WIDTH width: WIZARD_TABLE_COLUMN_WIDTH
}, },
{ {
displayName: constants.BLOB_CONTAINER, displayName: constants.BLOB_CONTAINER,
@@ -468,7 +469,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
rowCssStyles: rowCssStyle, rowCssStyles: rowCssStyle,
headerCssStyles: headerCssStyles, headerCssStyles: headerCssStyles,
isReadOnly: true, isReadOnly: true,
width: WIZARD_INPUT_COMPONENT_WIDTH width: WIZARD_TABLE_COLUMN_WIDTH
} }
] ]
}).component(); }).component();
@@ -637,7 +638,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
public async onPageEnter(): Promise<void> { public async onPageEnter(): Promise<void> {
if (this.migrationStateModel.refreshDatabaseBackupPage) { if (this.migrationStateModel.refreshDatabaseBackupPage) {
const WIZARD_INPUT_COMPONENT_WIDTH = '200px';
const connectionProfile = await this.migrationStateModel.getSourceConnectionProfile(); const connectionProfile = await this.migrationStateModel.getSourceConnectionProfile();
const queryProvider = azdata.dataprotocol.getProvider<azdata.QueryProvider>((await this.migrationStateModel.getSourceConnectionProfile()).providerId, azdata.DataProviderType.QueryProvider); const queryProvider = azdata.dataprotocol.getProvider<azdata.QueryProvider>((await this.migrationStateModel.getSourceConnectionProfile()).providerId, azdata.DataProviderType.QueryProvider);
const query = 'select SUSER_NAME()'; const query = 'select SUSER_NAME()';
@@ -666,7 +666,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
const targetDatabaseInput = this._view.modelBuilder.inputBox().withProps({ const targetDatabaseInput = this._view.modelBuilder.inputBox().withProps({
required: true, required: true,
value: db, value: db,
width: WIZARD_INPUT_COMPONENT_WIDTH width: WIZARD_TABLE_COLUMN_WIDTH
}).withValidation(c => { }).withValidation(c => {
if (this._networkShareTargetDatabaseNames.filter(t => t.value === c.value).length > 1) { //Making sure no databases have duplicate values. if (this._networkShareTargetDatabaseNames.filter(t => t.value === c.value).length > 1) { //Making sure no databases have duplicate values.
c.validationErrorMessage = constants.DUPLICATE_NAME_ERROR; c.validationErrorMessage = constants.DUPLICATE_NAME_ERROR;
@@ -690,7 +690,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
const blobtargetDatabaseInput = this._view.modelBuilder.inputBox().withProps({ const blobtargetDatabaseInput = this._view.modelBuilder.inputBox().withProps({
required: true, required: true,
value: db, value: db,
width: WIZARD_INPUT_COMPONENT_WIDTH width: WIZARD_TABLE_COLUMN_WIDTH
}).withValidation(c => { }).withValidation(c => {
if (this._blobContainerTargetDatabaseNames.filter(t => t.value === c.value).length > 1) { //Making sure no databases have duplicate values. if (this._blobContainerTargetDatabaseNames.filter(t => t.value === c.value).length > 1) { //Making sure no databases have duplicate values.
c.validationErrorMessage = constants.DUPLICATE_NAME_ERROR; c.validationErrorMessage = constants.DUPLICATE_NAME_ERROR;
@@ -712,7 +712,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._blobContainerTargetDatabaseNames.push(blobtargetDatabaseInput); this._blobContainerTargetDatabaseNames.push(blobtargetDatabaseInput);
const blobContainerResourceDropdown = this._view.modelBuilder.dropDown().withProps({ const blobContainerResourceDropdown = this._view.modelBuilder.dropDown().withProps({
width: WIZARD_INPUT_COMPONENT_WIDTH, width: WIZARD_TABLE_COLUMN_WIDTH,
editable: true, editable: true,
fireOnTextChange: true, fireOnTextChange: true,
}).component(); }).component();
@@ -728,7 +728,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
const blobContainerStorageAccountDropdown = this._view.modelBuilder.dropDown() const blobContainerStorageAccountDropdown = this._view.modelBuilder.dropDown()
.withProps({ .withProps({
width: WIZARD_INPUT_COMPONENT_WIDTH, width: WIZARD_TABLE_COLUMN_WIDTH,
editable: true, editable: true,
fireOnTextChange: true, fireOnTextChange: true,
}).component(); }).component();
@@ -744,7 +744,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
const blobContainerDropdown = this._view.modelBuilder.dropDown() const blobContainerDropdown = this._view.modelBuilder.dropDown()
.withProps({ .withProps({
width: WIZARD_INPUT_COMPONENT_WIDTH, width: WIZARD_TABLE_COLUMN_WIDTH,
editable: true, editable: true,
fireOnTextChange: true, fireOnTextChange: true,
}).component(); }).component();