Skip to content

Commit a852378

Browse files
authored
Add children for create new project and create new function (#4490)
* Convert execute activity steps to v2 children * Delete extra code causing npm lint to fail * Fix build errors for activity Children * Add children for create new project and create new function * Minor edits * Local changes for deployment activity children * Update appservice package for deploy changes * Fix package-lock.json * Missed merge conflict * Lock it up
1 parent 673a96c commit a852378

25 files changed

+288
-47
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@
14101410
"@azure/core-client": "^1.7.3",
14111411
"@azure/core-rest-pipeline": "^1.11.0",
14121412
"@azure/storage-blob": "^12.5.0",
1413-
"@microsoft/vscode-azext-azureappservice": "^3.6.0",
1413+
"@microsoft/vscode-azext-azureappservice": "^3.6.1",
14141414
"@microsoft/vscode-azext-azureappsettings": "^0.2.8",
14151415
"@microsoft/vscode-azext-azureutils": "^3.2.1",
14161416
"@microsoft/vscode-azext-utils": "^3.0.1",

src/commands/addBinding/BindingCreateStep.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,36 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { AzureWizardExecuteStep } from "@microsoft/vscode-azext-utils";
6+
import { AzureWizardExecuteStepWithActivityOutput } from "@microsoft/vscode-azext-utils";
77
import { Uri, window, workspace, type Progress } from "vscode";
88
import { type IFunctionBinding, type IFunctionJson } from "../../funcConfig/function";
9+
import { localize } from "../../localize";
910
import { type IBindingTemplate } from "../../templates/IBindingTemplate";
1011
import { confirmEditJsonFile } from '../../utils/fs';
1112
import { nonNullProp } from "../../utils/nonNull";
1213
import { verifyExtensionBundle } from "../../utils/verifyExtensionBundle";
1314
import { getBindingSetting } from "../createFunction/IFunctionWizardContext";
1415
import { type IBindingWizardContext } from "./IBindingWizardContext";
1516

16-
export class BindingCreateStep extends AzureWizardExecuteStep<IBindingWizardContext> {
17+
export class BindingCreateStep extends AzureWizardExecuteStepWithActivityOutput<IBindingWizardContext> {
1718
public priority: number = 220;
19+
stepName = 'bindingCreateStep';
20+
public getTreeItemLabel(context: IBindingWizardContext): string {
21+
const bindingTemplate: IBindingTemplate = nonNullProp(context, 'bindingTemplate');
22+
return localize('addBinding', 'Add {0} binding', bindingTemplate.type);
23+
}
24+
public getOutputLogSuccess(context: IBindingWizardContext): string {
25+
const bindingTemplate: IBindingTemplate = nonNullProp(context, 'bindingTemplate');
26+
return localize('addBindingSuccess', 'Successfully added {0} binding.', bindingTemplate.type);
27+
}
28+
public getOutputLogFail(context: IBindingWizardContext): string {
29+
const bindingTemplate: IBindingTemplate = nonNullProp(context, 'bindingTemplate');
30+
return localize('addBindingFail', 'Failed to add {0} binding.', bindingTemplate.type);
31+
}
32+
public getOutputLogProgress(context: IBindingWizardContext): string {
33+
const bindingTemplate: IBindingTemplate = nonNullProp(context, 'bindingTemplate');
34+
return localize('addingBinding', 'Adding {0} binding...', bindingTemplate.type);
35+
}
1836

1937
public async execute(context: IBindingWizardContext, _progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> {
2038
const bindingTemplate: IBindingTemplate = nonNullProp(context, 'bindingTemplate');

src/commands/addBinding/addBinding.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ext } from "../../extensionVariables";
1111
import { localize } from "../../localize";
1212
import { type LocalFunctionTreeItem } from "../../tree/localProject/LocalFunctionTreeItem";
1313
import { type LocalProjectTreeItem } from "../../tree/localProject/LocalProjectTreeItem";
14+
import { createActivityContext } from "../../utils/activityUtils";
1415
import { nonNullValue } from "../../utils/nonNull";
1516
import { getContainingWorkspace } from "../../utils/workspace";
1617
import { getWorkspaceSetting } from "../../vsCodeConfig/settings";
@@ -55,7 +56,7 @@ export async function addBinding(context: IActionContext, data: Uri | LocalFunct
5556
}
5657

5758
const projectTemplateKey: string | undefined = getWorkspaceSetting(projectTemplateKeySetting, projectPath);
58-
const wizardContext: IBindingWizardContext = Object.assign(context, { functionJsonPath, workspacePath, projectPath, workspaceFolder, language, version, projectTemplateKey });
59+
const wizardContext: IBindingWizardContext = Object.assign(context, await createActivityContext(), { functionJsonPath, workspacePath, projectPath, workspaceFolder, language, version, projectTemplateKey });
5960
const wizard: AzureWizard<IBindingWizardContext> = createBindingWizard(wizardContext);
6061
await wizard.prompt();
6162
await wizard.execute();

src/commands/addBinding/settingSteps/AzureConnectionCreateStepBase.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { AzureWizardExecuteStep } from '@microsoft/vscode-azext-utils';
6+
import { AzureWizardExecuteStepWithActivityOutput } from '@microsoft/vscode-azext-utils';
77
import { type Progress } from 'vscode';
88
import { setLocalAppSetting } from '../../../funcConfig/local.settings';
99
import { localize } from '../../../localize';
@@ -16,8 +16,21 @@ export interface IConnection {
1616
connectionString: string;
1717
}
1818

19-
export abstract class AzureConnectionCreateStepBase<T extends IFunctionWizardContext> extends AzureWizardExecuteStep<T> {
19+
export abstract class AzureConnectionCreateStepBase<T extends IFunctionWizardContext> extends AzureWizardExecuteStepWithActivityOutput<T> {
2020
public priority: number = 200;
21+
stepName = 'azureConnectionCreateStepBase';
22+
public getTreeItemLabel(_context: T): string {
23+
return localize('azureConnection', 'Add connection string');
24+
}
25+
public getOutputLogSuccess(_context: T): string {
26+
return localize('azureConnectionSuccess', 'Successfully added connection string.');
27+
}
28+
public getOutputLogFail(_context: T): string {
29+
return localize('azureConnectionFail', 'Failed to add connection string.');
30+
}
31+
public getOutputLogProgress(_context: T): string {
32+
return localize('addingConnectionString', 'Adding connection string...');
33+
}
2134

2235
private readonly _setting: IBindingSetting | ParsedInput;
2336
private readonly _resourceType: string;

src/commands/addBinding/settingSteps/LocalAppSettingCreateStep.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { AzureWizardExecuteStep } from '@microsoft/vscode-azext-utils';
6+
import { AzureWizardExecuteStepWithActivityOutput } from '@microsoft/vscode-azext-utils';
77
import { type Progress } from 'vscode';
88
import { localSettingsFileName } from '../../../constants';
99
import { setLocalAppSetting } from '../../../funcConfig/local.settings';
@@ -14,8 +14,21 @@ import { nonNullProp, nonNullValue } from '../../../utils/nonNull';
1414
import { getBindingSetting, setBindingSetting } from '../../createFunction/IFunctionWizardContext';
1515
import { type IBindingWizardContext } from '../IBindingWizardContext';
1616

17-
export class LocalAppSettingCreateStep extends AzureWizardExecuteStep<IBindingWizardContext> {
17+
export class LocalAppSettingCreateStep extends AzureWizardExecuteStepWithActivityOutput<IBindingWizardContext> {
1818
public priority: number = 210;
19+
stepName = 'localAppSettingCreateStep';
20+
public getTreeItemLabel(_context: IBindingWizardContext): string {
21+
return localize('localAppSetting', 'Update {0}', localSettingsFileName);
22+
}
23+
public getOutputLogSuccess(_context: IBindingWizardContext): string {
24+
return localize('localAppSettingSuccess', 'Successfully updated {0}.', localSettingsFileName);
25+
}
26+
public getOutputLogFail(_context: IBindingWizardContext): string {
27+
return localize('localAppSettingFail', 'Failed to update {0}.', localSettingsFileName);
28+
}
29+
public getOutputLogProgress(_context: IBindingWizardContext): string {
30+
return localize('updatingLocalSettings', 'Updating {0}...', localSettingsFileName);
31+
}
1932

2033
private readonly _setting: IBindingSetting | ParsedInput;
2134
private readonly _valueKey: string;
@@ -26,8 +39,7 @@ export class LocalAppSettingCreateStep extends AzureWizardExecuteStep<IBindingWi
2639
this._valueKey = valueKey;
2740
}
2841

29-
public async execute(context: IBindingWizardContext, progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> {
30-
progress.report({ message: localize('updatingLocalSettings', 'Updating {0}...', localSettingsFileName) });
42+
public async execute(context: IBindingWizardContext, _progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void> {
3143
const appSettingName = String(nonNullValue(getBindingSetting(context, this._setting), this._setting.name));
3244
await setLocalAppSetting(context, context.projectPath, appSettingName, nonNullProp(context, this._valueKey as keyof IBindingWizardContext) as string);
3345
// if the binding isn't already set then a new one was created

src/commands/createFunction/FunctionCreateStepBase.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { AzExtFsExtra, AzureWizardExecuteStep, callWithTelemetryAndErrorHandling, nonNullValue, type IActionContext } from '@microsoft/vscode-azext-utils';
6+
import { AzExtFsExtra, AzureWizardExecuteStepWithActivityOutput, callWithTelemetryAndErrorHandling, nonNullValue, type IActionContext } from '@microsoft/vscode-azext-utils';
77
import * as path from 'path';
88
import { Uri, window, workspace, type Progress } from 'vscode';
99
import { hostFileName } from '../../constants';
@@ -35,9 +35,25 @@ export async function runPostFunctionCreateStepsFromCache(): Promise<void> {
3535
}
3636
}
3737

38-
export abstract class FunctionCreateStepBase<T extends IFunctionWizardContext> extends AzureWizardExecuteStep<T> {
38+
export abstract class FunctionCreateStepBase<T extends IFunctionWizardContext> extends AzureWizardExecuteStepWithActivityOutput<T> {
3939
public priority: number = 220;
40-
40+
public stepName: string = 'FunctionCreateStepBase';
41+
public getTreeItemLabel(context: T): string {
42+
const template: FunctionTemplateBase = nonNullValue(context.functionTemplate);
43+
return localize('creatingFunction', 'Create new {0} "{1}"', template.name, context.functionName);
44+
}
45+
public getOutputLogSuccess(context: T): string {
46+
const template: FunctionTemplateBase = nonNullValue(context.functionTemplate);
47+
return localize('createdFunction', 'Successfully created new {0} "{1}".', template.name, context.functionName);
48+
}
49+
public getOutputLogFail(context: T): string {
50+
const template: FunctionTemplateBase = nonNullValue(context.functionTemplate);
51+
return localize('failedToCreateFunction', 'Failed to create new {0} "{1}".', template.name, context.functionName);
52+
}
53+
public getOutputLogProgress(context: T): string {
54+
const template: FunctionTemplateBase = nonNullValue(context.functionTemplate);
55+
return localize('creatingFunction', 'Creating new {0} "{1}"...', template.name, context.functionName);
56+
}
4157
/**
4258
* Returns the full path to the new function file
4359
*/

src/commands/createFunction/IFunctionWizardContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { type ISubscriptionContext } from "@microsoft/vscode-azext-utils";
6+
import { type ExecuteActivityContext, type ISubscriptionContext } from "@microsoft/vscode-azext-utils";
77
import { type DurableBackendValues } from "../../constants";
88
import { type BindingSettingValue } from "../../funcConfig/function";
99
import { type IBindingSetting } from "../../templates/IBindingTemplate";
1010
import { type FunctionTemplateBase } from "../../templates/IFunctionTemplate";
1111
import { type ParsedInput, type ParsedJob } from "../../templates/script/parseScriptTemplatesV2";
1212
import { type IProjectWizardContext } from "../createNewProject/IProjectWizardContext";
1313

14-
export interface IFunctionWizardContext extends Partial<ISubscriptionContext>, IProjectWizardContext {
14+
export interface IFunctionWizardContext extends Partial<ISubscriptionContext>, IProjectWizardContext, ExecuteActivityContext {
1515
functionTemplate?: FunctionTemplateBase;
1616
functionName?: string;
1717

src/commands/createFunction/JobsListStep.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { JobType, type ParsedJob } from '../../templates/script/parseScriptTempl
99
import { assertTemplateIsV2 } from '../../utils/templateVersionUtils';
1010
import { isFunctionProject } from '../createNewProject/verifyIsProject';
1111
import { type FunctionV2WizardContext, type IFunctionWizardContext } from './IFunctionWizardContext';
12+
import { JobNameExecuteStep } from './actionStepsV2/JobNameExecuteStep';
1213
import { actionStepFactory } from './actionStepsV2/actionStepFactory';
1314
import { promptStepFactory } from './promptStepsV2/promptStepFactory';
1415

@@ -34,9 +35,10 @@ export class JobsListStep extends AzureWizardPromptStep<IFunctionWizardContext>
3435
});
3536

3637
const executeSteps: AzureWizardExecuteStep<FunctionV2WizardContext>[] = [];
38+
executeSteps.push(new JobNameExecuteStep(context.job.name));
3739
context.job.parsedActions.map((pa, index) => {
3840
// add index to increment the priority number; start at 500 so other execute steps can be injected
39-
executeSteps.push(actionStepFactory(pa, index + 500));
41+
executeSteps.push(actionStepFactory(pa, index + 1 + 500));
4042
});
4143

4244
return { promptSteps, executeSteps };

src/commands/createFunction/actionStepsV2/ActionSchemaStepBase.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export abstract class ActionSchemaStepBase<T extends FunctionV2WizardContext> ex
1212
super();
1313
}
1414

15+
public stepName = `${this.action.name}ActionSchemaStep`;
1516
public async execute(context: T): Promise<void> {
1617
try {
1718
await this.executeAction(context);

0 commit comments

Comments
 (0)