@@ -107,7 +107,12 @@ export async function globalUriHandler(uri: vscode.Uri): Promise<void> {
107107 params . connectionString ,
108108 ) ;
109109 ext . cosmosDBWorkspaceBranchDataProvider . refresh ( ) ;
110- await revealAttachedInWorkspaceExplorer ( parsedConnection . connectionString . accountId ) ;
110+ await revealAttachedInWorkspaceExplorer (
111+ parsedConnection . connectionString . accountId ,
112+ parsedConnection . api ,
113+ params . database ,
114+ params . container ,
115+ ) ;
111116 } else {
112117 // Handle MongoDB and MongoClusters
113118 const accountId =
@@ -123,7 +128,12 @@ export async function globalUriHandler(uri: vscode.Uri): Promise<void> {
123128 params . connectionString ,
124129 ) ;
125130 ext . cosmosDBWorkspaceBranchDataProvider . refresh ( ) ;
126- await revealAttachedInWorkspaceExplorer ( accountId ) ;
131+ await revealAttachedInWorkspaceExplorer (
132+ accountId ,
133+ parsedConnection . api ,
134+ params . database ,
135+ params . container ,
136+ ) ;
127137 }
128138 }
129139
@@ -132,7 +142,7 @@ export async function globalUriHandler(uri: vscode.Uri): Promise<void> {
132142 }
133143
134144 // Open appropriate editor based on API type
135- await openAppropriateEditor ( context , parsedConnection , params . container , params . database ) ;
145+ await openAppropriateEditorForConnection ( context , parsedConnection , params . container , params . database ) ;
136146 }
137147 } ) ;
138148}
@@ -177,10 +187,10 @@ async function createAttachedForConnection(
177187 api : API ,
178188 connectionString : string ,
179189) : Promise < void > {
180- const parentId = '' ;
190+ const parentId = ` ${ api === API . Core ? WorkspaceResourceType . AttachedAccounts : WorkspaceResourceType . MongoClusters } /accounts` ;
181191 await ext . state . showCreatingChild ( parentId , l10n . t ( 'Creating "{nodeName}"…' , { nodeName : accountId } ) , async ( ) => {
182192 const storageItem : SharedWorkspaceStorageItem = {
183- id : accountId ,
193+ id : ` ${ api === API . Core ? WorkspaceResourceType . AttachedAccounts : WorkspaceResourceType . MongoClusters } /accounts/ ${ accountId } ` ,
184194 name : accountName ,
185195 properties : { isEmulator : false , api } ,
186196 secrets : [ connectionString ] ,
@@ -193,23 +203,28 @@ async function createAttachedForConnection(
193203/**
194204 * Reveals the resource in Azure Explorer
195205 */
196- async function revealAttachedInWorkspaceExplorer ( _accountId : string ) : Promise < void > {
206+ async function revealAttachedInWorkspaceExplorer (
207+ accountId : string ,
208+ api : API ,
209+ database ?: string ,
210+ container ?: string ,
211+ ) : Promise < void > {
197212 // Open the Azure Workspace view
198213 await vscode . commands . executeCommand ( 'azureWorkspace.focus' ) ;
199-
200- //TODO: we need to implement a refresh and revealTreeItem methods for attached accounts
201- // await ext.rgApiV2.resources.revealWorkspaceItem(
202- // WorkspaceResourceType.AttachedAccounts,
203- // accountId ,
204- // { select: true, focus: true, expand: true }
205- // );
206- return Promise . resolve ( ) ;
214+ const fullId = ` ${ api === API . Core ? WorkspaceResourceType . AttachedAccounts : WorkspaceResourceType . MongoClusters } /accounts/ ${ accountId } ` ;
215+ const fullResourceId = ` ${ fullId } ${ database ? `/ ${ database } ${ container ? `/ ${ container } ` : '' } ` : '' } ` ;
216+ // TODO: use revealWorkspaceResource!
217+ await ext . rgApiV2 . resources . revealAzureResource ( fullResourceId , {
218+ select : true ,
219+ focus : true ,
220+ expand : true ,
221+ } ) ;
207222}
208223
209224/**
210225 * Opens the appropriate editor based on the API type
211226 */
212- async function openAppropriateEditor (
227+ async function openAppropriateEditorForConnection (
213228 context : IActionContext ,
214229 parsedConnection :
215230 | { api : API . Core ; connectionString : ParsedCosmosDBConnectionString }
0 commit comments