Skip to content

Commit 4f5be7f

Browse files
committed
feat: add GitProviderIcon component and update related components to use it
1 parent de6bc06 commit 4f5be7f

File tree

6 files changed

+36
-1
lines changed

6 files changed

+36
-1
lines changed

src/Common/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ export enum GitProviderType {
421421
BITBUCKET = 'bitbucket',
422422
AZURE = 'azure',
423423
GITEA = 'gitea',
424+
GIT = 'git',
424425
}
425426

426427
/**

src/Shared/Components/CICDHistory/Sidebar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
SourceTypeMap,
3737
createGitCommitUrl,
3838
DropdownIndicator,
39+
GitProviderType,
3940
} from '../../../Common'
4041
import { ReactComponent as ICArrowBackward } from '../../../Assets/Icon/ic-arrow-backward.svg'
4142
import { ReactComponent as ICDocker } from '../../../Assets/Icon/ic-docker.svg'
@@ -46,6 +47,7 @@ import { statusColor as colorMap } from '../../constants'
4647
import { DeploymentStatus } from '../StatusComponent'
4748
import { Icon } from '../Icon'
4849
import { getTriggerStatusIcon } from './utils'
50+
import { GitProviderIcon } from '../GitProviderIcon'
4951

5052
const SummaryTooltipCard = React.memo(
5153
({
@@ -91,7 +93,7 @@ const SummaryTooltipCard = React.memo(
9193
</div>
9294
) : (
9395
<>
94-
<Icon name="ic-git" size={24} color={null} />
96+
<GitProviderIcon gitProvider={GitProviderType.GIT} size={24} />
9597
<div className="flex left column">
9698
<a
9799
href={createGitCommitUrl(gitMaterialUrl, gitDetail.Commit)}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { GitProviderType } from '@Common/Constants'
2+
3+
import { Icon, IconName } from '../Icon'
4+
import { GitProviderIconProps } from './types'
5+
6+
const gitProviderIconMap: Record<GitProviderType, IconName> = {
7+
[GitProviderType.GIT]: 'ic-git',
8+
[GitProviderType.GITHUB]: 'ic-github',
9+
[GitProviderType.GITLAB]: 'ic-gitlab',
10+
[GitProviderType.BITBUCKET]: 'ic-bitbucket',
11+
[GitProviderType.GITEA]: 'ic-git',
12+
[GitProviderType.AZURE]: 'ic-azure',
13+
}
14+
15+
export const GitProviderIcon = ({ gitProvider, size = 20 }: GitProviderIconProps) => (
16+
<Icon name={gitProviderIconMap[gitProvider] || 'ic-git'} size={size} color={null} />
17+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './GitProviderIcon'
2+
export * from './types'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { GitProviderType } from '@Common/Constants'
2+
3+
import { IconsProps } from '../Icon'
4+
5+
export interface GitProviderIconProps {
6+
gitProvider: GitProviderType
7+
/**
8+
* The size of the icon in pixels.
9+
* @default 20
10+
*/
11+
size?: IconsProps['size']
12+
}

src/Shared/Components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ export * from './UnsavedChangesDialog'
7979
export * from './Icon'
8080
export * from './StatusComponent'
8181
export * from './RegistryIcon'
82+
export * from './GitProviderIcon'

0 commit comments

Comments
 (0)