@@ -14,10 +14,11 @@ import { getGitpodService, gitpodHostUrl } from "../service/service";
14
14
import { TeamsContext , getCurrentTeam } from "../teams/teams-context" ;
15
15
import { prebuildStatusIcon , prebuildStatusLabel } from "./Prebuilds" ;
16
16
import { shortCommitMessage , toRemoteURL } from "./render-utils" ;
17
- import Spinner from "../icons/Spinner.svg" ;
17
+ import { ReactComponent as Spinner } from "../icons/Spinner.svg" ;
18
18
import NoAccess from "../icons/NoAccess.svg" ;
19
19
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error" ;
20
20
import { openAuthorizeWindow } from "../provider-utils" ;
21
+ import Alert from "../components/Alert" ;
21
22
22
23
export default function ( ) {
23
24
const location = useLocation ( ) ;
@@ -34,6 +35,8 @@ export default function () {
34
35
const [ isLoading , setIsLoading ] = useState < boolean > ( false ) ;
35
36
const [ isLoadingBranches , setIsLoadingBranches ] = useState < boolean > ( false ) ;
36
37
const [ branches , setBranches ] = useState < Project . BranchDetails [ ] > ( [ ] ) ;
38
+ const [ isConsideredInactive , setIsConsideredInactive ] = useState < boolean > ( false ) ;
39
+ const [ isResuming , setIsResuming ] = useState < boolean > ( false ) ;
37
40
const [ prebuilds , setPrebuilds ] = useState < Map < string , PrebuildWithStatus | undefined > > ( new Map ( ) ) ;
38
41
const [ prebuildLoaders ] = useState < Set < string > > ( new Set ( ) ) ;
39
42
@@ -91,6 +94,7 @@ export default function () {
91
94
// default branch on top of the rest
92
95
const branches = details . branches . sort ( ( a , b ) => ( b . isDefault as any ) - ( a . isDefault as any ) ) || [ ] ;
93
96
setBranches ( branches ) ;
97
+ setIsConsideredInactive ( ! ! details . isConsideredInactive ) ;
94
98
}
95
99
} finally {
96
100
setIsLoadingBranches ( false ) ;
@@ -184,6 +188,22 @@ export default function () {
184
188
return date ? dayjs ( date ) . fromNow ( ) : "" ;
185
189
} ;
186
190
191
+ const resumePrebuilds = async ( ) => {
192
+ if ( ! project ) {
193
+ return ;
194
+ }
195
+ try {
196
+ setIsResuming ( true ) ;
197
+ const response = await getGitpodService ( ) . server . triggerPrebuild ( project . id , null ) ;
198
+ setIsConsideredInactive ( false ) ;
199
+ history . push ( `/${ ! ! team ? "t/" + team . slug : "projects" } /${ projectSlug } /${ response . prebuildId } ` ) ;
200
+ } catch ( error ) {
201
+ console . error ( error ) ;
202
+ } finally {
203
+ setIsResuming ( false ) ;
204
+ }
205
+ } ;
206
+
187
207
return (
188
208
< >
189
209
< Header
@@ -243,7 +263,7 @@ export default function () {
243
263
< div className = "flex-1" />
244
264
{ isLoading && (
245
265
< div className = "flex justify-center w-1/12" >
246
- < img alt = "" className = "h-4 w-4 animate-spin" src = { Spinner } />
266
+ < Spinner className = "h-4 w-4 animate-spin" />
247
267
</ div >
248
268
) }
249
269
</ div >
@@ -259,9 +279,34 @@ export default function () {
259
279
< span > Prebuild</ span >
260
280
</ ItemField >
261
281
</ Item >
282
+ { isConsideredInactive && (
283
+ < Alert
284
+ type = { "warning" }
285
+ onClose = { ( ) => { } }
286
+ showIcon = { true }
287
+ className = "flex rounded mb-2 w-full"
288
+ >
289
+ To reduce resource usage, prebuilds are automatically paused when not used for a
290
+ workspace after 7 days.{ " " }
291
+ { isResuming && (
292
+ < >
293
+ Resuming < Spinner className = "h-4 w-4 animate-spin" />
294
+ </ >
295
+ ) }
296
+ { ! isResuming && (
297
+ < a
298
+ href = "javascript:void(0)"
299
+ className = "gp-link hover:text-gray-600"
300
+ onClick = { ( ) => resumePrebuilds ( ) }
301
+ >
302
+ Resume prebuilds
303
+ </ a >
304
+ ) }
305
+ </ Alert >
306
+ ) }
262
307
{ isLoadingBranches && (
263
308
< div className = "flex items-center justify-center space-x-2 text-gray-400 text-sm pt-16 pb-40" >
264
- < img className = "h-4 w-4 animate-spin" src = { Spinner } />
309
+ < Spinner className = "h-4 w-4 animate-spin" />
265
310
< span > Fetching repository branches...</ span >
266
311
</ div >
267
312
) }
0 commit comments