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); }