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