@@ -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,20 @@ 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
+ const response = await getGitpodService ( ) . server . triggerPrebuild ( project . id , null ) ;
197
+ setIsConsideredInactive ( false ) ;
198
+ setIsResuming ( false ) ;
199
+ history . push ( `/${ ! ! team ? "t/" + team . slug : "projects" } /${ projectSlug } /${ response . prebuildId } ` ) ;
200
+ } catch ( error ) {
201
+ console . error ( error ) ;
202
+ }
203
+ } ;
204
+
187
205
return (
188
206
< >
189
207
< Header
@@ -243,7 +261,7 @@ export default function () {
243
261
< div className = "flex-1" />
244
262
{ isLoading && (
245
263
< div className = "flex justify-center w-1/12" >
246
- < img alt = "" className = "h-4 w-4 animate-spin" src = { Spinner } />
264
+ < Spinner className = "h-4 w-4 animate-spin" />
247
265
</ div >
248
266
) }
249
267
</ div >
@@ -259,9 +277,34 @@ export default function () {
259
277
< span > Prebuild</ span >
260
278
</ ItemField >
261
279
</ Item >
280
+ { isConsideredInactive && (
281
+ < Alert
282
+ type = { "warning" }
283
+ onClose = { ( ) => { } }
284
+ showIcon = { true }
285
+ className = "flex rounded mb-2 w-full"
286
+ >
287
+ To reduce resource usage, prebuilds are automatically paused when not used for a
288
+ workspace after 7 days.{ " " }
289
+ { isResuming && (
290
+ < >
291
+ Resuming < Spinner className = "h-4 w-4 animate-spin" />
292
+ </ >
293
+ ) }
294
+ { ! isResuming && (
295
+ < a
296
+ href = "javascript:void(0)"
297
+ className = "gp-link hover:text-gray-600"
298
+ onClick = { ( ) => resumePrebuilds ( ) }
299
+ >
300
+ Resume prebuilds
301
+ </ a >
302
+ ) }
303
+ </ Alert >
304
+ ) }
262
305
{ isLoadingBranches && (
263
306
< 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 } />
307
+ < Spinner className = "h-4 w-4 animate-spin" />
265
308
< span > Fetching repository branches...</ span >
266
309
</ div >
267
310
) }
0 commit comments