@@ -2,7 +2,7 @@ import { useEffect, useState, useRef } from "react";
2
2
import Logo from "react:./logo-mark.svg"
3
3
import type { SupportedApplication } from "./button-contributions" ;
4
4
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" ;
6
6
import { DEFAULT_GITPOD_ENDPOINT } from "~constants" ;
7
7
import { useStorage } from "@plasmohq/storage/hook" ;
8
8
import React from "react" ;
@@ -15,18 +15,19 @@ export interface GitpodButtonProps {
15
15
export const GitpodButton = ( { application, additionalClassNames } : GitpodButtonProps ) => {
16
16
const [ address ] = useStorage < string > ( STORAGE_KEY_ADDRESS , DEFAULT_GITPOD_ENDPOINT ) ;
17
17
const [ openInNewTab ] = useStorage < boolean > ( STORAGE_KEY_NEW_TAB , true ) ;
18
-
18
+ const [ disableAutostart ] = useStorage < boolean > ( STORAGE_KEY_ALWAYS_OPTIONS , false ) ;
19
19
const [ showDropdown , setShowDropdown ] = useState ( false ) ;
20
+
20
21
const actions = [
21
22
{
22
- href : address + " /?autostart=true#" + window . location . toString ( ) ,
23
+ href : ` ${ address } /?autostart=${ ! disableAutostart } # ${ window . location . toString ( ) } ` ,
23
24
label : "Open" ,
24
25
} ,
25
26
{
26
- href : address + " /?autostart=false#" + window . location . toString ( ) ,
27
+ href : ` ${ address } /?autostart=false#${ window . location . toString ( ) } ` ,
27
28
label : "Open with options..." ,
28
29
} ,
29
- ]
30
+ ] ;
30
31
const dropdownRef = useRef < HTMLDivElement | null > ( null ) ;
31
32
const firstActionRef = useRef < HTMLAnchorElement | null > ( null ) ;
32
33
@@ -57,7 +58,7 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
57
58
< div id = "gitpod-btn-nav" title = "Gitpod" className = { classNames ( "gitpod-button" , application , ...( additionalClassNames || [ ] ) ) } >
58
59
< div className = { classNames ( "button" ) } >
59
60
< a
60
- className = { classNames ( "button-part" , "action" ) }
61
+ className = { classNames ( "button-part" , disableAutostart ? "action-no-options" : "action" ) }
61
62
href = { actions [ 0 ] . href }
62
63
target = { openInNewTab ? "_blank" : "_self" }
63
64
rel = "noreferrer"
@@ -67,14 +68,16 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
67
68
{ actions [ 0 ] . label }
68
69
</ span >
69
70
</ 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
+ ) }
78
81
</ div >
79
82
80
83
{ showDropdown && (
0 commit comments