Skip to content

Commit 90498ce

Browse files
authored
Add a way to call from cmd pallette (#4430)
1 parent 16664bd commit 90498ce

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/commands/identity/enableSystemIdentity.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
import { AzureWizard, type ExecuteActivityContext, type IActionContext } from "@microsoft/vscode-azext-utils";
77
import { localize } from "../../localize";
88
import { type SystemIdentityTreeItemBase } from "../../tree/remoteProject/SystemIdentityTreeItemBase";
9+
import { type SlotTreeItem } from "../../tree/SlotTreeItem";
910
import { createActivityContext } from "../../utils/activityUtils";
11+
import { pickAppResource } from "../../utils/pickAppResource";
1012
import { EnableSystemIdentityAssignStep } from "./EnableSystemIdentityStep";
1113
import { type ManagedIdentityAssignContext } from "./ManagedIdentityAssignContext";
1214

13-
export async function enableSystemIdentity(context: IActionContext, node: SystemIdentityTreeItemBase): Promise<undefined> {
14-
const slotTreeItem = node.parent.parent;
15+
export async function enableSystemIdentity(context: IActionContext, node?: SystemIdentityTreeItemBase): Promise<undefined> {
16+
let slotTreeItem: SlotTreeItem;
17+
if (!node) {
18+
slotTreeItem = await pickAppResource({ ...context, suppressCreatePick: true });
19+
} else {
20+
slotTreeItem = node.parent.parent;
21+
}
1522
const title: string = localize('enabling', 'Enable system assigned identity for "{0}".', slotTreeItem.site.fullName);
1623

1724
const wizardContext: ManagedIdentityAssignContext & ExecuteActivityContext = Object.assign(context, {
@@ -24,7 +31,7 @@ export async function enableSystemIdentity(context: IActionContext, node: System
2431
executeSteps: [new EnableSystemIdentityAssignStep()]
2532
});
2633

27-
await node.runWithTemporaryDescription(context, localize('enabling', 'Enabling system assigned identity...'), async () => {
34+
await (node ?? slotTreeItem).runWithTemporaryDescription(context, localize('enabling', 'Enabling system assigned identity...'), async () => {
2835
await wizard.execute();
2936
});
3037

0 commit comments

Comments
 (0)