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