@@ -43,8 +43,8 @@ const TASKS = {
43
43
- init: pip install -r requirements.txt
44
44
command: python main.py` ,
45
45
Other : `tasks:
46
- - init: # TODO: install dependencies, build project
47
- command: # TODO: start app`
46
+ - init: echo ' TODO: build project'
47
+ command: echo ' TODO: start app' `
48
48
}
49
49
50
50
// const IMAGES = {
@@ -75,6 +75,7 @@ export default function () {
75
75
const { isDark } = useContext ( ThemeContext ) ;
76
76
77
77
const [ showAuthBanner , setShowAuthBanner ] = useState < { host : string } | undefined > ( undefined ) ;
78
+ const [ buttonNewWorkspaceEnabled , setButtonNewWorkspaceEnabled ] = useState < boolean > ( true ) ;
78
79
79
80
useEffect ( ( ) => {
80
81
// Disable editing while loading, or when the config comes from Git.
@@ -164,11 +165,10 @@ export default function () {
164
165
} ) ;
165
166
} ;
166
167
167
- const buildProject = async ( event : React . MouseEvent ) => {
168
+ const buildProject = async ( ) => {
168
169
if ( ! project ) {
169
170
return ;
170
171
}
171
- // (event.target as HTMLButtonElement).disabled = true;
172
172
setEditorMessage ( null ) ;
173
173
if ( ! ! startPrebuildResult ) {
174
174
setStartPrebuildResult ( undefined ) ;
@@ -209,6 +209,26 @@ export default function () {
209
209
210
210
useEffect ( ( ) => { document . title = 'Configure Project — Gitpod' } , [ ] ) ;
211
211
212
+ const onNewWorkspace = async ( ) => {
213
+ setButtonNewWorkspaceEnabled ( false ) ;
214
+ const redirectToNewWorkspace = ( ) => {
215
+ // instead of `history.push` we want forcibly to redirect here in order to avoid a following redirect from `/` -> `/projects` (cf. App.tsx)
216
+ const url = new URL ( window . location . toString ( ) ) ;
217
+ url . pathname = "/" ;
218
+ url . hash = project ?. cloneUrl ! ;
219
+ window . location . href = url . toString ( ) ;
220
+ }
221
+
222
+ if ( prebuildInstance ?. status . phase === "stopped" && ! prebuildInstance ?. status . conditions . failed && ! prebuildInstance ?. status . conditions . headlessTaskFailed ) {
223
+ redirectToNewWorkspace ( ) ;
224
+ return ;
225
+ }
226
+ if ( ! prebuildWasTriggered ) {
227
+ await buildProject ( ) ;
228
+ }
229
+ redirectToNewWorkspace ( ) ;
230
+ }
231
+
212
232
return < >
213
233
< Header title = "Configuration" subtitle = "View and edit project configuration." />
214
234
< div className = "app-container mt-8 flex space-x-4" >
@@ -257,14 +277,12 @@ export default function () {
257
277
< div className = "h-20 px-6 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-600 flex space-x-2" >
258
278
{ prebuildWasTriggered && < PrebuildInstanceStatus prebuildInstance = { prebuildInstance } /> }
259
279
< div className = "flex-grow" />
260
- { ( ( ! isDetecting && isEditorDisabled ) || ( prebuildInstance ?. status . phase === "stopped" && ! prebuildInstance ?. status . conditions . failed && ! prebuildInstance ?. status . conditions . headlessTaskFailed ) )
261
- ? < a className = "my-auto" href = { `/#${ project ?. cloneUrl } ` } > < button className = "secondary" > New Workspace</ button > </ a >
262
- : < button disabled = { true } className = "secondary" > New Workspace</ button > }
263
280
{ ( prebuildWasTriggered && prebuildInstance ?. status . phase !== "stopped" )
264
281
? < button className = "danger flex items-center space-x-2" disabled = { prebuildWasCancelled || ( prebuildInstance ?. status . phase !== "initializing" && prebuildInstance ?. status . phase !== "running" ) } onClick = { cancelPrebuild } >
265
282
< span > Cancel Prebuild</ span >
266
283
</ button >
267
- : < button disabled = { isDetecting } onClick = { buildProject } > Run Prebuild</ button > }
284
+ : < button disabled = { isDetecting } className = "secondary" onClick = { buildProject } > Run Prebuild</ button > }
285
+ < button disabled = { isDetecting && buttonNewWorkspaceEnabled } onClick = { onNewWorkspace } > New Workspace</ button >
268
286
</ div >
269
287
</ div >
270
288
</ div >
0 commit comments