Skip to content

Commit 9dc077e

Browse files
Option for options... always :) (#102)
1 parent c930af3 commit 9dc077e

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

src/button/button.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@
9292
border-top-left-radius: var(--border-radius);
9393
}
9494

95+
.action-no-options {
96+
border-radius: var(--border-radius);
97+
}
98+
9599
.action-logo {
96100
padding-right: 6px;
97101
fill: currentColor;

src/button/button.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect, useState, useRef } from "react";
22
import Logo from "react:./logo-mark.svg"
33
import type { SupportedApplication } from "./button-contributions";
44
import classNames from "classnames";
5-
import { STORAGE_KEY_ADDRESS, STORAGE_KEY_NEW_TAB } from "~storage";
5+
import { STORAGE_KEY_ADDRESS, STORAGE_KEY_ALWAYS_OPTIONS, STORAGE_KEY_NEW_TAB } from "~storage";
66
import { DEFAULT_GITPOD_ENDPOINT } from "~constants";
77
import { useStorage } from "@plasmohq/storage/hook";
88
import React from "react";
@@ -15,18 +15,19 @@ export interface GitpodButtonProps {
1515
export const GitpodButton = ({ application, additionalClassNames }: GitpodButtonProps) => {
1616
const [address] = useStorage<string>(STORAGE_KEY_ADDRESS, DEFAULT_GITPOD_ENDPOINT);
1717
const [openInNewTab] = useStorage<boolean>(STORAGE_KEY_NEW_TAB, true);
18-
18+
const [disableAutostart] = useStorage<boolean>(STORAGE_KEY_ALWAYS_OPTIONS, false);
1919
const [showDropdown, setShowDropdown] = useState(false);
20+
2021
const actions = [
2122
{
22-
href: address + "/?autostart=true#" + window.location.toString(),
23+
href: `${address}/?autostart=${!disableAutostart}#${window.location.toString()}`,
2324
label: "Open",
2425
},
2526
{
26-
href: address + "/?autostart=false#" + window.location.toString(),
27+
href: `${address}/?autostart=false#${window.location.toString()}`,
2728
label: "Open with options...",
2829
},
29-
]
30+
];
3031
const dropdownRef = useRef<HTMLDivElement | null>(null);
3132
const firstActionRef = useRef<HTMLAnchorElement | null>(null);
3233

@@ -57,7 +58,7 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
5758
<div id="gitpod-btn-nav" title="Gitpod" className={classNames("gitpod-button", application, ...(additionalClassNames || []))}>
5859
<div className={classNames("button")}>
5960
<a
60-
className={classNames("button-part", "action")}
61+
className={classNames("button-part", disableAutostart ? "action-no-options" : "action")}
6162
href={actions[0].href}
6263
target={openInNewTab ? "_blank" : "_self"}
6364
rel="noreferrer"
@@ -67,14 +68,16 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
6768
{actions[0].label}
6869
</span>
6970
</a>
70-
<button className={classNames("button-part", "action-chevron")} onClick={(e) => {
71-
e.stopPropagation();
72-
toggleDropdown();
73-
}}>
74-
<svg width="18" viewBox="0 0 24 24" className={classNames("chevron-icon")}>
75-
<path d="M7 10L12 15L17 10H7Z"></path>
76-
</svg>
77-
</button>
71+
{!disableAutostart && (
72+
<button className={classNames("button-part", "action-chevron")} onClick={(e) => {
73+
e.stopPropagation();
74+
toggleDropdown();
75+
}}>
76+
<svg width="18" viewBox="0 0 24 24" className={classNames("chevron-icon")}>
77+
<path d="M7 10L12 15L17 10H7Z"></path>
78+
</svg>
79+
</button>
80+
)}
7881
</div>
7982

8083
{showDropdown && (

src/popup.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useStorage } from "@plasmohq/storage/hook";
22
import { useCallback, useEffect, useState } from "react"
3-
import { STORAGE_AUTOMATICALLY_DETECT_GITPOD, STORAGE_KEY_ADDRESS, STORAGE_KEY_NEW_TAB } from "~storage";
3+
import { STORAGE_AUTOMATICALLY_DETECT_GITPOD, STORAGE_KEY_ADDRESS, STORAGE_KEY_ALWAYS_OPTIONS, STORAGE_KEY_NEW_TAB } from "~storage";
44
import { parseEndpoint } from "~utils/parse-endpoint";
55
import React from "react";
66

@@ -33,6 +33,7 @@ function IndexPopup() {
3333

3434
const [openInNewTab, setOpenInNewTab] = useStorage<boolean>(STORAGE_KEY_NEW_TAB, true);
3535
const [automaticallyDetect, setAutomaticallyDetect] = useStorage<boolean>(STORAGE_AUTOMATICALLY_DETECT_GITPOD, true);
36+
const [disableAutostart, setDisableAutostart] = useStorage<boolean>(STORAGE_KEY_ALWAYS_OPTIONS, false);
3637

3738
return (
3839
<div
@@ -70,6 +71,12 @@ function IndexPopup() {
7071
checked={automaticallyDetect}
7172
onChange={setAutomaticallyDetect}
7273
/>
74+
<CheckboxInputField
75+
label="Always start with options"
76+
hint="Changes the primary button to always open with options"
77+
checked={disableAutostart}
78+
onChange={setDisableAutostart}
79+
/>
7380
</form>
7481

7582
{/* show error if set */}

src/storage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

22
export const STORAGE_KEY_ADDRESS = "gitpod-installation-address";
33
export const STORAGE_KEY_NEW_TAB = "gitpod-installation-new-tab";
4-
export const STORAGE_AUTOMATICALLY_DETECT_GITPOD = "gitpod-installation-automatically-detect-gitpod";
4+
export const STORAGE_AUTOMATICALLY_DETECT_GITPOD = "gitpod-installation-automatically-detect-gitpod";
5+
export const STORAGE_KEY_ALWAYS_OPTIONS = "gitpod-installation-always-options";

0 commit comments

Comments
 (0)