@@ -43,8 +43,8 @@ const TASKS = {
4343 - init: pip install -r requirements.txt
4444 command: python main.py` ,
4545 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' `
4848}
4949
5050// const IMAGES = {
@@ -164,11 +164,10 @@ export default function () {
164164 } ) ;
165165 } ;
166166
167- const buildProject = async ( event : React . MouseEvent ) => {
167+ const buildProject = async ( ) => {
168168 if ( ! project ) {
169169 return ;
170170 }
171- // (event.target as HTMLButtonElement).disabled = true;
172171 setEditorMessage ( null ) ;
173172 if ( ! ! startPrebuildResult ) {
174173 setStartPrebuildResult ( undefined ) ;
@@ -209,6 +208,25 @@ export default function () {
209208
210209 useEffect ( ( ) => { document . title = 'Configure Project — Gitpod' } , [ ] ) ;
211210
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+
212230 return < >
213231 < Header title = "Configuration" subtitle = "View and edit project configuration." />
214232 < div className = "lg:px-28 px-10 mt-8 flex space-x-4" >
@@ -257,9 +275,7 @@ export default function () {
257275 < 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" >
258276 { prebuildWasTriggered && < PrebuildInstanceStatus prebuildInstance = { prebuildInstance } /> }
259277 < 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 >
263279 { ( prebuildWasTriggered && prebuildInstance ?. status . phase !== "stopped" )
264280 ? < button className = "danger flex items-center space-x-2" disabled = { prebuildWasCancelled || ( prebuildInstance ?. status . phase !== "initializing" && prebuildInstance ?. status . phase !== "running" ) } onClick = { cancelPrebuild } >
265281 < span > Cancel Prebuild</ span >
0 commit comments