Skip to content

Commit 4b58838

Browse files
authored
Disable contributions when in gp next remote window (#109)
* Disable contributions when in gpnext remote window * 🆙 bump version
1 parent 116e4a6 commit 4b58838

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

package.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Gitpod",
44
"description": "Gitpod Support",
55
"publisher": "gitpod",
6-
"version": "0.0.172",
6+
"version": "0.0.173",
77
"license": "MIT",
88
"icon": "resources/gitpod.png",
99
"repository": {
@@ -270,24 +270,28 @@
270270
],
271271
"commandPalette": [
272272
{
273-
"command": "gitpod.workspaces.refresh",
274-
"when": "false"
273+
"command": "gitpod.signIn",
274+
"when": "!gitpod.inGpNextRemoteWindow"
275+
},
276+
{
277+
"command": "gitpod.exportLogs",
278+
"when": "!gitpod.inGpNextRemoteWindow"
275279
},
276280
{
277281
"command": "gitpod.workspaces.refresh",
278-
"when": "gitpod.authenticated == true"
282+
"when": "gitpod.authenticated == true && !gitpod.inGpNextRemoteWindow"
279283
},
280284
{
281285
"command": "gitpod.workspaces.connectInNewWindow",
282-
"when": "gitpod.authenticated == true"
286+
"when": "gitpod.authenticated == true && !gitpod.inGpNextRemoteWindow"
283287
},
284288
{
285289
"command": "gitpod.workspaces.connectInNewWindow_context",
286290
"when": "false"
287291
},
288292
{
289293
"command": "gitpod.workspaces.connectInCurrentWindow",
290-
"when": "gitpod.authenticated == true"
294+
"when": "gitpod.authenticated == true && !gitpod.inGpNextRemoteWindow"
291295
},
292296
{
293297
"command": "gitpod.workspaces.connectInCurrentWindow_context",
@@ -307,7 +311,7 @@
307311
},
308312
{
309313
"command": "gitpod.workspaces.stopWorkspace",
310-
"when": "gitpod.authenticated == true && gitpod.inWorkspace != true"
314+
"when": "gitpod.authenticated == true && gitpod.inWorkspace != true && !gitpod.inGpNextRemoteWindow"
311315
},
312316
{
313317
"command": "gitpod.workspaces.stopWorkspace_context",
@@ -335,7 +339,7 @@
335339
},
336340
{
337341
"command": "gitpod.workspaces.deleteWorkspace",
338-
"when": "gitpod.authenticated == true && gitpod.inWorkspace != true"
342+
"when": "gitpod.authenticated == true && gitpod.inWorkspace != true && !gitpod.inGpNextRemoteWindow"
339343
},
340344
{
341345
"command": "gitpod.workspaces.deleteWorkspace_context",
@@ -362,13 +366,13 @@
362366
"id": "gitpod-login",
363367
"name": "Login",
364368
"icon": "$(squirrel)",
365-
"when": "gitpod.authenticated != true"
369+
"when": "gitpod.authenticated != true && !gitpod.inGpNextRemoteWindow"
366370
},
367371
{
368372
"id": "gitpod-workspaces",
369373
"name": "Workspaces",
370374
"icon": "$(squirrel)",
371-
"when": "gitpod.authenticated == true"
375+
"when": "gitpod.authenticated == true && !gitpod.inGpNextRemoteWindow"
372376
},
373377
{
374378
"id": "gitpod-workspace",
@@ -381,7 +385,7 @@
381385
"viewsWelcome": [
382386
{
383387
"view": "gitpod-login",
384-
"when": "gitpod.authenticated != true",
388+
"when": "gitpod.authenticated != true && !gitpod.inGpNextRemoteWindow",
385389
"contents": "You have not yet signed in with Gitpod\n[Sign in](command:gitpod.signIn)"
386390
}
387391
]

src/extension.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { NotificationService } from './services/notificationService';
1313
import { RemoteConnector } from './remoteConnector';
1414
import { TelemetryService } from './services/telemetryService';
1515
import { RemoteSession } from './remoteSession';
16-
import { SSHConnectionParams, getGitpodRemoteWindowConnectionInfo } from './remote';
16+
import { SSHConnectionParams, getGitpodRemoteWindowConnectionInfo, isGitpodNextRemoteWindow } from './remote';
1717
import { HostService } from './services/hostService';
1818
import { SessionService } from './services/sessionService';
1919
import { CommandManager } from './commandManager';
@@ -45,6 +45,11 @@ export async function activate(context: vscode.ExtensionContext) {
4545
const extensionId = context.extension.id;
4646
const packageJSON = context.extension.packageJSON;
4747

48+
if (isGitpodNextRemoteWindow()) {
49+
vscode.commands.executeCommand('setContext', 'gitpod.inGpNextRemoteWindow', true);
50+
return;
51+
}
52+
4853
let remoteConnectionInfo: { connectionInfo: SSHConnectionParams; remoteUri: vscode.Uri; sshDestStr: string } | undefined;
4954
let success = false;
5055
try {

src/remote.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7+
import SSHDestination from './ssh/sshDestination';
78

89
export interface SSHConnectionParams {
910
workspaceId: string;
@@ -69,6 +70,35 @@ export function getGitpodRemoteWindowConnectionInfo(context: vscode.ExtensionCon
6970
return undefined;
7071
}
7172

73+
export function isGitpodNextRemoteWindow() {
74+
const remoteUri = vscode.workspace.workspaceFile?.scheme !== 'untitled'
75+
? vscode.workspace.workspaceFile || vscode.workspace.workspaceFolders?.[0].uri
76+
: vscode.workspace.workspaceFolders?.[0].uri;
77+
if (!remoteUri) {
78+
return false;
79+
}
80+
if (vscode.env.remoteName === 'dev-container') {
81+
const authorities = remoteUri.authority.split('@');
82+
const sshAuthority = authorities.find((str) => str.includes('ssh-remote'));
83+
const containerAuthority = authorities.find((str) => str.includes('dev-container'));
84+
if (!sshAuthority || !containerAuthority) {
85+
return false;
86+
}
87+
const [, sshEncoded] = sshAuthority.split('+');
88+
if (!sshEncoded) {
89+
return false;
90+
}
91+
const [, containerEncoded] = containerAuthority.split('+');
92+
if (!containerEncoded) {
93+
return false;
94+
}
95+
const sshDest = SSHDestination.fromRemoteSSHString(sshEncoded);
96+
97+
return /gitpod\.(local|remote)$/.test(sshDest.hostname);
98+
}
99+
return false;
100+
}
101+
72102
export function getLocalSSHDomain(gitpodHost: string): string {
73103
const scope = vscode.env.appName.includes('Insiders') ? 'vsi' : 'vss';
74104
return `${scope}.` + (new URL(gitpodHost)).hostname;

0 commit comments

Comments
 (0)