Skip to content

Commit d2d06e6

Browse files
committed
SNAPSHOT.3
1 parent 9e94aaf commit d2d06e6

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "servermanager",
33
"displayName": "InterSystems Server Manager",
4-
"version": "2.0.0-SNAPSHOT.2",
4+
"version": "2.0.0-SNAPSHOT.3",
55
"publisher": "intersystems-community",
66
"description": "Helper extension for defining connections to InterSystems servers.",
77
"repository": {
@@ -297,6 +297,16 @@
297297
{
298298
"command": "intersystems-community.servermanager.resetIconColor",
299299
"title": "default"
300+
},
301+
{
302+
"command": "intersystems-community.servermanager.editNamespace",
303+
"title": "Edit Code in Namespace",
304+
"icon": "$(edit)"
305+
},
306+
{
307+
"command": "intersystems-community.servermanager.viewNamespace",
308+
"title": "View Code in Namespace",
309+
"icon": "$(eye)"
300310
}
301311
],
302312
"submenus": [
@@ -391,6 +401,16 @@
391401
"when": "view == intersystems-community_servermanager && viewItem == starred.server.starred",
392402
"group": "inline@10"
393403
},
404+
{
405+
"command": "intersystems-community.servermanager.editNamespace",
406+
"when": "view == intersystems-community_servermanager && viewItem =~ /namespace$/",
407+
"group": "inline@10"
408+
},
409+
{
410+
"command": "intersystems-community.servermanager.viewNamespace",
411+
"when": "view == intersystems-community_servermanager && viewItem =~ /namespace$/",
412+
"group": "inline@20"
413+
},
394414
{
395415
"command": "intersystems-community.servermanager.openPortalTab",
396416
"when": "view == intersystems-community_servermanager && viewItem =~ /\\.server\\./",

src/extension.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,43 @@ export function activate(context: vscode.ExtensionContext) {
187187
})
188188
);
189189

190+
const addWorkspaceFolderAsync = async (readonly: boolean, namespaceTreeItem?: ServerTreeItem) => {
191+
if (namespaceTreeItem) {
192+
const pathParts = namespaceTreeItem.id?.split(':');
193+
if (pathParts && pathParts.length === 4) {
194+
const serverName = pathParts[1];
195+
const namespace = pathParts[3];
196+
const serverSpec = await getServerSpec(serverName, undefined, undefined, true);
197+
if (serverSpec) {
198+
const uri = vscode.Uri.parse(`isfs${readonly ? "-readonly" : ""}://${serverName}:${namespace}/${serverSpec.webServer.pathPrefix || ''}`);
199+
const label = `${serverName}:${namespace}${readonly ? " (read-only)" : ""}`;
200+
const added = vscode.workspace.updateWorkspaceFolders(
201+
vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders.length : 0,
202+
0,
203+
{ uri, name: label }
204+
);
205+
// Switch to Explorer view so user sees the outcome
206+
await vscode.commands.executeCommand("workbench.view.explorer");
207+
// Handle failure
208+
if (added) {
209+
await view.addToRecents(serverName);
210+
}
211+
else {
212+
vscode.window.showErrorMessage(`Folder ${uri.toString()} could not be added. Maybe it already exists in the workspace.`, "Close")
213+
}
214+
}
215+
}
216+
}
217+
}
218+
219+
context.subscriptions.push(
220+
vscode.commands.registerCommand(`${extensionId}.editNamespace`, async (namespaceTreeItem?: ServerTreeItem) => {await addWorkspaceFolderAsync(false, namespaceTreeItem)})
221+
);
222+
223+
context.subscriptions.push(
224+
vscode.commands.registerCommand(`${extensionId}.viewNamespace`, async (namespaceTreeItem?: ServerTreeItem) => {await addWorkspaceFolderAsync(true, namespaceTreeItem)})
225+
);
226+
190227
// Listen for relevant configuration changes
191228
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(e => {
192229
if (e.affectsConfiguration('intersystems.servers') || e.affectsConfiguration('objectscript.conn')) {

0 commit comments

Comments
 (0)