Skip to content

Commit

Permalink
Merge pull request #164 from gjsjohnmurray/fix-163
Browse files Browse the repository at this point in the history
fix-163 Studio Context Actions command errored if no file open
  • Loading branch information
rajrsingh authored Jul 1, 2020
2 parents b58e16f + cc8f338 commit 760c290
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 69 deletions.
89 changes: 73 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,20 @@
"when": "false"
},
{
"command": "vscode-objectscript.studio.actions",
"when": "vscode-objectscript.connectActive && resourceScheme == isfs"
"command": "vscode-objectscript.serverCommands.sourceControl",
"when": "vscode-objectscript.connectActive && resourceScheme == isfs || vscode-objectscript.connectActive && !editorIsOpen"
},
{
"command": "vscode-objectscript.serverCommands.contextSourceControl",
"when": "false"
},
{
"command": "vscode-objectscript.serverCommands.other",
"when": "vscode-objectscript.connectActive && resourceScheme == isfs || vscode-objectscript.connectActive && !editorIsOpen"
},
{
"command": "vscode-objectscript.serverCommands.contextOther",
"when": "false"
}
],
"view/title": [
Expand Down Expand Up @@ -157,7 +169,11 @@
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:/"
},
{
"command": "vscode-objectscript.studio.contextActions",
"command": "vscode-objectscript.serverCommands.contextSourceControl",
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:/"
},
{
"command": "vscode-objectscript.serverCommands.contextOther",
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:/"
},
{
Expand All @@ -182,21 +198,43 @@
"editor/context": [
{
"command": "vscode-objectscript.viewOthers",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"group": "objectscript@1"
},
{
"command": "vscode-objectscript.compile",
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"group": "objectscript@2"
},
{
"command": "vscode-objectscript.studio.actions",
"when": "resourceScheme == isfs && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"command": "vscode-objectscript.previewXml",
"when": "editorLangId =~ /^xml/",
"group": "objectscript@3"
},
{
"command": "vscode-objectscript.previewXml",
"when": "editorLangId =~ /^xml/"
"command": "vscode-objectscript.serverCommands.contextSourceControl",
"when": "resourceScheme == isfs && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"group": "objectscript@4"
},
{
"command": "vscode-objectscript.serverCommands.contextOther",
"when": "resourceScheme == isfs && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"group": "objectscript@5"
}
],
"editor/title": [
{
"command": "vscode-objectscript.serverCommands.sourceControl",
"group": "navigation@1",
"when": "vscode-objectscript.connectActive && resourceScheme == isfs"
},
{
"command": "vscode-objectscript.serverCommands.other",
"group": "navigation@2",
"when": "vscode-objectscript.connectActive && resourceScheme == isfs"
}

],
"touchBar": [
{
"command": "vscode-objectscript.touchBar.compile",
Expand All @@ -212,11 +250,18 @@
"explorer/context": [
{
"command": "vscode-objectscript.compileFolder",
"when": "vscode-objectscript.connectActive"
"when": "vscode-objectscript.connectActive",
"group": "objectscript@1"
},
{
"command": "vscode-objectscript.studio.actions",
"when": "resourceScheme == isfs && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
"command": "vscode-objectscript.serverCommands.contextSourceControl",
"when": "resourceScheme == isfs && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"group": "objectscript@2"
},
{
"command": "vscode-objectscript.serverCommands.contextOther",
"when": "resourceScheme == isfs && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
"group": "objectscript@3"
}
]
},
Expand Down Expand Up @@ -409,13 +454,25 @@
},
{
"category": "ObjectScript",
"command": "vscode-objectscript.studio.actions",
"title": "Studio Actions..."
"command": "vscode-objectscript.serverCommands.sourceControl",
"title": "Server Source Control...",
"icon": "$(source-control)"
},
{
"category": "ObjectScript",
"command": "vscode-objectscript.serverCommands.contextSourceControl",
"title": "Server Source Control..."
},
{
"category": "ObjectScript",
"command": "vscode-objectscript.serverCommands.other",
"title": "Server Command Menu...",
"icon": "$(server-environment)"
},
{
"category": "ObjectScript",
"command": "vscode-objectscript.studio.contextActions",
"title": "Studio Context Actions..."
"command": "vscode-objectscript.serverCommands.contextOther",
"title": "Server Command Menu..."
}
],
"keybindings": [
Expand Down
39 changes: 31 additions & 8 deletions src/commands/serverActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from "vscode";
import { config, workspaceState, checkConnection } from "../extension";
import { config, workspaceState, checkConnection, FILESYSTEM_SCHEMA } from "../extension";
import { currentWorkspaceFolder, terminalWithDocker, currentFile } from "../utils";
import { mainCommandMenu, mainSourceControlMenu } from "./studio";

export async function serverActions(): Promise<void> {
const { active, host, ns, https, port: defaultPort, username, password: defaultPassword, links } = config("conn");
Expand Down Expand Up @@ -45,34 +46,48 @@ export async function serverActions(): Promise<void> {
detail: "Use docker-compose to start session inside configured service",
});
}
const studio = [];
if (!vscode.window.activeTextEditor || vscode.window.activeTextEditor.document.uri.scheme === FILESYSTEM_SCHEMA) {
studio.push({
id: "serverSourceControlMenu",
label: "Server Source Control...",
detail: "Pick server-side source control action",
});
studio.push({
id: "serverCommandMenu",
label: "Server Command Menu...",
detail: "Pick server-side command",
});
}
return vscode.window
.showQuickPick(
[
...extraLinks,
{
id: "refreshConnection",
label: "Refresh connection",
label: "Refresh Connection",
detail: "Force attempt to connect to the server",
},
...terminal,
{
detail: "Enable/Disable current connection",
id: "toggleConnection",
label: "Toggle connection",
label: "Toggle Connection",
detail: "Enable/Disable current connection",
},
{
detail: portalUrl,
id: "openPortal",
label: "Open Management Portal",
detail: portalUrl,
},
{
detail: classRef,
id: "openClassReference",
label: "Open class reference",
label: "Open Class Reference",
detail: classRef,
},
...studio,
],
{
placeHolder: `Select action for server: ${connInfo}`,
placeHolder: `Select action for server ${connInfo}`,
}
)
.then((action) => {
Expand All @@ -99,6 +114,14 @@ export async function serverActions(): Promise<void> {
terminalWithDocker();
break;
}
case "serverSourceControlMenu": {
mainSourceControlMenu();
break;
}
case "serverCommandMenu": {
mainCommandMenu();
break;
}
default: {
vscode.env.openExternal(vscode.Uri.parse(action.detail));
}
Expand Down
Loading

0 comments on commit 760c290

Please sign in to comment.