@@ -18,13 +18,17 @@ import { User } from "@gitpod/gitpod-protocol";
18
18
import { useLocation } from "react-router" ;
19
19
import { StartWorkspaceModalContext , StartWorkspaceModalKeyBinding } from "./start-workspace-modal-context" ;
20
20
import SelectIDEModal from "../settings/SelectIDEModal" ;
21
+ import Arrow from "../components/Arrow" ;
22
+ import ConfirmationModal from "../components/ConfirmationModal" ;
21
23
22
24
export interface WorkspacesProps { }
23
25
24
26
export interface WorkspacesState {
25
27
workspaces : WorkspaceInfo [ ] ;
26
28
isTemplateModelOpen : boolean ;
27
29
repos : WhitelistedRepository [ ] ;
30
+ showInactive : boolean ;
31
+ deleteModalVisible : boolean ;
28
32
}
29
33
30
34
export default function ( ) {
@@ -35,6 +39,8 @@ export default function () {
35
39
const [ activeWorkspaces , setActiveWorkspaces ] = useState < WorkspaceInfo [ ] > ( [ ] ) ;
36
40
const [ inactiveWorkspaces , setInactiveWorkspaces ] = useState < WorkspaceInfo [ ] > ( [ ] ) ;
37
41
const [ workspaceModel , setWorkspaceModel ] = useState < WorkspaceModel > ( ) ;
42
+ const [ showInactive , setShowInactive ] = useState < boolean > ( ) ;
43
+ const [ deleteModalVisible , setDeleteModalVisible ] = useState < boolean > ( ) ;
38
44
const { setIsStartWorkspaceModalVisible } = useContext ( StartWorkspaceModalContext ) ;
39
45
40
46
useEffect ( ( ) => {
@@ -50,6 +56,18 @@ export default function () {
50
56
< >
51
57
< Header title = "Workspaces" subtitle = "Manage recent and stopped workspaces." />
52
58
59
+ < ConfirmationModal
60
+ title = "Delete Inactive Workspaces"
61
+ areYouSureText = "You are about to permanently delete your inactive workspaces."
62
+ buttonText = "Delete Inactive Workspaces"
63
+ visible = { ! ! deleteModalVisible }
64
+ onClose = { ( ) => setDeleteModalVisible ( false ) }
65
+ onConfirm = { ( ) => {
66
+ inactiveWorkspaces . forEach ( ( ws ) => workspaceModel ?. deleteWorkspace ( ws . workspace . id ) ) ;
67
+ setDeleteModalVisible ( false ) ;
68
+ } }
69
+ > </ ConfirmationModal >
70
+
53
71
{ isOnboardingUser && < SelectIDEModal location = { "workspace_list" } /> }
54
72
55
73
{ workspaceModel ?. initialized &&
@@ -128,27 +146,58 @@ export default function () {
128
146
} ) }
129
147
{ activeWorkspaces . length > 0 && < div className = "py-6" > </ div > }
130
148
{ inactiveWorkspaces . length > 0 && (
131
- < div className = "p-3 text-gray-400 bg-gray-50 dark:bg-gray-800 rounded-xl text-sm text-center" >
132
- Unpinned workspaces that have been inactive for more than 14 days will be
133
- automatically deleted.{ " " }
134
- < a
135
- className = "gp-link"
136
- href = "https://www.gitpod.io/docs/life-of-workspace/#garbage-collection"
149
+ < div className = "pt-14" >
150
+ < div className = "border-t border-gray-200 dark:border-gray-800" > </ div >
151
+ < div
152
+ onClick = { ( ) => setShowInactive ( ! showInactive ) }
153
+ className = "flex cursor-pointer py-6"
137
154
>
138
- Learn more
139
- </ a >
155
+ < div className = "flex flex-col" >
156
+ < h2 className = "" > Inactive Workspaces</ h2 >
157
+ </ div >
158
+ < div >
159
+ < Arrow
160
+ up = { ! ! showInactive }
161
+ customBorderClasses = "text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-400"
162
+ />
163
+ </ div >
164
+ </ div >
165
+ { showInactive ? (
166
+ < >
167
+ < div className = "flex flex-row p-3 text-gray-400 bg-gray-50 dark:bg-gray-800 rounded-xl" >
168
+ < div className = "text-sm flex-auto py-3" >
169
+ Unpinned workspaces that have been inactive for more than 14 days
170
+ will be automatically deleted.{ " " }
171
+ < a
172
+ className = "gp-link"
173
+ href = "https://www.gitpod.io/docs/life-of-workspace/#garbage-collection"
174
+ >
175
+ Learn more
176
+ </ a >
177
+ </ div >
178
+ < button
179
+ onClick = { ( ) => setDeleteModalVisible ( true ) }
180
+ className = "ml-2 danger secondary w-64 p-2"
181
+ >
182
+ Delete Inactive Workspaces
183
+ </ button >
184
+ </ div >
185
+ { inactiveWorkspaces . map ( ( e ) => {
186
+ return (
187
+ < WorkspaceEntry
188
+ key = { e . workspace . id }
189
+ desc = { e }
190
+ model = { workspaceModel }
191
+ stopWorkspace = { ( wsId ) =>
192
+ getGitpodService ( ) . server . stopWorkspace ( wsId )
193
+ }
194
+ />
195
+ ) ;
196
+ } ) }
197
+ </ >
198
+ ) : null }
140
199
</ div >
141
200
) }
142
- { inactiveWorkspaces . map ( ( e ) => {
143
- return (
144
- < WorkspaceEntry
145
- key = { e . workspace . id }
146
- desc = { e }
147
- model = { workspaceModel }
148
- stopWorkspace = { ( wsId ) => getGitpodService ( ) . server . stopWorkspace ( wsId ) }
149
- />
150
- ) ;
151
- } ) }
152
201
</ ItemsList >
153
202
</ >
154
203
) : (
0 commit comments