Skip to content

Commit 7251869

Browse files
authored
Enable durable configuration path for python v2 (#4688)
1 parent 073e8e6 commit 7251869

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

src/commands/createFunction/FunctionListStep.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { getWorkspaceSetting, updateWorkspaceSetting } from '../../vsCodeConfig/
1818
import { FunctionSubWizard } from './FunctionSubWizard';
1919
import { type IFunctionWizardContext } from './IFunctionWizardContext';
2020
import { JobsListStep } from './JobsListStep';
21-
import { DurableStorageTypePromptStep } from './durableSteps/DurableStorageTypePromptStep';
21+
import { DurableStorageTypeListStep } from './durableSteps/DurableStorageTypePromptStep';
2222

2323
export class FunctionListStep extends AzureWizardPromptStep<IFunctionWizardContext> {
2424
public hideStepCount: boolean = true;
@@ -66,17 +66,20 @@ export class FunctionListStep extends AzureWizardPromptStep<IFunctionWizardConte
6666
}
6767

6868
public async getSubWizard(context: IFunctionWizardContext): Promise<IWizardOptions<IFunctionWizardContext> | undefined> {
69+
const requiresDurableStorageSetup: boolean = durableUtils.requiresDurableStorageSetup(context);
70+
6971
if (context.functionTemplate?.templateSchemaVersion === TemplateSchemaVersion.v2) {
70-
return { promptSteps: [new JobsListStep(this._isProjectWizard)] };
72+
return requiresDurableStorageSetup ?
73+
{ promptSteps: [new DurableStorageTypeListStep(), new JobsListStep(this._isProjectWizard)] } :
74+
{ promptSteps: [new JobsListStep(this._isProjectWizard)] };
7175
}
7276

73-
const requiresDurableStorageSetup: boolean = durableUtils.requiresDurableStorageSetup(context);
77+
const { promptSteps = [], executeSteps = [] } = await FunctionSubWizard.createSubWizard(context, this._functionSettings, this._isProjectWizard) ?? { promptSteps: [], executeSteps: [] };
7478
if (requiresDurableStorageSetup) {
75-
return { promptSteps: [new DurableStorageTypePromptStep()] };
76-
} else {
77-
return await FunctionSubWizard.createSubWizard(context, this._functionSettings, this._isProjectWizard);
79+
promptSteps.unshift(new DurableStorageTypeListStep());
7880
}
7981

82+
return { promptSteps, executeSteps };
8083
}
8184

8285
public async prompt(context: IFunctionWizardContext): Promise<void> {

src/commands/createFunction/FunctionSubWizard.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { BallerinaFunctionNameStep } from './ballerinaSteps/BallerinaFunctionNam
1919
import { DotnetFunctionCreateStep } from './dotnetSteps/DotnetFunctionCreateStep';
2020
import { DotnetFunctionNameStep } from './dotnetSteps/DotnetFunctionNameStep';
2121
import { DotnetNamespaceStep } from './dotnetSteps/DotnetNamespaceStep';
22-
import { DurableProjectConfigureStep } from './durableSteps/DurableProjectConfigureStep';
2322
import { JavaFunctionCreateStep } from './javaSteps/JavaFunctionCreateStep';
2423
import { JavaFunctionNameStep } from './javaSteps/JavaFunctionNameStep';
2524
import { OpenAPICreateStep } from './openAPISteps/OpenAPICreateStep';
@@ -98,10 +97,6 @@ export class FunctionSubWizard {
9897
}
9998
}
10099

101-
if (context.newDurableStorageType) {
102-
executeSteps.push(new DurableProjectConfigureStep());
103-
}
104-
105100
const title: string = localize('createFunction', 'Create new {0}', template.name);
106101
return { promptSteps, executeSteps, title };
107102
} else if (context.generateFromOpenAPI) {

src/commands/createFunction/durableSteps/DurableStorageTypePromptStep.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,10 @@ import { AzureWizardPromptStep, openUrl, type IAzureQuickPickItem, type IWizardO
77
import { DurableBackend } from "../../../constants";
88
import { defaultDescription, previewDescription } from "../../../constants-nls";
99
import { localize } from "../../../localize";
10-
import { FunctionSubWizard } from "../FunctionSubWizard";
1110
import { type IFunctionWizardContext } from "../IFunctionWizardContext";
11+
import { DurableProjectConfigureStep } from "./DurableProjectConfigureStep";
1212

13-
export class DurableStorageTypePromptStep<T extends IFunctionWizardContext> extends AzureWizardPromptStep<T> {
14-
private readonly _functionSettings: { [key: string]: string | undefined };
15-
16-
public constructor(functionSettings?: { [key: string]: string | undefined }) {
17-
super();
18-
this._functionSettings = functionSettings || {};
19-
}
20-
13+
export class DurableStorageTypeListStep<T extends IFunctionWizardContext> extends AzureWizardPromptStep<T> {
2114
public async prompt(context: T): Promise<void> {
2215
const durableStorageInfo: string = localize('durableStorageInfo', '$(link-external) Learn more about the tradeoffs between storage providers');
2316

@@ -45,7 +38,7 @@ export class DurableStorageTypePromptStep<T extends IFunctionWizardContext> exte
4538
return !context.hasDurableStorage && !context.newDurableStorageType;
4639
}
4740

48-
public async getSubWizard(context: T): Promise<IWizardOptions<T> | undefined> {
49-
return await FunctionSubWizard.createSubWizard(context, this._functionSettings);
41+
public async getSubWizard(): Promise<IWizardOptions<T> | undefined> {
42+
return { executeSteps: [new DurableProjectConfigureStep()] };
5043
}
5144
}

0 commit comments

Comments
 (0)