@@ -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 = {
@@ -164,11 +164,10 @@ export default function () {
164
164
} ) ;
165
165
} ;
166
166
167
- const buildProject = async ( event : React . MouseEvent ) => {
167
+ const buildProject = async ( ) => {
168
168
if ( ! project ) {
169
169
return ;
170
170
}
171
- // (event.target as HTMLButtonElement).disabled = true;
172
171
setEditorMessage ( null ) ;
173
172
if ( ! ! startPrebuildResult ) {
174
173
setStartPrebuildResult ( undefined ) ;
@@ -209,6 +208,25 @@ export default function () {
209
208
210
209
useEffect ( ( ) => { document . title = 'Configure Project — Gitpod' } , [ ] ) ;
211
210
211
+ const onNewWorkspace = async ( ) => {
212
+ const redirectToNewWorkspace = ( ) => {
213
+ // instead of `history.push` we want forcibly to redirect here in order to avoid a following redirect from `/` -> `/projects` (cf. App.tsx)
214
+ const url = new URL ( window . location . toString ( ) ) ;
215
+ url . pathname = "/" ;
216
+ url . hash = project ?. cloneUrl ! ;
217
+ window . location . href = url . toString ( ) ;
218
+ }
219
+
220
+ if ( prebuildInstance ?. status . phase === "stopped" && ! prebuildInstance ?. status . conditions . failed && ! prebuildInstance ?. status . conditions . headlessTaskFailed ) {
221
+ redirectToNewWorkspace ( ) ;
222
+ return ;
223
+ }
224
+ if ( ! prebuildWasTriggered ) {
225
+ await buildProject ( ) ;
226
+ }
227
+ redirectToNewWorkspace ( ) ;
228
+ }
229
+
212
230
return < >
213
231
< Header title = "Configuration" subtitle = "View and edit project configuration." />
214
232
< div className = "lg:px-28 px-10 mt-8 flex space-x-4" >
@@ -257,9 +275,7 @@ export default function () {
257
275
< 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
276
{ prebuildWasTriggered && < PrebuildInstanceStatus prebuildInstance = { prebuildInstance } /> }
259
277
< 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 > }
278
+ < button disabled = { isDetecting } className = "secondary" onClick = { onNewWorkspace } > New Workspace</ button >
263
279
{ ( prebuildWasTriggered && prebuildInstance ?. status . phase !== "stopped" )
264
280
? < button className = "danger flex items-center space-x-2" disabled = { prebuildWasCancelled || ( prebuildInstance ?. status . phase !== "initializing" && prebuildInstance ?. status . phase !== "running" ) } onClick = { cancelPrebuild } >
265
281
< span > Cancel Prebuild</ span >
0 commit comments