diff --git a/src/config.ts b/src/config.ts index 7d22004..f4e49d7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -5,12 +5,14 @@ export interface Config { gitpodURL: string; openAsPopup: boolean; rewritePeriodKeybind: boolean; + useLatest: boolean; } export const DEFAULT_CONFIG: Config = { gitpodURL: "https://gitpod.io", openAsPopup: false, - rewritePeriodKeybind: false + rewritePeriodKeybind: false, + useLatest: false, }; export interface ConfigListener { diff --git a/src/injectors/bitbucket-injector.ts b/src/injectors/bitbucket-injector.ts index 542d6bd..707075b 100644 --- a/src/injectors/bitbucket-injector.ts +++ b/src/injectors/bitbucket-injector.ts @@ -60,7 +60,7 @@ abstract class ButtonInjectorBase implements ButtonInjector { abstract isApplicableToCurrentPage(): boolean; - inject(urlInfo: UrlInfo, openAsPopup: boolean) { + inject(urlInfo: UrlInfo, openAsPopup: boolean, useLatest: boolean) { let actionbar = select(this.parent); if (actionbar && this.up) { for (let i = 0; i < this.up; i++) { diff --git a/src/injectors/github-injector.ts b/src/injectors/github-injector.ts index c7fb872..b4a1499 100644 --- a/src/injectors/github-injector.ts +++ b/src/injectors/github-injector.ts @@ -81,7 +81,7 @@ abstract class ButtonInjectorBase implements ButtonInjector { // do nothing } - inject(urlInfo: UrlInfo, openAsPopup: boolean) { + inject(urlInfo: UrlInfo, openAsPopup: boolean, useLatest: boolean) { const actionbar = select(this.parentSelector); if (!actionbar) { return; diff --git a/src/injectors/gitlab-injector.ts b/src/injectors/gitlab-injector.ts index 431d8ba..ab9bfa5 100644 --- a/src/injectors/gitlab-injector.ts +++ b/src/injectors/gitlab-injector.ts @@ -57,7 +57,7 @@ class RepositoryInjector implements ButtonInjector { return result; } - inject(urlInfo: UrlInfo, openAsPopup: boolean) { + inject(urlInfo: UrlInfo, openAsPopup: boolean, useLatest: boolean) { const parent = select(RepositoryInjector.PARENT_SELECTOR); if (!parent || !parent.firstElementChild) { return; diff --git a/src/injectors/injector.ts b/src/injectors/injector.ts index 9db8d24..581ae10 100644 --- a/src/injectors/injector.ts +++ b/src/injectors/injector.ts @@ -37,7 +37,7 @@ export interface ButtonInjector { * Injects the actual button * @param currentUrl The currently configured Gitpod URL */ - inject(urlInfo: UrlInfo, openAsPopup: boolean): void; + inject(urlInfo: UrlInfo, openAsPopup: boolean, useLatest: boolean): void; } export abstract class InjectorBase implements Injector { @@ -55,7 +55,7 @@ export abstract class InjectorBase implements Injector { const urlInfo = renderGitpodUrl(this.config.gitpodURL); for (const injector of this.buttonInjectors) { if (injector.isApplicableToCurrentPage()) { - injector.inject(urlInfo, this.config.openAsPopup); + injector.inject(urlInfo, this.config.openAsPopup, this.config.useLatest); if (singleInjector) { break; } diff --git a/src/options/options.html b/src/options/options.html index ab52ed3..62da782 100644 --- a/src/options/options.html +++ b/src/options/options.html @@ -2,7 +2,7 @@ - +
@@ -10,6 +10,13 @@
+
+ + +
diff --git a/src/options/options.ts b/src/options/options.ts index eed9820..f1be70e 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -3,6 +3,7 @@ import { ConfigProvider } from "../config"; const gitpodUrlInput = document.getElementById("gitpod-url-input")! as HTMLInputElement; const gitpodRewriteKeybind = document.getElementById("gitpod-replace-keybind")! as HTMLInputElement; const gitpodPopupInput = document.getElementById("gitpod-open-as-popup")! as HTMLInputElement; +const useLatestCheckbox = document.getElementById("use-latest")! as HTMLInputElement; const messageElement = document.getElementById("message")! as HTMLDivElement; @@ -12,6 +13,7 @@ const init = async () => { // Initialize UI const initialConfig = configProvider.getConfig(); gitpodUrlInput.value = initialConfig.gitpodURL; + useLatestCheckbox.checked = initialConfig.useLatest; gitpodPopupInput.checked = initialConfig.openAsPopup; gitpodRewriteKeybind.checked = initialConfig.rewritePeriodKeybind; @@ -22,6 +24,7 @@ const init = async () => { // Update config (propagated internally) configProvider.setConfig({ gitpodURL: gitpodUrlInput.value || undefined, + useLatest: useLatestCheckbox.checked, openAsPopup: gitpodPopupInput.checked, rewritePeriodKeybind: gitpodRewriteKeybind.checked }); @@ -38,7 +41,7 @@ const init = async () => { } save() }); - [gitpodPopupInput, gitpodRewriteKeybind].forEach((el) => el.addEventListener('change', save)) + [useLatestCheckbox, gitpodPopupInput, gitpodRewriteKeybind].forEach((el) => el.addEventListener('change', save)) }; init().catch(err => console.error(err));