4
4
* See License-AGPL.txt in the project root for license information.
5
5
*/
6
6
7
- import { IDEOption , IDEOptions } from "@gitpod/gitpod-protocol/lib/ide-protocol" ;
8
- import { useContext , useEffect , useState } from "react" ;
9
- import InfoBox from "../components/InfoBox" ;
7
+ import { useContext , useState } from "react" ;
10
8
import { PageWithSubMenu } from "../components/PageWithSubMenu" ;
11
9
import PillLabel from "../components/PillLabel" ;
12
10
import SelectableCard from "../components/SelectableCard" ;
13
- import SelectableCardSolid from "../components/SelectableCardSolid" ;
14
- import Tooltip from "../components/Tooltip" ;
15
11
import { getGitpodService } from "../service/service" ;
16
12
import { ThemeContext } from "../theme-context" ;
17
13
import { UserContext } from "../user-context" ;
18
14
import getSettingsMenu from "./settings-menu" ;
19
15
import { trackEvent } from "../Analytics" ;
20
16
import { PaymentContext } from "../payment-context" ;
21
- import CheckBox from "../components/CheckBox" ;
22
17
import { IDESettings } from "@gitpod/gitpod-protocol" ;
18
+ import SelectIDE from "./SelectIDE" ;
23
19
24
20
type Theme = "light" | "dark" | "system" ;
25
21
@@ -55,52 +51,6 @@ export default function Preferences() {
55
51
} ;
56
52
migrationIDESettings ( ) ;
57
53
58
- const updateUserIDEInfo = async ( selectedIde : string , useLatestVersion : boolean ) => {
59
- const additionalData = user ?. additionalData ?? { } ;
60
- const settings = additionalData . ideSettings ?? { } ;
61
- settings . settingVersion = "2.0" ;
62
- settings . defaultIde = selectedIde ;
63
- settings . useLatestVersion = useLatestVersion ;
64
- additionalData . ideSettings = settings ;
65
- getGitpodService ( )
66
- . server . trackEvent ( {
67
- event : "ide_configuration_changed" ,
68
- properties : settings ,
69
- } )
70
- . then ( )
71
- . catch ( console . error ) ;
72
- await getGitpodService ( ) . server . updateLoggedInUser ( { additionalData } ) ;
73
- } ;
74
-
75
- const [ defaultIde , setDefaultIde ] = useState < string > ( user ?. additionalData ?. ideSettings ?. defaultIde || "" ) ;
76
- const actuallySetDefaultIde = async ( value : string ) => {
77
- await updateUserIDEInfo ( value , useLatestVersion ) ;
78
- setDefaultIde ( value ) ;
79
- } ;
80
-
81
- const [ useLatestVersion , setUseLatestVersion ] = useState < boolean > (
82
- user ?. additionalData ?. ideSettings ?. useLatestVersion ?? false ,
83
- ) ;
84
- const actuallySetUseLatestVersion = async ( value : boolean ) => {
85
- await updateUserIDEInfo ( defaultIde , value ) ;
86
- setUseLatestVersion ( value ) ;
87
- } ;
88
-
89
- const [ ideOptions , setIdeOptions ] = useState < IDEOptions | undefined > ( undefined ) ;
90
- useEffect ( ( ) => {
91
- ( async ( ) => {
92
- const ideopts = await getGitpodService ( ) . server . getIDEOptions ( ) ;
93
- // TODO: Compatible with ide-config not deployed, need revert after ide-config deployed
94
- delete ideopts . options [ "code-latest" ] ;
95
- delete ideopts . options [ "code-desktop-insiders" ] ;
96
-
97
- setIdeOptions ( ideopts ) ;
98
- if ( ! defaultIde || ideopts . options [ defaultIde ] == null ) {
99
- setDefaultIde ( ideopts . defaultIde ) ;
100
- }
101
- } ) ( ) ;
102
- } , [ ] ) ;
103
-
104
54
const [ theme , setTheme ] = useState < Theme > ( localStorage . theme || "system" ) ;
105
55
const actuallySetTheme = ( theme : Theme ) => {
106
56
if ( theme === "dark" || theme === "light" ) {
@@ -115,8 +65,6 @@ export default function Preferences() {
115
65
setTheme ( theme ) ;
116
66
} ;
117
67
118
- const allIdeOptions = ideOptions && orderedIdeOptions ( ideOptions ) ;
119
-
120
68
const [ dotfileRepo , setDotfileRepo ] = useState < string > ( user ?. additionalData ?. dotfileRepo || "" ) ;
121
69
const actuallySetDotfileRepo = async ( value : string ) => {
122
70
const additionalData = user ?. additionalData || { } ;
@@ -136,80 +84,9 @@ export default function Preferences() {
136
84
title = "Preferences"
137
85
subtitle = "Configure user preferences."
138
86
>
139
- { ideOptions && (
140
- < >
141
- { allIdeOptions && (
142
- < >
143
- < h3 > Editor</ h3 >
144
- < p className = "text-base text-gray-500 dark:text-gray-400" >
145
- Choose the editor for opening workspaces.
146
- </ p >
147
- < div className = "my-4 gap-4 flex flex-wrap max-w-2xl" >
148
- { allIdeOptions . map ( ( [ id , option ] ) => {
149
- const selected = defaultIde === id ;
150
- const onSelect = ( ) => actuallySetDefaultIde ( id ) ;
151
- return renderIdeOption ( option , selected , onSelect ) ;
152
- } ) }
153
- </ div >
154
- { ideOptions . options [ defaultIde ] ?. notes && (
155
- < InfoBox className = "my-5 max-w-2xl" >
156
- < ul >
157
- { ideOptions . options [ defaultIde ] . notes ?. map ( ( x , idx ) => (
158
- < li className = { idx > 0 ? "mt-2" : "" } > { x } </ li >
159
- ) ) }
160
- </ ul >
161
- </ InfoBox >
162
- ) }
163
- < p className = "text-left w-full text-gray-500" >
164
- The < strong > JetBrains desktop IDEs</ strong > are currently in beta.{ " " }
165
- < a
166
- href = "https://github.com/gitpod-io/gitpod/issues/6576"
167
- target = "gitpod-feedback-issue"
168
- rel = "noopener"
169
- className = "gp-link"
170
- >
171
- Send feedback
172
- </ a > { " " }
173
- ·{ " " }
174
- < a
175
- href = "https://www.gitpod.io/docs/integrations/jetbrains"
176
- target = "_blank"
177
- rel = "noopener noreferrer"
178
- className = "gp-link"
179
- >
180
- Documentation
181
- </ a >
182
- </ p >
183
- </ >
184
- ) }
185
- < CheckBox
186
- title = "Latest Release (Unstable)"
187
- desc = {
188
- < span >
189
- Use the latest version for each editor.{ " " }
190
- < a
191
- className = "gp-link"
192
- target = "_blank"
193
- href = "https://code.visualstudio.com/blogs/2016/02/01/introducing_insiders_build"
194
- >
195
- Insiders
196
- </ a > { " " }
197
- for VS Code,{ " " }
198
- < a
199
- className = "gp-link"
200
- target = "_blank"
201
- href = "https://www.jetbrains.com/resources/eap/"
202
- >
203
- EAP
204
- </ a > { " " }
205
- for JetBrains IDEs.
206
- </ span >
207
- }
208
- checked = { useLatestVersion }
209
- onChange = { ( e ) => actuallySetUseLatestVersion ( e . target . checked ) }
210
- />
211
- </ >
212
- ) }
87
+ < h3 > Editor</ h3 >
88
+ < p className = "text-base text-gray-500 dark:text-gray-400" > Choose the editor for opening workspaces.</ p >
89
+ < SelectIDE />
213
90
< h3 className = "mt-12" > Theme</ h3 >
214
91
< p className = "text-base text-gray-500 dark:text-gray-400" > Early bird or night owl? Choose your side.</ p >
215
92
< div className = "mt-4 space-x-4 flex" >
@@ -294,41 +171,3 @@ export default function Preferences() {
294
171
</ div >
295
172
) ;
296
173
}
297
-
298
- function orderedIdeOptions ( ideOptions : IDEOptions ) {
299
- // TODO: Maybe convert orderKey to number before sort?
300
- return Object . entries ( ideOptions . options )
301
- . filter ( ( [ _ , x ] ) => ! x . hidden )
302
- . sort ( ( a , b ) => {
303
- const keyA = a [ 1 ] . orderKey || a [ 0 ] ;
304
- const keyB = b [ 1 ] . orderKey || b [ 0 ] ;
305
- return keyA . localeCompare ( keyB ) ;
306
- } ) ;
307
- }
308
-
309
- function renderIdeOption ( option : IDEOption , selected : boolean , onSelect : ( ) => void ) : JSX . Element {
310
- const label = option . type === "desktop" ? "" : option . type ;
311
- const card = (
312
- < SelectableCardSolid className = "w-36 h-40" title = { option . title } selected = { selected } onClick = { onSelect } >
313
- < div className = "flex justify-center mt-3" >
314
- < img className = "w-16 filter-grayscale self-center" src = { option . logo } alt = "logo" />
315
- </ div >
316
- { label ? (
317
- < div
318
- className = { `font-semibold text-sm ${
319
- selected ? "text-gray-100 dark:text-gray-600" : "text-gray-600 dark:text-gray-500"
320
- } uppercase mt-2 px-3 py-1 self-center`}
321
- >
322
- { label }
323
- </ div >
324
- ) : (
325
- < > </ >
326
- ) }
327
- </ SelectableCardSolid >
328
- ) ;
329
-
330
- if ( option . tooltip ) {
331
- return < Tooltip content = { option . tooltip } > { card } </ Tooltip > ;
332
- }
333
- return card ;
334
- }
0 commit comments