Skip to content

Commit 6ba9035

Browse files
committed
feat: add support for multiple version control icons and improve rendering logic in CICD components
1 parent 3836bab commit 6ba9035

File tree

7 files changed

+138
-6
lines changed

7 files changed

+138
-6
lines changed

src/Assets/Icon/ic-aws-codecommit.svg

Lines changed: 26 additions & 0 deletions
Loading

src/Assets/Icon/ic-bitbucket.svg

Lines changed: 30 additions & 0 deletions
Loading

src/Assets/Icon/ic-git.svg

Lines changed: 17 additions & 0 deletions
Loading

src/Assets/Icon/ic-gitlab.svg

Lines changed: 31 additions & 0 deletions
Loading

src/Shared/Components/CICDHistory/Sidebar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ import { ReactComponent as ICArrowBackward } from '@Icons/ic-arrow-backward.svg'
2424
import { ReactComponent as ICDocker } from '@Icons/ic-docker.svg'
2525
import { ReactComponent as ICCalendar } from '@Icons/ic-calendar.svg'
2626
import { ReactComponent as ICUserCircle } from '@Icons/ic-user-circle.svg'
27-
import { ReactComponent as ICGithub } from '@Icons/ic-github.svg'
2827
import { ReactComponent as ICBranch } from '@Icons/ic-branch.svg'
2928
import { DeploymentStageType } from '@Shared/constants'
30-
import { getHandleOpenURL } from '@Shared/Helpers'
29+
import { getHandleOpenURL, renderMaterialIcon } from '@Shared/Helpers'
3130
import {
3231
SidebarType,
3332
CICDSidebarFilterOptionType,
@@ -83,6 +82,7 @@ const GitTriggerList = memo(
8382
if (sourceType !== SourceTypeMap.WEBHOOK && !gitDetail) {
8483
return null
8584
}
85+
8686
return (
8787
<div className={`${addMarginTop ? 'mt-22' : ''} ci-material-detail"`} key={ciMaterial.id}>
8888
{sourceType === SourceTypeMap.WEBHOOK ? (
@@ -96,7 +96,7 @@ const GitTriggerList = memo(
9696
) : (
9797
<div className="flexbox-col dc__gap-8">
9898
<div className="flexbox dc__gap-4 dc__align-start">
99-
<ICGithub className="icon-dim-20 dc__no-shrink" />
99+
{renderMaterialIcon(gitDetail?.GitRepoName)}
100100

101101
{gitDetail?.GitRepoName && (
102102
<>
@@ -111,7 +111,7 @@ const GitTriggerList = memo(
111111
)}
112112

113113
<a
114-
href={createGitCommitUrl(gitMaterialUrl, gitDetail.Commit)}
114+
href={createGitCommitUrl(gitMaterialUrl, gitDetail?.Commit)}
115115
target="_blank"
116116
rel="noopener noreferrer"
117117
className="anchor flexbox dc__gap-2 dc__align-items-center"

src/Shared/Components/CICDHistory/TriggerOutput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ export const WorkerStatus = React.memo(
157157
<div className="flexbox dc__gap-8">
158158
<div className={`flexbox cn-9 ${titleClassName}`}>
159159
<span>{stage === DeploymentStageType.DEPLOY && !podStatus ? 'Message' : 'Worker'}</span>
160-
&nbsp;
161160
{podStatus && (
162161
<span>
163162
:&nbsp;{WORKFLOW_STAGE_STATUS_TO_TEXT_MAP[podStatus] || podStatus.toLowerCase()}

src/Shared/Helpers.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/* eslint-disable no-param-reassign */
1818
import { useEffect, useRef, useState, ReactElement } from 'react'
19+
import { PromptProps } from 'react-router-dom'
1920
import Tippy from '@tippyjs/react'
2021
import { Pair } from 'yaml'
2122
import moment from 'moment'
@@ -25,7 +26,11 @@ import { MaterialHistoryType } from '@Shared/Services/app.types'
2526
import { ReactComponent as ICPullRequest } from '@Icons/ic-pull-request.svg'
2627
import { ReactComponent as ICTag } from '@Icons/ic-tag.svg'
2728
import { ReactComponent as ICWebhook } from '@Icons/ic-webhook.svg'
28-
import { PromptProps } from 'react-router-dom'
29+
import { ReactComponent as ICGithub } from '@Icons/ic-github.svg'
30+
import { ReactComponent as ICGitlab } from '@Icons/ic-gitlab.svg'
31+
import { ReactComponent as ICGit } from '@Icons/ic-git.svg'
32+
import { ReactComponent as ICBitbucket } from '@Icons/ic-bitbucket.svg'
33+
import { ReactComponent as ICAWSCodeCommit } from '@Icons/ic-aws-codecommit.svg'
2934
import {
3035
handleUTCTime,
3136
ManualApprovalType,
@@ -1004,3 +1009,27 @@ export const sanitizeTargetPlatforms = (
10041009

10051010
return uniquePlatforms
10061011
}
1012+
1013+
// Should contain git-codecommit.*.amazonaws.com
1014+
export const isAWSCodeCommitURL = (url: string = ''): boolean =>
1015+
url.includes('git-codecommit.') && url.includes('.amazonaws.com')
1016+
1017+
export const renderMaterialIcon = (url: string = '') => {
1018+
if (url.includes('gitlab')) {
1019+
return <ICGitlab className="dc__vertical-align-middle icon-dim-20" />
1020+
}
1021+
1022+
if (url.includes('github')) {
1023+
return <ICGithub className="dc__vertical-align-middle icon-dim-20 fcn-8" />
1024+
}
1025+
1026+
if (url.includes('bitbucket')) {
1027+
return <ICBitbucket className="dc__vertical-align-middle icon-dim-20" />
1028+
}
1029+
1030+
if (isAWSCodeCommitURL(url)) {
1031+
return <ICAWSCodeCommit className="dc__vertical-align-middle icon-dim-18" />
1032+
}
1033+
1034+
return <ICGit className="dc__vertical-align-middle icon-dim-20" />
1035+
}

0 commit comments

Comments
 (0)