Skip to content

Commit 760c290

Browse files
authored
Merge pull request #164 from gjsjohnmurray/fix-163
fix-163 Studio Context Actions command errored if no file open
2 parents b58e16f + cc8f338 commit 760c290

File tree

4 files changed

+181
-69
lines changed

4 files changed

+181
-69
lines changed

package.json

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,20 @@
128128
"when": "false"
129129
},
130130
{
131-
"command": "vscode-objectscript.studio.actions",
132-
"when": "vscode-objectscript.connectActive && resourceScheme == isfs"
131+
"command": "vscode-objectscript.serverCommands.sourceControl",
132+
"when": "vscode-objectscript.connectActive && resourceScheme == isfs || vscode-objectscript.connectActive && !editorIsOpen"
133+
},
134+
{
135+
"command": "vscode-objectscript.serverCommands.contextSourceControl",
136+
"when": "false"
137+
},
138+
{
139+
"command": "vscode-objectscript.serverCommands.other",
140+
"when": "vscode-objectscript.connectActive && resourceScheme == isfs || vscode-objectscript.connectActive && !editorIsOpen"
141+
},
142+
{
143+
"command": "vscode-objectscript.serverCommands.contextOther",
144+
"when": "false"
133145
}
134146
],
135147
"view/title": [
@@ -157,7 +169,11 @@
157169
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:/"
158170
},
159171
{
160-
"command": "vscode-objectscript.studio.contextActions",
172+
"command": "vscode-objectscript.serverCommands.contextSourceControl",
173+
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:/"
174+
},
175+
{
176+
"command": "vscode-objectscript.serverCommands.contextOther",
161177
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:/"
162178
},
163179
{
@@ -182,21 +198,43 @@
182198
"editor/context": [
183199
{
184200
"command": "vscode-objectscript.viewOthers",
185-
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
201+
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
202+
"group": "objectscript@1"
186203
},
187204
{
188205
"command": "vscode-objectscript.compile",
189-
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
206+
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
207+
"group": "objectscript@2"
190208
},
191209
{
192-
"command": "vscode-objectscript.studio.actions",
193-
"when": "resourceScheme == isfs && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
210+
"command": "vscode-objectscript.previewXml",
211+
"when": "editorLangId =~ /^xml/",
212+
"group": "objectscript@3"
194213
},
195214
{
196-
"command": "vscode-objectscript.previewXml",
197-
"when": "editorLangId =~ /^xml/"
215+
"command": "vscode-objectscript.serverCommands.contextSourceControl",
216+
"when": "resourceScheme == isfs && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
217+
"group": "objectscript@4"
218+
},
219+
{
220+
"command": "vscode-objectscript.serverCommands.contextOther",
221+
"when": "resourceScheme == isfs && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
222+
"group": "objectscript@5"
198223
}
199224
],
225+
"editor/title": [
226+
{
227+
"command": "vscode-objectscript.serverCommands.sourceControl",
228+
"group": "navigation@1",
229+
"when": "vscode-objectscript.connectActive && resourceScheme == isfs"
230+
},
231+
{
232+
"command": "vscode-objectscript.serverCommands.other",
233+
"group": "navigation@2",
234+
"when": "vscode-objectscript.connectActive && resourceScheme == isfs"
235+
}
236+
237+
],
200238
"touchBar": [
201239
{
202240
"command": "vscode-objectscript.touchBar.compile",
@@ -212,11 +250,18 @@
212250
"explorer/context": [
213251
{
214252
"command": "vscode-objectscript.compileFolder",
215-
"when": "vscode-objectscript.connectActive"
253+
"when": "vscode-objectscript.connectActive",
254+
"group": "objectscript@1"
216255
},
217256
{
218-
"command": "vscode-objectscript.studio.actions",
219-
"when": "resourceScheme == isfs && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
257+
"command": "vscode-objectscript.serverCommands.contextSourceControl",
258+
"when": "resourceScheme == isfs && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
259+
"group": "objectscript@2"
260+
},
261+
{
262+
"command": "vscode-objectscript.serverCommands.contextOther",
263+
"when": "resourceScheme == isfs && resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
264+
"group": "objectscript@3"
220265
}
221266
]
222267
},
@@ -409,13 +454,25 @@
409454
},
410455
{
411456
"category": "ObjectScript",
412-
"command": "vscode-objectscript.studio.actions",
413-
"title": "Studio Actions..."
457+
"command": "vscode-objectscript.serverCommands.sourceControl",
458+
"title": "Server Source Control...",
459+
"icon": "$(source-control)"
460+
},
461+
{
462+
"category": "ObjectScript",
463+
"command": "vscode-objectscript.serverCommands.contextSourceControl",
464+
"title": "Server Source Control..."
465+
},
466+
{
467+
"category": "ObjectScript",
468+
"command": "vscode-objectscript.serverCommands.other",
469+
"title": "Server Command Menu...",
470+
"icon": "$(server-environment)"
414471
},
415472
{
416473
"category": "ObjectScript",
417-
"command": "vscode-objectscript.studio.contextActions",
418-
"title": "Studio Context Actions..."
474+
"command": "vscode-objectscript.serverCommands.contextOther",
475+
"title": "Server Command Menu..."
419476
}
420477
],
421478
"keybindings": [

src/commands/serverActions.ts

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as vscode from "vscode";
2-
import { config, workspaceState, checkConnection } from "../extension";
2+
import { config, workspaceState, checkConnection, FILESYSTEM_SCHEMA } from "../extension";
33
import { currentWorkspaceFolder, terminalWithDocker, currentFile } from "../utils";
4+
import { mainCommandMenu, mainSourceControlMenu } from "./studio";
45

56
export async function serverActions(): Promise<void> {
67
const { active, host, ns, https, port: defaultPort, username, password: defaultPassword, links } = config("conn");
@@ -45,34 +46,48 @@ export async function serverActions(): Promise<void> {
4546
detail: "Use docker-compose to start session inside configured service",
4647
});
4748
}
49+
const studio = [];
50+
if (!vscode.window.activeTextEditor || vscode.window.activeTextEditor.document.uri.scheme === FILESYSTEM_SCHEMA) {
51+
studio.push({
52+
id: "serverSourceControlMenu",
53+
label: "Server Source Control...",
54+
detail: "Pick server-side source control action",
55+
});
56+
studio.push({
57+
id: "serverCommandMenu",
58+
label: "Server Command Menu...",
59+
detail: "Pick server-side command",
60+
});
61+
}
4862
return vscode.window
4963
.showQuickPick(
5064
[
5165
...extraLinks,
5266
{
5367
id: "refreshConnection",
54-
label: "Refresh connection",
68+
label: "Refresh Connection",
5569
detail: "Force attempt to connect to the server",
5670
},
5771
...terminal,
5872
{
59-
detail: "Enable/Disable current connection",
6073
id: "toggleConnection",
61-
label: "Toggle connection",
74+
label: "Toggle Connection",
75+
detail: "Enable/Disable current connection",
6276
},
6377
{
64-
detail: portalUrl,
6578
id: "openPortal",
6679
label: "Open Management Portal",
80+
detail: portalUrl,
6781
},
6882
{
69-
detail: classRef,
7083
id: "openClassReference",
71-
label: "Open class reference",
84+
label: "Open Class Reference",
85+
detail: classRef,
7286
},
87+
...studio,
7388
],
7489
{
75-
placeHolder: `Select action for server: ${connInfo}`,
90+
placeHolder: `Select action for server ${connInfo}`,
7691
}
7792
)
7893
.then((action) => {
@@ -99,6 +114,14 @@ export async function serverActions(): Promise<void> {
99114
terminalWithDocker();
100115
break;
101116
}
117+
case "serverSourceControlMenu": {
118+
mainSourceControlMenu();
119+
break;
120+
}
121+
case "serverCommandMenu": {
122+
mainCommandMenu();
123+
break;
124+
}
102125
default: {
103126
vscode.env.openExternal(vscode.Uri.parse(action.detail));
104127
}

0 commit comments

Comments
 (0)