mirror of
https://github.com/harness/drone.git
synced 2025-05-31 11:43:15 +00:00
feat: [CODE-2382] update review events with the latest changes (#2717)
* fix: [CODE-2382] updated interface * feat: [CODE-2382] update review events with the latest changes
This commit is contained in:
parent
8dac8c2797
commit
1725841f67
@ -36,7 +36,9 @@ export enum CommentType {
|
|||||||
BRANCH_DELETE = 'branch-delete',
|
BRANCH_DELETE = 'branch-delete',
|
||||||
BRANCH_RESTORE = 'branch-restore',
|
BRANCH_RESTORE = 'branch-restore',
|
||||||
STATE_CHANGE = 'state-change',
|
STATE_CHANGE = 'state-change',
|
||||||
LABEL_MODIFY = 'label-modify'
|
LABEL_MODIFY = 'label-modify',
|
||||||
|
REVIEWER_ADD = 'reviewer-add',
|
||||||
|
REVIEWER_DELETE = 'reviewer-delete'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum LabelActivity {
|
export enum LabelActivity {
|
||||||
@ -45,6 +47,12 @@ export enum LabelActivity {
|
|||||||
RE_ASSIGN = 'reassign'
|
RE_ASSIGN = 'reassign'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum ReviewerAddActivity {
|
||||||
|
REQUESTED = 'requested',
|
||||||
|
ASSIGNED = 'assigned',
|
||||||
|
SELF_ASSIGNED = 'self_assigned'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
|
@ -851,6 +851,11 @@ export interface StringsMap {
|
|||||||
prGenSummary: string
|
prGenSummary: string
|
||||||
prHasNoConflicts: string
|
prHasNoConflicts: string
|
||||||
prMustSelectSourceAndTargetBranches: string
|
prMustSelectSourceAndTargetBranches: string
|
||||||
|
'prReview.assigned': string
|
||||||
|
'prReview.removed': string
|
||||||
|
'prReview.requested': string
|
||||||
|
'prReview.selfAssigned': string
|
||||||
|
'prReview.selfRemoved': string
|
||||||
prSourceAndTargetMustBeDifferent: string
|
prSourceAndTargetMustBeDifferent: string
|
||||||
'prState.draftDesc': string
|
'prState.draftDesc': string
|
||||||
'prState.draftHeading': string
|
'prState.draftHeading': string
|
||||||
|
@ -367,6 +367,12 @@ prChecks:
|
|||||||
killed: '{count}/{total} {count|1:check,checks} killed.'
|
killed: '{count}/{total} {count|1:check,checks} killed.'
|
||||||
notFound: No pipelines or external checks found for this repository.
|
notFound: No pipelines or external checks found for this repository.
|
||||||
viewExternal: View Details
|
viewExternal: View Details
|
||||||
|
prReview:
|
||||||
|
assigned: '{author} assigned {reviewer} as a reviewer'
|
||||||
|
requested: '{author} requested a review from {reviewer}'
|
||||||
|
selfAssigned: '{reviewer} self-requested a review'
|
||||||
|
removed: '{author} removed the request for review from {reviewer}'
|
||||||
|
selfRemoved: '{author} removed their request for review'
|
||||||
webhookListingContent: 'create,delete,deployment ...'
|
webhookListingContent: 'create,delete,deployment ...'
|
||||||
general: 'General'
|
general: 'General'
|
||||||
webhooks: 'Webhooks'
|
webhooks: 'Webhooks'
|
||||||
|
@ -19,13 +19,13 @@ import { Avatar, Container, Layout, StringSubstitute, Text } from '@harnessio/ui
|
|||||||
import { Icon, IconName } from '@harnessio/icons'
|
import { Icon, IconName } from '@harnessio/icons'
|
||||||
import { Color, FontVariation } from '@harnessio/design-system'
|
import { Color, FontVariation } from '@harnessio/design-system'
|
||||||
import { defaultTo } from 'lodash-es'
|
import { defaultTo } from 'lodash-es'
|
||||||
import { Case, Match } from 'react-jsx-match'
|
import { Case, Falsy, Match, Truthy } from 'react-jsx-match'
|
||||||
import { CodeIcon, GitInfoProps, MergeStrategy } from 'utils/GitUtils'
|
import { CodeIcon, GitInfoProps, MergeStrategy } from 'utils/GitUtils'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings } from 'framework/strings'
|
||||||
import type { TypesPullReqActivity } from 'services/code'
|
import type { TypesPullReqActivity } from 'services/code'
|
||||||
import type { CommentItem } from 'components/CommentBox/CommentBox'
|
import type { CommentItem } from 'components/CommentBox/CommentBox'
|
||||||
import { PullRequestSection } from 'utils/Utils'
|
import { PullRequestSection } from 'utils/Utils'
|
||||||
import { CommentType, LabelActivity } from 'components/DiffViewer/DiffViewerUtils'
|
import { CommentType, LabelActivity, ReviewerAddActivity } from 'components/DiffViewer/DiffViewerUtils'
|
||||||
import { useAppContext } from 'AppContext'
|
import { useAppContext } from 'AppContext'
|
||||||
import { CommitActions } from 'components/CommitActions/CommitActions'
|
import { CommitActions } from 'components/CommitActions/CommitActions'
|
||||||
import { PipeSeparator } from 'components/PipeSeparator/PipeSeparator'
|
import { PipeSeparator } from 'components/PipeSeparator/PipeSeparator'
|
||||||
@ -44,6 +44,10 @@ interface MergePayload {
|
|||||||
merge_method: string
|
merge_method: string
|
||||||
rules_bypassed: boolean
|
rules_bypassed: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ReviewerAddActivityPayload {
|
||||||
|
reviewer_type: ReviewerAddActivity
|
||||||
|
}
|
||||||
//ToDo : update all comment options with the correct payload type and remove Unknown
|
//ToDo : update all comment options with the correct payload type and remove Unknown
|
||||||
export const SystemComment: React.FC<SystemCommentProps> = ({ pullReqMetadata, commentItems, repoMetadataPath }) => {
|
export const SystemComment: React.FC<SystemCommentProps> = ({ pullReqMetadata, commentItems, repoMetadataPath }) => {
|
||||||
const { getString } = useStrings()
|
const { getString } = useStrings()
|
||||||
@ -424,6 +428,99 @@ export const SystemComment: React.FC<SystemCommentProps> = ({ pullReqMetadata, c
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case CommentType.REVIEWER_ADD: {
|
||||||
|
const mentionId = payload?.metadata?.mentions?.ids?.[0] ?? 0
|
||||||
|
const mentionDisplayName = payload?.mentions?.[mentionId]?.display_name ?? ''
|
||||||
|
return (
|
||||||
|
<Container className={css.mergedBox}>
|
||||||
|
<Layout.Horizontal spacing="small" style={{ alignItems: 'center' }}>
|
||||||
|
<Avatar name={payload?.author?.display_name} size="small" hoverCard={false} />
|
||||||
|
<Text tag="div">
|
||||||
|
<Match expr={(payload?.payload as ReviewerAddActivityPayload).reviewer_type}>
|
||||||
|
<Case val={ReviewerAddActivity.ASSIGNED}>
|
||||||
|
<StringSubstitute
|
||||||
|
str={getString('prReview.assigned')}
|
||||||
|
vars={{
|
||||||
|
author: <strong>{payload?.author?.display_name}</strong>,
|
||||||
|
reviewer: <strong>{mentionDisplayName}</strong>
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Case>
|
||||||
|
<Case val={ReviewerAddActivity.REQUESTED}>
|
||||||
|
<StringSubstitute
|
||||||
|
str={getString('prReview.requested')}
|
||||||
|
vars={{
|
||||||
|
author: <strong>{payload?.author?.display_name}</strong>,
|
||||||
|
reviewer: <strong>{mentionDisplayName}</strong>
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Case>
|
||||||
|
<Case val={ReviewerAddActivity.SELF_ASSIGNED}>
|
||||||
|
<StringSubstitute
|
||||||
|
str={getString('prReview.selfAssigned')}
|
||||||
|
vars={{
|
||||||
|
reviewer: <strong>{mentionDisplayName}</strong>
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Case>
|
||||||
|
</Match>
|
||||||
|
</Text>
|
||||||
|
<PipeSeparator height={9} />
|
||||||
|
|
||||||
|
<TimePopoverWithLocal
|
||||||
|
time={defaultTo(payload?.created as number, 0)}
|
||||||
|
inline={true}
|
||||||
|
width={100}
|
||||||
|
font={{ variation: FontVariation.SMALL }}
|
||||||
|
color={Color.GREY_400}
|
||||||
|
/>
|
||||||
|
</Layout.Horizontal>
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
case CommentType.REVIEWER_DELETE: {
|
||||||
|
const mentionId = payload?.metadata?.mentions?.ids?.[0] ?? 0
|
||||||
|
const mentionDisplayName = payload?.mentions?.[mentionId]?.display_name ?? ''
|
||||||
|
return (
|
||||||
|
<Container className={css.mergedBox}>
|
||||||
|
<Layout.Horizontal spacing="small" style={{ alignItems: 'center' }}>
|
||||||
|
<Avatar name={payload?.author?.display_name} size="small" hoverCard={false} />
|
||||||
|
<Text tag="div">
|
||||||
|
<Match expr={payload?.author?.id === mentionId}>
|
||||||
|
<Truthy>
|
||||||
|
<StringSubstitute
|
||||||
|
str={getString('prReview.selfRemoved')}
|
||||||
|
vars={{
|
||||||
|
author: <strong>{payload?.author?.display_name}</strong>
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Truthy>
|
||||||
|
<Falsy>
|
||||||
|
<StringSubstitute
|
||||||
|
str={getString('prReview.removed')}
|
||||||
|
vars={{
|
||||||
|
author: <strong>{payload?.author?.display_name}</strong>,
|
||||||
|
reviewer: <strong>{mentionDisplayName}</strong>
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Falsy>
|
||||||
|
</Match>
|
||||||
|
</Text>
|
||||||
|
<PipeSeparator height={9} />
|
||||||
|
|
||||||
|
<TimePopoverWithLocal
|
||||||
|
time={defaultTo(payload?.created as number, 0)}
|
||||||
|
inline={true}
|
||||||
|
width={100}
|
||||||
|
font={{ variation: FontVariation.SMALL }}
|
||||||
|
color={Color.GREY_400}
|
||||||
|
/>
|
||||||
|
</Layout.Horizontal>
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.warn('Unable to render system type activity', commentItems)
|
console.warn('Unable to render system type activity', commentItems)
|
||||||
|
@ -135,6 +135,7 @@ export type EnumPullReqActivityType =
|
|||||||
| 'label-modify'
|
| 'label-modify'
|
||||||
| 'merge'
|
| 'merge'
|
||||||
| 'review-submit'
|
| 'review-submit'
|
||||||
|
| 'reviewer-add'
|
||||||
| 'reviewer-delete'
|
| 'reviewer-delete'
|
||||||
| 'state-change'
|
| 'state-change'
|
||||||
| 'title-change'
|
| 'title-change'
|
||||||
@ -4996,6 +4997,7 @@ export interface ListPullReqActivitiesQueryParams {
|
|||||||
| 'label-modify'
|
| 'label-modify'
|
||||||
| 'merge'
|
| 'merge'
|
||||||
| 'review-submit'
|
| 'review-submit'
|
||||||
|
| 'reviewer-add'
|
||||||
| 'reviewer-delete'
|
| 'reviewer-delete'
|
||||||
| 'state-change'
|
| 'state-change'
|
||||||
| 'title-change'
|
| 'title-change'
|
||||||
|
@ -4644,6 +4644,7 @@ paths:
|
|||||||
- label-modify
|
- label-modify
|
||||||
- merge
|
- merge
|
||||||
- review-submit
|
- review-submit
|
||||||
|
- reviewer-add
|
||||||
- reviewer-delete
|
- reviewer-delete
|
||||||
- state-change
|
- state-change
|
||||||
- title-change
|
- title-change
|
||||||
@ -4772,6 +4773,12 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/UsererrorError'
|
$ref: '#/components/schemas/UsererrorError'
|
||||||
description: Not Found
|
description: Not Found
|
||||||
|
'409':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/UsererrorError'
|
||||||
|
description: Conflict
|
||||||
'422':
|
'422':
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
@ -4834,6 +4841,12 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/UsererrorError'
|
$ref: '#/components/schemas/UsererrorError'
|
||||||
description: Forbidden
|
description: Forbidden
|
||||||
|
'409':
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/UsererrorError'
|
||||||
|
description: Conflict
|
||||||
'422':
|
'422':
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
@ -10562,6 +10575,7 @@ components:
|
|||||||
- label-modify
|
- label-modify
|
||||||
- merge
|
- merge
|
||||||
- review-submit
|
- review-submit
|
||||||
|
- reviewer-add
|
||||||
- reviewer-delete
|
- reviewer-delete
|
||||||
- state-change
|
- state-change
|
||||||
- title-change
|
- title-change
|
||||||
|
Loading…
x
Reference in New Issue
Block a user