-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathpickEnvironment.ts
More file actions
49 lines (43 loc) · 2.48 KB
/
pickEnvironment.ts
File metadata and controls
49 lines (43 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureResourceQuickPickWizardContext, AzureWizardPromptStep, ContextValueQuickPickStep, IActionContext, QuickPickAzureSubscriptionStep, QuickPickGroupStep, QuickPickWizardContext, runQuickPickWizard } from "@microsoft/vscode-azext-utils";
import { AzExtResourceType, ResourceGroupsTreeDataProvider } from "@microsoft/vscode-azureresources-api";
import { ext } from "../../extensionVariables";
import { ManagedEnvironmentItem } from "../../tree/ManagedEnvironmentItem";
import { localize } from "../localize";
import type { PickItemOptions } from "./PickItemOptions";
export function getPickEnvironmentSteps(skipIfOne: boolean = false, environmentName?: string | RegExp): AzureWizardPromptStep<AzureResourceQuickPickWizardContext>[] {
const tdp: ResourceGroupsTreeDataProvider = ext.rgApiV2.resources.azureResourceTreeDataProvider;
const types = [AzExtResourceType.ContainerAppsEnvironment];
let environmentFilter: RegExp | undefined;
if (environmentName) {
environmentFilter = environmentName instanceof RegExp ? environmentName : new RegExp(`^${environmentName}$`);
} else {
environmentFilter = ManagedEnvironmentItem.contextValueRegExp;
}
return [
new QuickPickAzureSubscriptionStep(tdp),
new QuickPickGroupStep(tdp, {
groupType: types
}),
new ContextValueQuickPickStep(ext.rgApiV2.resources.azureResourceTreeDataProvider, {
contextValueFilter: { include: environmentFilter },
skipIfOne,
}, {
placeHolder: localize('selectContainerAppsEnvironment', 'Select a container apps environment'),
noPicksMessage: localize('noContainerAppsEnvironment', 'Current subscription has no container apps environments'),
})
];
}
export async function pickEnvironment(context: IActionContext, options?: PickItemOptions): Promise<ManagedEnvironmentItem> {
const promptSteps: AzureWizardPromptStep<QuickPickWizardContext>[] = [
...getPickEnvironmentSteps()
];
return await runQuickPickWizard(context, {
promptSteps,
title: options?.title,
showLoadingPrompt: options?.showLoadingPrompt
});
}