@@ -10,34 +10,28 @@ import InfoBox from "../components/InfoBox";
10
10
import { PageWithSubMenu } from "../components/PageWithSubMenu" ;
11
11
import PillLabel from "../components/PillLabel" ;
12
12
import SelectableCard from "../components/SelectableCard" ;
13
+ import SelectableCardSolid from "../components/SelectableCardSolid" ;
13
14
import Tooltip from "../components/Tooltip" ;
14
15
import { getGitpodService } from "../service/service" ;
15
16
import { ThemeContext } from "../theme-context" ;
16
17
import { UserContext } from "../user-context" ;
17
18
import settingsMenu from "./settings-menu" ;
18
- import IDENone from "../icons/IDENone.svg" ;
19
- import IDENoneDark from "../icons/IDENoneDark.svg" ;
20
19
import CheckBox from "../components/CheckBox" ;
21
20
import { trackEvent } from "../Analytics" ;
22
21
23
22
type Theme = "light" | "dark" | "system" ;
24
23
25
- const DesktopNoneId = "none" ;
26
- const DesktopNone : IDEOption = {
27
- image : "" ,
28
- logo : IDENone ,
29
- orderKey : "-1" ,
30
- title : "None" ,
31
- type : "desktop" ,
32
- } ;
24
+ const DefaultBrowserIDE = "code" ;
33
25
34
26
export default function Preferences ( ) {
35
27
const { user } = useContext ( UserContext ) ;
36
- const { setIsDark, isDark } = useContext ( ThemeContext ) ;
28
+ const { setIsDark } = useContext ( ThemeContext ) ;
37
29
38
- const updateUserIDEInfo = async ( defaultDesktopIde : string , defaultIde : string , useLatestVersion : boolean ) => {
39
- const useDesktopIde = defaultDesktopIde !== DesktopNoneId ;
40
- const desktopIde = useDesktopIde ? defaultDesktopIde : undefined ;
30
+ const updateUserIDEInfo = async ( selectedIde : string , useLatestVersion : boolean ) => {
31
+ // Always start vscode browser ide
32
+ const defaultIde = DefaultBrowserIDE ;
33
+ const useDesktopIde = selectedIde !== DefaultBrowserIDE ;
34
+ const desktopIde = useDesktopIde ? selectedIde : undefined ;
41
35
const additionalData = user ?. additionalData ?? { } ;
42
36
const settings = additionalData . ideSettings ?? { } ;
43
37
settings . useDesktopIde = useDesktopIde ;
@@ -61,38 +55,32 @@ export default function Preferences() {
61
55
} ;
62
56
63
57
const [ defaultIde , setDefaultIde ] = useState < string > ( user ?. additionalData ?. ideSettings ?. defaultIde || "" ) ;
64
- const actuallySetDefaultIde = async ( value : string ) => {
65
- await updateUserIDEInfo ( defaultDesktopIde , value , useLatestVersion ) ;
66
- setDefaultIde ( value ) ;
67
- } ;
68
58
69
59
const [ defaultDesktopIde , setDefaultDesktopIde ] = useState < string > (
70
- ( user ?. additionalData ?. ideSettings ?. useDesktopIde && user ?. additionalData ?. ideSettings ?. defaultDesktopIde ) ||
71
- DesktopNoneId ,
60
+ user ?. additionalData ?. ideSettings ?. defaultDesktopIde || "" ,
72
61
) ;
73
62
const actuallySetDefaultDesktopIde = async ( value : string ) => {
74
- await updateUserIDEInfo ( value , defaultIde , useLatestVersion ) ;
63
+ await updateUserIDEInfo ( value , useLatestVersion ) ;
75
64
setDefaultDesktopIde ( value ) ;
76
65
} ;
77
66
78
67
const [ useLatestVersion , setUseLatestVersion ] = useState < boolean > (
79
68
user ?. additionalData ?. ideSettings ?. useLatestVersion ?? false ,
80
69
) ;
81
70
const actuallySetUseLatestVersion = async ( value : boolean ) => {
82
- await updateUserIDEInfo ( defaultDesktopIde , defaultIde , value ) ;
71
+ await updateUserIDEInfo ( defaultDesktopIde , value ) ;
83
72
setUseLatestVersion ( value ) ;
84
73
} ;
85
74
86
75
const [ ideOptions , setIdeOptions ] = useState < IDEOptions | undefined > ( undefined ) ;
87
76
useEffect ( ( ) => {
88
77
( async ( ) => {
89
78
const ideopts = await getGitpodService ( ) . server . getIDEOptions ( ) ;
90
- ideopts . options [ DesktopNoneId ] = DesktopNone ;
91
79
setIdeOptions ( ideopts ) ;
92
- if ( ! defaultIde ) {
80
+ if ( ! defaultIde || ideopts . options [ defaultIde ] == null ) {
93
81
setDefaultIde ( ideopts . defaultIde ) ;
94
82
}
95
- if ( ! defaultDesktopIde ) {
83
+ if ( ! defaultDesktopIde || ideopts . options [ defaultDesktopIde ] == null ) {
96
84
setDefaultDesktopIde ( ideopts . defaultDesktopIde ) ;
97
85
}
98
86
} ) ( ) ;
@@ -112,8 +100,7 @@ export default function Preferences() {
112
100
setTheme ( theme ) ;
113
101
} ;
114
102
115
- const browserIdeOptions = ideOptions && orderedIdeOptions ( ideOptions , "browser" ) ;
116
- const desktopIdeOptions = ideOptions && orderedIdeOptions ( ideOptions , "desktop" ) ;
103
+ const allIdeOptions = ideOptions && orderedIdeOptions ( ideOptions ) ;
117
104
118
105
const [ dotfileRepo , setDotfileRepo ] = useState < string > ( user ?. additionalData ?. dotfileRepo || "" ) ;
119
106
const actuallySetDotfileRepo = async ( value : string ) => {
@@ -132,48 +119,17 @@ export default function Preferences() {
132
119
< PageWithSubMenu subMenu = { settingsMenu } title = "Preferences" subtitle = "Configure user preferences." >
133
120
{ ideOptions && (
134
121
< >
135
- { browserIdeOptions && (
122
+ { /* <div>{JSON.stringify(user?.additionalData?.ideSettings, null, 4)}</div> */ }
123
+ { allIdeOptions && (
136
124
< >
137
- < h3 > Browser Editor</ h3 >
125
+ < h3 > Editor</ h3 >
138
126
< p className = "text-base text-gray-500 dark:text-gray-400" >
139
- Choose the default editor for opening workspaces in the browser.
140
- </ p >
141
- < div className = "my-4 gap-4 flex flex-wrap" >
142
- { browserIdeOptions . map ( ( [ id , option ] ) => {
143
- const selected = defaultIde === id ;
144
- const onSelect = ( ) => actuallySetDefaultIde ( id ) ;
145
- return renderIdeOption ( option , selected , onSelect ) ;
146
- } ) }
147
- </ div >
148
- { ideOptions . options [ defaultIde ] ?. notes && (
149
- < InfoBox className = "my-5 max-w-2xl" >
150
- < ul >
151
- { ideOptions . options [ defaultIde ] . notes ?. map ( ( x , idx ) => (
152
- < li className = { idx > 0 ? "mt-2" : "" } > { x } </ li >
153
- ) ) }
154
- </ ul >
155
- </ InfoBox >
156
- ) }
157
- </ >
158
- ) }
159
- { desktopIdeOptions && (
160
- < >
161
- < h3 className = "mt-12 flex" >
162
- Desktop Editor
163
- < PillLabel type = "warn" className = "font-semibold py-0.5 px-2 self-center" >
164
- Beta
165
- </ PillLabel >
166
- </ h3 >
167
- < p className = "text-base text-gray-500 dark:text-gray-400" >
168
- Optionally, choose the default desktop editor for opening workspaces.
127
+ Choose the editor for opening workspaces.
169
128
</ p >
170
129
< div className = "my-4 gap-4 flex flex-wrap max-w-2xl" >
171
- { desktopIdeOptions . map ( ( [ id , option ] ) => {
130
+ { allIdeOptions . map ( ( [ id , option ] ) => {
172
131
const selected = defaultDesktopIde === id ;
173
132
const onSelect = ( ) => actuallySetDefaultDesktopIde ( id ) ;
174
- if ( id === DesktopNoneId ) {
175
- option . logo = isDark ? IDENoneDark : IDENone ;
176
- }
177
133
return renderIdeOption ( option , selected , onSelect ) ;
178
134
} ) }
179
135
</ div >
@@ -210,7 +166,7 @@ export default function Preferences() {
210
166
) }
211
167
< CheckBox
212
168
title = "Latest Release"
213
- desc = "Include the latest Early Access Program (EAP) version for each JetBrains IDE ."
169
+ desc = "Use the latest version for each editor. Insiders for VS Code, EAP for JetBrains IDEs ."
214
170
checked = { useLatestVersion }
215
171
onChange = { ( e ) => actuallySetUseLatestVersion ( e . target . checked ) }
216
172
/>
@@ -301,35 +257,33 @@ export default function Preferences() {
301
257
) ;
302
258
}
303
259
304
- function orderedIdeOptions ( ideOptions : IDEOptions , type : "browser" | "desktop" ) {
260
+ function orderedIdeOptions ( ideOptions : IDEOptions ) {
305
261
// TODO: Maybe convert orderKey to number before sort?
306
- return Object . entries ( ideOptions . options )
307
- . filter ( ( [ _ , x ] ) => x . type === type && ! x . hidden )
308
- . sort ( ( a , b ) => {
309
- const keyA = a [ 1 ] . orderKey || a [ 0 ] ;
310
- const keyB = b [ 1 ] . orderKey || b [ 0 ] ;
311
- return keyA . localeCompare ( keyB ) ;
312
- } ) ;
262
+ return Object . entries ( ideOptions . options ) . sort ( ( a , b ) => {
263
+ const keyA = a [ 1 ] . orderKey || a [ 0 ] ;
264
+ const keyB = b [ 1 ] . orderKey || b [ 0 ] ;
265
+ return keyA . localeCompare ( keyB ) ;
266
+ } ) ;
313
267
}
314
268
315
269
function renderIdeOption ( option : IDEOption , selected : boolean , onSelect : ( ) => void ) : JSX . Element {
316
270
const card = (
317
- < SelectableCard className = "w-36 h-40" title = { option . title } selected = { selected } onClick = { onSelect } >
271
+ < SelectableCardSolid className = "w-36 h-40" title = { option . title } selected = { selected } onClick = { onSelect } >
318
272
< div className = "flex justify-center mt-3" >
319
273
< img className = "w-16 filter-grayscale self-center" src = { option . logo } alt = "logo" />
320
274
</ div >
321
275
{ option . label ? (
322
276
< div
323
277
className = { `font-semibold text-sm ${
324
- selected ? "text-green-500 " : "text-gray-500 dark:text-gray-400"
278
+ selected ? "text-gray-100 dark:text-gray-300 " : "text-gray-500 dark:text-gray-400"
325
279
} uppercase mt-2 px-3 py-1 self-center`}
326
280
>
327
281
{ option . label }
328
282
</ div >
329
283
) : (
330
284
< > </ >
331
285
) }
332
- </ SelectableCard >
286
+ </ SelectableCardSolid >
333
287
) ;
334
288
335
289
if ( option . tooltip ) {
0 commit comments