Skip to content

Commit 315a320

Browse files
committed
feat: DeploymentHistoryConfigDiff - uat changes, code refactor
1 parent e0fb0d3 commit 315a320

File tree

11 files changed

+74
-42
lines changed

11 files changed

+74
-42
lines changed

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryConfigDiff.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useMemo, useState } from 'react'
22
import { generatePath, Route, Switch, useLocation, useRouteMatch } from 'react-router-dom'
33

44
import { getAppEnvDeploymentConfigList } from '@Shared/Components/DeploymentConfigDiff'
5-
import { useAsync } from '@Common/Helper'
5+
import { capitalizeFirstLetter, useAsync } from '@Common/Helper'
66
import { EnvResourceType, getAppEnvDeploymentConfig } from '@Shared/Services'
77
import { groupArrayByObjectKey } from '@Shared/Helpers'
88
import ErrorScreenManager from '@Common/ErrorScreenManager'
@@ -114,17 +114,20 @@ export const DeploymentHistoryConfigDiff = ({
114114
)
115115

116116
const isLoading = compareDeploymentConfigLoader || (!compareDeploymentConfigErr && !deploymentConfigList)
117+
const errorConfig = {
118+
code: compareDeploymentConfigErr?.code,
119+
error: compareDeploymentConfigErr && !compareDeploymentConfigLoader,
120+
message: capitalizeFirstLetter(compareDeploymentConfigErr?.errors[0]?.userMessage || ''),
121+
reload: reloadCompareDeploymentConfig,
122+
}
123+
117124
return (
118125
<Switch>
119126
<Route path={`${path}/:resourceType(${Object.values(EnvResourceType).join('|')})/:resourceName?`}>
120127
<DeploymentHistoryConfigDiffCompare
121128
{...deploymentConfigList}
122129
isLoading={isLoading}
123-
errorConfig={{
124-
code: compareDeploymentConfigErr?.code,
125-
error: compareDeploymentConfigErr && !compareDeploymentConfigLoader,
126-
reload: reloadCompareDeploymentConfig,
127-
}}
130+
errorConfig={errorConfig}
128131
envName={envName}
129132
wfrId={wfrId}
130133
previousWfrId={previousWfrId}
@@ -140,8 +143,9 @@ export const DeploymentHistoryConfigDiff = ({
140143
<Route>
141144
{compareDeploymentConfigErr && !compareDeploymentConfigLoader ? (
142145
<ErrorScreenManager
143-
code={compareDeploymentConfigErr?.code}
144-
reload={reloadCompareDeploymentConfig}
146+
code={errorConfig.code}
147+
subtitle={errorConfig.message}
148+
reload={errorConfig.reload}
145149
/>
146150
) : (
147151
<div className="p-16 flexbox-col dc__gap-16 bcn-0 h-100">

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryConfigDiffCompare.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,32 @@ export const DeploymentHistoryConfigDiffCompare = ({
6464
}
6565

6666
const selectorsConfig: DeploymentConfigDiffProps['selectorsConfig'] = {
67-
primaryConfig: [
68-
{
69-
id: 'deployment-config-diff-deployment-selector',
70-
type: 'selectPicker',
71-
selectPickerProps: {
72-
name: 'deployment-config-diff-deployment-selector',
73-
inputId: 'deployment-config-diff-deployment-selector',
74-
classNamePrefix: 'deployment-config-diff-deployment-selector',
75-
variant: SelectPickerVariantType.BORDER_LESS,
76-
options: pipelineDeploymentsOptions,
77-
placeholder: 'Select Deployment',
78-
value: getSelectPickerOptionByValue(pipelineDeploymentsOptions, compareWfrId, null),
79-
onChange: deploymentSelectorOnChange,
80-
showSelectedOptionIcon: false,
81-
menuSize: ComponentSizeType.large,
82-
},
83-
},
84-
],
67+
primaryConfig: pipelineDeploymentsOptions.length
68+
? [
69+
{
70+
id: 'deployment-config-diff-deployment-selector',
71+
type: 'selectPicker',
72+
selectPickerProps: {
73+
name: 'deployment-config-diff-deployment-selector',
74+
inputId: 'deployment-config-diff-deployment-selector',
75+
classNamePrefix: 'deployment-config-diff-deployment-selector',
76+
variant: SelectPickerVariantType.BORDER_LESS,
77+
options: pipelineDeploymentsOptions,
78+
placeholder: 'Select Deployment',
79+
value: getSelectPickerOptionByValue(pipelineDeploymentsOptions, compareWfrId, null),
80+
onChange: deploymentSelectorOnChange,
81+
showSelectedOptionIcon: false,
82+
menuSize: ComponentSizeType.large,
83+
},
84+
},
85+
]
86+
: [
87+
{
88+
id: 'no-previous-deployment',
89+
type: 'string',
90+
text: 'No previous deployment',
91+
},
92+
],
8593
secondaryConfig: [
8694
{
8795
id: 'base-configuration',
@@ -109,6 +117,7 @@ export const DeploymentHistoryConfigDiffCompare = ({
109117
{...props}
110118
showDetailedDiffState
111119
navHeading={`Comparing ${envName}`}
120+
headerText={!pipelineDeploymentsOptions.length ? '' : undefined} // using `undefined` to ensure component picks default value
112121
navHelpText={
113122
compareWfrId
114123
? `Showing diff in configuration deployed on: ${pipelineDeploymentsOptions.find(({ value }) => value === compareWfrId).label} & ${currentDeployment}`

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryDiffView.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ const DeploymentHistoryDiffView = ({
3434
isUnpublished,
3535
isDeleteDraft,
3636
rootClassName,
37-
sortBy = '',
38-
sortOrder = null,
37+
sortingConfig,
38+
codeEditorKey,
3939
}: DeploymentTemplateHistoryType) => {
4040
const { historyComponent, historyComponentName } = useParams<DeploymentHistoryParamsType>()
41+
const { sortBy, sortOrder } = sortingConfig ?? { sortBy: '', sortOrder: null }
4142

4243
const [convertVariables, setConvertVariables] = useState(false)
4344

@@ -86,7 +87,7 @@ const DeploymentHistoryDiffView = ({
8687

8788
const renderDeploymentDiffViaCodeEditor = () => (
8889
<CodeEditor
89-
key={JSON.stringify(editorValuesLHS)}
90+
key={codeEditorKey}
9091
value={editorValuesRHS}
9192
defaultValue={editorValuesLHS}
9293
adjustEditorHeightToContent
@@ -177,7 +178,7 @@ const DeploymentHistoryDiffView = ({
177178
{(currentConfiguration?.codeEditorValue?.value || baseTemplateConfiguration?.codeEditorValue?.value) && (
178179
<div className="en-2 bw-1 br-4 mt-16">
179180
<div
180-
className="code-editor-header-value pl-16 pr-16 pt-12 pb-12 fs-13 fw-6 cn-9 bcn-0 dc__top-radius-4 dc__border-bottom"
181+
className="code-editor-header-value px-12 py-8 fs-13 fw-6 cn-9 bcn-0 dc__top-radius-4 dc__border-bottom"
181182
data-testid="configuration-link-comparison-body-heading"
182183
>
183184
<span>{baseTemplateConfiguration?.codeEditorValue?.displayName}</span>

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/helpers.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const renderDeploymentHistoryConfig = (
2929
heading: string,
3030
pathname: string,
3131
) => (
32-
<div className="dc__border br-4">
32+
<div className="dc__border br-4 dc__overflow-hidden">
3333
{heading && (
3434
<div className="px-16 py-8 dc__border-bottom-n1">
3535
<h4 className="m-0 cn-7 fs-12 lh-20 fw-6">{heading}</h4>
@@ -41,7 +41,7 @@ export const renderDeploymentHistoryConfig = (
4141
return (
4242
<NavLink
4343
key={id}
44-
className={`cursor dc__no-decor px-16 py-12 flex dc__content-space ${index !== config.length - 1 ? 'dc__border-bottom-n1' : ''}`}
44+
className={`cursor dc__no-decor px-16 py-12 flex dc__content-space dc__hover-n50 ${index !== config.length - 1 ? 'dc__border-bottom-n1' : ''}`}
4545
to={href}
4646
>
4747
<p className="m-0 flex dc__gap-8">
@@ -73,7 +73,7 @@ export const renderPipelineDeploymentOptionDescription = ({
7373
runSource,
7474
}: Pick<History, 'triggeredBy' | 'triggeredByEmail' | 'artifact' | 'stage'> &
7575
Pick<DeploymentHistoryConfigDiffProps, 'renderRunSource' | 'resourceId' | 'runSource'>) => (
76-
<div>
76+
<div className="flexbox-col dc__gap-4">
7777
<p className="m-0 fs-12 lh-20 cn-7 flex dc__gap-4">
7878
<span className="dc__capitalize">{stage}</span>
7979
<span className="dc__bullet dc__bullet--d2" />

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import { DeploymentHistoryConfigDiffProps } from './types'
1010

1111
export const getPipelineDeployments = (triggerHistory: DeploymentHistoryConfigDiffProps['triggerHistory']) =>
1212
Array.from(triggerHistory)
13-
.filter(([, value]) => value?.stage === DeploymentStageType.DEPLOY)
13+
.filter(
14+
([, value]) =>
15+
// TODO: check with Prakash when API returns this erro
16+
// (!value.message || value.message !== 'pg: no rows in result set') &&
17+
value.stage === DeploymentStageType.DEPLOY,
18+
)
1419
.map(([, value]) => value)
1520

1621
export const getPipelineDeploymentsWfrIds = ({

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,11 @@ export interface DeploymentTemplateHistoryType {
488488
isUnpublished?: boolean
489489
isDeleteDraft?: boolean
490490
rootClassName?: string
491-
sortBy?: string
492-
sortOrder?: SortingOrder
491+
codeEditorKey?: React.Key
492+
sortingConfig?: {
493+
sortBy: string
494+
sortOrder: SortingOrder
495+
}
493496
}
494497
export interface DeploymentHistoryDetailRes extends ResponseType {
495498
result?: DeploymentHistoryDetail

src/Shared/Components/CollapsibleList/CollapsibleList.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const CollapsibleList = ({ config, onCollapseBtnClick }: CollapsibleListP
4545
>
4646
<headerIconConfig.Icon
4747
{...headerIconConfig.props}
48-
className={`icon-dim-20 ${headerIconConfig.props?.className || ''}`}
48+
className={`icon-dim-20 p-2 ${headerIconConfig.props?.className || ''}`}
4949
/>
5050
</button>
5151
</ConditionalWrap>

src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export interface DeploymentConfigDiffProps {
6565
errorConfig?: {
6666
error: boolean
6767
code: number
68+
message?: string
69+
redirectURL?: string
6870
reload: () => void
6971
}
7072
configList: DeploymentConfigListItem[]

src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export const DeploymentConfigDiffMain = ({
186186
<div className="px-12 py-6">{secondaryHeading}</div>
187187
</div>
188188
<CodeEditor
189-
key={`${sortingConfig?.sortOrder}-${scopeVariablesConfig?.convertVariables}`}
189+
key={`${sortingConfig?.sortBy}-${sortingConfig?.sortOrder}-${scopeVariablesConfig?.convertVariables}`}
190190
diffView
191191
defaultValue={primaryList.codeEditorValue.value}
192192
value={secondaryList.codeEditorValue.value}
@@ -206,12 +206,12 @@ export const DeploymentConfigDiffMain = ({
206206
</div>
207207
)}
208208
<DeploymentHistoryDiffView
209+
codeEditorKey={`${sortingConfig?.sortBy}-${sortingConfig?.sortOrder}-${scopeVariablesConfig?.convertVariables}`}
209210
baseTemplateConfiguration={secondaryList}
210211
currentConfiguration={primaryList}
211212
previousConfigAvailable
212213
rootClassName={`${primaryHeading && secondaryHeading ? 'dc__no-top-radius dc__no-top-border' : ''}`}
213-
sortBy={sortingConfig?.sortBy}
214-
sortOrder={sortingConfig?.sortOrder}
214+
sortingConfig={sortingConfig}
215215
/>
216216
</div>
217217
)}
@@ -239,7 +239,14 @@ export const DeploymentConfigDiffMain = ({
239239
</div>
240240
</div>
241241
<div className="deployment-config-diff__main-content dc__overflow-y-auto">
242-
{errorConfig?.error && <ErrorScreenManager code={errorConfig.code} reload={errorConfig.reload} />}
242+
{errorConfig?.error && (
243+
<ErrorScreenManager
244+
code={errorConfig.code}
245+
subtitle={errorConfig.message}
246+
redirectURL={errorConfig.redirectURL}
247+
reload={errorConfig.reload}
248+
/>
249+
)}
243250
{!errorConfig?.error &&
244251
(isLoading ? (
245252
<Progressing fullHeight size={48} />

src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffNavigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const DeploymentConfigDiffNavigation = ({
4444
? {
4545
iconConfig: {
4646
Icon: showDetailedDiffState ? diffStateIconMap[diffState] : diffStateIconMap.hasDiff,
47-
props: { className: 'icon-dim-16 dc__no-shrink' },
47+
props: { className: 'dc__no-shrink' },
4848
tooltipProps: {
4949
content: showDetailedDiffState
5050
? diffStateTooltipTextMap[diffState]

0 commit comments

Comments
 (0)