33* Licensed under the MIT License. See License.txt in the project root for license information.
44*--------------------------------------------------------------------------------------------*/
55
6- import { AzureResourceQuickPickWizardContext , AzureWizardPromptStep , ContextValueQuickPickStep , IActionContext , QuickPickAzureResourceStep , QuickPickAzureSubscriptionStep , QuickPickGroupStep , ResourceGroupsItem , runQuickPickWizard } from "@microsoft/vscode-azext-utils" ;
6+ import { KnownActiveRevisionsMode } from "@azure/arm-appcontainers" ;
7+ import { AzureResourceQuickPickWizardContext , AzureWizardPromptStep , ContextValueQuickPickStep , IActionContext , QuickPickAzureResourceStep , QuickPickAzureSubscriptionStep , QuickPickGroupStep , ResourceGroupsItem , nonNullValue , runQuickPickWizard } from "@microsoft/vscode-azext-utils" ;
78import { AzExtResourceType } from "@microsoft/vscode-azureresources-api" ;
89import * as vscode from 'vscode' ;
10+ import { revisionModeMultipleContextValue , revisionModeSingleContextValue } from "../constants" ;
911import { ext } from "../extensionVariables" ;
1012import { ContainerAppItem } from "../tree/ContainerAppItem" ;
1113import { ManagedEnvironmentItem } from "../tree/ManagedEnvironmentItem" ;
@@ -15,6 +17,10 @@ export interface PickItemOptions {
1517 title ?: string ;
1618}
1719
20+ export interface ContainerAppPickItemOptions extends PickItemOptions {
21+ revisionsMode ?: KnownActiveRevisionsMode ;
22+ }
23+
1824function getPickEnvironmentSteps ( tdp : vscode . TreeDataProvider < unknown > ) : AzureWizardPromptStep < AzureResourceQuickPickWizardContext > [ ] {
1925 const types = [ AzExtResourceType . ContainerAppsEnvironment ] ;
2026 return [
@@ -26,25 +32,36 @@ function getPickEnvironmentSteps(tdp: vscode.TreeDataProvider<unknown>): AzureWi
2632 resourceTypes : types ,
2733 skipIfOne : false ,
2834 } , {
29- placeHolder : localize ( 'selectContainerAppsEnvironment' , 'Select Container Apps Environment ' ) ,
35+ placeHolder : localize ( 'selectContainerAppsEnvironment' , 'Select a container apps environment ' ) ,
3036 } ) ,
3137 ] ;
3238}
3339
34- export async function pickContainerApp ( context : IActionContext , options ?: PickItemOptions ) : Promise < ContainerAppItem > {
40+ export async function pickContainerApp ( context : IActionContext , options ?: ContainerAppPickItemOptions ) : Promise < ContainerAppItem > {
3541 return await containerAppExperience < ContainerAppItem > ( context , ext . rgApiV2 . resources . azureResourceTreeDataProvider , options ) ;
3642}
3743
38- export async function containerAppExperience < TPick > ( context : IActionContext , tdp : vscode . TreeDataProvider < ResourceGroupsItem > , options ?: PickItemOptions ) : Promise < TPick > {
44+ export async function containerAppExperience < TPick > ( context : IActionContext , tdp : vscode . TreeDataProvider < ResourceGroupsItem > , options ?: ContainerAppPickItemOptions ) : Promise < TPick > {
45+ const contextFilter : RegExp [ ] | undefined = [ ContainerAppItem . contextValueRegExp ] ;
46+ let noPicksMessage : string | undefined ;
47+
48+ if ( options ?. revisionsMode === KnownActiveRevisionsMode . Single ) {
49+ contextFilter . push ( new RegExp ( revisionModeSingleContextValue ) ) ;
50+ noPicksMessage = localize ( 'noSingleRevisionApps' , 'Selected environment has no container apps in single revisions mode.' ) ;
51+ } else if ( options ?. revisionsMode === KnownActiveRevisionsMode . Multiple ) {
52+ contextFilter . push ( new RegExp ( revisionModeMultipleContextValue ) ) ;
53+ noPicksMessage = localize ( 'noMultipleRevisionApps' , 'Selected environment has no container apps in multiple revisions mode.' ) ;
54+ }
55+
3956 return await runQuickPickWizard ( context , {
4057 promptSteps : [
4158 ...getPickEnvironmentSteps ( tdp ) ,
4259 new ContextValueQuickPickStep ( tdp , {
43- contextValueFilter : { include : ContainerAppItem . contextValueRegExp } ,
60+ contextValueFilter : { include : nonNullValue ( contextFilter ) } ,
4461 skipIfOne : true ,
4562 } , {
46- placeHolder : localize ( 'selectContainerApp' , 'Select Container App ' ) ,
47- noPicksMessage : localize ( 'noContainerApps' , 'Selected Container Apps Environment has no Apps ' ) ,
63+ placeHolder : localize ( 'selectContainerApp' , 'Select a container app ' ) ,
64+ noPicksMessage : noPicksMessage ?? localize ( 'noContainerApps' , 'Selected environment has no container apps. ' ) ,
4865 } ) ,
4966 ] ,
5067 title : options ?. title ,
0 commit comments