diff --git a/api/src/AzExtResourceType.ts b/api/src/AzExtResourceType.ts index 43a4b171..541ae71b 100644 --- a/api/src/AzExtResourceType.ts +++ b/api/src/AzExtResourceType.ts @@ -70,6 +70,7 @@ export enum AzExtResourceType { SpringApps = 'SpringApps', SqlDatabases = 'SqlDatabases', SqlServers = 'SqlServers', + Subscription = 'Subscription', VirtualMachineScaleSets = 'VirtualMachineScaleSets', VirtualNetworks = 'VirtualNetworks', WebHostingEnvironments = 'WebHostingEnvironments', diff --git a/resources/azureIcons/Subscription.svg b/resources/azureIcons/Subscription.svg new file mode 100644 index 00000000..f4f80d2a --- /dev/null +++ b/resources/azureIcons/Subscription.svg @@ -0,0 +1,16 @@ + + + + + + + + + + Icon-general-2 + + + + + diff --git a/src/managedIdentity/ManagedIdentityBranchDataProvider.ts b/src/managedIdentity/ManagedIdentityBranchDataProvider.ts index b8fa3a9d..7f484850 100644 --- a/src/managedIdentity/ManagedIdentityBranchDataProvider.ts +++ b/src/managedIdentity/ManagedIdentityBranchDataProvider.ts @@ -43,11 +43,7 @@ export class ManagedIdentityBranchDataProvider extends vscode.Disposable impleme async getChildren(element: ResourceGroupsItem): Promise { return (await element.getChildren?.())?.map((child) => { - if (child.id) { - return ext.azureTreeState.wrapItemInStateHandling(child, () => this.refresh(child)) - } - - return child; + return ext.azureTreeState.wrapItemInStateHandling(child, () => this.refresh(child)) }); } diff --git a/src/managedIdentity/RoleDefinitionsItem.ts b/src/managedIdentity/RoleDefinitionsItem.ts index 77690af8..6d1d0dcc 100644 --- a/src/managedIdentity/RoleDefinitionsItem.ts +++ b/src/managedIdentity/RoleDefinitionsItem.ts @@ -42,10 +42,19 @@ export class RoleDefinitionsItem implements ResourceGroupsItem { iconPath = getIconPath(getAzExtResourceType({ type: parsedAzureResourceId.provider })); } catch (error) { - // if this fails, then it was a resource group ID - parsedAzureResourceGroupId = parseAzureResourceGroupId(scope); - label = parsedAzureResourceGroupId.resourceGroup; - iconPath = getIconPath(AzExtResourceType.ResourceGroup); + try { + // if it's not a resource, then it's possibly a resource group or subscription + parsedAzureResourceGroupId = parseAzureResourceGroupId(scope); + label = parsedAzureResourceGroupId.resourceGroup; + iconPath = getIconPath(AzExtResourceType.ResourceGroup); + } catch (error) { + // if it's not a resource group, then it's a subscription + const subscriptions = await (await ext.subscriptionProviderFactory()).getSubscriptions(false); + const subscriptionId = scope.split('/').pop(); + label = subscriptions.find(s => s.subscriptionId === subscriptionId)?.name ?? scope; + iconPath = getIconPath(AzExtResourceType.Subscription); + } + } if (fromOtherSub) { diff --git a/src/utils/azureUtils.ts b/src/utils/azureUtils.ts index 2e819826..4135b2ce 100644 --- a/src/utils/azureUtils.ts +++ b/src/utils/azureUtils.ts @@ -101,7 +101,7 @@ const azExtDisplayInfo: Partial