Skip to content

Commit

Permalink
PR feedbakc
Browse files Browse the repository at this point in the history
  • Loading branch information
nturinski committed Jul 26, 2023
1 parent 0c6c753 commit d9beb89
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
17 changes: 6 additions & 11 deletions src/FuncVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,21 @@ export enum FuncVersion {

export const latestGAVersion: FuncVersion = FuncVersion.v4;
export const funcVersionLink: string = 'https://aka.ms/AA1tpij';
const funcRuntimeVersionWarningLink: string = 'https://aka.ms/function-runtime-host-warning';
const funcRuntimeWarningLabel: string = localize('runtimeWarning', `$(extensions-warning-message) Azure Functions runtimes v2 and v3 have reached the end of life.`);

export async function promptForFuncVersion(context: IActionContext, message?: string): Promise<FuncVersion> {
const recommended: string = localize('recommended', '(Recommended)');
let picks: IAzureQuickPickItem<FuncVersion | undefined>[] = [
{ label: 'Azure Functions v4', description: recommended, data: FuncVersion.v4 },
{ label: 'Azure Functions v3', data: FuncVersion.v3, description: '(EOL)' },
{ label: 'Azure Functions v2', data: FuncVersion.v2, description: '(EOL)' },
{ label: 'Azure Functions v1', data: FuncVersion.v1 }, {
label: localize('runtimeWarning', `$(extensions-warning-message) Azure Functions runtime v2.x and v3.x have reached the EOL. Learn more...`),
onPicked: async () => {
await openUrl(funcRuntimeVersionWarningLink);
},
data: undefined
}
{ label: 'Azure Functions v3', data: FuncVersion.v3, description: '$(extensions-warning-message)' },
{ label: 'Azure Functions v2', data: FuncVersion.v2, description: '$(extensions-warning-message)' },
{ label: 'Azure Functions v1', data: FuncVersion.v1 },
{ label: funcRuntimeWarningLabel, data: undefined, onPicked: () => {/*do nothing*/ } }
];

picks = picks.filter(p => osSupportsVersion(p.data));

const learnMoreQp = { label: localize('learnMore', '$(link-external) Learn more...'), description: '', data: undefined };
const learnMoreQp = { label: localize('learnMore', '$(link-external) Learn about Azure Functions versioning...'), description: '', data: undefined };
picks.push(learnMoreQp);

const options: IAzureQuickPickOptions = { placeHolder: message || localize('selectVersion', 'Select a version'), stepName: 'funcVersion', suppressPersistence: true };
Expand Down
16 changes: 11 additions & 5 deletions src/commands/createFunctionApp/stacks/FunctionAppStackStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*--------------------------------------------------------------------------------------------*/

import { setLocationsTask, SiteOSStep, WebsiteOS } from '@microsoft/vscode-azext-azureappservice';
import { AzureWizardPromptStep, IAzureQuickPickItem, IWizardOptions } from '@microsoft/vscode-azext-utils';
import { AzureWizardPromptStep, IAzureQuickPickItem, IWizardOptions, openUrl } from '@microsoft/vscode-azext-utils';
import { noRuntimeStacksAvailableLabel } from '../../../constants';
import { getMajorVersion, promptForFuncVersion } from '../../../FuncVersion';
import { localize } from '../../../localize';
import { FullFunctionAppStack, IFunctionAppWizardContext } from '../IFunctionAppWizardContext';
Expand Down Expand Up @@ -53,19 +54,24 @@ export class FunctionAppStackStep extends AzureWizardPromptStep<IFunctionAppWiza
}

private async getPicks(context: IFunctionAppWizardContext): Promise<IAzureQuickPickItem<FullFunctionAppStack | undefined>[]> {
const picks: IAzureQuickPickItem<FullFunctionAppStack | undefined>[] = await getStackPicks(context);
let picks: IAzureQuickPickItem<FullFunctionAppStack | undefined>[] = await getStackPicks(context);
if (picks.filter(p => p.label !== noRuntimeStacksAvailableLabel).length === 0) {
// if every runtime only has noRuntimeStackAvailable quickpick items, reset picks to []
picks = [];
}

const majorVersion = getMajorVersion(context.version);
const isEol = Number(majorVersion) === 2 || Number(majorVersion) === 3;
if (picks.length === 0) {
const noPicksMessage = context.stackFilter ?
localize('noStacksFoundWithFilter', '$(warning) No stacks found for "{0}" on Azure Functions v{1}', context.stackFilter, majorVersion) :
localize('noStacksFound', '$(warning) No stacks found for Azure Functions v{0}', majorVersion);
const upgradeMessage = localize('eolWarning', '$(warning) No stacks found for Azure Functions v{0} due to being EOL. Upgrade your runtime version to see available stacks.')
const upgradeMessage = localize('eolWarning', '$(warning) No stacks found for Azure Functions v{0} due to being EOL. Learn how to upgrade to V4...', majorVersion)
picks.push({
label: isEol ? upgradeMessage : noPicksMessage,
data: undefined,
onPicked: () => {
// do nothing
onPicked: async () => {
await openUrl('https://aka.ms/function-runtime-host-warning');
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/createFunctionApp/stacks/getStackPicks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createPipelineRequest } from '@azure/core-rest-pipeline';
import { AzExtPipelineResponse, createGenericClient } from '@microsoft/vscode-azext-azureutils';
import { IAzureQuickPickItem, openUrl, parseError } from '@microsoft/vscode-azext-utils';
import { FuncVersion, funcVersionLink } from '../../../FuncVersion';
import { hiddenStacksSetting } from '../../../constants';
import { hiddenStacksSetting, noRuntimeStacksAvailableLabel } from '../../../constants';
import { localize } from '../../../localize';
import { requestUtils } from '../../../utils/requestUtils';
import { getWorkspaceSetting } from '../../../vsCodeConfig/settings';
Expand Down Expand Up @@ -68,7 +68,7 @@ export async function getStackPicks(context: IFunctionAppWizardContext): Promise
}

if (shouldShowEolWarning(minorVersion)) {
description = '$(extensions-warning-message)'
description = localize('endOfLife', `$(extensions-warning-message)`)
hasEndOfLife = true;
}

Expand All @@ -84,7 +84,7 @@ export async function getStackPicks(context: IFunctionAppWizardContext): Promise

if (!stackHasPicks) {
picks.push({
label: localize('noRuntimeStacksAvailable', 'No valid runtime stacks available'),
label: noRuntimeStacksAvailableLabel,
group: stack.displayText,
data: undefined
});
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,4 @@ export const functionFilter = {
};

export const sqlBindingTemplateRegex: RegExp = /Sql.*Binding/i;
export const noRuntimeStacksAvailableLabel = localize('noRuntimeStacksAvailable', 'No valid runtime stacks available');

0 comments on commit d9beb89

Please sign in to comment.