Skip to content

Commit 4170841

Browse files
committed
Support start workspace with other IDEs in Github
1 parent bcf7e96 commit 4170841

14 files changed

+794
-110
lines changed

.gitpod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tasks:
66
gp sync-await start &&
77
gp await-port 6080 &&
88
for i in `seq 10 -1 1` ; do echo -ne "\rStarting Chrome in $i " && sleep 1 && echo -ne "\r" ; done &&
9-
google-chrome --no-first-run --disable-dev-shm-usage --start-maximized --load-extension=/workspace/browser-extension https://github.com/gitpod-io/template-sveltekit
9+
google-chrome --no-first-run --disable-dev-shm-usage --start-maximized --load-extension=/workspace/browser-extension https://github.com/gitpod-io/template-sveltekit https://github.com/gitpod-io/gitpod/pull/9378 https://github.com/gitpod-io/gitpod/issues/6707 https://github.com/gitpod-io/gitpod/blob/main/components/supervisor-api/notification.proto
1010
- name: Webpack Dev Server
1111
init: yarn install && yarn build && yarn package
1212
command: >

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"dom-loaded": "^2.0.0",
2020
"github-injection": "^1.0.1",
2121
"select-dom": "^5.1.0",
22-
"webextension-polyfill": "^0.7.0"
22+
"webextension-polyfill": "^0.7.0",
23+
"@gitpod/gitpod-protocol": "main"
2324
},
2425
"devDependencies": {
2526
"copy-webpack-plugin": "^7.0.0",

src/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ export interface Config {
55
gitpodURL: string;
66
openAsPopup: boolean;
77
rewritePeriodKeybind: boolean;
8+
useLatest: boolean;
89
}
910

1011
export const DEFAULT_CONFIG: Config = {
1112
gitpodURL: "https://gitpod.io",
1213
openAsPopup: false,
13-
rewritePeriodKeybind: false
14+
rewritePeriodKeybind: false,
15+
useLatest: false,
1416
};
1517

1618
export interface ConfigListener {

src/gitpodify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const init = async (injectedByUserClick: boolean = false) => {
4242

4343
if (injectedByUserClick) {
4444
// User clicked on the Gitpod extension icon. We open the Gitpod with this page as context.
45-
window.open(renderGitpodUrl(config.gitpodURL));
45+
window.open(renderGitpodUrl(config.gitpodURL).gitpodUrl);
4646
}
4747

4848
// Perform the actual, initial injection

src/ide-options.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"clients": {
3+
"jetbrains-gateway": {
4+
"defaultDesktopIDE": "intellij",
5+
"desktopIDEs": [
6+
"intellij",
7+
"goland",
8+
"pycharm",
9+
"phpstorm"
10+
],
11+
"installationSteps": [
12+
"If you don't see an open dialog in your browser, make sure you have the <a target='_blank' class='gp-link' href='https://www.gitpod.io/docs/ides-and-editors/jetbrains-gateway#getting-started-jetbrains-gateway'>JetBrains Gateway with Gitpod Plugin</a> installed on your machine, and then click <b>${OPEN_LINK_LABEL}</b> below."
13+
]
14+
},
15+
"vscode": {
16+
"defaultDesktopIDE": "code-desktop",
17+
"desktopIDEs": [
18+
"code-desktop"
19+
],
20+
"installationSteps": [
21+
"If you don't see an open dialog in your browser, make sure you have <a target='_blank' class='gp-link' href='https://code.visualstudio.com/download'>VS Code</a> installed on your machine, and then click <b>${OPEN_LINK_LABEL}</b> below."
22+
]
23+
},
24+
"vscode-insiders": {
25+
"defaultDesktopIDE": "code-desktop",
26+
"desktopIDEs": [
27+
"code-desktop"
28+
],
29+
"installationSteps": [
30+
"If you don't see an open dialog in your browser, make sure you have <a target='_blank' class='gp-link' href='https://code.visualstudio.com/insiders'>VS Code Insiders</a> installed on your machine, and then click <b>${OPEN_LINK_LABEL}</b> below."
31+
]
32+
}
33+
},
34+
"defaultDesktopIde": "code-desktop",
35+
"defaultIde": "code",
36+
"options": {
37+
"code": {
38+
"image": "eu.gcr.io/gitpod-core-dev/build/ide/code:commit-54b4098031a1a3a600c1fd73d070c4aab27e1cd8",
39+
"label": "Browser",
40+
"latestImage": "eu.gcr.io/gitpod-core-dev/build/ide/code:nightly@sha256:b62ea2f415d46505c1ffa75f171dc00a0b099105e99ef070ee65ec05084fba61",
41+
"logo": "https://ide.gitpod.io/image/ide-logo/vscode.svg",
42+
"orderKey": "00",
43+
"title": "VS Code",
44+
"type": "browser"
45+
},
46+
"code-desktop": {
47+
"image": "eu.gcr.io/gitpod-core-dev/build/ide/code-desktop:commit-b121fec8e215abd2d0328ef28b8808a59852cb4c",
48+
"latestImage": "eu.gcr.io/gitpod-core-dev/build/ide/code-desktop-insiders:commit-b121fec8e215abd2d0328ef28b8808a59852cb4c@sha256:1b65f8959b1eac330e736c18d1824f34c2ad21df81438ba8c3351e04d5f539ad",
49+
"logo": "https://ide.gitpod.io/image/ide-logo/vscode.svg",
50+
"orderKey": "02",
51+
"title": "VS Code",
52+
"type": "desktop"
53+
},
54+
"goland": {
55+
"image": "eu.gcr.io/gitpod-core-dev/build/ide/goland:commit-a4234aa724a4658207fdf6a64e5c07f204da86d1",
56+
"latestImage": "eu.gcr.io/gitpod-core-dev/build/ide/goland:latest@sha256:2c23f10430fb3fe62d19fe39f40b4dea4869eab31ae72e5f7bddeb6679a4dcd7",
57+
"logo": "https://ide.gitpod.io/image/ide-logo/golandLogo.svg",
58+
"orderKey": "05",
59+
"title": "GoLand",
60+
"type": "desktop"
61+
},
62+
"intellij": {
63+
"image": "eu.gcr.io/gitpod-core-dev/build/ide/intellij:commit-bbdbb44b0a85a2c36e6854d818fe920d0ee5369c",
64+
"latestImage": "eu.gcr.io/gitpod-core-dev/build/ide/intellij:latest@sha256:6109564a542707a8962054d864ee0679388b77bcb66c8fd987924a831cbaf486",
65+
"logo": "https://ide.gitpod.io/image/ide-logo/intellijIdeaLogo.svg",
66+
"orderKey": "04",
67+
"title": "IntelliJ IDEA",
68+
"type": "desktop"
69+
},
70+
"phpstorm": {
71+
"image": "eu.gcr.io/gitpod-core-dev/build/ide/phpstorm:commit-a4234aa724a4658207fdf6a64e5c07f204da86d1",
72+
"latestImage": "eu.gcr.io/gitpod-core-dev/build/ide/phpstorm:latest@sha256:81085f80e4227b9e034aa37adb2256c279d2cca4cd3b4101feb3abd8f53e90d2",
73+
"logo": "https://ide.gitpod.io/image/ide-logo/phpstormLogo.svg",
74+
"orderKey": "07",
75+
"title": "PhpStorm",
76+
"type": "desktop"
77+
},
78+
"pycharm": {
79+
"image": "eu.gcr.io/gitpod-core-dev/build/ide/pycharm:commit-a4234aa724a4658207fdf6a64e5c07f204da86d1",
80+
"latestImage": "eu.gcr.io/gitpod-core-dev/build/ide/pycharm:latest@sha256:4698b906f4852d44b48ef3df858fcef73da69628a2da3188cd6e70116d84865e",
81+
"logo": "https://ide.gitpod.io/image/ide-logo/pycharmLogo.svg",
82+
"orderKey": "06",
83+
"title": "PyCharm",
84+
"type": "desktop"
85+
}
86+
}
87+
}

src/injectors/bitbucket-injector.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { InjectorBase, ButtonInjector, checkIsBtnUpToDate } from "./injector";
22
import { ConfigProvider } from "../config";
3-
import { renderGitpodUrl, makeOpenInPopup } from "../utils";
3+
import { renderGitpodUrl, makeOpenInPopup, UrlInfo } from "../utils";
44
import select = require("select-dom");
55

66
namespace Gitpodify {
7-
export const NAV_BTN_ID = "gitpod-btn-nav";
8-
export const NAV_BTN_CLASS = "gitpod-nav-btn";
7+
export const NAV_BTN_ID = "gitpod-btn-nav";
8+
export const NAV_BTN_CLASS = "gitpod-nav-btn";
99
export const NAV_BTN_CLASS_SELECTOR = "." + NAV_BTN_CLASS;
10-
10+
1111
export const CSS_REF_BTN_CONTAINER = "gitpod-btn-container";
1212
export const CSS_REF_NO_CONTAINER = "no-container";
1313
}
@@ -38,8 +38,8 @@ export class BitbucketInjector extends InjectorBase {
3838

3939
checkIsInjected(): boolean {
4040
const button = document.getElementById(`${Gitpodify.NAV_BTN_ID}`);
41-
const currentUrl = renderGitpodUrl(this.config.gitpodURL);
42-
return checkIsBtnUpToDate(button, currentUrl);
41+
const urlInfo = renderGitpodUrl(this.config.gitpodURL);
42+
return checkIsBtnUpToDate(button, urlInfo.gitpodUrl);
4343
}
4444

4545
async inject(): Promise<void> {
@@ -54,17 +54,17 @@ export class BitbucketInjector extends InjectorBase {
5454

5555
abstract class ButtonInjectorBase implements ButtonInjector {
5656

57-
constructor(protected readonly parent: string, protected btnClasses: string, protected readonly up?: number) {
57+
constructor(protected readonly parent: string, protected btnClasses: string, protected readonly up?: number, protected readonly test?: boolean) {
5858

5959
}
6060

6161
abstract isApplicableToCurrentPage(): boolean;
6262

63-
inject(currentUrl: string, openAsPopup: boolean) {
63+
inject(urlInfo: UrlInfo, openAsPopup: boolean, useLatest: boolean) {
6464
let actionbar = select(this.parent);
65-
if(actionbar && this.up) {
66-
for(let i = 0; i < this.up; i++) {
67-
if(actionbar.parentElement) {
65+
if (actionbar && this.up) {
66+
for (let i = 0; i < this.up; i++) {
67+
if (actionbar.parentElement) {
6868
actionbar = actionbar.parentElement;
6969
} else {
7070
return;
@@ -75,6 +75,7 @@ abstract class ButtonInjectorBase implements ButtonInjector {
7575
return;
7676
}
7777

78+
const currentUrl = urlInfo.gitpodUrl;
7879
const oldBtn = document.getElementById(Gitpodify.NAV_BTN_ID);
7980
if (oldBtn) {
8081
if (!checkIsBtnUpToDate(oldBtn, currentUrl)) {
@@ -88,16 +89,16 @@ abstract class ButtonInjectorBase implements ButtonInjector {
8889
const btn = this.renderButton(currentUrl, openAsPopup);
8990

9091
const btnGroup = actionbar.children;
91-
if (btnGroup && btnGroup.length > 0){
92+
if (btnGroup && btnGroup.length > 0) {
9293
actionbar.insertBefore(btn, btnGroup[0]);
93-
}
94+
}
9495
}
9596

9697
protected renderButton(url: string, openAsPopup: boolean, float: boolean = true): HTMLElement {
9798
let classes = Gitpodify.NAV_BTN_CLASS;
9899
if (float) {
99100
classes = `${classes} ${this.btnClasses} aui-button`;
100-
}
101+
}
101102

102103
const container = document.createElement('div');
103104
container.id = Gitpodify.CSS_REF_BTN_CONTAINER;

0 commit comments

Comments
 (0)