import { setLocationsTask , SiteOSStep , WebsiteOS } from 'vscode-azureappservice' ; import { AzureWizardPromptStep , IAzureQuickPickItem , IWizardOptions } from 'vscode-azureextensionui' ; import { getMajorVersion , promptForFuncVersion } from '../../../FuncVersion' ; import { localize } from '../../../localize' ; import { FullFunctionAppStack , IFunctionAppWizardContext } from '../IFunctionAppWizardContext' ; import { getStackPicks } from './getStackPicks' ; export class FunctionAppStackStep extends AzureWizardPromptStep < IFunctionAppWizardContext > { public async prompt ( context ) { const placeHolder = localize ( 'selectRuntimeStack' , 'Select a runtime stack.' ) ; let result ; while ( true ) { result = ( await context . ui . showQuickPick ( this . getPicks ( context ) , { placeHolder , enableGrouping : true } ) ) . data ; if ( ! result ) { context . version = await promptForFuncVersion ( context ) ; } else { break ; } } context . newSiteStack = result ; if ( ! context . newSiteStack . minorVersion . stackSettings . linuxRuntimeSettings ) { context . newSiteOS = WebsiteOS . windows ; } else if ( ! context . newSiteStack . minorVersion . stackSettings . windowsRuntimeSettings ) { context . newSiteOS = WebsiteOS . linux ; } else if ( ! context . advancedCreation ) { context . newSiteOS = < WebsiteOS > context . newSiteStack . stack . preferredOs ; } } public shouldPrompt ( context ) { return ! context . newSiteStack ; } public async getSubWizard ( context ) { if ( context . newSiteOS === undefined ) { return { promptSteps : [ new SiteOSStep ( ) ] } ; } else { await setLocationsTask ( context ) ; return undefined ; } } private async getPicks ( context ) { const picks = await getStackPicks ( context ) ; if ( picks . length === 0 ) { const majorVersion = getMajorVersion ( context . version ) ; 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 ) ; picks . push ( { label : noPicksMessage , data : undefined , onPicked : ( ) => { } } ) ; } picks . push ( { label : localize ( 'changeFuncVersion' , '$(gear) Change Azure Functions version' ) , description : localize ( 'currentFuncVersion' , 'Current: {0}' , context . version ) , data : undefined , suppressPersistence : true } ) ; return picks ; } }