@@ -16,18 +16,18 @@ import withOrganization from 'app/utils/withOrganization';
16
16
import withGlobalSelection from 'app/utils/withGlobalSelection' ;
17
17
import LoadingIndicator from 'app/components/loadingIndicator' ;
18
18
import LightWeightNoProjectMessage from 'app/components/lightWeightNoProjectMessage' ;
19
- import IntroBanner from 'app/views/releasesV2/list/introBanner' ;
20
19
import { PageContent , PageHeader } from 'app/styles/organization' ;
21
20
import EmptyStateWarning from 'app/components/emptyStateWarning' ;
22
- import ReleaseCard from 'app/views/releasesV2/list/releaseCard' ;
23
21
import GlobalSelectionHeader from 'app/components/organizations/globalSelectionHeader' ;
24
22
import { getRelativeSummary } from 'app/components/organizations/timeRangeSelector/utils' ;
25
23
import { DEFAULT_STATS_PERIOD } from 'app/constants' ;
26
24
import { defined } from 'app/utils' ;
27
25
28
26
import ReleaseListSortOptions from './releaseListSortOptions' ;
29
27
import ReleasePromo from './releasePromo' ;
28
+ import IntroBanner from './introBanner' ;
30
29
import SwitchReleasesButton from '../utils/switchReleasesButton' ;
30
+ import ReleaseCard from './releaseCard' ;
31
31
32
32
type RouteParams = {
33
33
orgId : string ;
@@ -38,7 +38,10 @@ type Props = RouteComponentProps<RouteParams, {}> & {
38
38
selection : GlobalSelection ;
39
39
} ;
40
40
41
- type State = { releases : Release [ ] } & AsyncView [ 'state' ] ;
41
+ type State = {
42
+ releases : Release [ ] ;
43
+ loadingHealth : boolean ;
44
+ } & AsyncView [ 'state' ] ;
42
45
43
46
class ReleasesList extends AsyncView < Props , State > {
44
47
shouldReload = true ;
@@ -47,15 +50,10 @@ class ReleasesList extends AsyncView<Props, State> {
47
50
return routeTitleGen ( t ( 'Releases' ) , this . props . organization . slug , false ) ;
48
51
}
49
52
50
- getDefaultState ( ) {
51
- return {
52
- ...super . getDefaultState ( ) ,
53
- } ;
54
- }
55
-
56
- getEndpoints ( ) : [ string , string , { } ] [ ] {
53
+ getEndpoints ( ) {
57
54
const { organization, location} = this . props ;
58
- const { statsPeriod, sort} = location . query ;
55
+ const { statsPeriod} = location . query ;
56
+ const sort = this . getSort ( ) ;
59
57
60
58
const query = {
61
59
...pick ( location . query , [
@@ -68,15 +66,43 @@ class ReleasesList extends AsyncView<Props, State> {
68
66
'healthStat' ,
69
67
] ) ,
70
68
summaryStatsPeriod : statsPeriod ,
71
- per_page : 50 ,
69
+ per_page : 25 ,
72
70
health : 1 ,
73
- flatten : ! sort || sort === 'date' ? 0 : 1 ,
71
+ flatten : sort === 'date' ? 0 : 1 ,
74
72
} ;
75
73
76
- return [ [ 'releases' , `/organizations/${ organization . slug } /releases/` , { query} ] ] ;
74
+ const endpoints : ReturnType < AsyncView [ 'getEndpoints' ] > = [
75
+ [ 'releasesWithHealth' , `/organizations/${ organization . slug } /releases/` , { query} ] ,
76
+ ] ;
77
+
78
+ // when sorting by date we fetch releases without health and then fetch health lazily
79
+ if ( sort === 'date' ) {
80
+ endpoints . push ( [
81
+ 'releasesWithoutHealth' ,
82
+ `/organizations/${ organization . slug } /releases/` ,
83
+ { query : { ...query , health : 0 } } ,
84
+ ] ) ;
85
+ }
86
+
87
+ return endpoints ;
88
+ }
89
+
90
+ onRequestSuccess ( { stateKey, data, jqXHR} ) {
91
+ const { remainingRequests} = this . state ;
92
+
93
+ // make sure there's no withHealth/withoutHealth race condition and set proper loading state
94
+ if ( stateKey === 'releasesWithHealth' || remainingRequests === 1 ) {
95
+ this . setState ( {
96
+ reloading : false ,
97
+ loading : false ,
98
+ loadingHealth : stateKey === 'releasesWithoutHealth' ,
99
+ releases : data ,
100
+ releasesPageLinks : jqXHR ?. getResponseHeader ( 'Link' ) ,
101
+ } ) ;
102
+ }
77
103
}
78
104
79
- componentDidUpdate ( prevProps , prevState ) {
105
+ componentDidUpdate ( prevProps : Props , prevState : State ) {
80
106
super . componentDidUpdate ( prevProps , prevState ) ;
81
107
82
108
if ( prevState . releases !== this . state . releases ) {
@@ -176,7 +202,7 @@ class ReleasesList extends AsyncView<Props, State> {
176
202
177
203
renderInnerBody ( ) {
178
204
const { location, selection, organization} = this . props ;
179
- const { releases, reloading} = this . state ;
205
+ const { releases, reloading, loadingHealth } = this . state ;
180
206
181
207
if ( this . shouldShowLoadingIndicator ( ) ) {
182
208
return < LoadingIndicator /> ;
@@ -194,12 +220,14 @@ class ReleasesList extends AsyncView<Props, State> {
194
220
selection = { selection }
195
221
reloading = { reloading }
196
222
key = { `${ release . version } -${ release . projects [ 0 ] . slug } ` }
223
+ showHealthPlaceholders = { loadingHealth }
197
224
/>
198
225
) ) ;
199
226
}
200
227
201
228
renderBody ( ) {
202
229
const { organization} = this . props ;
230
+ const { releasesPageLinks} = this . state ;
203
231
204
232
return (
205
233
< GlobalSelectionHeader
@@ -229,7 +257,7 @@ class ReleasesList extends AsyncView<Props, State> {
229
257
230
258
{ this . renderInnerBody ( ) }
231
259
232
- < Pagination pageLinks = { this . state . releasesPageLinks } />
260
+ < Pagination pageLinks = { releasesPageLinks } />
233
261
234
262
{ ! this . shouldShowLoadingIndicator ( ) && (
235
263
< SwitchReleasesButton version = "1" orgId = { organization . id } />
0 commit comments