1- import { Storage } from "@plasmohq/storage" ;
21import { useStorage } from "@plasmohq/storage/hook" ;
32import classNames from "classnames" ;
43import { useEffect , useMemo , useRef , useState } from "react" ;
54import { useHotkeys } from "react-hotkeys-hook" ;
65import 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" ;
87import { FeatureFlags , useFlag } from "~hooks/use-configcat" ;
98import { OnaLettermark } from "~icons/OnaLettermark" ;
109import { STORAGE_KEY_ADDRESS , STORAGE_KEY_ALWAYS_OPTIONS , STORAGE_KEY_NEW_TAB } from "~storage" ;
10+ import { isOnaEndpoint } from "~utils/parse-endpoint" ;
1111import type { SupportedApplication } from "./button-contributions" ;
1212import { 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 ) => {
0 commit comments