Skip to content

Commit 848a53f

Browse files
committed
more alignments
1 parent 29805e7 commit 848a53f

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

src/button/button.tsx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { Storage } from "@plasmohq/storage";
21
import { useStorage } from "@plasmohq/storage/hook";
32
import classNames from "classnames";
43
import { useEffect, useMemo, useRef, useState } from "react";
54
import { useHotkeys } from "react-hotkeys-hook";
65
import Logo from "react:./logo-mark.svg";
7-
import { DEFAULT_GITPOD_ENDPOINT, EVENT_CURRENT_URL_CHANGED } from "~constants";
6+
import { EVENT_CURRENT_URL_CHANGED } from "~constants";
87
import { FeatureFlags, useFlag } from "~hooks/use-configcat";
98
import { OnaLettermark } from "~icons/OnaLettermark";
109
import { STORAGE_KEY_ADDRESS, STORAGE_KEY_ALWAYS_OPTIONS, STORAGE_KEY_NEW_TAB } from "~storage";
10+
import { isOnaEndpoint } from "~utils/parse-endpoint";
1111
import type { SupportedApplication } from "./button-contributions";
1212
import { CaretForProvider } from "./CaretForProvider";
1313

@@ -38,18 +38,6 @@ export const GitpodButton = ({ application, additionalClassNames, urlTransformer
3838
};
3939
}, []);
4040

41-
// if the user has no address configured, set it to the default endpoint
42-
useEffect(() => {
43-
(async () => {
44-
// we don't use the useStorage hook because it does not offer a way see if the value is set (it could just be loading), meaning we could end up setting the default endpoint even if it's already set
45-
const storage = new Storage();
46-
const persistedAddress = await storage.get(STORAGE_KEY_ADDRESS);
47-
if (!persistedAddress) {
48-
await storage.set(STORAGE_KEY_ADDRESS, DEFAULT_GITPOD_ENDPOINT);
49-
}
50-
})();
51-
}, []);
52-
5341
const actions = useMemo(() => {
5442
const parsedHref = !urlTransformer ? currentHref : urlTransformer(currentHref);
5543
return [
@@ -66,6 +54,10 @@ export const GitpodButton = ({ application, additionalClassNames, urlTransformer
6654
const dropdownRef = useRef<HTMLDivElement | null>(null);
6755
const firstActionRef = useRef<HTMLAnchorElement | null>(null);
6856

57+
const target = openInNewTab ? "_blank" : "_self";
58+
const isOna = useMemo(() => address && isOnaEndpoint(address), [address]);
59+
const effectiveDisableAutostart = isOna ? true : disableAutostart;
60+
6961
const toggleDropdown = () => {
7062
setShowDropdown(!showDropdown);
7163
};
@@ -89,8 +81,6 @@ export const GitpodButton = ({ application, additionalClassNames, urlTransformer
8981
}
9082
}, [showDropdown]);
9183

92-
const target = openInNewTab ? "_blank" : "_self";
93-
9484
useHotkeys("alt+g", () => linkRef.current?.click(), [linkRef.current]);
9585

9686
return (
@@ -101,7 +91,7 @@ export const GitpodButton = ({ application, additionalClassNames, urlTransformer
10191
>
10292
<div className={classNames("button")}>
10393
<a
104-
className={classNames("button-part", disableAutostart ? "action-no-options" : "action")}
94+
className={classNames("button-part", effectiveDisableAutostart ? "action-no-options" : "action")}
10595
href={actions[0].href}
10696
target={target}
10797
rel="noreferrer"
@@ -115,7 +105,7 @@ export const GitpodButton = ({ application, additionalClassNames, urlTransformer
115105
{actions[0].label}
116106
</span>
117107
</a>
118-
{!disableAutostart && (
108+
{!effectiveDisableAutostart && (
119109
<button
120110
className={classNames("button-part", "action-chevron")}
121111
onClick={(e) => {

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const DEFAULT_GITPOD_ENDPOINT = "https://gitpod.io";
1+
export const DEFAULT_GITPOD_ENDPOINT = "https://app.ona.com";
22
export const ALL_ORIGINS_WILDCARD = "*://*/*";
33
export const EVENT_CURRENT_URL_CHANGED = "current-url-changed";

src/popup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function PopupContent() {
120120
</div>
121121
</InputField>
122122
<CheckboxInputField
123-
label="Open Workspaces in a new tab"
123+
label={`Open ${isOnaEnabled ? "Environments" : "Workspaces"} in a new tab`}
124124
checked={openInNewTab}
125125
onChange={setOpenInNewTab}
126126
/>

src/utils/parse-endpoint.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,10 @@ 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+
36+
return parsedUrl.hostname === "app.ona.com" || parsedUrl.hostname === "app.gitpod.io";
37+
};

0 commit comments

Comments
 (0)