@@ -10,37 +10,33 @@ import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
10
10
import { Deferred } from "@gitpod/gitpod-protocol/lib/util/deferred" ;
11
11
import { FC , FunctionComponent , useCallback , useContext , useEffect , useMemo , useState } from "react" ;
12
12
import { useHistory , useLocation } from "react-router" ;
13
- import { Link } from "react-router-dom" ;
13
+ import Alert from "../components/Alert" ;
14
+ import { AuthorizeGit , useNeedsGitAuthorization } from "../components/AuthorizeGit" ;
14
15
import { Button } from "../components/Button" ;
16
+ import { LinkButton } from "../components/LinkButton" ;
15
17
import Modal from "../components/Modal" ;
16
18
import RepositoryFinder from "../components/RepositoryFinder" ;
17
19
import SelectIDEComponent from "../components/SelectIDEComponent" ;
18
20
import SelectWorkspaceClassComponent from "../components/SelectWorkspaceClassComponent" ;
19
21
import { UsageLimitReachedModal } from "../components/UsageLimitReachedModal" ;
20
- import { CheckboxInputField } from "../components/forms/CheckboxInputField " ;
22
+ import { InputField } from "../components/forms/InputField " ;
21
23
import { Heading1 } from "../components/typography/headings" ;
22
24
import { useAuthProviders } from "../data/auth-providers/auth-provider-query" ;
23
25
import { useCurrentOrg } from "../data/organizations/orgs-query" ;
24
26
import { useListProjectsQuery } from "../data/projects/list-projects-query" ;
25
27
import { useCreateWorkspaceMutation } from "../data/workspaces/create-workspace-mutation" ;
26
28
import { useListWorkspacesQuery } from "../data/workspaces/list-workspaces-query" ;
27
29
import { useWorkspaceContext } from "../data/workspaces/resolve-context-query" ;
30
+ import { useDirtyState } from "../hooks/use-dirty-state" ;
28
31
import { openAuthorizeWindow } from "../provider-utils" ;
29
32
import { getGitpodService , gitpodHostUrl } from "../service/service" ;
30
33
import { StartWorkspaceError } from "../start/StartPage" ;
31
34
import { VerifyModal } from "../start/VerifyModal" ;
32
35
import { StartWorkspaceOptions } from "../start/start-workspace-options" ;
33
36
import { UserContext , useCurrentUser } from "../user-context" ;
34
37
import { SelectAccountModal } from "../user-settings/SelectAccountModal" ;
35
- import { settingsPathPreferences } from "../user-settings/settings.routes" ;
36
- import { WorkspaceEntry } from "./WorkspaceEntry" ;
37
- import { AuthorizeGit , useNeedsGitAuthorization } from "../components/AuthorizeGit" ;
38
38
import { settingsPathIntegrations } from "../user-settings/settings.routes" ;
39
- import { useDirtyState } from "../hooks/use-dirty-state" ;
40
- import { LinkButton } from "../components/LinkButton" ;
41
- import { InputField } from "../components/forms/InputField" ;
42
- import Alert from "../components/Alert" ;
43
- import { useFeatureFlag } from "../data/featureflag-query" ;
39
+ import { WorkspaceEntry } from "./WorkspaceEntry" ;
44
40
45
41
export function CreateWorkspacePage ( ) {
46
42
const { user, setUser } = useContext ( UserContext ) ;
@@ -49,8 +45,14 @@ export function CreateWorkspacePage() {
49
45
const workspaces = useListWorkspacesQuery ( { limit : 50 } ) ;
50
46
const location = useLocation ( ) ;
51
47
const history = useHistory ( ) ;
48
+ const [ contextURL , setContextURL ] = useState < string | undefined > (
49
+ StartWorkspaceOptions . parseContextUrl ( location . hash ) ,
50
+ ) ;
52
51
const props = StartWorkspaceOptions . parseSearchParams ( location . search ) ;
53
- const [ autostart , setAutostart ] = useState < boolean | undefined > ( props . autostart ) ;
52
+ // we autostart when a contextURL is provided via the URL hash and autostart is not explicitly set to false
53
+ const [ autostart , setAutostart ] = useState < boolean | undefined > (
54
+ contextURL !== undefined && props . autostart !== false ,
55
+ ) ;
54
56
const createWorkspaceMutation = useCreateWorkspaceMutation ( ) ;
55
57
56
58
const defaultLatestIde =
@@ -66,11 +68,7 @@ export function CreateWorkspacePage() {
66
68
const defaultWorkspaceClass = props . workspaceClass ;
67
69
const [ selectedWsClass , setSelectedWsClass , selectedWsClassIsDirty ] = useDirtyState ( defaultWorkspaceClass ) ;
68
70
const [ errorWsClass , setErrorWsClass ] = useState < string | undefined > ( undefined ) ;
69
- const [ contextURL , setContextURL ] = useState < string | undefined > (
70
- StartWorkspaceOptions . parseContextUrl ( location . hash ) ,
71
- ) ;
72
71
const workspaceContext = useWorkspaceContext ( contextURL ) ;
73
- const [ rememberOptions , setRememberOptions ] = useState ( false ) ;
74
72
const needsGitAuthorization = useNeedsGitAuthorization ( ) ;
75
73
76
74
const storeAutoStartOptions = useCallback ( async ( ) => {
@@ -88,24 +86,22 @@ export function CreateWorkspacePage() {
88
86
// we only keep the last 20 options
89
87
workspaceAutoStartOptions = workspaceAutoStartOptions . slice ( - 40 ) ;
90
88
91
- if ( rememberOptions ) {
92
- workspaceAutoStartOptions . push ( {
93
- cloneURL,
94
- organizationId : currentOrg . id ,
95
- ideSettings : {
96
- defaultIde : selectedIde ,
97
- useLatestVersion : useLatestIde ,
98
- } ,
99
- workspaceClass : selectedWsClass ,
100
- } ) ;
101
- }
89
+ workspaceAutoStartOptions . push ( {
90
+ cloneURL,
91
+ organizationId : currentOrg . id ,
92
+ ideSettings : {
93
+ defaultIde : selectedIde ,
94
+ useLatestVersion : useLatestIde ,
95
+ } ,
96
+ workspaceClass : selectedWsClass ,
97
+ } ) ;
102
98
AdditionalUserData . set ( user , {
103
99
workspaceAutostartOptions : workspaceAutoStartOptions ,
104
100
} ) ;
105
101
setUser ( user ) ;
106
102
await getGitpodService ( ) . server . updateLoggedInUser ( user ) ;
107
103
console . log ( "Stored autostart options" , workspaceAutoStartOptions ) ;
108
- } , [ currentOrg , rememberOptions , selectedIde , selectedWsClass , setUser , useLatestIde , user , workspaceContext . data ] ) ;
104
+ } , [ currentOrg , selectedIde , selectedWsClass , setUser , useLatestIde , user , workspaceContext . data ] ) ;
109
105
110
106
// see if we have a matching project based on context url and project's repo url
111
107
const project = useMemo ( ( ) => {
@@ -275,7 +271,6 @@ export function CreateWorkspacePage() {
275
271
( e ) => e . cloneURL === cloneURL && e . organizationId === currentOrg ?. id ,
276
272
) ;
277
273
if ( rememberedOptions ) {
278
- setRememberOptions ( true ) ;
279
274
if ( ! selectedIdeIsDirty ) {
280
275
setSelectedIde ( rememberedOptions . ideSettings ?. defaultIde , false ) ;
281
276
setUseLatestIde ( ! ! rememberedOptions . ideSettings ?. useLatestVersion ) ;
@@ -288,12 +283,15 @@ export function CreateWorkspacePage() {
288
283
setAutostart ( true ) ;
289
284
}
290
285
} else {
291
- setRememberOptions ( false ) ;
292
286
// reset the ide settings to the user's default IF they haven't changed it manually
293
287
if ( ! selectedIdeIsDirty ) {
294
288
setSelectedIde ( defaultIde , false ) ;
295
289
setUseLatestIde ( defaultLatestIde ) ;
296
290
}
291
+
292
+ if ( ! selectedWsClassIsDirty ) {
293
+ setSelectedWsClass ( defaultWorkspaceClass , false ) ;
294
+ }
297
295
}
298
296
// we only update the remembered options when the workspaceContext changes
299
297
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -314,7 +312,14 @@ export function CreateWorkspacePage() {
314
312
315
313
// Derive if the continue button is disabled based on current state
316
314
const continueButtonDisabled = useMemo ( ( ) => {
317
- if ( workspaceContext . isLoading || ! contextURL || contextURL . length === 0 || ! ! errorIde || ! ! errorWsClass ) {
315
+ if (
316
+ createWorkspaceMutation . isStarting ||
317
+ workspaceContext . isLoading ||
318
+ ! contextURL ||
319
+ contextURL . length === 0 ||
320
+ ! ! errorIde ||
321
+ ! ! errorWsClass
322
+ ) {
318
323
return true ;
319
324
}
320
325
if ( workspaceContext . error ) {
@@ -327,7 +332,14 @@ export function CreateWorkspacePage() {
327
332
}
328
333
329
334
return false ;
330
- } , [ contextURL , errorIde , errorWsClass , workspaceContext . error , workspaceContext . isLoading ] ) ;
335
+ } , [
336
+ contextURL ,
337
+ createWorkspaceMutation . isStarting ,
338
+ errorIde ,
339
+ errorWsClass ,
340
+ workspaceContext . error ,
341
+ workspaceContext . isLoading ,
342
+ ] ) ;
331
343
332
344
if ( SelectAccountPayload . is ( selectAccountError ) ) {
333
345
return (
@@ -419,14 +431,6 @@ export function CreateWorkspacePage() {
419
431
</ Button >
420
432
</ div >
421
433
422
- { selectedIde === "code-desktop" && < LocalSSHWarning className = "mx-6 mt-3 rounded-lg overflow-hidden" /> }
423
- { workspaceContext . data && (
424
- < RememberOptions
425
- disabled = { workspaceContext . isLoading || createWorkspaceMutation . isStarting }
426
- checked = { rememberOptions }
427
- onChange = { setRememberOptions }
428
- />
429
- ) }
430
434
{ existingWorkspaces . length > 0 && ! createWorkspaceMutation . isStarting && (
431
435
< div className = "w-full flex flex-col justify-end px-6" >
432
436
< p className = "mt-6 text-center text-base" > Running workspaces on this revision</ p >
@@ -448,67 +452,6 @@ export function CreateWorkspacePage() {
448
452
) ;
449
453
}
450
454
451
- function LocalSSHWarning ( props : { className : string } ) {
452
- const isLocalSSHProxyEnabled = useFeatureFlag ( "gitpod_desktop_use_local_ssh_proxy" ) ;
453
-
454
- if ( ! isLocalSSHProxyEnabled ) {
455
- return null ;
456
- }
457
-
458
- return (
459
- < div className = { props . className } >
460
- < Alert light className = "bg-gray-100 dark:bg-gray-800" type = "info" >
461
- Choosing VS Code for Desktop will add a single entry to your local SSH configuration. Gitpod won't
462
- interfere with your existing SSH configurations.
463
- < a
464
- className = "gp-link"
465
- href = "https://www.gitpod.io/docs/references/ides-and-editors/vscode#connecting-to-vs-code-desktop"
466
- target = "_blank"
467
- rel = "noreferrer"
468
- >
469
- Learn more
470
- </ a >
471
- ·
472
- < a
473
- className = "gp-link"
474
- href = "https://github.com/gitpod-io/gitpod/issues/18109"
475
- target = "_blank"
476
- rel = "noreferrer"
477
- >
478
- Send feedback
479
- </ a >
480
- </ Alert >
481
- </ div >
482
- ) ;
483
- }
484
-
485
- function RememberOptions ( params : { disabled ?: boolean ; checked : boolean ; onChange : ( checked : boolean ) => void } ) {
486
- const { disabled, checked, onChange } = params ;
487
-
488
- return (
489
- < >
490
- < div className = { "w-full flex justify-center mt-3 px-8 mx-2" } >
491
- < CheckboxInputField
492
- label = "Autostart with these options for this repository."
493
- checked = { checked }
494
- disabled = { disabled }
495
- topMargin = { false }
496
- onChange = { onChange }
497
- />
498
- </ div >
499
- < div className = { "w-full flex justify-center px-8 mx-2" } >
500
- < p className = "text-gray-400 dark:text-gray-500 text-sm" >
501
- Don't worry, you can reset this anytime in your{ " " }
502
- < Link to = { settingsPathPreferences } className = "gp-link" >
503
- preferences
504
- </ Link >
505
- .
506
- </ p >
507
- </ div >
508
- </ >
509
- ) ;
510
- }
511
-
512
455
function tryAuthorize ( host : string , scopes ?: string [ ] ) : Promise < SelectAccountPayload | undefined > {
513
456
const result = new Deferred < SelectAccountPayload | undefined > ( ) ;
514
457
openAuthorizeWindow ( {
0 commit comments