Fix deployment wizard to not close when cancelling out of password prompt (#14083)

This commit is contained in:
Charles Gagnon
2021-01-28 09:00:46 -08:00
committed by GitHub
parent 14cf6add73
commit 8677ffc68c
6 changed files with 27 additions and 108 deletions

View File

@@ -10,7 +10,7 @@ import * as path from 'path';
import { IOptionsSourceProvider } from 'resource-deployment';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { getDateTimeString, getErrorMessage, throwUnless } from '../common/utils';
import { getDateTimeString, getErrorMessage, isUserCancelledError, throwUnless } from '../common/utils';
import { AzureAccountFieldInfo, AzureLocationsFieldInfo, ComponentCSSStyles, DialogInfoBase, FieldInfo, FieldType, FilePickerFieldInfo, instanceOfDynamicEnablementInfo, IOptionsSource, KubeClusterContextFieldInfo, LabelPosition, NoteBookEnvironmentVariablePrefix, OptionsInfo, OptionsType, PageInfoBase, RowInfo, SectionInfo, TextCSSStyles } from '../interfaces';
import * as loc from '../localizedConstants';
import { apiService } from '../services/apiService';
@@ -667,12 +667,16 @@ async function configureOptionsSourceSubfields(context: FieldContext, optionsSou
try {
return await optionsSourceProvider.getVariableValue!(variableKey, value);
} catch (e) {
disableControlButtons(context.container);
context.container.message = {
text: getErrorMessage(e),
description: '',
level: azdata.window.MessageLevel.Error
};
if (!isUserCancelledError(e)) {
// User cancelled is a normal scenario so we shouldn't disable anything in that case
// so that the user can retry if they want to
disableControlButtons(context.container);
context.container.message = {
text: getErrorMessage(e),
description: '',
level: azdata.window.MessageLevel.Error
};
}
throw e;
}
},

View File

@@ -12,7 +12,7 @@ import { DeploymentType, NotebookWizardDeploymentProvider, NotebookWizardInfo }
import { IPlatformService } from '../../services/platformService';
import { NotebookWizardAutoSummaryPage } from './notebookWizardAutoSummaryPage';
import { NotebookWizardPage } from './notebookWizardPage';
import { ErrorType, ErrorWithType } from 'resource-deployment';
import { isUserCancelledError } from '../../common/utils';
export class NotebookWizardModel extends ResourceTypeModel {
private _inputComponents: InputComponents = {};
@@ -68,11 +68,13 @@ export class NotebookWizardModel extends ResourceTypeModel {
try {
notebook = await this.prepareNotebookAndEnvironment();
} catch (e) {
const isUserCancelled = e instanceof Error && 'type' in e && (<ErrorWithType>e).type === ErrorType.userCancelled;
// user cancellation is a normal scenario, we just bail out of the wizard without actually opening the notebook, so rethrow for any other case
if (!isUserCancelled) {
throw e;
// If there was a user prompt while preparing the Notebook environment (such as prompting for password) and the user
// cancelled out of that then we shouldn't display an error since that's a normal case but should still keep the Wizard
// open so they can make any changes they want and try again without needing to re-enter the information again.
if (isUserCancelledError(e)) {
return false;
}
throw e;
}
if (notebook) { // open the notebook if it was successfully prepared
await this.openNotebook(notebook);