Skip to content

Commit

Permalink
Refresh CAE children instead of trying to refresh individual CAs (#268)
Browse files Browse the repository at this point in the history
* Refresh CAE children instead of CA

* Undo change
  • Loading branch information
alexweininger authored Feb 23, 2023
1 parent 451c433 commit 006c7bf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/commands/chooseRevisionMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { KnownActiveRevisionsMode } from "@azure/arm-appcontainers";
import { IActionContext, IAzureQuickPickItem } from "@microsoft/vscode-azext-utils";
import { ProgressLocation, window } from "vscode";
import { ext } from "../extensionVariables";
import { ContainerAppModel, refreshContainerApp } from "../tree/ContainerAppItem";
import { ContainerAppModel } from "../tree/ContainerAppItem";
import { ContainerAppsItem } from "../tree/ContainerAppsBranchDataProvider";
import { localize } from "../utils/localize";
import { pickContainerApp } from "../utils/pickContainerApp";
Expand All @@ -24,7 +24,7 @@ export async function chooseRevisionMode(context: IActionContext, node?: Contain

await window.withProgress({ location: ProgressLocation.Notification, title: updating }, async (): Promise<void> => {
await updateContainerApp(context, subscription, containerApp, { configuration: { activeRevisionsMode: pickedRevisionMode } });
refreshContainerApp(containerApp.id);
ext.state.notifyChildrenChanged(containerApp.managedEnvironmentId);
});

const updated = localize('updatedRevision', 'Updated revision mode of "{0}" to "{1}".', containerApp.name, pickedRevisionMode);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/deployImage/deployImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AzureWizard, AzureWizardExecuteStep, AzureWizardPromptStep, createSubsc
import { MessageItem, ProgressLocation, window } from "vscode";
import { acrDomain, webProvider } from "../../constants";
import { ext } from "../../extensionVariables";
import { ContainerAppItem, getContainerEnvelopeWithSecrets, refreshContainerApp } from "../../tree/ContainerAppItem";
import { ContainerAppItem, getContainerEnvelopeWithSecrets } from "../../tree/ContainerAppItem";
import { createContainerAppsAPIClient } from '../../utils/azureClients';
import { localize } from "../../utils/localize";
import { pickContainerApp } from "../../utils/pickContainerApp";
Expand Down Expand Up @@ -95,7 +95,7 @@ export async function deployImage(context: ITreeItemPickerContext & Partial<IDep
void showContainerAppCreated(updatedContainerApp, true);
});

refreshContainerApp(containerApp.id);
ext.state.notifyChildrenChanged(containerApp.managedEnvironmentId);
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/commands/scaling/editScalingRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { IActionContext, nonNullValue } from "@microsoft/vscode-azext-utils";
import { ProgressLocation, window } from "vscode";
import { ext } from "../../extensionVariables";
import { refreshContainerApp } from "../../tree/ContainerAppItem";
import { ScaleItem } from "../../tree/scaling/ScaleItem";
import { localize } from "../../utils/localize";
import { updateContainerApp } from "../updateContainerApp";
Expand Down Expand Up @@ -38,7 +37,7 @@ export async function editScalingRange(context: IActionContext, node?: ScaleItem
await window.withProgress({ location: ProgressLocation.Notification, title: updating }, async (): Promise<void> => {
ext.outputChannel.appendLog(updating);
await updateContainerApp(context, subscription, containerApp, { template })
refreshContainerApp(containerApp.id);
ext.state.notifyChildrenChanged(containerApp.managedEnvironmentId);
void window.showInformationMessage(updated);
ext.outputChannel.appendLog(updated);
});
Expand Down
22 changes: 1 addition & 21 deletions src/tree/ContainerAppItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ContainerApp, ContainerAppsAPIClient, KnownActiveRevisionsMode } from "
import { getResourceGroupFromId, uiUtils } from "@microsoft/vscode-azext-azureutils";
import { AzureWizard, callWithTelemetryAndErrorHandling, createSubscriptionContext, DeleteConfirmationStep, IActionContext, nonNullProp } from "@microsoft/vscode-azext-utils";
import { AzureSubscription, ViewPropertiesModel } from "@microsoft/vscode-azureresources-api";
import { EventEmitter, TreeItem, TreeItemCollapsibleState, Uri } from "vscode";
import { TreeItem, TreeItemCollapsibleState, Uri } from "vscode";
import { DeleteAllContainerAppsStep } from "../commands/deleteContainerApp/DeleteAllContainerAppsStep";
import { IDeleteContainerAppWizardContext } from "../commands/deleteContainerApp/IDeleteContainerAppWizardContext";
import { ext } from "../extensionVariables";
Expand All @@ -23,13 +23,6 @@ import { LogsItem } from "./LogsItem";
import { RevisionsItem } from "./RevisionsItem";
import { ScaleItem } from "./scaling/ScaleItem";

const refreshContainerAppEmitter = new EventEmitter<string>();
const refreshContainerAppEvent = refreshContainerAppEmitter.event;

export function refreshContainerApp(id: string): void {
refreshContainerAppEmitter.fire(id);
}

export interface ContainerAppModel extends ContainerApp {
id: string;
name: string;
Expand All @@ -56,19 +49,6 @@ export class ContainerAppItem implements ContainerAppsItem {
this.id = this.containerApp.id;
this.resourceGroup = this.containerApp.resourceGroup;
this.name = this.containerApp.name;
refreshContainerAppEvent((id) => {
if (id === this.id) {
void this.refresh();
}
})
}

private async refresh(): Promise<void> {
await callWithTelemetryAndErrorHandling('containerAppItem.refresh', async (context) => {
const client: ContainerAppsAPIClient = await createContainerAppsClient(context, this.subscription);
this._containerApp = ContainerAppItem.CreateContainerAppModel(await client.containerApps.get(this.resourceGroup, this.name));
ext.branchDataProvider.refresh(this);
});
}

viewProperties: ViewPropertiesModel = {
Expand Down

0 comments on commit 006c7bf

Please sign in to comment.