import { AzureWizardPromptStep , IAzureQuickPickItem , IWizardOptions } from 'vscode-azureextensionui' ; import { ProjectLanguage } from '../../constants' ; import { ext } from '../../extensionVariables' ; import { FuncVersion } from '../../FuncVersion' ; import { localize } from '../../localize' ; import { IBindingTemplate } from '../../templates/IBindingTemplate' ; import { nonNullProp } from '../../utils/nonNull' ; import { IBindingWizardContext } from './IBindingWizardContext' ; import { addBindingSettingSteps } from './settingSteps/addBindingSettingSteps' ; export class BindingListStep extends AzureWizardPromptStep < IBindingWizardContext > { public hideStepCount : boolean = true ; public async prompt ( context ) { const direction = nonNullProp ( context , 'bindingDirection' ) ; const placeHolder = localize ( 'selectBinding' , 'Select binding with direction "{0}"' , direction ) ; context . bindingTemplate = ( await context . ui . showQuickPick ( this . getPicks ( context , direction ) , { placeHolder } ) ) . data ; } public shouldPrompt ( context ) { return ! context . bindingTemplate ; } public async getSubWizard ( context ) { const binding = context . bindingTemplate ; if ( binding ) { const promptSteps = [ ] ; addBindingSettingSteps ( binding . settings , promptSteps ) ; return { promptSteps } ; } else { return undefined ; } } private async getPicks ( context , direction ) { const language = nonNullProp ( context , 'language' ) ; const version = nonNullProp ( context , 'version' ) ; const templateProvider = ext . templateProvider . get ( context ) ; const templates = await templateProvider . getBindingTemplates ( context , context . projectPath , language , version ) ; return templates . filter ( b => b . direction . toLowerCase ( ) === direction . toLowerCase ( ) ) . sort ( ( a , b ) => a . displayName . localeCompare ( b . displayName ) ) . map ( b => { return { label : b . displayName , data : b } ; } ) ; } }