@@ -9,8 +9,9 @@ import { GitpodHostUrl } from '@gitpod/gitpod-protocol/lib/util/gitpod-host-url'
9
9
import ContextMenu , { ContextMenuEntry } from '../components/ContextMenu' ;
10
10
import moment from 'moment' ;
11
11
import Modal from '../components/Modal' ;
12
- import { MouseEvent , useState } from 'react' ;
12
+ import { useState } from 'react' ;
13
13
import { WorkspaceModel } from './workspace-model' ;
14
+ import PendingChangesDropdown from '../components/PendingChangesDropdown' ;
14
15
import Tooltip from '../components/Tooltip' ;
15
16
16
17
function getLabel ( state : WorkspaceInstancePhase ) {
@@ -26,16 +27,7 @@ interface Props {
26
27
27
28
export function WorkspaceEntry ( { desc, model, isAdmin, stopWorkspace } : Props ) {
28
29
const [ isModalVisible , setModalVisible ] = useState ( false ) ;
29
- const [ isChangesModalVisible , setChangesModalVisible ] = useState ( false ) ;
30
30
const state : WorkspaceInstancePhase = desc . latestInstance ?. status ?. phase || 'stopped' ;
31
- const pendingChanges = getPendingChanges ( desc . latestInstance ) ;
32
- const numberOfChanges = pendingChanges . reduceRight ( ( i , c ) => i + c . items . length , 0 )
33
- let changesLabel = 'No Changes' ;
34
- if ( numberOfChanges === 1 ) {
35
- changesLabel = '1 Change' ;
36
- } else if ( numberOfChanges > 1 ) {
37
- changesLabel = numberOfChanges + ' Changes' ;
38
- }
39
31
const currentBranch = desc . latestInstance ?. status . repo ?. branch || Workspace . getBranchName ( desc . workspace ) || '<unknown>' ;
40
32
const ws = desc . workspace ;
41
33
const startUrl = new GitpodHostUrl ( window . location . href ) . with ( {
@@ -88,10 +80,6 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
88
80
) ;
89
81
}
90
82
const project = getProject ( ws ) ;
91
- const showChanges = ( event : MouseEvent ) => {
92
- event . preventDefault ( ) ;
93
- setChangesModalVisible ( true ) ;
94
- }
95
83
return < div >
96
84
< div className = "rounded-xl whitespace-nowrap flex space-x-2 py-6 px-6 w-full justify-between hover:bg-gray-100 dark:hover:bg-gray-800 focus:bg-gitpod-kumquat-light group" >
97
85
< div className = "pr-3 self-center" >
@@ -109,16 +97,9 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
109
97
</ a >
110
98
</ div >
111
99
</ div >
112
- < div className = "flex w-2/12 truncate" onClick = { numberOfChanges > 0 ? showChanges : undefined } >
113
- < div className = "flex flex-col" >
114
- < div className = "text-gray-500 truncate" > { currentBranch } </ div >
115
- {
116
- numberOfChanges > 0 ?
117
- < div className = { "text-sm text-red-600 truncate cursor-pointer bg-red-50 group-hover:bg-red-100 hover:text-red-800 px-1.5 py-0.5 relative rounded-md -top-0.5" } onClick = { showChanges } > { changesLabel } </ div >
118
- :
119
- < div className = "text-sm text-gray-400 truncate " > No Changes</ div >
120
- }
121
- </ div >
100
+ < div className = "flex flex-col items-start w-2/12" >
101
+ < div className = "text-gray-500 truncate" > { currentBranch } </ div >
102
+ < PendingChangesDropdown workspaceInstance = { desc . latestInstance } />
122
103
</ div >
123
104
< div className = "flex w-2/12 self-center" >
124
105
< Tooltip content = { `Created ${ moment ( desc . workspace . creationTime ) . fromNow ( ) } ` } >
@@ -131,9 +112,6 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
131
112
</ ContextMenu >
132
113
</ div >
133
114
</ div >
134
- < Modal visible = { isChangesModalVisible } onClose = { ( ) => setChangesModalVisible ( false ) } >
135
- { getChangesPopup ( pendingChanges ) }
136
- </ Modal >
137
115
{ isModalVisible && < Modal visible = { isModalVisible } onClose = { ( ) => setModalVisible ( false ) } >
138
116
< div >
139
117
< h3 className = "pb-2" > Delete Workspace</ h3 >
@@ -155,36 +133,6 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
155
133
</ div > ;
156
134
}
157
135
158
- export interface PendingChanges {
159
- message : string , items : string [ ]
160
- }
161
-
162
- export function getPendingChanges ( wsi ?: WorkspaceInstance ) : PendingChanges [ ] {
163
- const pendingChanges : { message : string , items : string [ ] } [ ] = [ ] ;
164
- const repo = wsi ?. status . repo ;
165
- if ( repo ) {
166
- if ( repo . totalUncommitedFiles || 0 > 0 ) {
167
- pendingChanges . push ( {
168
- message : repo . totalUncommitedFiles === 1 ? 'an uncommited file' : `${ repo . totalUncommitedFiles } uncommited files` ,
169
- items : repo . uncommitedFiles || [ ]
170
- } ) ;
171
- }
172
- if ( repo . totalUntrackedFiles || 0 > 0 ) {
173
- pendingChanges . push ( {
174
- message : repo . totalUntrackedFiles === 1 ? 'an untracked file' : `${ repo . totalUntrackedFiles } untracked files` ,
175
- items : repo . untrackedFiles || [ ]
176
- } ) ;
177
- }
178
- if ( repo . totalUnpushedCommits || 0 > 0 ) {
179
- pendingChanges . push ( {
180
- message : repo . totalUnpushedCommits === 1 ? 'an unpushed commit' : `${ repo . totalUnpushedCommits } unpushed commits` ,
181
- items : repo . unpushedCommits || [ ]
182
- } ) ;
183
- }
184
- }
185
- return pendingChanges ;
186
- }
187
-
188
136
export function getProject ( ws : Workspace ) {
189
137
if ( CommitContext . is ( ws . context ) ) {
190
138
return `${ ws . context . repository . host } /${ ws . context . repository . owner } /${ ws . context . repository . name } ` ;
@@ -193,17 +141,6 @@ export function getProject(ws: Workspace) {
193
141
}
194
142
}
195
143
196
- export function getChangesPopup ( changes : PendingChanges [ ] ) {
197
- return < div className = "flex flex-col space-y-4 w-96" >
198
- { changes . map ( c => {
199
- return < div className = "" >
200
- < div className = "text-gray-500" > { c . message } </ div >
201
- { c . items . map ( i => < div className = "text-gray-400 text-xs" > { i } </ div > ) }
202
- </ div > ;
203
- } ) }
204
- </ div >
205
- }
206
-
207
144
export function WorkspaceStatusIndicator ( { instance} : { instance ?: WorkspaceInstance } ) {
208
145
const state : WorkspaceInstancePhase = instance ?. status ?. phase || 'stopped' ;
209
146
let stateClassName = 'rounded-full w-3 h-3 text-sm align-middle' ;
0 commit comments