@@ -21,9 +21,9 @@ import { ReactComponent as ICError } from '@Icons/ic-error.svg'
21
21
import ErrorScreenManager from '@Common/ErrorScreenManager'
22
22
import { useAsync } from '@Common/Helper'
23
23
import { useUrlFilters } from '@Common/Hooks'
24
- import { GenericEmptyState , InfoColourBar } from '@Common/index'
24
+ import { GenericEmptyState , InfoColourBar , SortingOrder } from '@Common/index'
25
25
import { Progressing } from '@Common/Progressing'
26
- import { getAppEnvDeploymentConfigList } from '@Shared/Components/DeploymentConfigDiff'
26
+ import { DEPLOYMENT_CONFIG_DIFF_SORT_KEY , getAppEnvDeploymentConfigList } from '@Shared/Components/DeploymentConfigDiff'
27
27
import { groupArrayByObjectKey } from '@Shared/Helpers'
28
28
import { useMainContext } from '@Shared/Providers'
29
29
import { EnvResourceType , getAppEnvDeploymentConfig , getCompareSecretsData } from '@Shared/Services'
@@ -125,7 +125,7 @@ export const DeploymentHistoryConfigDiff = ({
125
125
`${ generatePath ( path , { ...params } ) } /${ resourceType } ${ resourceName ? `/${ resourceName } ` : '' } ${ search } `
126
126
127
127
// Generate the deployment history config list
128
- const deploymentConfigList = useMemo ( ( ) => {
128
+ const { deploymentConfigList, sortedDeploymentConfigList } = useMemo ( ( ) => {
129
129
if ( ! compareDeploymentConfigLoader && compareDeploymentConfig ) {
130
130
const compareList =
131
131
isPreviousDeploymentConfigAvailable && compareDeploymentConfig [ 1 ] . status === 'fulfilled'
@@ -140,17 +140,30 @@ export const DeploymentHistoryConfigDiff = ({
140
140
const currentList =
141
141
compareDeploymentConfig [ 0 ] . status === 'fulfilled' ? compareDeploymentConfig [ 0 ] . value . result : null
142
142
143
+ // This data is displayed on the deployment history diff view page.
144
+ // It requires dynamic sorting based on the current sortBy and sortOrder, which the user can modify using the Sort Button.
143
145
const configData = getAppEnvDeploymentConfigList ( {
144
146
currentList,
145
147
compareList,
146
148
getNavItemHref,
147
149
convertVariables,
148
150
sortingConfig : { sortBy, sortOrder } ,
149
151
} )
150
- return configData
152
+
153
+ // Sorting is hardcoded here because this data is displayed on the deployment history configuration tab.
154
+ // The diff needs to be shown on sorted data, and no additional sorting will be applied.
155
+ const sortedConfigData = getAppEnvDeploymentConfigList ( {
156
+ currentList,
157
+ compareList,
158
+ getNavItemHref,
159
+ convertVariables,
160
+ sortingConfig : { sortBy : DEPLOYMENT_CONFIG_DIFF_SORT_KEY , sortOrder : SortingOrder . ASC } ,
161
+ } )
162
+
163
+ return { deploymentConfigList : configData , sortedDeploymentConfigList : sortedConfigData }
151
164
}
152
165
153
- return null
166
+ return { deploymentConfigList : null , sortedDeploymentConfigList : null }
154
167
} , [
155
168
isPreviousDeploymentConfigAvailable ,
156
169
compareDeploymentConfigLoader ,
@@ -170,8 +183,11 @@ export const DeploymentHistoryConfigDiff = ({
170
183
)
171
184
172
185
const groupedDeploymentConfigList = useMemo (
173
- ( ) => ( deploymentConfigList ? groupArrayByObjectKey ( deploymentConfigList . configList , 'groupHeader' ) : [ ] ) ,
174
- [ deploymentConfigList ] ,
186
+ ( ) =>
187
+ sortedDeploymentConfigList
188
+ ? groupArrayByObjectKey ( sortedDeploymentConfigList . configList , 'groupHeader' )
189
+ : [ ] ,
190
+ [ sortedDeploymentConfigList ] ,
175
191
)
176
192
177
193
/** Previous deployment config has 404 error. */
0 commit comments