Skip to content

Commit 39fd834

Browse files
committed
feat: improve content rendering logic in SequentialCDCardTitle component
1 parent e72e55d commit 39fd834

File tree

1 file changed

+36
-38
lines changed

1 file changed

+36
-38
lines changed

src/Shared/Components/ImageCard/SequentialCDCardTitle/SequentialCDCardTitle.tsx

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -68,54 +68,52 @@ const SequentialCDCardTitle = ({
6868
}
6969

7070
const addFlexGap = stageType !== STAGE_TYPE.CD
71+
const noContent =
72+
(stageType !== STAGE_TYPE.CD && !isLatest && !additionalInfo) ||
73+
(stageType === STAGE_TYPE.CD &&
74+
!isLatest &&
75+
!isRunningOnParentCD &&
76+
!Object.values(ARTIFACT_STATUS).includes(artifactStatus) &&
77+
!showLatestTag &&
78+
!deployedOn?.length &&
79+
!additionalInfo)
80+
81+
if (noContent) {
82+
return null
83+
}
7184

7285
const renderContent = () => {
7386
if (stageType !== STAGE_TYPE.CD) {
74-
if (isLatest || additionalInfo) {
75-
return (
76-
<>
77-
{isLatest && <span className="last-deployed-status">Last Run</span>}
78-
{additionalInfo}
79-
</>
80-
)
81-
}
82-
83-
return null
84-
}
85-
86-
if (
87-
isLatest ||
88-
isRunningOnParentCD ||
89-
Object.values(ARTIFACT_STATUS).includes(artifactStatus) ||
90-
showLatestTag ||
91-
deployedOn?.length ||
92-
additionalInfo
93-
) {
9487
return (
9588
<>
96-
{renderDeployedEnvironmentName()}
97-
{artifactStatus === ARTIFACT_STATUS.PROGRESSING && (
98-
<DeploymentEnvState envStateText={DEPLOYMENT_ENV_TEXT.DEPLOYING} title={environmentName} />
99-
)}
100-
{(artifactStatus === ARTIFACT_STATUS.DEGRADED || artifactStatus === ARTIFACT_STATUS.FAILED) && (
101-
<DeploymentEnvState envStateText={DEPLOYMENT_ENV_TEXT.FAILED} title={environmentName} />
102-
)}
103-
{showLatestTag && (
104-
<ImageTagButton
105-
text="Latest"
106-
isSoftDeleted={false}
107-
isEditing={false}
108-
tagId={0}
109-
softDeleteTags={[]}
110-
isSuperAdmin
111-
/>
112-
)}
89+
{isLatest && <span className="last-deployed-status">Last Run</span>}
11390
{additionalInfo}
11491
</>
11592
)
11693
}
11794

118-
return null
95+
return (
96+
<>
97+
{renderDeployedEnvironmentName()}
98+
{artifactStatus === ARTIFACT_STATUS.PROGRESSING && (
99+
<DeploymentEnvState envStateText={DEPLOYMENT_ENV_TEXT.DEPLOYING} title={environmentName} />
100+
)}
101+
{(artifactStatus === ARTIFACT_STATUS.DEGRADED || artifactStatus === ARTIFACT_STATUS.FAILED) && (
102+
<DeploymentEnvState envStateText={DEPLOYMENT_ENV_TEXT.FAILED} title={environmentName} />
103+
)}
104+
{showLatestTag && (
105+
<ImageTagButton
106+
text="Latest"
107+
isSoftDeleted={false}
108+
isEditing={false}
109+
tagId={0}
110+
softDeleteTags={[]}
111+
isSuperAdmin
112+
/>
113+
)}
114+
{additionalInfo}
115+
</>
116+
)
119117
}
120118

121119
return (

0 commit comments

Comments
 (0)