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

Conversation

nturinski
Copy link
Member

@nturinski nturinski commented May 14, 2024

This is basically this PR #4042 but I removed some of the UX changes regarding "Create function locally...".

I really didn't like having the prompt asking for what type of project does the user want to create. It doesn't really make sense to have it in our main entry point, so until we can think of a good solution, the command list looks like this:

Old:
image
New:
image

  • 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

Other changes I probably should have made separate PRs for 😅:

  • Added Create New Project... to workspace view if there's no project in the workspace. It actually does call azureFunctions.createNewProject because we know that we need to start from scratch. createFunction has to do some checks before it ultimately cancels and calls createNewProject so performance is slightly better to just call it directly.
    Old:
    image
    New:
    image

  • Added two entry points for "Create Function..." which live on the local project node and context menu
    image

@nturinski nturinski requested a review from a team as a code owner May 14, 2024 01:09
@@ -0,0 +1,164 @@
/*---------------------------------------------------------------------------------------------
Copy link
Member Author

Choose a reason for hiding this comment

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

This is basically moving all the code from SubscriptionTreeItem. Please pay careful attention that I actually got everything-- small things have been changing with create here and there (flex, containerized, etc.)

@@ -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

return version;
}

async function createFunctionAppWizard(wizardContext: IFunctionAppWizardContext): Promise<{ promptSteps: AzureWizardPromptStep<IAppServiceWizardContext>[], executeSteps: AzureWizardExecuteStep<IAppServiceWizardContext>[] }> {
Copy link
Member

Choose a reason for hiding this comment

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

I don't love that this function is returning a whole wizard object, but then only the prompt and execute steps on that object are used. I think the return type should be changed to reflect what is actually used.

Also it's a bit weird that this function also sets some wizard context, but I can't provide a better place to set it so 🤷

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 disagree with you, but this is logic that was pre-existing to this PR. I'm open to changing it, but I'd rather do it in a separate PR since I wanted to keep the core logic fundamentally the same.

https://github.com/microsoft/vscode-azurefunctions/pull/4130/files#diff-3b26e2c6749863538fbe756b9eb0e37aaa43b559e370bd6daf7aaa84a871a158L233

}
}

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?

Comment on lines 21 to 26
const promptSteps = [new SubscriptionListStep(), new FunctionAppListStep()];
const title: string = l10n.t('Select Function App');
const wizard: AzureWizard<IAppServiceWizardContext> = new AzureWizard(context, {
promptSteps,
title
});
Copy link
Member

Choose a reason for hiding this comment

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

I prefer if you just put the promptSteps and title values inline here since they aren't used anywhere else.


await wizard.prompt();

node = context.site ? await ext.rgApi.tree.findTreeItem(nonNullProp(context.site, 'id'), context) : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Find tree item is sort of sketchy to use. Have you tested this when the tree hasn't been loaded yet?

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, it works though it's pretty unbearably slow. I may try to refactor this to just use the data model instead because of the performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's pretty tough without some significant refactoring. We need to pass the tree ndoe to deploy because it does the whole temporary description thing on it. If the node isn't there or if the parent is undefined, it'll throw an error.

}
});

qp.unshift({ label: '$(plus) Create new function app', description: '', data: undefined });
Copy link
Member

Choose a reason for hiding this comment

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

Why the empty description?

Copy link
Member Author

Choose a reason for hiding this comment

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

You see the description as half empty, but I see it as half full.

}

public async getSubWizard(context: IFuncDeployContext): Promise<IWizardOptions<IFuncDeployContext> | undefined> {
if (!context.site) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment here. It seems like this the pivotal place where the code decides if we're creating a FA or not for deploy.

Copy link
Contributor

@MicroFish91 MicroFish91 May 16, 2024

Choose a reason for hiding this comment

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

Nit: I would also like to suggest using a guard clause here to clean this up a bit more :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you clarify what you mean by using a guard clause here? I'm not really sure what I would be type guarding in this case.

Copy link
Contributor

@MicroFish91 MicroFish91 May 17, 2024

Choose a reason for hiding this comment

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

Basically invert it and add this guard at the beginning instead:

if (context.site) {
  return undefined;
}

// Do the rest of your normal logic but now without the nesting

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey guy, I already did that.

@alexweininger
Copy link
Member

I expected there to be a way to deploy from the local project. Was that ever discussed?
image

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.

@nturinski nturinski merged commit 6f40f43 into main May 20, 2024
2 checks passed
@nturinski nturinski deleted the nat/createFromDeploy2 branch May 20, 2024 18:06
@nturinski
Copy link
Member Author

Whoo boy 🥵

@nturinski nturinski added this to the 1.15.0 milestone May 21, 2024
@microsoft microsoft locked and limited conversation to collaborators Jul 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants