Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
alexweininger committed Jan 6, 2025
1 parent 1fd0407 commit f2627ea
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/commands/createResourceGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { window } from 'vscode';
import { AzureSubscription } from '../../api/src/index';
import { ext } from '../extensionVariables';
import { SubscriptionItem } from '../tree/azure/SubscriptionItem';
import { createAzureIdPrefix } from '../tree/azure/idPrefix';
import { getAccountAndTenantPrefix } from '../tree/azure/idPrefix';
import { createActivityContext } from '../utils/activityUtils';
import { localize } from '../utils/localize';

Expand Down Expand Up @@ -38,5 +38,5 @@ export async function createResourceGroup(context: IActionContext, node?: Subscr
if (!wizardContext.suppressNotification) {
void window.showInformationMessage(localize('createdRg', 'Created resource group "{0}".', newResourceGroupName));
}
ext.azureTreeState.notifyChildrenChanged(`${createAzureIdPrefix(subscription)}/subscriptions/${subscription.subscriptionId}`);
ext.azureTreeState.notifyChildrenChanged(`${getAccountAndTenantPrefix(subscription)}/subscriptions/${subscription.subscriptionId}`);
}
6 changes: 3 additions & 3 deletions src/commands/deleteResourceGroup/v2/deleteResourceGroupV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { AzureResource, AzureSubscription } from '../../../../api/src/index';
import { createResourceGroup } from '../../../api/DefaultAzureResourceProvider';
import { ext } from '../../../extensionVariables';
import { isResourceGroupGroupingItem, ResourceGroupGroupingItem } from '../../../tree/azure/grouping/ResourceGroupGroupingItem';
import { createAzureIdPrefix } from '../../../tree/azure/idPrefix';
import { getAccountAndTenantPrefix } from '../../../tree/azure/idPrefix';
import { createActivityContext } from '../../../utils/activityUtils';
import { createResourceClient } from '../../../utils/azureClients';
import { localize } from '../../../utils/localize';
Expand Down Expand Up @@ -112,7 +112,7 @@ async function deleteResourceGroups(context: IActionContext, subscription: Azure
}
}

void ext.azureTreeState.runWithTemporaryDescription(`${createAzureIdPrefix(rg.subscription)}${rg.id}`, localize('deleting', 'Deleting...'), async () => {
void ext.azureTreeState.runWithTemporaryDescription(`${getAccountAndTenantPrefix(rg.subscription)}${rg.id}`, localize('deleting', 'Deleting...'), async () => {
const wizard = new AzureWizard<DeleteResourceGroupContext>({
subscription: createSubscriptionContext(subscription),
resourceGroupToDelete: rg.name,
Expand All @@ -124,7 +124,7 @@ async function deleteResourceGroups(context: IActionContext, subscription: Azure
});

await wizard.execute();
ext.azureTreeState.notifyChildrenChanged(`${createAzureIdPrefix(rg.subscription)}/subscriptions/${rg.subscription.subscriptionId}`);
ext.azureTreeState.notifyChildrenChanged(`${getAccountAndTenantPrefix(rg.subscription)}/subscriptions/${rg.subscription.subscriptionId}`);
});
}
}
6 changes: 3 additions & 3 deletions src/tree/azure/AzureResourceItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createPortalUrl } from '../../utils/v2/createPortalUrl';
import { BranchDataItemCache } from '../BranchDataItemCache';
import { BranchDataItemOptions, BranchDataItemWrapper } from '../BranchDataItemWrapper';
import { ResourceGroupsItem } from '../ResourceGroupsItem';
import { createAzureIdPrefix } from './idPrefix';
import { getAccountAndTenantPrefix } from './idPrefix';

