Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/commands/revision/changeRevisionActiveState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ContainerAppsAPIClient } from "@azure/arm-appcontainers";
import { IActionContext, nonNullProp } from "@microsoft/vscode-azext-utils";
import { ContainerAppsAPIClient, KnownActiveRevisionsMode } from "@azure/arm-appcontainers";
import { IActionContext, nonNullProp, nonNullValue } from "@microsoft/vscode-azext-utils";
import { ext } from "../../extensionVariables";
import type { ContainerAppItem } from "../../tree/ContainerAppItem";
import { RevisionItem } from "../../tree/revisionManagement/RevisionItem";
import { createContainerAppsClient } from "../../utils/azureClients";
import { localize } from "../../utils/localize";
import { pickContainerApp } from "../../utils/pickItem/pickContainerApp";
import { pickRevision } from "../../utils/pickItem/pickRevision";

export async function executeRevisionOperation(context: IActionContext, node: ContainerAppItem | RevisionItem | undefined, operation: RevisionOperation): Promise<void> {
const item = node ?? await pickContainerApp(context);
if (!node) {
Copy link
Copy Markdown
Member

@alexweininger alexweininger Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the node is a ContainerAppItem but it's in multiple revision mode? Do we still need to pick a revision in that case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be good with this scenario because the command is removed from the context menu when in multiple revisions mode. When in multiple revisions mode the command should only be executable from either no node (command-palette) or a RevisionItem!

node = await pickContainerApp(context);

if (node.containerApp.revisionsMode === KnownActiveRevisionsMode.Multiple) {
node = await pickRevision(context, node);
}
}

const item: ContainerAppItem | RevisionItem = nonNullValue(node);

await ext.state.runWithTemporaryDescription(item.id, revisionOperationDescriptions[operation], async () => {
const appClient: ContainerAppsAPIClient = await createContainerAppsClient(context, item.subscription);
Expand Down