import { Uri , window } from 'vscode' ; import { IActionContext , openReadOnlyJson } from 'vscode-azureextensionui' ; import { ext } from '../extensionVariables' ; import { localize } from '../localize' ; import { LocalFunctionTreeItem } from '../tree/localProject/LocalFunctionTreeItem' ; import { ProductionSlotTreeItem } from '../tree/ProductionSlotTreeItem' ; import { RemoteFunctionTreeItem } from '../tree/remoteProject/RemoteFunctionTreeItem' ; import { SlotTreeItemBase } from '../tree/SlotTreeItemBase' ; export async function viewProperties ( context , node ? ) { if ( ! node ) { node = await ext . tree . showTreeItemPicker < ProductionSlotTreeItem > ( ProductionSlotTreeItem . contextValue , context ) ; } if ( node instanceof LocalFunctionTreeItem ) { if ( ! node . functionJsonPath ) { throw new Error ( localize ( 'viewPropsNotSupported' , 'View function properties is not supported for this project type.' ) ) ; } await window . showTextDocument ( Uri . file ( node . functionJsonPath ) ) ; } else { let data ; if ( node instanceof SlotTreeItemBase ) { const siteNode = node ; await node . runWithTemporaryDescription ( context , localize ( 'retrievingProps' , 'Retrieving properties...' ) , async ( ) => { const client = await siteNode . site . createClient ( context ) ; siteNode . site . rawSite . siteConfig = await client . getSiteConfig ( ) ; } ) ; data = node . site . rawSite ; } else { data = node . rawConfig ; } await openReadOnlyJson ( node , data ) ; } }