export class AzureResourceItem<T extends AzureResource> extends BranchDataItemWrapper {
constructor(
Expand All @@ -28,7 +28,7 @@ export class AzureResourceItem<T extends AzureResource> extends BranchDataItemWr
}

override readonly portalUrl: Uri;
readonly id = `${createAzureIdPrefix(this.resource.subscription)}${this.resource.id}`;
readonly id = `${getAccountAndTenantPrefix(this.resource.subscription)}${this.resource.id}`;
readonly tagsModel = new ResourceTags(this.resource);

override async getParent(): Promise<ResourceGroupsItem | undefined> {
Expand Down Expand Up @@ -59,6 +59,6 @@ export function createResourceItemFactory<T extends AzureResource>(itemCache: Br
itemCache.createOrGetItem(
branchItem,
() => new AzureResourceItem(resource, branchItem, branchDataProvider, itemCache, parent, options),
`${createAzureIdPrefix(resource.subscription)}${resource.id}`,
`${getAccountAndTenantPrefix(resource.subscription)}${resource.id}`,
);
}
4 changes: 2 additions & 2 deletions src/tree/azure/SubscriptionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { createPortalUrl } from "../../utils/v2/createPortalUrl";
import { ResourceGroupsItem } from "../ResourceGroupsItem";
import { ResourceGroupsTreeContext } from "../ResourceGroupsTreeContext";
import { AzureResourceGroupingManager } from "./grouping/AzureResourceGroupingManager";
import { createAzureIdPrefix } from "./idPrefix";
import { getAccountAndTenantPrefix } from "./idPrefix";

export class SubscriptionItem implements ResourceGroupsItem {
constructor(
Expand All @@ -29,7 +29,7 @@ export class SubscriptionItem implements ResourceGroupsItem {
...subscription
};

this.id = `${createAzureIdPrefix(this.subscription)}/subscriptions/${subscription.subscriptionId}`;
this.id = `${getAccountAndTenantPrefix(this.subscription)}/subscriptions/${subscription.subscriptionId}`;
this.description = description ? description : '';

this.portalUrl = createPortalUrl(this.subscription, `/subscriptions/${this.subscription.subscriptionId}`);
Expand Down
6 changes: 3 additions & 3 deletions src/tree/azure/grouping/GroupingItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ResourceGroupsItem } from '../../ResourceGroupsItem';
import { ResourceGroupsTreeContext } from '../../ResourceGroupsTreeContext';
import { BranchDataProviderFactory } from '../AzureResourceBranchDataProviderManager';
import { ResourceItemFactory } from '../AzureResourceItem';
import { createAzureIdPrefix } from '../idPrefix';
import { getAccountAndTenantPrefix } from '../idPrefix';
import { GroupingItemFactoryOptions } from './GroupingItemFactory';

export class GroupingItem implements ResourceGroupsItem {
Expand Down Expand Up @@ -57,7 +57,7 @@ export class GroupingItem implements ResourceGroupsItem {
} : undefined;

if (this.context?.subscription) {
this.id = `${createAzureIdPrefix(this.context?.subscription)}/subscriptions/${this.context?.subscriptionContext.subscriptionId}/groupings/${this.label}`;
this.id = `${getAccountAndTenantPrefix(this.context?.subscription)}/subscriptions/${this.context?.subscriptionContext.subscriptionId}/groupings/${this.label}`;
} else {
// favorites groups don't always have a subscription
this.id = `/groupings/${this.label}`;
Expand Down Expand Up @@ -122,7 +122,7 @@ export class GroupingItem implements ResourceGroupsItem {
data: resource.raw
},
// prefix child items with the account and tenant id
idPrefix: createAzureIdPrefix(resource.subscription),
idPrefix: getAccountAndTenantPrefix(resource.subscription),
};

items.push(this.resourceItemFactory(resource, resourceItem, branchDataProvider, this, options));
Expand Down
4 changes: 2 additions & 2 deletions src/tree/azure/grouping/ResourceGroupGroupingItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ITagsModel, ResourceTags } from "../../../commands/tags/TagFileSystem";
import { canFocusContextValue, showHiddenTypesSettingKey } from "../../../constants";
import { settingUtils } from "../../../utils/settingUtils";
import { createPortalUrl } from "../../../utils/v2/createPortalUrl";
import { createAzureIdPrefix } from "../idPrefix";
import { getAccountAndTenantPrefix } from "../idPrefix";
import { GroupingItem, GroupingItemOptions } from "./GroupingItem";
import { GroupingItemFactoryOptions } from "./GroupingItemFactory";

Expand All @@ -36,7 +36,7 @@ export class ResourceGroupGroupingItem extends GroupingItem {
...this.resourceGroup.subscription,
...createSubscriptionContext(resourceGroup.subscription),
};
this.id = `${createAzureIdPrefix(this.subscription)}${resourceGroup.id}`;
this.id = `${getAccountAndTenantPrefix(this.subscription)}${resourceGroup.id}`;
this.tagsModel = new ResourceTags(resourceGroup);
this.contextValues.push('hasPortalUrl', 'azureResourceGroup', canFocusContextValue);
}
Expand Down
5 changes: 4 additions & 1 deletion src/tree/azure/idPrefix.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { AzureSubscription } from "api/src/resources/azure";

export function createAzureIdPrefix(subscription: AzureSubscription): string {
/**
* @returns `/accounts/<account id>/tenants/<tenant id>`
*/
export function getAccountAndTenantPrefix(subscription: AzureSubscription): string {
return `/accounts/${subscription.account?.id}/tenants/${subscription.tenantId}`;
}

0 comments on commit f2627ea

Please sign in to comment.