diff --git a/web/src/pages/PullRequest/Conversation/Conversation.module.scss b/web/src/pages/PullRequest/Conversation/Conversation.module.scss index 9d4c55e8c..b71155214 100644 --- a/web/src/pages/PullRequest/Conversation/Conversation.module.scss +++ b/web/src/pages/PullRequest/Conversation/Conversation.module.scss @@ -1,4 +1,4 @@ -.descBox { +.box { background: var(--white) !important; box-shadow: 0px 0px 1px rgba(40, 41, 61, 0.08), 0px 0.5px 2px rgba(96, 97, 112, 0.16), diff --git a/web/src/pages/PullRequest/Conversation/Conversation.module.scss.d.ts b/web/src/pages/PullRequest/Conversation/Conversation.module.scss.d.ts index 438edb329..644c2b3e8 100644 --- a/web/src/pages/PullRequest/Conversation/Conversation.module.scss.d.ts +++ b/web/src/pages/PullRequest/Conversation/Conversation.module.scss.d.ts @@ -1,6 +1,6 @@ /* eslint-disable */ // this is an auto-generated file declare const styles: { - readonly descBox: string + readonly box: string } export default styles diff --git a/web/src/pages/PullRequest/Conversation/Conversation.tsx b/web/src/pages/PullRequest/Conversation/Conversation.tsx index ab65cda81..ad7dc6372 100644 --- a/web/src/pages/PullRequest/Conversation/Conversation.tsx +++ b/web/src/pages/PullRequest/Conversation/Conversation.tsx @@ -1,5 +1,15 @@ import React, { useMemo, useState } from 'react' -import { Avatar, Color, Container, FlexExpander, FontVariation, Layout, Text, useToaster } from '@harness/uicore' +import { + Avatar, + Color, + Container, + FlexExpander, + FontVariation, + Layout, + StringSubstitute, + Text, + useToaster +} from '@harness/uicore' import { useGet, useMutate } from 'restful-react' import ReactTimeago from 'react-timeago' import type { GitInfoProps } from 'utils/GitUtils' @@ -87,63 +97,71 @@ export const Conversation: React.FC = ({ refreshPullRequestMetadata={refreshPullRequestMetadata} /> - {Object.entries(commentThreads).map(([threadId, commentItems]) => ( - { - let result = true - let updatedItem: CommentItem | undefined = undefined - const id = (commentItem as CommentItem)?.payload?.id + {Object.entries(commentThreads).map(([threadId, commentItems]) => { + if (commentItems.length === 1 && commentItems[0].payload?.kind === 'system') { + return ( + + ) + } - switch (action) { - case CommentAction.DELETE: - result = false - await confirmAct({ - message: getString('deleteCommentConfirm'), - action: async () => { - await deleteComment({}, { pathParams: { id } }) - .then(() => { - result = true - }) - .catch(exception => { - result = false - showError(getErrorMessage(exception), 0, getString('pr.failedToDeleteComment')) - }) - } - }) - break + return ( + { + let result = true + let updatedItem: CommentItem | undefined = undefined + const id = (commentItem as CommentItem)?.payload?.id - case CommentAction.REPLY: - await saveComment({ text: value, parent_id: Number(threadId) }) - .then(newComment => { - updatedItem = toCommentItem(newComment) + switch (action) { + case CommentAction.DELETE: + result = false + await confirmAct({ + message: getString('deleteCommentConfirm'), + action: async () => { + await deleteComment({}, { pathParams: { id } }) + .then(() => { + result = true + }) + .catch(exception => { + result = false + showError(getErrorMessage(exception), 0, getString('pr.failedToDeleteComment')) + }) + } }) - .catch(exception => { - result = false - showError(getErrorMessage(exception), 0, getString('pr.failedToSaveComment')) - }) - break + break - case CommentAction.UPDATE: - await updateComment({ text: value }, { pathParams: { id } }) - .then(newComment => { - updatedItem = toCommentItem(newComment) - }) - .catch(exception => { - result = false - showError(getErrorMessage(exception), 0, getString('pr.failedToSaveComment')) - }) - break - } + case CommentAction.REPLY: + await saveComment({ text: value, parent_id: Number(threadId) }) + .then(newComment => { + updatedItem = toCommentItem(newComment) + }) + .catch(exception => { + result = false + showError(getErrorMessage(exception), 0, getString('pr.failedToSaveComment')) + }) + break - return [result, updatedItem] - }} - /> - ))} + case CommentAction.UPDATE: + await updateComment({ text: value }, { pathParams: { id } }) + .then(newComment => { + updatedItem = toCommentItem(newComment) + }) + .catch(exception => { + result = false + showError(getErrorMessage(exception), 0, getString('pr.failedToSaveComment')) + }) + break + } + + return [result, updatedItem] + }} + /> + ) + })} = ({ const name = pullRequestMetadata.author?.display_name return ( - + @@ -259,6 +277,33 @@ const DescriptionBox: React.FC = ({ ) } +interface SystemBoxProps extends Pick { + commentItems: CommentItem[] +} +const SystemBox: React.FC = ({ pullRequestMetadata, commentItems }) => { + const { getString } = useStrings() + + if (commentItems[0].payload?.type === 'merge') { + return ( + + {pullRequestMetadata.merger?.display_name}, + source: {pullRequestMetadata.source_branch}, + target: {pullRequestMetadata.target_branch} , + time: + }} + /> + + ) + } + + // eslint-disable-next-line no-console + console.warn('Unable to render system type activity', commentItems) + return null +} + const toCommentItem = (activity: TypesPullReqActivity) => ({ author: activity.author?.display_name as string, created: activity.created as number,