Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create from Deploy feature and some local UX changes #4130

Merged
merged 20 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 30 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@
"title": "%azureFunctions.deleteSlot%",
"category": "Azure Functions"
},
{
"command": "azureFunctions.deployProject",
"title": "%azureFunctions.deployProject%",
"category": "Azure Functions",
"icon": "$(cloud-upload)",
"enablement": "!virtualWorkspace"
},
{
"command": "azureFunctions.deploy",
"title": "%azureFunctions.deploy%",
Expand Down Expand Up @@ -389,16 +396,8 @@
"group": "1_projects@3"
},
{
"command": "azureFunctions.deploy",
"command": "azureFunctions.deployProject",
"group": "2_deploy@1"
},
{
"command": "azureFunctions.createFunctionApp",
"group": "3_create@1"
},
{
"command": "azureFunctions.createFunctionAppAdvanced",
"group": "3_create@2"
}
],
"view/title": [
Expand All @@ -409,6 +408,26 @@
}
],
"view/item/context": [
{
"command": "azureFunctions.createFunction",
"when": "view == azureWorkspace && viewItem =~ /azFuncLocalProject/i",
"group": "inline"
},
{
"command": "azureFunctions.createFunction",
"when": "view == azureWorkspace && viewItem =~ /azFuncLocalProject/i",
"group": "1@1"
},
{
"command": "azureFunctions.deployProject",
"when": "view == azureWorkspace && viewItem =~ /azFuncLocalProject/i",
"group": "inline"
},
{
"command": "azureFunctions.deployProject",
"when": "view == azureWorkspace && viewItem =~ /azFuncLocalProject/i",
"group": "1@2"
},
{
"command": "azureFunctions.createFunctionApp",
"when": "view == azureResourceGroups && viewItem =~ /functionapp/i && viewItem =~ /azureResourceTypeGroup/i",
Expand Down Expand Up @@ -1114,7 +1133,7 @@
"id": "create",
"title": "%azureFunctions.walkthrough.functionsStart.create.title%",
"completionEvents": [
"onCommand:azureFunctions.createNewProject"
"onCommand:azureFunctions.createFunction"
],
"description": "%azureFunctions.walkthrough.functionsStart.create.description%",
"media": {
Expand Down Expand Up @@ -1204,7 +1223,7 @@
"@microsoft/vscode-azext-azureappsettings": "^0.2.1",
"@microsoft/vscode-azext-azureutils": "^3.0.0",
"@microsoft/vscode-azext-serviceconnector": "^0.1.3",
"@microsoft/vscode-azext-utils": "^2.3.1",
"@microsoft/vscode-azext-utils": "^2.5.0",
"@microsoft/vscode-azureresources-api": "^2.0.4",
"cross-fetch": "^4.0.0",
"escape-string-regexp": "^4.0.0",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"azureFunctions.deleteFunction": "Delete Function...",
"azureFunctions.deleteFunctionApp": "Delete Function App...",
"azureFunctions.deleteSlot": "Delete Slot...",
"azureFunctions.deployProject": "Deploy to Azure...",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed Create Function App... option in the local workspace view
This was replaced with just Deploy function to Azure... which includes a + Create new function app option as a quick pick when we prompt for the app

image

Is it supposed to be "Deploy to Azure..." or "Deploy function to Azure..."?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think we originally went with "Deploy function to Azure..." but after more discussion, just went with a more generic "Deploy to Azure..."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't think we need to give more context to users on what they are deploying?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I mean you're in the workspace part of the extension so I think it's kind of clear. That being said, I think it still prompts you for a workspace folder.

I'm thinking of adding a right-click context item on the local project node though that also has "Deploy to Azure..." on it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I was thinking that they might need to know that the command is for deploying Functions to Azure and not App Service or anything else. But maybe they should already know?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you click the Functions symbol to open the menu for the commands. I thought that was kind of the reason we had those buttons there to give them that context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's fine

"azureFunctions.deploy": "Deploy to Function App...",
"azureFunctions.deployByFunctionAppId": "Deploy to Function App by ID...",
"azureFunctions.deploySlot": "Deploy to Slot...",
Expand Down
18 changes: 17 additions & 1 deletion src/LocalResourceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { type AzExtParentTreeItem, type AzExtTreeItem } from "@microsoft/vscode-azext-utils";
import { GenericTreeItem, type AzExtParentTreeItem, type AzExtTreeItem } from "@microsoft/vscode-azext-utils";
import { type WorkspaceResourceProvider } from "@microsoft/vscode-azext-utils/hostapi";
import { Disposable } from "vscode";
import { localize } from "./localize";
import { InitLocalProjectTreeItem } from "./tree/localProject/InitLocalProjectTreeItem";
import { InvalidLocalProjectTreeItem } from "./tree/localProject/InvalidLocalProjectTreeItem";
import { LocalProjectTreeItem } from "./tree/localProject/LocalProjectTreeItem";
import { treeUtils } from "./utils/treeUtils";
import { listLocalProjects, type LocalProjectInternal } from "./workspace/listLocalProjects";

export class FunctionsLocalResourceProvider implements WorkspaceResourceProvider {
Expand All @@ -21,6 +23,7 @@ export class FunctionsLocalResourceProvider implements WorkspaceResourceProvider
this._projectDisposables = [];

const localProjects = await listLocalProjects();
let hasLocalProject = false;

for (const project of localProjects.initializedProjects) {
const treeItem: LocalProjectTreeItem = new LocalProjectTreeItem(parent, project as LocalProjectInternal);
Expand All @@ -29,13 +32,26 @@ export class FunctionsLocalResourceProvider implements WorkspaceResourceProvider
}

for (const unintializedProject of localProjects.unintializedProjects) {
hasLocalProject = true;
children.push(new InitLocalProjectTreeItem(parent, unintializedProject.projectPath, unintializedProject.workspaceFolder));
}

for (const invalidProject of localProjects.invalidProjects) {
hasLocalProject = true;
children.push(new InvalidLocalProjectTreeItem(parent, invalidProject.projectPath, invalidProject.error, invalidProject.workspaceFolder));
}

if (!hasLocalProject && children.length === 0) {
const ti: GenericTreeItem = new GenericTreeItem(parent, {
label: localize('createFunctionLocally', 'Create Function Project...'),
commandId: 'azureFunctions.createNewProject',
contextValue: 'createNewProject',
iconPath: treeUtils.getThemedIconPath('CreateNewProject')
});
ti.commandArgs = [];
children.push(ti);
}

return children;
}
private _projectDisposables: Disposable[] = [];
Expand Down
4 changes: 2 additions & 2 deletions src/agent/agentIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export async function getCommands(): Promise<(WizardCommandConfig | SimpleComman
{
type: "simple",
name: createFunctionProjectCommandName,
commandId: "azureFunctions.createNewProject",
displayName: "Create Function Project",
commandId: "azureFunctions.createFunction",
displayName: "Create Function Locally",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember if there was a reason we couldn't do something like Create Function (Local)? I vaguely recall a reason but can't really remember anymore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there was a reason or not, but personally if I see (Local), it makes me think that there is another version of Create Function. Probably Create Function (Remote) or something like that.

intentDescription: "This is best when users ask to create a new function project in VS Code. They may also refer to creating a function project by asking to create a project based upon a function project template.",
requiresAzureLogin: true,
},
Expand Down
37 changes: 37 additions & 0 deletions src/commands/SubscriptionListStep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzureWizardPromptStep, type IAzureQuickPickItem } from "@microsoft/vscode-azext-utils";
import { type AzureSubscription } from "@microsoft/vscode-azureresources-api";
import { l10n } from "vscode";
import { ext } from "../extensionVariables";
import { type IFuncDeployContext } from "./deploy/deploy";

export class SubscriptionListStep extends AzureWizardPromptStep<IFuncDeployContext> {
private _picks: IAzureQuickPickItem<AzureSubscription>[] = [];
private _oneSubscription: boolean = false;
public async prompt(context: IFuncDeployContext): Promise<void> {
context.subscription = (await context.ui.showQuickPick(this._picks, { placeHolder: l10n.t("Select a subscription") })).data;
}

public shouldPrompt(_: IFuncDeployContext): boolean {
return !this._oneSubscription;
}

public async configureBeforePrompt(context: IFuncDeployContext): Promise<void> {
this._picks = await this.getPicks(context);
// auto select if only one subscription
if (this._picks.length === 1) {
this._oneSubscription = true;
context.subscription = this._picks[0].data;
}
}

private async getPicks(_: IFuncDeployContext): Promise<IAzureQuickPickItem<AzureSubscription>[]> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we didn't just remove the parameter if it's not being used?

return (await ext.rgApi.getSubscriptions(true)).map(s => {
return { label: s.name, description: s.subscriptionId, data: s };
});
}
}
34 changes: 34 additions & 0 deletions src/commands/createFunctionApp/UniqueNamePromptStep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { type IAppServiceWizardContext } from "@microsoft/vscode-azext-azureappservice";
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
import { localize } from "../../localize";
import { setConsumptionPlanProperties } from "./FunctionAppHostingPlanStep";
import { type IFunctionAppWizardContext } from "./IFunctionAppWizardContext";

export class ConfigureCommonNamesStep extends AzureWizardPromptStep<IAppServiceWizardContext> {
public async prompt(_context: IAppServiceWizardContext): Promise<void> {
// do nothing, will be handled in configuration
}

public shouldPrompt(_context: IAppServiceWizardContext): boolean {
// never prompt
return false;
}

public async configureBeforePrompt(context: IFunctionAppWizardContext): Promise<void> {
if (!context.advancedCreation) {
const newName: string | undefined = await context.relatedNameTask;
if (!newName) {
throw new Error(localize('noUniqueName', 'Failed to generate unique name for resources. Use advanced creation to manually enter resource names.'));
}
context.newResourceGroupName = context.newResourceGroupName || newName;
setConsumptionPlanProperties(context);
context.newStorageAccountName = newName;
context.newAppInsightsName = newName;
}
}
}
Loading
Loading