Skip to content

Commit

Permalink
Clean up some code
Browse files Browse the repository at this point in the history
  • Loading branch information
nturinski committed Jan 19, 2024
1 parent dbce2da commit 849c8ee
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export abstract class BindingSettingStepBase extends AzureWizardPromptStep<IFunc
public abstract promptCore(context: IFunctionWizardContext): Promise<BindingSettingValue>;

public async prompt(context: IFunctionWizardContext): Promise<void> {
setBindingSetting(context, this._setting as IBindingSetting, await this.promptCore(context));
setBindingSetting(context, this._setting, await this.promptCore(context));
}

public shouldPrompt(context: IFunctionWizardContext): boolean {
Expand Down
5 changes: 4 additions & 1 deletion src/commands/addBinding/settingSteps/EnumPromptStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import { type IBindingWizardContext } from "../IBindingWizardContext";
import { BindingSettingStepBase } from "./BindingSettingStepBase";

export class EnumPromptStep extends BindingSettingStepBase {
// not used by v2 schema so enforce IBindingSetting
protected readonly _setting: IBindingSetting;

public async promptCore(context: IBindingWizardContext): Promise<BindingSettingValue> {
const picks: IAzureQuickPickItem<string>[] = (this._setting as IBindingSetting).enums.map(e => { return { data: e.value, label: e.displayName }; });
const picks: IAzureQuickPickItem<string>[] = this._setting.enums.map(e => { return { data: e.value, label: e.displayName }; });
return (await context.ui.showQuickPick(picks, { placeHolder: this._setting.label })).data;
}
}
5 changes: 3 additions & 2 deletions src/commands/addBinding/settingSteps/StringPromptStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import { type IBindingSetting } from "../../../templates/IBindingTemplate";
import { type IBindingWizardContext } from "../IBindingWizardContext";
import { BindingSettingStepBase } from "./BindingSettingStepBase";

// not used by v2 schema so assume IBindingSetting
export class StringPromptStep extends BindingSettingStepBase {
// not used by v2 schema so assume IBindingSetting
protected readonly _setting: IBindingSetting;
public async promptCore(context: IBindingWizardContext): Promise<BindingSettingValue> {
return await context.ui.showInputBox({
placeHolder: this._setting.label,
prompt: (this._setting as IBindingSetting).description || localize('stringSettingPrompt', 'Provide a \'{0}\'', this._setting.label),
prompt: this._setting.description || localize('stringSettingPrompt', 'Provide a \'{0}\'', this._setting.label),
validateInput: async (s): Promise<string | undefined> => await this.validateInput(context, s),
value: await this.getDefaultValue(context)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export abstract class PromptSchemaStepBase<T extends FunctionV2WizardContext> ex
for (const validator of validators) {
if (value) {
if (!new RegExp(validator.expression).test(value)) {
// TODO: get the errorText properly
return validator.errorText;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/commands/createFunction/promptStepsV2/StringInputStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export class StringInputStep<T extends FunctionV2WizardContext> extends PromptSc
title: this.input.label,
prompt: this.input.help,
value: this.input.defaultValue,
validateInput: value => { return this.validateInput(value, this.input); }
validateInput: value => {
return this.validateInput(value, this.input);
}
};

return await context.ui.showInputBox(options);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { deleteServiceConnector } from '../serviceConnector/deleteServiceConnect
import { validateServiceConnector } from '../serviceConnector/validateServiceConnector';
import { ResolvedFunctionAppResource } from '../tree/ResolvedFunctionAppResource';
import { addBinding } from './addBinding/addBinding';
import { setAzureWebJobsStorage } from './appSettings/connectionSettings/azureWebJobsStorage/setAzureWebJobsStorage';
import { downloadAppSettings } from './appSettings/downloadAppSettings';
import { decryptLocalSettings } from './appSettings/localSettings/decryptLocalSettings';
import { encryptLocalSettings } from './appSettings/localSettings/encryptLocalSettings';
Expand Down Expand Up @@ -92,6 +93,7 @@ export function registerCommands(): void {
registerCommandWithTreeNodeUnwrapping('azureFunctions.pickProcess', pickFuncProcess);
registerCommandWithTreeNodeUnwrapping('azureFunctions.redeploy', redeployDeployment);
registerCommandWithTreeNodeUnwrapping('azureFunctions.restartFunctionApp', restartFunctionApp);
registerCommandWithTreeNodeUnwrapping('azureFunctions.setAzureWebJobsStorage', setAzureWebJobsStorage);
registerCommandWithTreeNodeUnwrapping('azureFunctions.startFunctionApp', startFunctionApp);
registerCommandWithTreeNodeUnwrapping('azureFunctions.startJavaRemoteDebug', remoteDebugJavaFunctionApp);
registerCommandWithTreeNodeUnwrapping('azureFunctions.startRemoteDebug', startRemoteDebug);
Expand Down

0 comments on commit 849c8ee

Please sign in to comment.