Skip to content

Commit

Permalink
SNAPSHOT.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gjsjohnmurray committed Apr 15, 2021
1 parent 9e94aaf commit d2d06e6
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
22 changes: 21 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "servermanager",
"displayName": "InterSystems Server Manager",
"version": "2.0.0-SNAPSHOT.2",
"version": "2.0.0-SNAPSHOT.3",
"publisher": "intersystems-community",
"description": "Helper extension for defining connections to InterSystems servers.",
"repository": {
Expand Down Expand Up @@ -297,6 +297,16 @@
{
"command": "intersystems-community.servermanager.resetIconColor",
"title": "default"
},
{
"command": "intersystems-community.servermanager.editNamespace",
"title": "Edit Code in Namespace",
"icon": "$(edit)"
},
{
"command": "intersystems-community.servermanager.viewNamespace",
"title": "View Code in Namespace",
"icon": "$(eye)"
}
],
"submenus": [
Expand Down Expand Up @@ -391,6 +401,16 @@
"when": "view == intersystems-community_servermanager && viewItem == starred.server.starred",
"group": "inline@10"
},
{
"command": "intersystems-community.servermanager.editNamespace",
"when": "view == intersystems-community_servermanager && viewItem =~ /namespace$/",
"group": "inline@10"
},
{
"command": "intersystems-community.servermanager.viewNamespace",
"when": "view == intersystems-community_servermanager && viewItem =~ /namespace$/",
"group": "inline@20"
},
{
"command": "intersystems-community.servermanager.openPortalTab",
"when": "view == intersystems-community_servermanager && viewItem =~ /\\.server\\./",
Expand Down
37 changes: 37 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,43 @@ export function activate(context: vscode.ExtensionContext) {
})
);

const addWorkspaceFolderAsync = async (readonly: boolean, namespaceTreeItem?: ServerTreeItem) => {
if (namespaceTreeItem) {
const pathParts = namespaceTreeItem.id?.split(':');
if (pathParts && pathParts.length === 4) {
const serverName = pathParts[1];
const namespace = pathParts[3];
const serverSpec = await getServerSpec(serverName, undefined, undefined, true);
if (serverSpec) {
const uri = vscode.Uri.parse(`isfs${readonly ? "-readonly" : ""}://${serverName}:${namespace}/${serverSpec.webServer.pathPrefix || ''}`);
const label = `${serverName}:${namespace}${readonly ? " (read-only)" : ""}`;
const added = vscode.workspace.updateWorkspaceFolders(
vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders.length : 0,
0,
{ uri, name: label }
);
// Switch to Explorer view so user sees the outcome
await vscode.commands.executeCommand("workbench.view.explorer");
// Handle failure
if (added) {
await view.addToRecents(serverName);
}
else {
vscode.window.showErrorMessage(`Folder ${uri.toString()} could not be added. Maybe it already exists in the workspace.`, "Close")
}
}
}
}
}

context.subscriptions.push(
vscode.commands.registerCommand(`${extensionId}.editNamespace`, async (namespaceTreeItem?: ServerTreeItem) => {await addWorkspaceFolderAsync(false, namespaceTreeItem)})
);

context.subscriptions.push(
vscode.commands.registerCommand(`${extensionId}.viewNamespace`, async (namespaceTreeItem?: ServerTreeItem) => {await addWorkspaceFolderAsync(true, namespaceTreeItem)})
);

// Listen for relevant configuration changes
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('intersystems.servers') || e.affectsConfiguration('objectscript.conn')) {
Expand Down

0 comments on commit d2d06e6

Please sign in to comment.