@@ -21,9 +21,9 @@ import { ReactComponent as ICError } from '@Icons/ic-error.svg'
2121import ErrorScreenManager from '@Common/ErrorScreenManager'
2222import { useAsync } from '@Common/Helper'
2323import { useUrlFilters } from '@Common/Hooks'
24- import { GenericEmptyState , InfoColourBar } from '@Common/index'
24+ import { GenericEmptyState , InfoColourBar , SortingOrder } from '@Common/index'
2525import { Progressing } from '@Common/Progressing'
26- import { getAppEnvDeploymentConfigList } from '@Shared/Components/DeploymentConfigDiff'
26+ import { DEPLOYMENT_CONFIG_DIFF_SORT_KEY , getAppEnvDeploymentConfigList } from '@Shared/Components/DeploymentConfigDiff'
2727import { groupArrayByObjectKey } from '@Shared/Helpers'
2828import { useMainContext } from '@Shared/Providers'
2929import { EnvResourceType , getAppEnvDeploymentConfig , getCompareSecretsData } from '@Shared/Services'
@@ -125,7 +125,7 @@ export const DeploymentHistoryConfigDiff = ({
125125 `${ generatePath ( path , { ...params } ) } /${ resourceType } ${ resourceName ? `/${ resourceName } ` : '' } ${ search } `
126126
127127 // Generate the deployment history config list
128- const deploymentConfigList = useMemo ( ( ) => {
128+ const { deploymentConfigList, sortedDeploymentConfigList } = useMemo ( ( ) => {
129129 if ( ! compareDeploymentConfigLoader && compareDeploymentConfig ) {
130130 const compareList =
131131 isPreviousDeploymentConfigAvailable && compareDeploymentConfig [ 1 ] . status === 'fulfilled'
@@ -140,17 +140,30 @@ export const DeploymentHistoryConfigDiff = ({
140140 const currentList =
141141 compareDeploymentConfig [ 0 ] . status === 'fulfilled' ? compareDeploymentConfig [ 0 ] . value . result : null
142142
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.
143145 const configData = getAppEnvDeploymentConfigList ( {
144146 currentList,
145147 compareList,
146148 getNavItemHref,
147149 convertVariables,
148150 sortingConfig : { sortBy, sortOrder } ,
149151 } )
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 }
151164 }
152165
153- return null
166+ return { deploymentConfigList : null , sortedDeploymentConfigList : null }
154167 } , [
155168 isPreviousDeploymentConfigAvailable ,
156169 compareDeploymentConfigLoader ,
@@ -170,8 +183,11 @@ export const DeploymentHistoryConfigDiff = ({
170183 )
171184
172185 const groupedDeploymentConfigList = useMemo (
173- ( ) => ( deploymentConfigList ? groupArrayByObjectKey ( deploymentConfigList . configList , 'groupHeader' ) : [ ] ) ,
174- [ deploymentConfigList ] ,
186+ ( ) =>
187+ sortedDeploymentConfigList
188+ ? groupArrayByObjectKey ( sortedDeploymentConfigList . configList , 'groupHeader' )
189+ : [ ] ,
190+ [ sortedDeploymentConfigList ] ,
175191 )
176192
177193 /** Previous deployment config has 404 error. */
0 commit comments