Skip to content

fix-163 Studio Context Actions command errored if no file open #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gjsjohnmurray I don't like "sourceControl" here - maybe call it serverCommands.studioExtension? (The "studio extension" framework is more general than just source control.)

Copy link
Contributor Author

@gjsjohnmurray gjsjohnmurray Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timleavitt with this PR I have implemented separate menus for the Source Control commands and the rest, to replicate how Studio behaves. This command brings up the %SourceMenu menu items, which Studio displays under a menu named "Source Control". The command vscode-objectscript.serverCommands.other brings up the items from all other menus for which context=0.

vscode-objectscript.serverCommands.contextSourceControl shows the %SourceContext menu's items, and vscode-objectscript.serverCommands.contextOther shows all the other ones for which context=1

If you'd like to see this in action you can always get the vsix artifact that our CI pipeline creates whenever I push stuff to this PR:

image

Install this in your VS Code and give it a try. I'll be glad to have more of your feedback.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gjsjohnmurray thanks - that makes more sense now. I'll try it out when I get a chance.

"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