-
Notifications
You must be signed in to change notification settings - Fork 12
Cs 10504/pr card should add approved or request changed by which reviewer #4254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,7 @@ import { | |||||
| buildLatestReviewByReviewer, | ||||||
| computeLatestReviewState, | ||||||
| findLatestChangesRequestedEvent, | ||||||
| findLatestApprovedEvent, | ||||||
| buildGithubEventCardRef, | ||||||
| searchEventQuery, | ||||||
| buildRealmHrefs, | ||||||
|
|
@@ -167,29 +168,36 @@ class IsolatedTemplate extends Component<typeof PrCard> { | |||||
| return computeLatestReviewState(this.latestReviewByReviewer); | ||||||
| } | ||||||
|
|
||||||
| get latestPrReviewCommentEventInstance() { | ||||||
| return findLatestChangesRequestedEvent(this.latestReviewByReviewer); | ||||||
| } | ||||||
|
|
||||||
| get latestChangesRequestedReviewerName() { | ||||||
| return ( | ||||||
| this.latestPrReviewCommentEventInstance?.payload?.review?.user?.login ?? | ||||||
| 'Unknown reviewer' | ||||||
| ); | ||||||
| get latestPrReviewEventInstance() { | ||||||
| let state = this.latestReviewState; | ||||||
| if (state === 'changes_requested') { | ||||||
| return findLatestChangesRequestedEvent(this.latestReviewByReviewer); | ||||||
| } | ||||||
|
Comment on lines
+173
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||||||
| if (state === 'approved') { | ||||||
| return findLatestApprovedEvent(this.latestReviewByReviewer); | ||||||
| } | ||||||
| return null; | ||||||
| } | ||||||
|
|
||||||
| get latestChangesRequestedComment() { | ||||||
| get latestReviewComment() { | ||||||
| let comment = | ||||||
| this.latestPrReviewCommentEventInstance?.payload?.review?.body?.trim(); | ||||||
| this.latestPrReviewEventInstance?.payload?.review?.body?.trim(); | ||||||
| return comment || '-'; | ||||||
| } | ||||||
|
|
||||||
| get latestChangesRequestedReviewUrl() { | ||||||
| return this.latestPrReviewCommentEventInstance?.payload?.review?.html_url; | ||||||
| get latestReviewCommentUrl() { | ||||||
| return this.latestPrReviewEventInstance?.payload?.review?.html_url; | ||||||
| } | ||||||
|
|
||||||
| get hasReview() { | ||||||
| return !!this.latestPrReviewCommentEventInstance; | ||||||
| return !!this.latestPrReviewEventInstance; | ||||||
| } | ||||||
|
|
||||||
| get latestReviewerName() { | ||||||
| return ( | ||||||
| this.latestPrReviewEventInstance?.payload?.review?.user?.login ?? | ||||||
| null | ||||||
|
||||||
| null | |
| 'Unknown reviewer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for this
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,10 +21,7 @@ export type CiGroup = { | |
| items: CiItem[]; | ||
| }; | ||
|
|
||
| export type ReviewState = | ||
| | 'changes_requested' | ||
| | 'approved' | ||
| | 'unknown'; | ||
| export type ReviewState = 'changes_requested' | 'approved' | 'unknown'; | ||
|
|
||
| // ── PR State Helpers ───────────────────────────────────────────────────── | ||
|
|
||
|
|
@@ -299,13 +296,24 @@ export function computeLatestReviewState( | |
| export function findLatestChangesRequestedEvent( | ||
| latestReviewByReviewer: Map<string, any>, | ||
| ): any | null { | ||
| let activeChangesRequestedEvents = [...latestReviewByReviewer.values()].filter( | ||
| (event: any) => | ||
| normalizeReviewState(event?.payload?.review?.state) === | ||
| 'changes_requested' && | ||
| (event?.payload?.review?.body ?? '').trim().length > 0, | ||
| return ( | ||
| [...latestReviewByReviewer.values()].find( | ||
| (event: any) => | ||
| normalizeReviewState(event?.payload?.review?.state) === | ||
| 'changes_requested', | ||
| ) ?? null | ||
| ); | ||
| } | ||
|
|
||
| export function findLatestApprovedEvent( | ||
| latestReviewByReviewer: Map<string, any>, | ||
| ): any | null { | ||
| return ( | ||
| [...latestReviewByReviewer.values()].find( | ||
| (event: any) => | ||
| normalizeReviewState(event?.payload?.review?.state) === 'approved', | ||
| ) ?? null | ||
| ); | ||
| return activeChangesRequestedEvents[0] ?? null; | ||
| } | ||
|
Comment on lines
296
to
+317
|
||
|
|
||
| // ── Query Builders ─────────────────────────────────────────────────────── | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewerNameis now allowed to benulland is passed through toReviewStateBadge. Ifnullis possible in practice, the badge will omit the "by …" suffix and the rest of the section may also end up showing no author. Consider normalizingreviewerNameto a non-empty display string before passing it into the section/badge (e.g. "Unknown reviewer").There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When @reviewerName is null, Handlebars' {{#if null}} evaluates to falsy, so the by ... block doesn't render. The badge will only show "Approved" or "Changes Requested" without the "by" suffix.
Showing "Unknown reviewer" would make users think something is broken or the data is wrong