33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { type Template } from "@azure/arm-appcontainers" ;
6+ import { KnownActiveRevisionsMode , type Template } from "@azure/arm-appcontainers" ;
77import { AzureWizardExecuteStep , nonNullValueAndProp } from "@microsoft/vscode-azext-utils" ;
8- import type { Progress } from "vscode" ;
8+ import { ProgressLocation , window , type Progress } from "vscode" ;
99import { ext } from "../../extensionVariables" ;
1010import { ContainerAppItem } from "../../tree/ContainerAppItem" ;
11+ import { RevisionDraftItem } from "../../tree/revisionManagement/RevisionDraftItem" ;
1112import type { RevisionsItemModel } from "../../tree/revisionManagement/RevisionItem" ;
13+ import { localize } from "../../utils/localize" ;
14+ import { pickContainerAppWithoutPrompt } from "../../utils/pickItem/pickContainerApp" ;
15+ import { pickRevisionDraft } from "../../utils/pickItem/pickRevision" ;
1216import { getParentResourceFromItem } from "../../utils/revisionDraftUtils" ;
17+ import { settingUtils } from "../../utils/settingUtils" ;
1318import type { IContainerAppContext } from "../IContainerAppContext" ;
19+ import { deployRevisionDraft } from "./deployRevisionDraft/deployRevisionDraft" ;
1420
1521export abstract class RevisionDraftUpdateBaseStep < T extends IContainerAppContext > extends AzureWizardExecuteStep < T > {
1622 /**
@@ -29,8 +35,9 @@ export abstract class RevisionDraftUpdateBaseStep<T extends IContainerAppContext
2935 /**
3036 * Call this method to upload `revisionDraftTemplate` changes to the container app revision draft
3137 */
32- protected updateRevisionDraftWithTemplate ( ) : void {
38+ protected async updateRevisionDraftWithTemplate ( context : T ) : Promise < void > {
3339 ext . revisionDraftFileSystem . updateRevisionDraftWithTemplate ( this . baseItem , this . revisionDraftTemplate ) ;
40+ await this . showRevisionDraftDeployPopup ( context ) ;
3441 }
3542
3643 private initRevisionDraftTemplate ( ) : Template {
@@ -41,4 +48,44 @@ export abstract class RevisionDraftUpdateBaseStep<T extends IContainerAppContext
4148 }
4249 return template ;
4350 }
51+
52+ /**
53+ * An informational deploy pop-up to show after executing a revision draft command
54+ */
55+ private async showRevisionDraftDeployPopup ( context : T ) : Promise < void > {
56+ if ( ! await settingUtils . getGlobalSetting ( 'showDraftCommandDeployPopup' ) ) {
57+ return ;
58+ }
59+
60+ const yes : string = localize ( 'yes' , 'Yes' ) ;
61+ const no : string = localize ( 'no' , 'No' ) ;
62+ const dontShowAgain : string = localize ( 'dontShowAgain' , 'Don\'t show again' ) ;
63+
64+ const message : string = localize ( 'message' , 'Would you like to deploy these changes? Click "Yes" to proceed, or "No" to continue making changes.' ) ;
65+ const buttonMessages : string [ ] = [ yes , no , dontShowAgain ] ;
66+
67+ void window . showInformationMessage ( message , ...buttonMessages ) . then ( async ( result : string | undefined ) => {
68+ if ( result === yes ) {
69+ const item : ContainerAppItem | RevisionDraftItem = await window . withProgress ( {
70+ location : ProgressLocation . Notification ,
71+ cancellable : false ,
72+ title : localize ( 'preparingForDeployment' , 'Preparing for deployment...' )
73+ } , async ( ) => {
74+ const containerAppItem : ContainerAppItem = await pickContainerAppWithoutPrompt ( context , this . baseItem . containerApp , { showLoadingPrompt : false } ) ;
75+
76+ if ( this . baseItem . containerApp . revisionsMode === KnownActiveRevisionsMode . Single ) {
77+ return containerAppItem ;
78+ } else {
79+ return await pickRevisionDraft ( context , containerAppItem , { showLoadingPrompt : false } ) ;
80+ }
81+ } ) ;
82+
83+ await deployRevisionDraft ( context , item ) ;
84+ } else if ( result === dontShowAgain ) {
85+ await settingUtils . updateGlobalSetting ( 'showDraftCommandDeployPopup' , false ) ;
86+ } else {
87+ // Do nothing
88+ }
89+ } ) ;
90+ }
4491}
0 commit comments