Skip to content

Commit 4d4fee3

Browse files
committed
feat: add custom renderer for null state and generic section error state
1 parent 472f45a commit 4d4fee3

File tree

6 files changed

+34
-24
lines changed

6 files changed

+34
-24
lines changed

src/Assets/Icon/ic-info-outline.svg

Lines changed: 4 additions & 0 deletions
Loading

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const DeploymentHistoryDiffView = ({
3838
rootClassName,
3939
sortingConfig,
4040
codeEditorKey,
41-
diffState,
4241
}: DeploymentTemplateHistoryType) => {
4342
const { historyComponent, historyComponentName } = useParams<DeploymentHistoryParamsType>()
4443
const { sortBy, sortOrder } = sortingConfig ?? { sortBy: '', sortOrder: null }
@@ -93,7 +92,7 @@ const DeploymentHistoryDiffView = ({
9392
<DiffViewer
9493
oldValue={editorValuesLHS}
9594
newValue={editorValuesRHS}
96-
codeFoldMessageRenderer={renderDiffViewNoDifferenceState(diffState)}
95+
codeFoldMessageRenderer={renderDiffViewNoDifferenceState(editorValuesLHS, editorValuesRHS)}
9796
/>
9897
) : (
9998
<CodeEditor

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
import { DeploymentStageType } from '../../constants'
3333
import { AggregationKeys, GitTriggers, Node, NodeType, ResourceKindType, ResourceVersionType } from '../../types'
3434
import { TERMINAL_STATUS_MAP } from './constants'
35-
import { DeploymentConfigDiffState } from '../DeploymentConfigDiff'
3635

3736
export enum HistoryComponentType {
3837
CI = 'CI',
@@ -494,7 +493,6 @@ export interface DeploymentTemplateHistoryType {
494493
sortBy: string
495494
sortOrder: SortingOrder
496495
}
497-
diffState: DeploymentConfigDiffState
498496
}
499497
export interface DeploymentHistoryDetailRes extends ResponseType {
500498
result?: DeploymentHistoryDetail

src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.utils.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
prepareHistoryData,
1515
GenericSectionErrorState,
1616
} from '@Shared/Components'
17-
import { deepEqual } from '@Common/Helper'
17+
import { deepEqual, noop } from '@Common/Helper'
1818

1919
import { ManifestTemplateDTO } from '@Pages/Applications'
2020
import {
@@ -831,15 +831,19 @@ export const getDefaultVersionAndPreviousDeploymentOptions = (data: TemplateList
831831
)
832832

833833
export const renderDiffViewNoDifferenceState = (
834-
diffState: DeploymentConfigDiffState | null,
834+
lhsValue: string,
835+
rhsValue: string,
835836
): DiffViewerProps['codeFoldMessageRenderer'] =>
836-
diffState !== DeploymentConfigDiffState.NO_DIFF
837+
lhsValue === rhsValue
837838
? () => (
838839
<GenericSectionErrorState
839840
useInfoIcon
840-
title="There seems no difference in the compared values"
841-
subTitle="Click here to view the values"
841+
title="No diff in configurations"
842+
subTitle=""
842843
description=""
844+
buttonText="View values"
845+
// Click event is handled at the parent level
846+
reload={noop}
843847
/>
844848
)
845849
: null

src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ export const DeploymentConfigDiffMain = ({
196196
newValue={secondaryList.codeEditorValue.value}
197197
leftTitle={primaryHeading}
198198
rightTitle={secondaryHeading}
199-
codeFoldMessageRenderer={renderDiffViewNoDifferenceState(diffState)}
199+
codeFoldMessageRenderer={renderDiffViewNoDifferenceState(
200+
primaryList.codeEditorValue.value,
201+
secondaryList.codeEditorValue.value,
202+
)}
200203
/>
201204
) : (
202205
<div className="p-16">
@@ -213,7 +216,6 @@ export const DeploymentConfigDiffMain = ({
213216
previousConfigAvailable
214217
rootClassName={`${primaryHeading && secondaryHeading ? 'dc__no-top-radius dc__no-top-border' : ''}`}
215218
sortingConfig={sortingConfig}
216-
diffState={diffState}
217219
/>
218220
</div>
219221
)}

src/Shared/Components/GenericSectionErrorState/GenericSectionErrorState.component.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { ComponentSizeType } from '@Shared/constants'
1718
import { ReactComponent as ErrorIcon } from '../../../Assets/Icon/ic-error-exclamation.svg'
18-
import { ReactComponent as InfoIcon } from '../../../Assets/Icon/ic-exclamation.svg'
19+
import { ReactComponent as ICInfoOutline } from '../../../Assets/Icon/ic-info-outline.svg'
20+
import { Button, ButtonVariantType } from '../Button'
1921
import { GenericSectionErrorStateProps } from './types'
2022

2123
const GenericSectionErrorState = ({
@@ -30,27 +32,28 @@ const GenericSectionErrorState = ({
3032
}: GenericSectionErrorStateProps) => (
3133
<div className={`flex column dc__gap-8 p-16 ${withBorder ? 'dc__border br-4' : ''} ${rootClassName || ''}`}>
3234
{useInfoIcon ? (
33-
<InfoIcon className="icon-dim-24 fcn-6" />
35+
<ICInfoOutline className="icon-dim-24" />
3436
) : (
3537
<ErrorIcon className="icon-dim-24 alert-icon-r5-imp" />
3638
)}
3739
<div className="flex column dc__gap-4 dc__align-center">
3840
<h3 className="fs-13 lh-20 fw-6 cn-9 m-0">{title}</h3>
39-
<div className="flex column fs-13 lh-20 fw-4 cn-7">
40-
{subTitle && <p className="m-0">{subTitle}</p>}
41-
{description && <p className="m-0">{description}</p>}
42-
</div>
41+
{(subTitle || description) && (
42+
<div className="flex column fs-13 lh-20 fw-4 cn-7">
43+
{subTitle && <p className="m-0">{subTitle}</p>}
44+
{description && <p className="m-0">{description}</p>}
45+
</div>
46+
)}
4347
</div>
4448

4549
{reload && (
46-
<button
47-
type="button"
48-
className="cta text h-20 fs-13 lh-20-imp"
50+
<Button
51+
text={buttonText}
4952
onClick={reload}
50-
data-testid="generic-section-reload-button"
51-
>
52-
{buttonText}
53-
</button>
53+
variant={ButtonVariantType.text}
54+
size={ComponentSizeType.small}
55+
dataTestId="generic-section-reload-button"
56+
/>
5457
)}
5558
</div>
5659
)

0 commit comments

Comments
 (0)