Skip to content

Commit 03cb3f9

Browse files
authored
Convert execute activity steps to v2 children (#4487)
* Convert execute activity steps to v2 children * Delete extra code causing npm lint to fail * Fix build errors for activity Children * Address nitmaster Matts comments * Add context values
1 parent 14f15f4 commit 03cb3f9

File tree

11 files changed

+110
-88
lines changed

11 files changed

+110
-88
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,10 +1410,10 @@
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.5.4",
1413+
"@microsoft/vscode-azext-azureappservice": "^3.6.0",
14141414
"@microsoft/vscode-azext-azureappsettings": "^0.2.8",
1415-
"@microsoft/vscode-azext-azureutils": "^3.1.8",
1416-
"@microsoft/vscode-azext-utils": "^2.6.8",
1415+
"@microsoft/vscode-azext-azureutils": "^3.2.1",
1416+
"@microsoft/vscode-azext-utils": "^3.0.1",
14171417
"@microsoft/vscode-azureresources-api": "^2.0.4",
14181418
"cross-fetch": "^4.0.0",
14191419
"escape-string-regexp": "^4.0.0",

src/commands/addMIConnections/LocalSettingsAddStep.ts

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

6-
import { activitySuccessContext, activitySuccessIcon, AzExtFsExtra, AzureWizardExecuteStep, createUniversallyUniqueContextValue, GenericTreeItem, nonNullProp } from "@microsoft/vscode-azext-utils";
6+
import { ActivityChildItem, ActivityChildType, activitySuccessContext, activitySuccessIcon, AzExtFsExtra, AzureWizardExecuteStep, createContextValue, nonNullProp } from "@microsoft/vscode-azext-utils";
77
import { ext } from "../../extensionVariables";
88
import { getLocalSettingsJsonwithEncryption } from "../../funcConfig/local.settings";
99
import { localize } from "../../localize";
@@ -12,6 +12,7 @@ import { type AddMIConnectionsContext } from "./AddMIConnectionsContext";
1212

1313
export class LocalSettingsAddStep extends AzureWizardExecuteStep<AddMIConnectionsContext> {
1414
public priority: number = 160;
15+
public stepName: string = 'localSettingsAddStep';
1516

1617
public async execute(context: AddMIConnectionsContext): Promise<void> {
1718
// If right clicking on a connection we will have the connections to convert but not the local settings path
@@ -22,13 +23,16 @@ export class LocalSettingsAddStep extends AzureWizardExecuteStep<AddMIConnection
2223

2324
const localSettings = await getLocalSettingsJsonwithEncryption(context, context.localSettingsPath);
2425
if (localSettings.Values) {
26+
// Potentially split this up into multiple execute steps to allow for better progress reporting
2527
for (const connection of nonNullProp(context, 'connectionsToAdd')) {
2628
localSettings.Values[connection.name] = connection.value;
29+
// TODO: Convert to use createSuccessOutput
2730
context.activityChildren?.push(
28-
new GenericTreeItem(undefined, {
29-
contextValue: createUniversallyUniqueContextValue(['useExistingResourceGroupInfoItem', activitySuccessContext]),
31+
new ActivityChildItem({
32+
contextValue: createContextValue([this.stepName, activitySuccessContext]),
3033
label: localize('addedLocalSetting', 'Add local setting "{0}"', connection.name),
31-
iconPath: activitySuccessIcon
34+
iconPath: activitySuccessIcon,
35+
activityType: ActivityChildType.Success
3236
})
3337
);
3438
}

src/commands/addMIConnections/RemoteSettingsAddStep.ts

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

6-
import { activitySuccessContext, activitySuccessIcon, AzureWizardExecuteStep, createUniversallyUniqueContextValue, GenericTreeItem, nonNullProp } from "@microsoft/vscode-azext-utils";
6+
import { ActivityChildItem, ActivityChildType, activitySuccessContext, activitySuccessIcon, AzureWizardExecuteStep, createContextValue, nonNullProp } from "@microsoft/vscode-azext-utils";
77
import { ext } from "../../extensionVariables";
88
import { localize } from "../../localize";
99
import { type AddMIConnectionsContext } from "./AddMIConnectionsContext";
1010

1111
export class RemoteSettingsAddStep extends AzureWizardExecuteStep<AddMIConnectionsContext> {
1212
public priority: number = 160;
13+
public stepName: string = 'remoteSettingsAddStep';
1314

1415
public async execute(context: AddMIConnectionsContext): Promise<void> {
1516
const client = await nonNullProp(context, 'functionapp').site.createClient(context);
1617
const remoteSettings = await client.listApplicationSettings();
1718
const properties = remoteSettings.properties || {};
19+
// // Potentially split this up into multiple execute steps to allow for better progress reporting
1820
for (const connection of nonNullProp(context, 'connectionsToAdd')) {
1921
properties[connection.name] = connection.value;
2022
}
2123

2224
await client.updateApplicationSettings({ properties });
2325
for (const connection of nonNullProp(context, 'connectionsToAdd')) {
26+
// TODO: Convert to use createSuccessOutput
2427
context.activityChildren?.push(
25-
new GenericTreeItem(undefined, {
26-
contextValue: createUniversallyUniqueContextValue(['useExistingResourceGroupInfoItem', activitySuccessContext]),
28+
new ActivityChildItem({
29+
contextValue: createContextValue([this.stepName, activitySuccessContext]),
2730
label: localize('addedAppSetting', 'Add app setting "{0}"', connection.name),
28-
iconPath: activitySuccessIcon
31+
iconPath: activitySuccessIcon,
32+
activityType: ActivityChildType.Success
2933
})
3034
);
3135
}

src/commands/createFunctionApp/FunctionAppCreateStep.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { type Identity } from '@azure/arm-resources';
88
import { BlobServiceClient } from '@azure/storage-blob';
99
import { ParsedSite, WebsiteOS, type CustomLocation, type IAppServiceWizardContext } from '@microsoft/vscode-azext-azureappservice';
1010
import { LocationListStep } from '@microsoft/vscode-azext-azureutils';
11-
import { AzureWizardExecuteStep, maskUserInfo, parseError, randomUtils } from '@microsoft/vscode-azext-utils';
11+
import { AzureWizardExecuteStepWithActivityOutput, maskUserInfo, parseError, randomUtils } from '@microsoft/vscode-azext-utils';
1212
import { type AppResource } from '@microsoft/vscode-azext-utils/hostapi';
1313
import { type Progress } from 'vscode';
1414
import { FuncVersion, getMajorVersion } from '../../FuncVersion';
@@ -22,11 +22,11 @@ import { nonNullProp } from '../../utils/nonNull';
2222
import { getStorageConnectionString } from '../appSettings/connectionSettings/getLocalConnectionSetting';
2323
import { enableFileLogging } from '../logstream/enableFileLogging';
2424
import { type FullFunctionAppStack, type IFlexFunctionAppWizardContext, type IFunctionAppWizardContext } from './IFunctionAppWizardContext';
25-
import { showSiteCreated } from './showSiteCreated';
2625
import { type Sku } from './stacks/models/FlexSkuModel';
2726
import { type FunctionAppRuntimeSettings, } from './stacks/models/FunctionAppStackModel';
2827

29-
export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWizardContext> {
28+
export class FunctionAppCreateStep extends AzureWizardExecuteStepWithActivityOutput<IFunctionAppWizardContext> {
29+
stepName: string = 'createFunctionAppStep';
3030
public priority: number = 1000;
3131

3232
public async execute(context: IFlexFunctionAppWizardContext, progress: Progress<{ message?: string; increment?: number }>): Promise<void> {
@@ -39,8 +39,7 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi
3939
context.telemetry.properties.newSiteMinorVersion = stack.minorVersion.value;
4040
context.telemetry.properties.planSkuTier = context.plan?.sku?.tier;
4141

42-
const message: string = localize('creatingNewApp', 'Creating new function app "{0}"...', context.newSiteName);
43-
ext.outputChannel.appendLog(message);
42+
const message: string = localize('creatingFuncApp', 'Creating function app "{0}"...', context.newSiteName);
4443
progress.report({ message });
4544

4645
const siteName: string = nonNullProp(context, 'newSiteName');
@@ -58,7 +57,6 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi
5857
context.telemetry.properties.fileLoggingError = maskUserInfo(parseError(error).message, []);
5958
}
6059
}
61-
showSiteCreated(site, context);
6260
}
6361

6462
public shouldExecute(context: IFunctionAppWizardContext): boolean {
@@ -249,6 +247,23 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi
249247

250248
return result;
251249
}
250+
251+
protected getTreeItemLabel(context: IFunctionAppWizardContext): string {
252+
const siteName: string = nonNullProp(context, 'newSiteName');
253+
return localize('creatingNewApp', 'Create function app "{0}"', siteName);
254+
}
255+
protected getOutputLogSuccess(context: IFunctionAppWizardContext): string {
256+
const siteName: string = nonNullProp(context, 'newSiteName');
257+
return localize('createdNewApp', 'Successfully created function app "{0}".', siteName);
258+
}
259+
protected getOutputLogFail(context: IFunctionAppWizardContext): string {
260+
const siteName: string = nonNullProp(context, 'newSiteName');
261+
return localize('failedToCreateNewApp', 'Failed to create function app "{0}".', siteName);
262+
}
263+
protected getOutputLogProgress(context: IFunctionAppWizardContext): string {
264+
const siteName: string = nonNullProp(context, 'newSiteName');
265+
return localize('creatingNewApp', 'Creating function app "{0}"...', siteName);
266+
}
252267
}
253268

254269
function getNewFileShareName(siteName: string): string {

src/commands/createFunctionApp/containerImage/ContainerizedFunctionAppCreateStep.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,28 @@ import { AzureWizardExecuteStep, nonNullProp } from "@microsoft/vscode-azext-uti
1111
import { type AppResource } from "@microsoft/vscode-azext-utils/hostapi";
1212
import { type Progress } from "vscode";
1313
import { webProvider } from "../../../constants";
14-
import { ext } from "../../../extensionVariables";
1514
import { localize } from "../../../localize";
1615
import { createWebSiteClient } from "../../../utils/azureClients";
1716
import { getStorageConnectionString } from "../../appSettings/connectionSettings/getLocalConnectionSetting";
1817
import { type IFunctionAppWizardContext } from "../IFunctionAppWizardContext";
19-
import { showSiteCreated } from "../showSiteCreated";
2018

2119
export class ContainerizedFunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWizardContext> {
2220
public priority: number = 140;
2321

2422
public async execute(context: IFunctionAppWizardContext, progress: Progress<{ message?: string; increment?: number }>): Promise<void> {
25-
const message: string = localize('creatingNewApp', 'Creating new function app "{0}"...', context.newSiteName);
26-
ext.outputChannel.appendLog(message);
27-
progress.report({ message });
28-
2923
if (!context.deployWorkspaceResult?.registryLoginServer || !context.deployWorkspaceResult?.imageName) {
3024
throw new Error(localize('failToCreateApp', 'Failed to create function app. There was an error creating the necessary container resources.'));
3125
}
3226

27+
const message: string = localize('creatingNewApp', 'Creating function app "{0}"...', context.newSiteName);
28+
progress.report({ message });
29+
3330
const siteName: string = nonNullProp(context, 'newSiteName');
3431
const rgName: string = nonNullProp(nonNullProp(context, 'resourceGroup'), 'name');
3532
const client: WebSiteManagementClient = await createWebSiteClient(context);
3633
context.site = await client.webApps.beginCreateOrUpdateAndWait(rgName, siteName, await this.getNewSite(context));
3734
context.activityResult = context.site as AppResource;
38-
39-
const containerSite = Object.assign(context.site, { defaultHostUrl: `https://${context.site.defaultHostName}`, fullName: context.site.name, isSlot: false });
40-
4135
await pingContainerizedFunctionApp(context, client, context.site);
42-
showSiteCreated(containerSite, context);
4336
}
4437

4538
public shouldExecute(context: IFunctionAppWizardContext): boolean {
@@ -84,6 +77,23 @@ export class ContainerizedFunctionAppCreateStep extends AzureWizardExecuteStep<I
8477
}
8578
}
8679
}
80+
81+
protected getTreeItemLabel(context: IFunctionAppWizardContext): string {
82+
const siteName: string = nonNullProp(context, 'newSiteName');
83+
return localize('creatingNewApp', 'Create function app "{0}"', siteName);
84+
}
85+
protected getOutputLogSuccess(context: IFunctionAppWizardContext): string {
86+
const siteName: string = nonNullProp(context, 'newSiteName');
87+
return localize('createdNewApp', 'Successfully created function app "{0}".', siteName);
88+
}
89+
protected getOutputLogFail(context: IFunctionAppWizardContext): string {
90+
const siteName: string = nonNullProp(context, 'newSiteName');
91+
return localize('failedToCreateNewApp', 'Failed to create function app "{0}".', siteName);
92+
}
93+
protected getOutputLogProgress(context: IFunctionAppWizardContext): string {
94+
const siteName: string = nonNullProp(context, 'newSiteName');
95+
return localize('creatingNewApp', 'Creating function app "{0}"...', siteName);
96+
}
8797
}
8898

8999
async function pingContainerizedFunctionApp(context: IFunctionAppWizardContext, client: WebSiteManagementClient, site: Site): Promise<void> {

src/commands/createFunctionApp/createCreateFunctionAppComponents.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export async function createCreateFunctionAppComponents(context: ICreateFunction
4040
...(await createActivityContext())
4141
});
4242

43+
wizardContext.activityChildren = [];
44+
4345
const promptSteps: AzureWizardPromptStep<IFunctionAppWizardContext>[] = [];
4446
const executeSteps: AzureWizardExecuteStep<IFunctionAppWizardContext>[] = [];
4547

0 commit comments

Comments
 (0)