@@ -21,8 +21,10 @@ import Button from '@material-ui/core/Button';
21
21
import { ResponseError } from 'vscode-jsonrpc' ;
22
22
import { WithBranding } from './with-branding' ;
23
23
import { Context } from '../context' ;
24
+ import { colors } from '../withRoot' ;
24
25
25
26
interface StartWorkspaceState {
27
+ workspace ?: Workspace ;
26
28
workspaceInstance ?: WorkspaceInstance ;
27
29
errorMessage ?: string ;
28
30
errorCode ?: number ;
@@ -135,6 +137,9 @@ export class StartWorkspace extends React.Component<StartWorkspaceProps, StartWo
135
137
// (needed for already started workspaces, and not hanging in 'Starting ...' for too long)
136
138
this . props . service . server . getWorkspace ( workspaceId ) . then ( ws => {
137
139
if ( ws . latestInstance ) {
140
+ this . setState ( {
141
+ workspace : ws . workspace
142
+ } ) ;
138
143
this . onInstanceUpdate ( ws . latestInstance ) ;
139
144
}
140
145
} ) ;
@@ -336,37 +341,78 @@ export class StartWorkspace extends React.Component<StartWorkspaceProps, StartWo
336
341
message = < div className = 'message' >
337
342
{ this . process . getLabel ( this . state . workspaceInstance . status . phase ) }
338
343
</ div > ;
339
- if ( this . state . workspaceInstance . status . phase === 'stopping'
340
- || this . state . workspaceInstance . status . phase === 'stopped' ) {
341
- let stoppedReason ;
344
+ if ( this . state . workspaceInstance . status . phase === 'stopped' ) {
345
+ let stoppedReason = "The workspace has stopped." ;
342
346
if ( this . state . workspaceInstance . status . conditions . timeout ) {
343
- stoppedReason = "Workspace has timed out." ;
347
+ stoppedReason = "The workspace has timed out." ;
344
348
} else if ( this . state . workspaceInstance . status . conditions . failed ) {
345
349
stoppedReason = this . state . workspaceInstance . status . conditions . failed ;
346
350
} else if ( this . state . workspaceInstance . status . message ) {
347
351
stoppedReason = this . state . workspaceInstance . status . message ;
348
352
}
349
- if ( stoppedReason ) {
350
- // capitalize message
351
- stoppedReason = stoppedReason . charAt ( 0 ) . toUpperCase ( ) + stoppedReason . slice ( 1 ) ;
353
+ // capitalize message
354
+ stoppedReason = stoppedReason . charAt ( 0 ) . toUpperCase ( ) + stoppedReason . slice ( 1 ) ;
352
355
353
- if ( ! stoppedReason . endsWith ( "." ) ) {
354
- stoppedReason += "." ;
356
+ if ( ! stoppedReason . endsWith ( "." ) ) {
357
+ stoppedReason += "." ;
358
+ }
359
+
360
+ const pendingChanges : { message : string , items : string [ ] } [ ] = [ ] ;
361
+ const repo = this . state . workspaceInstance && this . state . workspaceInstance . status && this . state . workspaceInstance . status . repo ;
362
+ if ( repo ) {
363
+ if ( repo . totalUncommitedFiles || 0 > 0 ) {
364
+ pendingChanges . push ( {
365
+ message : repo . totalUncommitedFiles === 1 ? 'an uncommited file' : `${ repo . totalUncommitedFiles } uncommited files` ,
366
+ items : repo . uncommitedFiles || [ ]
367
+ } ) ;
368
+ }
369
+ if ( repo . totalUntrackedFiles || 0 > 0 ) {
370
+ pendingChanges . push ( {
371
+ message : repo . totalUntrackedFiles === 1 ? 'an untracked file' : `${ repo . totalUntrackedFiles } untracked files` ,
372
+ items : repo . untrackedFiles || [ ]
373
+ } ) ;
374
+ }
375
+ if ( repo . totalUnpushedCommits || 0 > 0 ) {
376
+ pendingChanges . push ( {
377
+ message : repo . totalUnpushedCommits === 1 ? 'an unpushed commit' : `${ repo . totalUnpushedCommits } unpushed commits` ,
378
+ items : repo . unpushedCommits || [ ]
379
+ } ) ;
355
380
}
356
- message = < React . Fragment >
357
- { message }
358
- < div className = 'message stopped-reason' > { stoppedReason } </ div >
359
- </ React . Fragment > ;
360
381
}
361
- }
362
- if ( this . state . workspaceInstance . status . phase === 'stopped' && this . props . workspaceId ) {
363
- const startUrl = new GitpodHostUrl ( window . location . toString ( ) ) . asStart ( this . props . workspaceId ) . toString ( ) ;
382
+
383
+ const urls = new GitpodHostUrl ( window . location . toString ( ) ) ;
384
+ const startUrl = urls . asStart ( this . props . workspaceId ) . toString ( ) ;
385
+ const ctxURL = new URL ( this . state . workspace ! . contextURL )
386
+ const host = "Back to " + ctxURL . host ;
364
387
message = < React . Fragment >
365
- { message }
366
- < div className = 'message start-action' > < Button className = 'button' variant = 'outlined' color = 'secondary' onClick = { ( ) => {
367
- this . redirectTo ( startUrl )
368
- } } > Start Workspace</ Button > </ div >
369
- </ React . Fragment > ;
388
+ < div className = 'message' >
389
+ < div style = { { display : '' } } >
390
+ < div style = { { fontWeight : 800 } } > { stoppedReason } </ div >
391
+ { pendingChanges . length === 0 ? < div style = { { color : colors . fontColor3 } } > There are no pending changes. All good.</ div > : (
392
+ < div style = { { margin : "20px auto" , width : '30%' , textAlign : 'left' , overflow : 'scroll' , maxHeight : 150 } } >
393
+ < div style = { { color : colors . brand2 , fontWeight : 800 } } > The workspace has pending changes. You can restart it to continue your work.</ div >
394
+ { pendingChanges . map ( c => {
395
+ return < React . Fragment >
396
+ < div style = { { marginLeft : 0 , color : colors . fontColor3 } } >
397
+ { c . message }
398
+ </ div >
399
+ { c . items . map ( i => {
400
+ return < div > < code style = { { marginLeft : 20 , whiteSpace : 'nowrap' } } >
401
+ - { i }
402
+ </ code > </ div >
403
+ } ) }
404
+ </ React . Fragment >
405
+ } ) }
406
+ </ div >
407
+ ) }
408
+ < div className = 'start-action' >
409
+ < Button className = 'button' variant = 'outlined' color = 'primary'
410
+ onClick = { ( ) => this . redirectTo ( this . state . workspace ! . contextURL ) } > { host } </ Button >
411
+ < Button className = 'button' variant = 'outlined' color = { pendingChanges . length !== 0 ? 'secondary' : 'primary' }
412
+ onClick = { ( ) => this . redirectTo ( startUrl ) } > Start Workspace</ Button > </ div >
413
+ </ div >
414
+ </ div >
415
+ </ React . Fragment > ;
370
416
}
371
417
}
372
418
0 commit comments