1
- import { useCallback , useEffect , useState } from 'react' ;
1
+ import { useCallback , useEffect , useMemo , useState } from 'react' ;
2
2
3
3
import { Build , GroupBuild } from 'pnc-api-types-ts' ;
4
4
5
5
import { breadcrumbData } from 'common/breadcrumbData' ;
6
+ import { buildEntityAttributes } from 'common/buildEntityAttributes' ;
6
7
import { groupBuildEntityAttributes } from 'common/groupBuildEntityAttributes' ;
7
8
8
9
import { useComponentQueryParams } from 'hooks/useComponentQueryParams' ;
9
10
import { useParamsRequired } from 'hooks/useParamsRequired' ;
10
11
import {
12
+ hasBrewPushFinished ,
11
13
hasBuildStarted ,
12
14
hasBuildStatusChanged ,
13
15
hasGroupBuildStatusChanged ,
@@ -39,7 +41,18 @@ import * as groupBuildApi from 'services/groupBuildApi';
39
41
40
42
import { refreshPage } from 'utils/refreshHelper' ;
41
43
import { generatePageTitle } from 'utils/titleHelper' ;
42
- import { createDateTime } from 'utils/utils' ;
44
+ import { createDateTime , debounce } from 'utils/utils' ;
45
+
46
+ const buildsListColumns = [
47
+ buildEntityAttributes . status . id ,
48
+ buildEntityAttributes . name . id ,
49
+ buildEntityAttributes . buildConfigName . id ,
50
+ buildEntityAttributes . submitTime . id ,
51
+ buildEntityAttributes . startTime . id ,
52
+ buildEntityAttributes . endTime . id ,
53
+ buildEntityAttributes [ 'user.username' ] . id ,
54
+ buildEntityAttributes . brewPush . id ,
55
+ ] ;
43
56
44
57
interface IGroupBuildDetailPageProps {
45
58
componentId ?: string ;
@@ -56,10 +69,15 @@ export const GroupBuildDetailPage = ({ componentId = 'gb2' }: IGroupBuildDetailP
56
69
const serviceContainerGroupBuildRunner = serviceContainerGroupBuild . run ;
57
70
const serviceContainerGroupBuildSetter = serviceContainerGroupBuild . setData ;
58
71
59
- const serviceContainerGroupBuildBuilds = useServiceContainer ( groupBuildApi . getBuilds ) ;
72
+ const serviceContainerGroupBuildBuilds = useServiceContainer ( groupBuildApi . getBuildsWithBrewPush ) ;
60
73
const serviceContainerGroupBuildBuildsRunner = serviceContainerGroupBuildBuilds . run ;
61
74
const serviceContainerGroupBuildBuildsSetter = serviceContainerGroupBuildBuilds . setData ;
62
75
76
+ const serviceContainerGroupBuildBuildsRunnerDebounced = useMemo (
77
+ ( ) => debounce ( serviceContainerGroupBuildBuildsRunner ) ,
78
+ [ serviceContainerGroupBuildBuildsRunner ]
79
+ ) ;
80
+
63
81
const serviceContainerDependencyGraph = useServiceContainer ( groupBuildApi . getDependencyGraph ) ;
64
82
const serviceContainerDependencyGraphRunner = serviceContainerDependencyGraph . run ;
65
83
const serviceContainerDependencyGraphSetter = serviceContainerDependencyGraph . setData ;
@@ -83,7 +101,7 @@ export const GroupBuildDetailPage = ({ componentId = 'gb2' }: IGroupBuildDetailP
83
101
serviceContainerGroupBuildSetter ( wsGroupBuild ) ;
84
102
} else if ( hasBuildStarted ( wsData , { groupBuildId } ) ) {
85
103
// very exceptional use case, mostly it means backend issues
86
- serviceContainerGroupBuildBuildsRunner ( {
104
+ serviceContainerGroupBuildBuildsRunnerDebounced ( {
87
105
serviceData : { id : groupBuildId } ,
88
106
requestConfig : { params : groupBuildBuildsComponentQueryParamsObject } ,
89
107
} ) ;
@@ -102,15 +120,25 @@ export const GroupBuildDetailPage = ({ componentId = 'gb2' }: IGroupBuildDetailP
102
120
vertices : { ...serviceContainerDependencyGraph . data . vertices , [ wsBuild . id ] : updatedVertex } ,
103
121
} ) ;
104
122
}
123
+ } else if (
124
+ hasBrewPushFinished ( wsData , {
125
+ buildIds : serviceContainerGroupBuildBuilds . data ?. content ?. map ( ( build ) => build . id ) ?? [ ] ,
126
+ } )
127
+ ) {
128
+ serviceContainerGroupBuildBuildsRunnerDebounced ( {
129
+ serviceData : { id : groupBuildId } ,
130
+ requestConfig : { params : groupBuildBuildsComponentQueryParamsObject } ,
131
+ } ) ;
105
132
}
106
133
} ,
107
134
[
108
135
serviceContainerGroupBuildSetter ,
109
136
groupBuildId ,
110
- serviceContainerGroupBuildBuildsRunner ,
137
+ serviceContainerGroupBuildBuildsRunnerDebounced ,
111
138
serviceContainerGroupBuildBuildsSetter ,
112
139
serviceContainerDependencyGraphSetter ,
113
140
serviceContainerDependencyGraph . data ,
141
+ serviceContainerGroupBuildBuilds . data ,
114
142
groupBuildBuildsComponentQueryParamsObject ,
115
143
]
116
144
)
@@ -187,6 +215,7 @@ export const GroupBuildDetailPage = ({ componentId = 'gb2' }: IGroupBuildDetailP
187
215
{ ...{
188
216
serviceContainerBuilds : serviceContainerGroupBuildBuilds ,
189
217
componentId,
218
+ columns : buildsListColumns ,
190
219
} }
191
220
/>
192
221
</ ContentBox >
0 commit comments