Skip to content

Commit 9c48ac6

Browse files
committed
Default to auto-starting for Ona endpoints
1 parent aa5fbfa commit 9c48ac6

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

src/button/button.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { useHotkeys } from "react-hotkeys-hook";
55
import { DEFAULT_ONA_ENDPOINT, EVENT_CURRENT_URL_CHANGED } from "~constants";
66
import { OnaLettermark } from "~icons/OnaLettermark";
77
import { STORAGE_KEY_ADDRESS, STORAGE_KEY_ALWAYS_OPTIONS, STORAGE_KEY_NEW_TAB } from "~storage";
8-
import { isOnaEndpoint } from "~utils/parse-endpoint";
98
import type { SupportedApplication } from "./button-contributions";
109
import { CaretForProvider } from "./CaretForProvider";
1110

@@ -35,15 +34,12 @@ export const OnaButton = ({ application, additionalClassNames, urlTransformer }:
3534
};
3635
}, []);
3736

38-
const isOna = useMemo(() => address && isOnaEndpoint(address), [address]);
3937
const actions = useMemo(() => {
4038
const parsedHref = !urlTransformer ? currentHref : urlTransformer(currentHref);
4139

42-
const autoStartParam = isOna ? "" : "?autostart=true";
43-
4440
return [
4541
{
46-
href: `${address}/${autoStartParam}#${parsedHref}`,
42+
href: `${address}/?autostart=${disableAutostart ? "false" : "true"}#${parsedHref}`,
4743
label: "Open",
4844
},
4945
{
@@ -56,7 +52,6 @@ export const OnaButton = ({ application, additionalClassNames, urlTransformer }:
5652
const firstActionRef = useRef<HTMLAnchorElement | null>(null);
5753

5854
const target = openInNewTab ? "_blank" : "_self";
59-
const effectiveDisableAutostart = isOna ? true : disableAutostart;
6055

6156
const toggleDropdown = () => {
6257
setShowDropdown(!showDropdown);
@@ -91,7 +86,7 @@ export const OnaButton = ({ application, additionalClassNames, urlTransformer }:
9186
>
9287
<div className={classNames("button")}>
9388
<a
94-
className={classNames("button-part", effectiveDisableAutostart ? "action-no-options" : "action")}
89+
className={classNames("button-part", disableAutostart ? "action-no-options" : "action")}
9590
href={actions[0].href}
9691
target={target}
9792
rel="noreferrer"
@@ -102,7 +97,7 @@ export const OnaButton = ({ application, additionalClassNames, urlTransformer }:
10297
{actions[0].label}
10398
</span>
10499
</a>
105-
{!effectiveDisableAutostart && (
100+
{!disableAutostart && (
106101
<button
107102
className={classNames("button-part", "action-chevron")}
108103
onClick={(e) => {

src/popup.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
STORAGE_KEY_ALWAYS_OPTIONS,
1717
STORAGE_KEY_NEW_TAB,
1818
} from "~storage";
19-
import { hostToOrigin, isOnaEndpoint, parseEndpoint } from "~utils/parse-endpoint";
19+
import { hostToOrigin, parseEndpoint } from "~utils/parse-endpoint";
2020
import { canAccessAllSites } from "~utils/permissions";
2121
import "./popup.css";
2222

@@ -35,7 +35,6 @@ function PopupContent() {
3535
const [error, setError] = useState<string>();
3636

3737
const [storedAddress] = useStorage<string>(STORAGE_KEY_ADDRESS, DEFAULT_ONA_ENDPOINT);
38-
const isStoredAddressOna = isOnaEndpoint(storedAddress);
3938
const [address, setAddress] = useState<string>(storedAddress);
4039
const [justSaved, setJustSaved] = useTemporaryState(false, 2000);
4140

@@ -143,9 +142,8 @@ function PopupContent() {
143142
<CheckboxInputField
144143
label="Always start with options"
145144
hint="Changes the primary button to always open with options"
146-
checked={isStoredAddressOna ? true : disableAutostart}
145+
checked={disableAutostart}
147146
onChange={setDisableAutostart}
148-
disabled={isStoredAddressOna}
149147
/>
150148
<CheckboxInputField
151149
label="Automatic instance hopping"

src/utils/parse-endpoint.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,3 @@ export const hostToOrigin = (host: string): string | undefined => {
2828

2929
return `${origin}/*`;
3030
};
31-
32-
export const isOnaEndpoint = (url: string): boolean => {
33-
const parsedUrl = new URL(url);
34-
35-
return parsedUrl.hostname === "app.ona.com" || parsedUrl.hostname === "app.gitpod.io";
36-
};

0 commit comments

Comments
 (0)