Skip to content

Commit 12f1e6d

Browse files
committed
сhore: add link to pr
1 parent 18bf7ff commit 12f1e6d

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

packages/ui/src/views/repo/repo-commits/components/commits-list.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { FC, useMemo } from 'react'
2+
import { Link } from 'react-router-dom'
23

3-
import { Avatar, AvatarFallback, CommitCopyActions, NodeGroup, StackedList } from '@/components'
4+
import { Avatar, AvatarFallback, CommitCopyActions, NodeGroup, StackedList, StyledLink } from '@/components'
45
import { formatDate, getInitials } from '@/utils/utils'
56
import { TypesCommit } from '@/views'
67

78
type CommitsGroupedByDate = Record<string, TypesCommit[]>
89

910
interface CommitProps {
1011
data?: TypesCommit[]
12+
useRepoBranchesStore: () => { spaceId: string; repoId: string }
1113
}
1214

13-
export const CommitsList: FC<CommitProps> = ({ data }) => {
15+
export const CommitsList: FC<CommitProps> = ({ data, useRepoBranchesStore }) => {
16+
const { spaceId, repoId } = useRepoBranchesStore()
1417
const entries = useMemo(() => {
1518
const commitsGroupedByDate = !data
1619
? {}
@@ -46,7 +49,27 @@ export const CommitsList: FC<CommitProps> = ({ data }) => {
4649
<StackedList.Field
4750
title={
4851
<div className="flex flex-col gap-y-1.5">
49-
<span className="truncate text-16 font-medium leading-snug">{commit.title}</span>
52+
<span className="truncate text-16 font-medium leading-snug">
53+
{(() => {
54+
const match = commit?.title?.match(/\s*\(#(\d+)\)$/)
55+
if (!match) return commit?.title
56+
57+
const [fullMatch, prNumber] = match
58+
const titleWithoutPR = commit?.title?.slice(0, -fullMatch.length)
59+
60+
if (!prNumber) return commit?.title
61+
62+
return (
63+
<>
64+
{titleWithoutPR} (
65+
<StyledLink to={`/${spaceId}/repos/${repoId}/pulls/${prNumber}`}>
66+
#{prNumber}
67+
</StyledLink>
68+
)
69+
</>
70+
)
71+
})()}
72+
</span>
5073
<div className="flex items-center gap-x-1.5">
5174
{authorName && (
5275
<Avatar className="size-[18px]">

packages/ui/src/views/repo/repo-commits/repo-commits-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const RepoCommitsView: FC<RepoCommitsViewProps> = ({
124124
/>
125125
) : (
126126
<>
127-
<CommitsList data={commitsList} />
127+
<CommitsList data={commitsList} useRepoBranchesStore={useRepoBranchesStore} />
128128
<PaginationComponent
129129
className="pl-[26px]"
130130
nextPage={xNextPage}

0 commit comments

Comments
 (0)