Skip to content

Commit

Permalink
fix: [PIPE-25374,PIPE-25382]: PR diff comments in MFE and PR panel ic…
Browse files Browse the repository at this point in the history
…on (#1168)

* fix: [PIPE-25374]: ellipsis icon for PR panel

* fix: [PIPE-25382]: PR diff comments proxy objects

* fix: [PIPE-25382]: PR diff comments proxy objects
  • Loading branch information
shaurya-harness authored Feb 28, 2025
1 parent d304aca commit 9ee4846
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'

import { Avatar, Layout } from '@/components'
import {
activitiesToDiffCommentItems,
CommentItem,
CommitSuggestion,
CreateCommentPullReqRequest,
Expand Down Expand Up @@ -215,7 +216,11 @@ const PullRequestDiffViewer = ({
updated: parentComment.updated,
deleted: parentComment.deleted,
outdated: parentComment.outdated,
payload: parentComment.payload
payload: parentComment.payload,
codeBlockContent: activitiesToDiffCommentItems(parentComment).codeBlockContent,
appliedCheckSum: parentComment.payload?.metadata?.suggestions?.applied_check_sum,
appliedCommitSha: parentComment.payload?.metadata?.suggestions?.applied_commit_sha,
checkSums: parentComment.payload?.metadata?.suggestions?.check_sums
}

const replies = threadArr.slice(1).map(reply => ({
Expand All @@ -227,7 +232,11 @@ const PullRequestDiffViewer = ({
edited: reply.edited,
updated: reply.updated,
deleted: reply.deleted,
outdated: reply.outdated
outdated: reply.outdated,
codeBlockContent: activitiesToDiffCommentItems(reply).codeBlockContent,
appliedCheckSum: reply.payload?.metadata?.suggestions?.applied_check_sum,
appliedCommitSha: reply.payload?.metadata?.suggestions?.applied_commit_sha,
checkSums: reply.payload?.metadata?.suggestions?.check_sums
}))

if (!newExtend[side][lineNumber]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { FC } from 'react'

import { Button, MarkdownViewer } from '@/components'
import { CommitSuggestion } from '@views/repo/pull-request/pull-request.types'
import { get } from 'lodash-es'

import { CommentItem, TypesPullReqActivity } from '../../pull-request-details-types'
import { activitiesToDiffCommentItems } from '../../pull-request-utils'

export interface PRCommentViewProps {
commentItem: CommentItem<TypesPullReqActivity>
Expand All @@ -29,24 +27,23 @@ const PRCommentView: FC<PRCommentViewProps> = ({
const pathSegments = commentItem?.payload?.code_comment?.path?.split('/') || []
const fileLang = filenameToLanguage?.(pathSegments.pop() || '') || ''

const appliedCheckSum = get(commentItem, 'payload.metadata.suggestions.applied_check_sum', '')
const checkSums = get(commentItem, 'payload.metadata.suggestions.check_sums', []) as string[]
const isSuggestion = !!checkSums.length
const appliedCheckSum = commentItem.appliedCheckSum ?? ''
const checkSums = commentItem.checkSums ?? []
const isSuggestion = !!checkSums?.length
const isApplied = appliedCheckSum === checkSums?.[0]
const isInBatch = suggestionsBatch?.some(suggestion => suggestion.comment_id === commentItem.id)
const diffCommentItem = activitiesToDiffCommentItems(commentItem)

return (
<>
<MarkdownViewer
markdownClassName="comment"
source={commentItem?.payload?.text || ''}
suggestionBlock={{
source: diffCommentItem.codeBlockContent || '',
source: commentItem.codeBlockContent || '',
lang: fileLang,
commentId: commentItem.id,
appliedCheckSum: appliedCheckSum,
appliedCommitSha: get(commentItem, 'payload.metadata.suggestions.applied_commit_sha', '')
appliedCommitSha: commentItem.appliedCommitSha || ''
}}
suggestionCheckSum={checkSums?.[0] || ''}
isSuggestion={isSuggestion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const PullRequestPanel = ({
<DropdownMenu.Trigger className="group flex h-6 items-center px-2">
<Icon
className="text-icons-1 transition-colors duration-200 group-hover:text-icons-2"
name="more-dots-fill"
name="vertical-ellipsis"
size={12}
/>
</DropdownMenu.Trigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ export interface CommentItem<T = unknown> {
outdated: boolean
content: string
payload?: T // optional payload for callers to handle on callback calls
appliedCheckSum?: string
checkSums?: string[]
codeBlockContent?: string
appliedCommitSha?: string
}

export interface DiffFileEntry extends DiffFile {
Expand Down

0 comments on commit 9ee4846

Please sign in to comment.