From b86b672f26f3d728a1d17dff9eb36286e0c46189 Mon Sep 17 00:00:00 2001 From: Maxime Dufour Date: Wed, 3 Jan 2024 13:52:38 +0000 Subject: [PATCH] Fix Account details Uri Signed-off-by: Maxime Dufour --- src/extension.ts | 6 +++--- src/virtual_filesystem/oscvirtualfs.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 33b6f54..1a29a53 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,7 +7,7 @@ import { OscExplorer } from "./explorer"; import { ExplorerResourceNode, ResourceNodeType } from './flat/node'; import { ResourceNode } from './flat/resources/node.resources'; import { VmResourceNode } from './flat/resources/node.resources.vms'; -import { OscVirtualContentProvider } from './virtual_filesystem/oscvirtualfs'; +import { OscVirtualContentProvider, computeUri } from './virtual_filesystem/oscvirtualfs'; import { LogsProvider } from './virtual_filesystem/logs'; import { ProfileNode } from './flat/node.profile'; import { FolderNode } from './flat/folders/node.folder'; @@ -28,7 +28,7 @@ function getMultipleSelection(mainSelectedItem: T, allSelectedItems?: any[]): } export async function showResourceDetails(profileName: string, resourceType: ResourceNodeType, resourceId: string) { - const uri = vscode.Uri.parse('osc:/' + profileName + "/" + resourceType + "/" + resourceId + ".json"); + const uri = computeUri(profileName, `${resourceType}`, resourceId); const doc = await vscode.workspace.openTextDocument(uri); // calls back into the provider await vscode.window.showTextDocument(doc); } @@ -187,7 +187,7 @@ export function activate(context: vscode.ExtensionContext) { }); vscode.commands.registerCommand('osc.showAccountInfo', async (arg: ProfileNode) => { - const uri = vscode.Uri.parse('osc:/' + arg.profile.name + "/profile/" + arg.profile.name); + const uri = computeUri(arg.profile.name, "profile", arg.profile.name); try { const doc = await vscode.workspace.openTextDocument(uri); // calls back into the provider await vscode.window.showTextDocument(doc); diff --git a/src/virtual_filesystem/oscvirtualfs.ts b/src/virtual_filesystem/oscvirtualfs.ts index 85c6737..5e99836 100644 --- a/src/virtual_filesystem/oscvirtualfs.ts +++ b/src/virtual_filesystem/oscvirtualfs.ts @@ -109,4 +109,8 @@ export class OscVirtualContentProvider implements vscode.TextDocumentContentProv } return JSON.stringify(resourceEncoding.toString(res), null, 4); } +} + +export function computeUri(profile: string, resourceType: string, resourceId: string): vscode.Uri { + return vscode.Uri.parse(`osc:/${profile}/${resourceType}/${resourceId}.json`); } \ No newline at end of file