Skip to content

Commit afcf34a

Browse files
committed
Add useLatest configuration
1 parent 0827ab8 commit afcf34a

File tree

7 files changed

+20
-8
lines changed

7 files changed

+20
-8
lines changed

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/injectors/bitbucket-injector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ abstract class ButtonInjectorBase implements ButtonInjector {
6060

6161
abstract isApplicableToCurrentPage(): boolean;
6262

63-
inject(urlInfo: UrlInfo, openAsPopup: boolean) {
63+
inject(urlInfo: UrlInfo, openAsPopup: boolean, useLatest: boolean) {
6464
let actionbar = select(this.parent);
6565
if (actionbar && this.up) {
6666
for (let i = 0; i < this.up; i++) {

src/injectors/github-injector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ abstract class ButtonInjectorBase implements ButtonInjector {
8181
// do nothing
8282
}
8383

84-
inject(urlInfo: UrlInfo, openAsPopup: boolean) {
84+
inject(urlInfo: UrlInfo, openAsPopup: boolean, useLatest: boolean) {
8585
const actionbar = select(this.parentSelector);
8686
if (!actionbar) {
8787
return;

src/injectors/gitlab-injector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class RepositoryInjector implements ButtonInjector {
5757
return result;
5858
}
5959

60-
inject(urlInfo: UrlInfo, openAsPopup: boolean) {
60+
inject(urlInfo: UrlInfo, openAsPopup: boolean, useLatest: boolean) {
6161
const parent = select(RepositoryInjector.PARENT_SELECTOR);
6262
if (!parent || !parent.firstElementChild) {
6363
return;

src/injectors/injector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface ButtonInjector {
3737
* Injects the actual button
3838
* @param currentUrl The currently configured Gitpod URL
3939
*/
40-
inject(urlInfo: UrlInfo, openAsPopup: boolean): void;
40+
inject(urlInfo: UrlInfo, openAsPopup: boolean, useLatest: boolean): void;
4141
}
4242

4343
export abstract class InjectorBase implements Injector {
@@ -55,7 +55,7 @@ export abstract class InjectorBase implements Injector {
5555
const urlInfo = renderGitpodUrl(this.config.gitpodURL);
5656
for (const injector of this.buttonInjectors) {
5757
if (injector.isApplicableToCurrentPage()) {
58-
injector.inject(urlInfo, this.config.openAsPopup);
58+
injector.inject(urlInfo, this.config.openAsPopup, this.config.useLatest);
5959
if (singleInjector) {
6060
break;
6161
}

src/options/options.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<link rel="stylesheet" href="options.css"/>
5+
<link rel="stylesheet" href="./options.css"/>
66
</head>
77
<body>
88
<div id="content">
99
<div class="row">
1010
<label>Gitpod installation URL:</label>
1111
<input id="gitpod-url-input" type="url" value=""/>
1212
</div>
13+
<div class="row">
14+
<label for="use-latest">
15+
Latest Release (Unstable)
16+
<div class="label-desc">Use the latest version for each editor. <a class="gp-link" target="_blank" href="https://code.visualstudio.com/blogs/2016/02/01/introducing_insiders_build">Insiders</a> for VS Code, <a class="gp-link" target="_blank" href="https://www.jetbrains.com/resources/eap/">EAP</a> for JetBrains IDEs.</div>
17+
</label>
18+
<input id="use-latest" type="checkbox"/>
19+
</div>
1320
<div class="row">
1421
<label>Open as popup:</label>
1522
<input id="gitpod-open-as-popup" type="checkbox"/>

src/options/options.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ConfigProvider } from "../config";
33
const gitpodUrlInput = document.getElementById("gitpod-url-input")! as HTMLInputElement;
44
const gitpodRewriteKeybind = document.getElementById("gitpod-replace-keybind")! as HTMLInputElement;
55
const gitpodPopupInput = document.getElementById("gitpod-open-as-popup")! as HTMLInputElement;
6+
const useLatestCheckbox = document.getElementById("use-latest")! as HTMLInputElement;
67
const messageElement = document.getElementById("message")! as HTMLDivElement;
78

89

@@ -12,6 +13,7 @@ const init = async () => {
1213
// Initialize UI
1314
const initialConfig = configProvider.getConfig();
1415
gitpodUrlInput.value = initialConfig.gitpodURL;
16+
useLatestCheckbox.checked = initialConfig.useLatest;
1517
gitpodPopupInput.checked = initialConfig.openAsPopup;
1618
gitpodRewriteKeybind.checked = initialConfig.rewritePeriodKeybind;
1719

@@ -22,6 +24,7 @@ const init = async () => {
2224
// Update config (propagated internally)
2325
configProvider.setConfig({
2426
gitpodURL: gitpodUrlInput.value || undefined,
27+
useLatest: useLatestCheckbox.checked,
2528
openAsPopup: gitpodPopupInput.checked,
2629
rewritePeriodKeybind: gitpodRewriteKeybind.checked
2730
});
@@ -38,7 +41,7 @@ const init = async () => {
3841
}
3942
save()
4043
});
41-
[gitpodPopupInput, gitpodRewriteKeybind].forEach((el) => el.addEventListener('change', save))
44+
[useLatestCheckbox, gitpodPopupInput, gitpodRewriteKeybind].forEach((el) => el.addEventListener('change', save))
4245
};
4346

4447
init().catch(err => console.error(err));

0 commit comments

Comments
 (0)