From 8a8cb3ab2775c0fb234656a145e324e95655c09b Mon Sep 17 00:00:00 2001 From: Cory Rivera Date: Wed, 3 Jul 2019 14:29:26 -0700 Subject: [PATCH] Clear fields on Add New Package page after getting No Valid Versions error. (#6261) --- .../dialog/managePackages/addNewPackageTab.ts | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/extensions/notebook/src/dialog/managePackages/addNewPackageTab.ts b/extensions/notebook/src/dialog/managePackages/addNewPackageTab.ts index 2e253c7aa5..0885a8a165 100644 --- a/extensions/notebook/src/dialog/managePackages/addNewPackageTab.ts +++ b/extensions/notebook/src/dialog/managePackages/addNewPackageTab.ts @@ -109,12 +109,7 @@ export class AddNewPackageTab { value: '', placeHolder: this.SearchPlaceholder(this.dialog.currentPkgType) }); - await this.newPackagesName.updateProperties({ value: this.InvalidTextPlaceholder }); - await this.newPackagesVersions.updateProperties({ - values: [this.InvalidTextPlaceholder], - value: this.InvalidTextPlaceholder - }); - await this.newPackagesSummary.updateProperties({ value: this.InvalidTextPlaceholder }); + await this.setFieldsToEmpty(); } finally { await this.toggleNewPackagesFields(true); } @@ -127,6 +122,19 @@ export class AddNewPackageTab { await this.newPackagesSummaryLoader.updateProperties({ loading: !enable }); } + private async setFieldsToEmpty(): Promise { + await this.newPackagesName.updateProperties({ + value: this.InvalidTextPlaceholder + }); + await this.newPackagesVersions.updateProperties({ + values: [this.InvalidTextPlaceholder], + value: this.InvalidTextPlaceholder + }); + await this.newPackagesSummary.updateProperties({ + value: this.InvalidTextPlaceholder + }); + } + private async loadNewPackageInfo(): Promise { await this.packageInstallButton.updateProperties({ enabled: false }); await this.toggleNewPackagesFields(false); @@ -146,6 +154,7 @@ export class AddNewPackageTab { this.dialog.showErrorMessage( localize('managePackages.noVersionsFound', "Could not find any valid versions for the specified package")); + await this.setFieldsToEmpty(); return; } @@ -164,17 +173,7 @@ export class AddNewPackageTab { await this.packageInstallButton.updateProperties({ enabled: true }); } catch (err) { this.dialog.showErrorMessage(utils.getErrorMessage(err)); - - await this.newPackagesName.updateProperties({ - value: this.InvalidTextPlaceholder - }); - await this.newPackagesVersions.updateProperties({ - value: this.InvalidTextPlaceholder, - values: [this.InvalidTextPlaceholder], - }); - await this.newPackagesSummary.updateProperties({ - value: this.InvalidTextPlaceholder - }); + await this.setFieldsToEmpty(); } finally { await this.toggleNewPackagesFields(true); }