@@ -2,14 +2,15 @@ import { useEffect, useState } from 'react'
2
2
import { generatePath , useRouteMatch } from 'react-router-dom'
3
3
4
4
import { DeploymentConfigDiff , DeploymentConfigDiffProps } from '@Shared/Components/DeploymentConfigDiff'
5
- import { SortingOrder } from '@Common/Constants'
5
+ import { DEFAULT_BASE_PAGE_SIZE , SortingOrder } from '@Common/Constants'
6
6
import { useUrlFilters } from '@Common/Hooks'
7
7
import {
8
8
getSelectPickerOptionByValue ,
9
9
SelectPickerOptionType ,
10
10
SelectPickerVariantType ,
11
11
} from '@Shared/Components/SelectPicker'
12
12
import { ComponentSizeType } from '@Shared/constants'
13
+ import { Button , ButtonVariantType } from '@Shared/Components/Button'
13
14
14
15
import {
15
16
DeploymentHistoryDiffDetailedProps ,
@@ -19,8 +20,6 @@ import {
19
20
import { getPipelineDeployments , getPipelineDeploymentsOptions , parseDeploymentHistoryDiffSearchParams } from './utils'
20
21
import { getTriggerHistory } from '../service'
21
22
22
- const paginationSize = 20
23
-
24
23
export const DeploymentHistoryConfigDiffCompare = ( {
25
24
envName,
26
25
setFullScreenView,
@@ -51,7 +50,7 @@ export const DeploymentHistoryConfigDiffCompare = ({
51
50
const [ triggerHistory , setTriggerHistory ] = useState ( {
52
51
isLoading : false ,
53
52
data : initialTriggerHistory ,
54
- hasMore : initialTriggerHistory . size >= paginationSize ,
53
+ hasMore : initialTriggerHistory . size >= DEFAULT_BASE_PAGE_SIZE ,
55
54
} )
56
55
const [ pipelineDeployments , setPipelineDeployments ] = useState ( initialPipelineDeployments )
57
56
@@ -75,15 +74,15 @@ export const DeploymentHistoryConfigDiffCompare = ({
75
74
const { result } = await getTriggerHistory ( {
76
75
appId : + appId ,
77
76
envId : + envId ,
78
- pagination : { offset : paginationOffset , size : paginationSize } ,
77
+ pagination : { offset : paginationOffset , size : DEFAULT_BASE_PAGE_SIZE } ,
79
78
} )
80
79
const nextTriggerHistory = new Map ( ( result . cdWorkflows || [ ] ) . map ( ( item ) => [ item . id , item ] ) )
81
80
const updatedTriggerHistory = new Map ( [ ...triggerHistory . data , ...nextTriggerHistory ] )
82
81
83
82
setTriggerHistory ( {
84
83
isLoading : false ,
85
84
data : updatedTriggerHistory ,
86
- hasMore : result . cdWorkflows ?. length === paginationSize ,
85
+ hasMore : result . cdWorkflows ?. length === DEFAULT_BASE_PAGE_SIZE ,
87
86
} )
88
87
setPipelineDeployments ( getPipelineDeployments ( updatedTriggerHistory ) )
89
88
} catch {
@@ -93,6 +92,22 @@ export const DeploymentHistoryConfigDiffCompare = ({
93
92
94
93
const handleLoadMore = ( ) => fetchDeploymentHistory ( triggerHistory . data . size )
95
94
95
+ // RENDERERS
96
+ const renderOptionsFooter = ( ) =>
97
+ triggerHistory . hasMore ? (
98
+ < div className = "px-4" >
99
+ < Button
100
+ isLoading = { triggerHistory . isLoading }
101
+ onClick = { handleLoadMore }
102
+ dataTestId = "load-more-previous-deployments"
103
+ variant = { ButtonVariantType . borderLess }
104
+ text = "Load more"
105
+ size = { ComponentSizeType . small }
106
+ fullWidth
107
+ />
108
+ </ div >
109
+ ) : null
110
+
96
111
// DEPLOYMENT_CONFIG_DIFF_PROPS
97
112
const { currentDeployment, pipelineDeploymentsOptions } = getPipelineDeploymentsOptions ( {
98
113
pipelineDeployments,
@@ -125,11 +140,7 @@ export const DeploymentHistoryConfigDiffCompare = ({
125
140
onChange : deploymentSelectorOnChange ,
126
141
showSelectedOptionIcon : false ,
127
142
menuSize : ComponentSizeType . large ,
128
- loadMoreButtonConfig : {
129
- show : triggerHistory . hasMore ,
130
- isLoading : triggerHistory . isLoading ,
131
- onClick : handleLoadMore ,
132
- } ,
143
+ renderOptionsFooter,
133
144
} ,
134
145
} ,
135
146
]
0 commit comments