import * as path from 'path' ; import { AzExtTreeDataProvider , AzureParentTreeItem , AzureTreeItem , SubscriptionTreeItemBase } from 'vscode-azureextensionui' ; import { ext } from '../extensionVariables' ; import { localize } from '../localize' ; export namespace treeUtils { export interface IThemedIconPath { light : string ; dark : string ; } export function getIconPath ( iconName ) { return path . join ( getResourcesPath ( ) , `${ iconName }.svg` ) ; } export function getThemedIconPath ( iconName ) { return { light : path . join ( getResourcesPath ( ) , 'light' , `${ iconName }.svg` ) , dark : path . join ( getResourcesPath ( ) , 'dark' , `${ iconName }.svg` ) } ; } function getResourcesPath ( ) { return ext . context . asAbsolutePath ( 'resources' ) ; } export async function getSubscriptionNode ( tree , subscriptionId ) { const node = < AzureParentTreeItem | undefined > ( await tree . getChildren ( ) ) . find ( ( n ) => n . root . subscriptionId === subscriptionId ) ; if ( node ) { return node ; } else { throw new Error ( localize ( 'noMatchingSubscription' , 'Failed to find a subscription matching id "{0}".' , subscriptionId ) ) ; } } export async function getRootNode ( tree ) { return < AzureParentTreeItem > ( await tree . getChildren ( ) ) . find ( ( n ) => n instanceof SubscriptionTreeItemBase ) ; } }