|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import { AzureWizardPromptStep, IAzureQuickPickItem, IWizardOptions } from "@microsoft/vscode-azext-utils"; |
| 7 | +import { ImageSource, ImageSourceValues } from "../../constants"; |
| 8 | +import { localize } from "../../utils/localize"; |
| 9 | +import { ContainerRegistryListStep } from "../deployImage/ContainerRegistryListStep"; |
| 10 | +import { EnvironmentVariablesListStep } from "./EnvironmentVariablesListStep"; |
| 11 | +import { IContainerAppContext } from './IContainerAppContext'; |
| 12 | + |
| 13 | +export class ImageSourceListStep extends AzureWizardPromptStep<IContainerAppContext> { |
| 14 | + public async prompt(context: IContainerAppContext): Promise<void> { |
| 15 | + const imageSourceLabels: string[] = [ |
| 16 | + localize('quickStartImage', 'Use quickstart image'), |
| 17 | + localize('externalRegistry', 'Use existing image'), |
| 18 | + // localize('buildFromProject', 'Build from project'), |
| 19 | + ]; |
| 20 | + |
| 21 | + const placeHolder: string = localize('imageBuildSourcePrompt', 'Select an image source for the container app'); |
| 22 | + const picks: IAzureQuickPickItem<ImageSourceValues | undefined>[] = [ |
| 23 | + { label: imageSourceLabels[0], data: ImageSource.QuickStartImage, suppressPersistence: true }, |
| 24 | + { label: imageSourceLabels[1], data: ImageSource.ExternalRegistry, suppressPersistence: true }, |
| 25 | + // { label: imageSourceLabels[2], data: undefined, suppressPersistence: true }, |
| 26 | + ]; |
| 27 | + |
| 28 | + context.imageSource = (await context.ui.showQuickPick(picks, { placeHolder })).data; |
| 29 | + } |
| 30 | + |
| 31 | + public shouldPrompt(context: IContainerAppContext): boolean { |
| 32 | + return !context.imageSource; |
| 33 | + } |
| 34 | + |
| 35 | + public async getSubWizard(context: IContainerAppContext): Promise<IWizardOptions<IContainerAppContext> | undefined> { |
| 36 | + const promptSteps: AzureWizardPromptStep<IContainerAppContext>[] = []; |
| 37 | + |
| 38 | + switch (context.imageSource) { |
| 39 | + case ImageSource.QuickStartImage: |
| 40 | + // Todo: @mmott |
| 41 | + throw new Error('Not implemented yet'); |
| 42 | + case ImageSource.ExternalRegistry: |
| 43 | + promptSteps.push(new ContainerRegistryListStep(), new EnvironmentVariablesListStep()); |
| 44 | + break; |
| 45 | + default: |
| 46 | + // Todo: Steps that lead to additional 'Build from project' options |
| 47 | + } |
| 48 | + |
| 49 | + return { promptSteps }; |
| 50 | + } |
| 51 | +} |
0 commit comments