@@ -10,52 +10,62 @@ 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 getSettingsMenu from "./settings-menu" ;
18
- import IDENone from "../icons/IDENone.svg" ;
19
- import IDENoneDark from "../icons/IDENoneDark.svg" ;
20
- import CheckBox from "../components/CheckBox" ;
21
19
import { trackEvent } from "../Analytics" ;
22
20
import { PaymentContext } from "../payment-context" ;
21
+ import CheckBox from "../components/CheckBox" ;
22
+ import { IDESettings } from "@gitpod/gitpod-protocol" ;
23
23
24
24
type Theme = "light" | "dark" | "system" ;
25
25
26
- const DesktopNoneId = "none" ;
27
- const DesktopNone : IDEOption = {
28
- image : "" ,
29
- logo : IDENone ,
30
- orderKey : "-1" ,
31
- title : "None" ,
32
- type : "desktop" ,
33
- } ;
34
-
35
26
export default function Preferences ( ) {
36
27
const { user } = useContext ( UserContext ) ;
37
28
const { showPaymentUI } = useContext ( PaymentContext ) ;
38
- const { setIsDark, isDark } = useContext ( ThemeContext ) ;
29
+ const { setIsDark } = useContext ( ThemeContext ) ;
39
30
40
- const updateUserIDEInfo = async ( defaultDesktopIde : string , defaultIde : string , useLatestVersion : boolean ) => {
41
- const useDesktopIde = defaultDesktopIde !== DesktopNoneId ;
42
- const desktopIde = useDesktopIde ? defaultDesktopIde : undefined ;
31
+ const migrationIDESettings = ( ) => {
32
+ if ( ! user ?. additionalData ?. ideSettings || user . additionalData . ideSettings . settingVersion === "2.0" ) {
33
+ return ;
34
+ }
35
+ const newIDESettings : IDESettings = {
36
+ settingVersion : "2.0" ,
37
+ } ;
38
+ const ideSettings = user . additionalData . ideSettings ;
39
+ if ( ideSettings . useDesktopIde ) {
40
+ if ( ideSettings . defaultDesktopIde === "code-desktop" ) {
41
+ newIDESettings . defaultIde = "code-desktop" ;
42
+ } else if ( ideSettings . defaultDesktopIde === "code-desktop-insiders" ) {
43
+ newIDESettings . defaultIde = "code-desktop" ;
44
+ newIDESettings . useLatestVersion = true ;
45
+ } else {
46
+ newIDESettings . defaultIde = ideSettings . defaultDesktopIde ;
47
+ newIDESettings . useLatestVersion = ideSettings . useLatestVersion ;
48
+ }
49
+ } else {
50
+ const useLatest = ideSettings . defaultIde === "code-latest" ;
51
+ newIDESettings . defaultIde = "code" ;
52
+ newIDESettings . useLatestVersion = useLatest ;
53
+ }
54
+ user . additionalData . ideSettings = newIDESettings ;
55
+ } ;
56
+ migrationIDESettings ( ) ;
57
+
58
+ const updateUserIDEInfo = async ( selectedIde : string , useLatestVersion : boolean ) => {
43
59
const additionalData = user ?. additionalData ?? { } ;
44
60
const settings = additionalData . ideSettings ?? { } ;
45
- settings . useDesktopIde = useDesktopIde ;
46
- settings . defaultIde = defaultIde ;
47
- settings . defaultDesktopIde = desktopIde ;
61
+ settings . settingVersion = "2.0" ;
62
+ settings . defaultIde = selectedIde ;
48
63
settings . useLatestVersion = useLatestVersion ;
49
64
additionalData . ideSettings = settings ;
50
65
getGitpodService ( )
51
66
. server . trackEvent ( {
52
67
event : "ide_configuration_changed" ,
53
- properties : {
54
- useDesktopIde,
55
- defaultIde,
56
- defaultDesktopIde : desktopIde ,
57
- useLatestVersion,
58
- } ,
68
+ properties : settings ,
59
69
} )
60
70
. then ( )
61
71
. catch ( console . error ) ;
@@ -64,39 +74,27 @@ export default function Preferences() {
64
74
65
75
const [ defaultIde , setDefaultIde ] = useState < string > ( user ?. additionalData ?. ideSettings ?. defaultIde || "" ) ;
66
76
const actuallySetDefaultIde = async ( value : string ) => {
67
- await updateUserIDEInfo ( defaultDesktopIde , value , useLatestVersion ) ;
77
+ await updateUserIDEInfo ( value , useLatestVersion ) ;
68
78
setDefaultIde ( value ) ;
69
79
} ;
70
80
71
- const [ defaultDesktopIde , setDefaultDesktopIde ] = useState < string > (
72
- ( user ?. additionalData ?. ideSettings ?. useDesktopIde && user ?. additionalData ?. ideSettings ?. defaultDesktopIde ) ||
73
- DesktopNoneId ,
74
- ) ;
75
- const actuallySetDefaultDesktopIde = async ( value : string ) => {
76
- await updateUserIDEInfo ( value , defaultIde , useLatestVersion ) ;
77
- setDefaultDesktopIde ( value ) ;
78
- } ;
79
-
80
81
const [ useLatestVersion , setUseLatestVersion ] = useState < boolean > (
81
82
user ?. additionalData ?. ideSettings ?. useLatestVersion ?? false ,
82
83
) ;
83
84
const actuallySetUseLatestVersion = async ( value : boolean ) => {
84
- await updateUserIDEInfo ( defaultDesktopIde , defaultIde , value ) ;
85
+ await updateUserIDEInfo ( defaultIde , value ) ;
85
86
setUseLatestVersion ( value ) ;
86
87
} ;
87
88
88
89
const [ ideOptions , setIdeOptions ] = useState < IDEOptions | undefined > ( undefined ) ;
89
90
useEffect ( ( ) => {
90
91
( async ( ) => {
91
92
const ideopts = await getGitpodService ( ) . server . getIDEOptions ( ) ;
92
- ideopts . options [ DesktopNoneId ] = DesktopNone ;
93
+
93
94
setIdeOptions ( ideopts ) ;
94
- if ( ! defaultIde ) {
95
+ if ( ! defaultIde || ideopts . options [ defaultIde ] == null ) {
95
96
setDefaultIde ( ideopts . defaultIde ) ;
96
97
}
97
- if ( ! defaultDesktopIde ) {
98
- setDefaultDesktopIde ( ideopts . defaultDesktopIde ) ;
99
- }
100
98
} ) ( ) ;
101
99
} , [ ] ) ;
102
100
@@ -114,8 +112,7 @@ export default function Preferences() {
114
112
setTheme ( theme ) ;
115
113
} ;
116
114
117
- const browserIdeOptions = ideOptions && orderedIdeOptions ( ideOptions , "browser" ) ;
118
- const desktopIdeOptions = ideOptions && orderedIdeOptions ( ideOptions , "desktop" ) ;
115
+ const allIdeOptions = ideOptions && orderedIdeOptions ( ideOptions ) ;
119
116
120
117
const [ dotfileRepo , setDotfileRepo ] = useState < string > ( user ?. additionalData ?. dotfileRepo || "" ) ;
121
118
const actuallySetDotfileRepo = async ( value : string ) => {
@@ -138,14 +135,14 @@ export default function Preferences() {
138
135
>
139
136
{ ideOptions && (
140
137
< >
141
- { browserIdeOptions && (
138
+ { allIdeOptions && (
142
139
< >
143
- < h3 > Browser Editor</ h3 >
140
+ < h3 > Editor</ h3 >
144
141
< p className = "text-base text-gray-500 dark:text-gray-400" >
145
- Choose the default editor for opening workspaces in the browser .
142
+ Choose the editor for opening workspaces.
146
143
</ p >
147
- < div className = "my-4 gap-4 flex flex-wrap" >
148
- { browserIdeOptions . map ( ( [ id , option ] ) => {
144
+ < div className = "my-4 gap-4 flex flex-wrap max-w-2xl " >
145
+ { allIdeOptions . map ( ( [ id , option ] ) => {
149
146
const selected = defaultIde === id ;
150
147
const onSelect = ( ) => actuallySetDefaultIde ( id ) ;
151
148
return renderIdeOption ( option , selected , onSelect ) ;
@@ -160,38 +157,6 @@ export default function Preferences() {
160
157
</ ul >
161
158
</ InfoBox >
162
159
) }
163
- </ >
164
- ) }
165
- { desktopIdeOptions && (
166
- < >
167
- < h3 className = "mt-12 flex" >
168
- Desktop Editor
169
- < PillLabel type = "warn" className = "font-semibold py-0.5 px-2 self-center" >
170
- Beta
171
- </ PillLabel >
172
- </ h3 >
173
- < p className = "text-base text-gray-500 dark:text-gray-400" >
174
- Optionally, choose the default desktop editor for opening workspaces.
175
- </ p >
176
- < div className = "my-4 gap-4 flex flex-wrap max-w-2xl" >
177
- { desktopIdeOptions . map ( ( [ id , option ] ) => {
178
- const selected = defaultDesktopIde === id ;
179
- const onSelect = ( ) => actuallySetDefaultDesktopIde ( id ) ;
180
- if ( id === DesktopNoneId ) {
181
- option . logo = isDark ? IDENoneDark : IDENone ;
182
- }
183
- return renderIdeOption ( option , selected , onSelect ) ;
184
- } ) }
185
- </ div >
186
- { ideOptions . options [ defaultDesktopIde ] ?. notes && (
187
- < InfoBox className = "my-5 max-w-2xl" >
188
- < ul >
189
- { ideOptions . options [ defaultDesktopIde ] . notes ?. map ( ( x , idx ) => (
190
- < li className = { idx > 0 ? "mt-2" : "" } > { x } </ li >
191
- ) ) }
192
- </ ul >
193
- </ InfoBox >
194
- ) }
195
160
< p className = "text-left w-full text-gray-500" >
196
161
The < strong > JetBrains desktop IDEs</ strong > are currently in beta.{ " " }
197
162
< a
@@ -215,8 +180,28 @@ export default function Preferences() {
215
180
</ >
216
181
) }
217
182
< CheckBox
218
- title = "Latest Release"
219
- desc = "Include the latest Early Access Program (EAP) version for each JetBrains IDE."
183
+ title = "Latest Release (Unstable)"
184
+ desc = {
185
+ < span >
186
+ Use the latest version for each editor.{ " " }
187
+ < a
188
+ className = "gp-link"
189
+ target = "_blank"
190
+ href = "https://code.visualstudio.com/blogs/2016/02/01/introducing_insiders_build"
191
+ >
192
+ Insiders
193
+ </ a > { " " }
194
+ for VS Code,{ " " }
195
+ < a
196
+ className = "gp-link"
197
+ target = "_blank"
198
+ href = "https://www.jetbrains.com/resources/eap/"
199
+ >
200
+ EAP
201
+ </ a > { " " }
202
+ for JetBrains IDEs.
203
+ </ span >
204
+ }
220
205
checked = { useLatestVersion }
221
206
onChange = { ( e ) => actuallySetUseLatestVersion ( e . target . checked ) }
222
207
/>
@@ -307,10 +292,10 @@ export default function Preferences() {
307
292
) ;
308
293
}
309
294
310
- function orderedIdeOptions ( ideOptions : IDEOptions , type : "browser" | "desktop" ) {
295
+ function orderedIdeOptions ( ideOptions : IDEOptions ) {
311
296
// TODO: Maybe convert orderKey to number before sort?
312
297
return Object . entries ( ideOptions . options )
313
- . filter ( ( [ _ , x ] ) => x . type === type && ! x . hidden )
298
+ . filter ( ( [ _ , x ] ) => ! x . hidden )
314
299
. sort ( ( a , b ) => {
315
300
const keyA = a [ 1 ] . orderKey || a [ 0 ] ;
316
301
const keyB = b [ 1 ] . orderKey || b [ 0 ] ;
@@ -319,23 +304,24 @@ function orderedIdeOptions(ideOptions: IDEOptions, type: "browser" | "desktop")
319
304
}
320
305
321
306
function renderIdeOption ( option : IDEOption , selected : boolean , onSelect : ( ) => void ) : JSX . Element {
307
+ const label = option . type === "desktop" ? "" : option . type ;
322
308
const card = (
323
- < SelectableCard className = "w-36 h-40" title = { option . title } selected = { selected } onClick = { onSelect } >
309
+ < SelectableCardSolid className = "w-36 h-40" title = { option . title } selected = { selected } onClick = { onSelect } >
324
310
< div className = "flex justify-center mt-3" >
325
311
< img className = "w-16 filter-grayscale self-center" src = { option . logo } alt = "logo" />
326
312
</ div >
327
- { option . label ? (
313
+ { label ? (
328
314
< div
329
315
className = { `font-semibold text-sm ${
330
- selected ? "text-green-500 " : "text-gray-500 dark:text-gray-400 "
316
+ selected ? "text-gray-100 dark:text-gray-600 " : "text-gray-600 dark:text-gray-500 "
331
317
} uppercase mt-2 px-3 py-1 self-center`}
332
318
>
333
- { option . label }
319
+ { label }
334
320
</ div >
335
321
) : (
336
322
< > </ >
337
323
) }
338
- </ SelectableCard >
324
+ </ SelectableCardSolid >
339
325
) ;
340
326
341
327
if ( option . tooltip ) {
0 commit comments