feat(web): make review verdicts legible in the pull request detail (#7077)
This commit is contained in:
1 parent
cd096b9ad5
commit
c7e6d711d3
6 files changed
+761
-41
No files matched your search
@@ -103,6 +103,7 @@ import {
|
||||
buildResolveConflictsPrompt,
|
||||
handoffPrompt,
|
||||
handoffReviewComments,
|
||||
latestPullRequestReviewOutcomes,
|
||||
pullRequestActionMenuHasGroup,
|
||||
pullRequestActionNeedsHostRefresh,
|
||||
pullRequestComposerTarget,
|
||||
@@ -123,7 +124,9 @@ import {
|
||||
PullRequestActorLabel,
|
||||
PullRequestDiffStat,
|
||||
PullRequestMetaLine,
|
||||
PullRequestReviewOutcomeIcon,
|
||||
pullRequestChecksState,
|
||||
pullRequestReviewOutcomeToneClassName,
|
||||
resolvePullRequestState,
|
||||
summarizePullRequestChecks,
|
||||
} from "./pullRequestPresentation";
|
||||
@@ -1075,6 +1078,19 @@ export function PullRequestDetailPanel({
|
||||
: null;
|
||||
const checksSummary = detail ? summarizePullRequestChecks(detail.checks) : null;
|
||||
const checksState = detail ? pullRequestChecksState(detail.checks) : null;
|
||||
// Approvals that still stand, and only those. A superseded one is dimmed beside the reviewer
|
||||
// who gave it, so counting it here would have the header assert in a number what the row next
|
||||
// to it has just qualified.
|
||||
//
|
||||
// Not counted at all from a conversation this page only holds the recent end of: an approval
|
||||
// older than the window would be missing, and "1" beside a tick is read as the whole answer.
|
||||
// The Summary tab's row can say it may be short; a bare number cannot, so it stays away.
|
||||
const approvalCount =
|
||||
detail && !detail.commentsTruncated
|
||||
? latestPullRequestReviewOutcomes(detail.comments, detail.commits).filter(
|
||||
(entry) => entry.outcome === "approved" && !entry.stale,
|
||||
).length
|
||||
: 0;
|
||||
|
||||
return (
|
||||
<div className="flex h-full min-h-0 w-full flex-col bg-background">
|
||||
@@ -1813,6 +1829,24 @@ export function PullRequestDetailPanel({
|
||||
? "…"
|
||||
: detail.commits.length.toLocaleString()}
|
||||
</span>
|
||||
{/* Only once somebody has approved: a nought beside a tick would read as a
|
||||
verdict of its own on a change nobody has looked at yet. */}
|
||||
{approvalCount > 0 ? (
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex items-center gap-1",
|
||||
pullRequestReviewOutcomeToneClassName("approved"),
|
||||
)}
|
||||
>
|
||||
<PullRequestReviewOutcomeIcon outcome="approved" className="size-3" />
|
||||
{approvalCount.toLocaleString()}
|
||||
{/* The icon is decorative and a name written onto a generic span is
|
||||
not announced, so the bare number says what it counts in words. */}
|
||||
<span className="sr-only">
|
||||
{approvalCount === 1 ? "approval" : "approvals"}
|
||||
</span>
|
||||
</span>
|
||||
) : null}
|
||||
</PullRequestMetaLine>
|
||||
<Button
|
||||
size="xs"
|
||||
|
||||
@@ -33,13 +33,20 @@ import {
|
||||
PullRequestActorAvatar,
|
||||
PullRequestActorLabel,
|
||||
PullRequestCheckStatusIcon,
|
||||
PullRequestReviewOutcomeBadge,
|
||||
pullRequestCheckStatusLabel,
|
||||
pullRequestReviewOutcomeLabel,
|
||||
pullRequestReviewOutcomeRingClassName,
|
||||
pullRequestReviewOutcomeStaleLabel,
|
||||
} from "./pullRequestPresentation";
|
||||
import { PullRequestReviewerPicker } from "./PullRequestReviewerPicker";
|
||||
import { PullRequestActivityUnavailableState } from "./PullRequestActivityUnavailableState";
|
||||
import {
|
||||
latestPullRequestReviewOutcomes,
|
||||
orderPullRequestComments,
|
||||
pullRequestFindingKey,
|
||||
pullRequestReviewOutcome,
|
||||
visibleBody,
|
||||
type PullRequestFinding,
|
||||
} from "./pullRequestDetail.logic";
|
||||
import {
|
||||
@@ -52,6 +59,11 @@ import { PullRequestReactionBar } from "./PullRequestReactions";
|
||||
import { PullRequestConversationGhost } from "./PullRequestGhosts";
|
||||
import { sectionCollapseAnchorScrollTop } from "./pullRequestSummaryScroll.logic";
|
||||
|
||||
/** One reviewer, however a host happens to have cased their login this time. */
|
||||
function reviewerKey(login: string): string {
|
||||
return login.toLowerCase();
|
||||
}
|
||||
|
||||
/** A host colour only when it is one, so a malformed value falls back to the neutral dot. */
|
||||
function labelDotColor(color: string | null): string | null {
|
||||
const hex = color?.trim().replace(/^#/, "") ?? "";
|
||||
@@ -138,11 +150,14 @@ function CollapsedComment({
|
||||
comment,
|
||||
editing,
|
||||
label,
|
||||
body,
|
||||
reactionBar,
|
||||
}: {
|
||||
comment: PullRequestComment;
|
||||
editing: CommentEditing;
|
||||
label: string;
|
||||
/** Null where the remark is nothing but its verdict, which a dismissal usually is. */
|
||||
body: string | null;
|
||||
reactionBar: ReactNode;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
@@ -181,7 +196,11 @@ function CollapsedComment({
|
||||
<TooltipPopup side="top">{comment.path}</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
<CommentBody className="mt-2" comment={comment} editing={editing} />
|
||||
{/* A dismissal carries no more words than an approval does, and an empty markdown
|
||||
block reads as a card somebody forgot to fill in. */}
|
||||
{body === null && !editing.canEdit(comment) ? null : (
|
||||
<CommentBody className="mt-2" comment={comment} editing={editing} />
|
||||
)}
|
||||
{reactionBar}
|
||||
</div>
|
||||
) : null}
|
||||
@@ -386,6 +405,42 @@ export function PullRequestSummaryTab({
|
||||
const hiddenCommentCount = detail.comments.length - recentComments.length;
|
||||
const [commentOrder, setCommentOrder] = useState<"newest" | "oldest">("newest");
|
||||
const visibleComments = orderPullRequestComments(recentComments, commentOrder);
|
||||
// Read from the whole conversation, not the window shown below it: a verdict older than the
|
||||
// last thirty comments still stands.
|
||||
const reviewOutcomes = latestPullRequestReviewOutcomes(detail.comments, detail.commits);
|
||||
// Hosts do not promise one casing for a login across two fields of the same response, and
|
||||
// none of them lets `Octocat` and `octocat` be two people — so matching on the literal string
|
||||
// would show one reviewer twice and drop the verdict off both.
|
||||
const outcomeByLogin = new Map(
|
||||
reviewOutcomes.flatMap((entry) =>
|
||||
entry.actor ? [[reviewerKey(entry.actor.login), entry] as const] : [],
|
||||
),
|
||||
);
|
||||
// Everyone whose face belongs on this row: the people a review was asked of, then anyone who
|
||||
// ruled without being on that list. A host drops a reviewer from the requested set once they
|
||||
// have reviewed, and their verdict is the thing this row now exists to show.
|
||||
const reviewerEntries = [
|
||||
...detail.reviewers.map((actor) => ({
|
||||
key: actor.login,
|
||||
actor,
|
||||
outcome: outcomeByLogin.get(reviewerKey(actor.login))?.outcome ?? null,
|
||||
stale: outcomeByLogin.get(reviewerKey(actor.login))?.stale ?? false,
|
||||
})),
|
||||
...reviewOutcomes
|
||||
.filter(
|
||||
(entry) =>
|
||||
!detail.reviewers.some(
|
||||
(actor) =>
|
||||
entry.actor !== null && reviewerKey(actor.login) === reviewerKey(entry.actor.login),
|
||||
),
|
||||
)
|
||||
.map((entry) => ({
|
||||
key: entry.key,
|
||||
actor: entry.actor,
|
||||
outcome: entry.outcome,
|
||||
stale: entry.stale,
|
||||
})),
|
||||
];
|
||||
|
||||
// A comment that already lives on a review thread is that thread: the thread carries the line
|
||||
// and side the bare comment has lost, and a resolved one is finished work nobody should be
|
||||
@@ -464,33 +519,76 @@ export function PullRequestSummaryTab({
|
||||
<div>
|
||||
<MetaRow icon={<UsersIcon className="size-3.5" />} label="Reviewers">
|
||||
<span className="flex min-w-0 flex-wrap items-center gap-1.5">
|
||||
{detail.reviewers.length === 0 ? (
|
||||
{reviewerEntries.length === 0 ? (
|
||||
<span className="text-muted-foreground">None</span>
|
||||
) : (
|
||||
<span className="flex items-center -space-x-1">
|
||||
{detail.reviewers.map((actor) => (
|
||||
<Tooltip key={actor.login}>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<span
|
||||
className="relative rounded-full hover:z-10"
|
||||
aria-label={actor.name ?? actor.login}
|
||||
{reviewerEntries.map((entry) => {
|
||||
const login = entry.actor?.login ?? "ghost";
|
||||
const named =
|
||||
entry.actor?.name && entry.actor.name !== login
|
||||
? `${entry.actor.name} (@${login})`
|
||||
: login;
|
||||
return (
|
||||
<Tooltip key={entry.key}>
|
||||
{/* A verdict rides the face that earned it rather than a row of its own:
|
||||
the ring sits outside the one that separates overlapping avatars, so
|
||||
it reads at a glance without adding anything to scroll past. */}
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<span
|
||||
className={cn(
|
||||
"relative rounded-full hover:z-10",
|
||||
// The verdict replaces the separator rather than ringing it. Both
|
||||
// occupy the same 2px immediately outside a 16px avatar, so the
|
||||
// colour costs no size: anything drawn further out would be a
|
||||
// halo wide enough to eclipse the neighbour this stack overlaps
|
||||
// by 4px. Painted by this wrapper because a child's box-shadow
|
||||
// covers its parent's, never the other way round.
|
||||
entry.outcome
|
||||
? pullRequestReviewOutcomeRingClassName(
|
||||
entry.outcome,
|
||||
entry.stale,
|
||||
)
|
||||
: undefined,
|
||||
)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<PullRequestActorLabel
|
||||
actor={entry.actor}
|
||||
tooltip={false}
|
||||
className={cn(
|
||||
"gap-0 [&>span:last-child]:sr-only",
|
||||
// Only where the wrapper is not already drawing one, or the opaque
|
||||
// separator would cover the verdict in the band they share.
|
||||
entry.outcome
|
||||
? undefined
|
||||
: "[&>img]:ring-2 [&>img]:ring-background [&>span:first-child]:ring-2 [&>span:first-child]:ring-background",
|
||||
)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<PullRequestActorLabel
|
||||
actor={actor}
|
||||
tooltip={false}
|
||||
className="gap-0 [&>img]:ring-2 [&>img]:ring-background [&>span:first-child]:ring-2 [&>span:first-child]:ring-background [&>span:last-child]:sr-only"
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="bottom">
|
||||
{actor.name && actor.name !== actor.login
|
||||
? `${actor.name} (@${actor.login})`
|
||||
: actor.login}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
))}
|
||||
{/* Colour alone says nothing to a reader who cannot see it, and the
|
||||
login beside this is already in the accessible name. */}
|
||||
{entry.outcome ? (
|
||||
<span className="sr-only">
|
||||
{entry.stale
|
||||
? pullRequestReviewOutcomeStaleLabel(entry.outcome)
|
||||
: pullRequestReviewOutcomeLabel(entry.outcome)}
|
||||
</span>
|
||||
) : null}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="bottom">
|
||||
{entry.outcome
|
||||
? `${named} — ${
|
||||
entry.stale
|
||||
? pullRequestReviewOutcomeStaleLabel(entry.outcome)
|
||||
: pullRequestReviewOutcomeLabel(entry.outcome)
|
||||
}`
|
||||
: named}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
);
|
||||
})}
|
||||
</span>
|
||||
)}
|
||||
{/* Shown wherever the host can take a review request at all, and disabled with the
|
||||
@@ -697,14 +795,16 @@ export function PullRequestSummaryTab({
|
||||
) : null}
|
||||
{visibleComments.map((comment) => {
|
||||
const thread = threadByCommentId.get(comment.id);
|
||||
const reviewState = comment.reviewState?.toLowerCase();
|
||||
if (thread?.isResolved || reviewState === "dismissed") {
|
||||
const body = visibleBody(comment.body);
|
||||
const outcome = pullRequestReviewOutcome(comment.reviewState);
|
||||
if (thread?.isResolved || outcome === "dismissed") {
|
||||
return (
|
||||
<CollapsedComment
|
||||
key={comment.id}
|
||||
comment={comment}
|
||||
editing={commentEditing}
|
||||
label={thread?.isResolved ? "Resolved" : "Approval dismissed"}
|
||||
body={body}
|
||||
reactionBar={
|
||||
<PullRequestReactionBar
|
||||
className="mt-2"
|
||||
@@ -722,11 +822,30 @@ export function PullRequestSummaryTab({
|
||||
// An approval is a verdict, not a finding: there is nothing in it to fix.
|
||||
const finding: PullRequestFinding | null =
|
||||
(comment.kind !== "review" && comment.kind !== "review-comment") ||
|
||||
reviewState === "approved"
|
||||
outcome === "approved"
|
||||
? null
|
||||
: thread === undefined
|
||||
? { kind: "comment", comment }
|
||||
? // Nor is a remark with nothing in it: offering to hand an empty review
|
||||
// to a thread promises work it does not describe.
|
||||
body === null
|
||||
? null
|
||||
: { kind: "comment", comment }
|
||||
: { kind: "thread", thread };
|
||||
// One bar, two homes. Under a card with words in it, it is the row beneath
|
||||
// them. A bodiless verdict has nothing above it, so a row reserved for an add
|
||||
// button nobody can see until they hover is a hole — there it rides the header
|
||||
// line instead, which keeps the affordance every sibling card offers.
|
||||
const reactionBar = (
|
||||
<PullRequestReactionBar
|
||||
reactions={comment.reactions ?? []}
|
||||
canReact={detail.capabilities.reactions === true}
|
||||
subjectId={comment.id}
|
||||
environmentId={environmentId}
|
||||
reference={reference}
|
||||
onRefresh={onRefresh}
|
||||
{...(body === null ? {} : { className: "mt-2" })}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<article
|
||||
key={comment.id}
|
||||
@@ -738,9 +857,12 @@ export function PullRequestSummaryTab({
|
||||
<span className="flex min-w-0 flex-1 items-center gap-2 text-xs text-muted-foreground">
|
||||
<CommentAuthor actor={comment.author} />
|
||||
<span>{formatRelativeTimeLabel(comment.createdAt)}</span>
|
||||
{comment.reviewState ? (
|
||||
{outcome ? (
|
||||
<PullRequestReviewOutcomeBadge outcome={outcome} />
|
||||
) : comment.reviewState ? (
|
||||
<span>{reviewStateLabel(comment.reviewState)}</span>
|
||||
) : null}
|
||||
{body === null ? reactionBar : null}
|
||||
</span>
|
||||
{/* Review remarks only. A plain conversation comment is talk, not a finding,
|
||||
and offering to fix one would promise more than it says. */}
|
||||
@@ -771,16 +893,14 @@ export function PullRequestSummaryTab({
|
||||
<TooltipPopup side="top">{comment.path}</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
<CommentBody className="mt-2" comment={comment} editing={commentEditing} />
|
||||
<PullRequestReactionBar
|
||||
className="mt-2"
|
||||
reactions={comment.reactions ?? []}
|
||||
canReact={detail.capabilities.reactions === true}
|
||||
subjectId={comment.id}
|
||||
environmentId={environmentId}
|
||||
reference={reference}
|
||||
onRefresh={onRefresh}
|
||||
/>
|
||||
{/* A verdict usually carries no words, and an empty markdown block reads as
|
||||
a card somebody forgot to fill in — the badge above already said it.
|
||||
Kept where this reader may rewrite the remark: the pencil lives in here,
|
||||
and hiding the block would take away the only way back to it. */}
|
||||
{body === null && !commentEditing.canEdit(comment) ? null : (
|
||||
<CommentBody className="mt-2" comment={comment} editing={commentEditing} />
|
||||
)}
|
||||
{body === null ? null : reactionBar}
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -27,9 +27,14 @@ import { formatRelativeTimeLabel } from "~/timestampFormat";
|
||||
import { Button } from "../ui/button";
|
||||
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible";
|
||||
import { toastManager } from "../ui/toast";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
import {
|
||||
buildPullRequestTimeline,
|
||||
groupPullRequestTimelineConversations,
|
||||
isPullRequestVerdictStale,
|
||||
newestPullRequestCommitAt,
|
||||
pullRequestReviewOutcome,
|
||||
type PullRequestReviewOutcome,
|
||||
type PullRequestTimelineEvent,
|
||||
} from "./pullRequestDetail.logic";
|
||||
import { canEditPullRequestComment } from "./pullRequestEditing.logic";
|
||||
@@ -40,6 +45,10 @@ import {
|
||||
PullRequestActorAvatar,
|
||||
PullRequestDiffStat,
|
||||
PullRequestMetaLine,
|
||||
PullRequestReviewOutcomeIcon,
|
||||
pullRequestReviewOutcomeLabel,
|
||||
pullRequestReviewOutcomeStaleLabel,
|
||||
pullRequestReviewOutcomeToneClassName,
|
||||
} from "./pullRequestPresentation";
|
||||
|
||||
/** What every comment on the timeline needs to react; only the subject differs between them. */
|
||||
@@ -411,6 +420,100 @@ function LifecycleEvent({ event }: { event: PullRequestTimelineEvent }) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A verdict, as its own row rather than a line inside a collapsed conversation. It wears the
|
||||
* reviewer's face on the rail and the verdict's own icon beside their name, so "approved" reads
|
||||
* at a glance from the same place a merge or a commit does.
|
||||
*/
|
||||
function ReviewVerdictEvent({
|
||||
event,
|
||||
outcome,
|
||||
stale,
|
||||
cwd,
|
||||
onOpen,
|
||||
reactions,
|
||||
}: {
|
||||
event: PullRequestTimelineEvent;
|
||||
outcome: PullRequestReviewOutcome;
|
||||
/** Commits landed after this verdict, so it speaks for code the branch no longer has. */
|
||||
stale: boolean;
|
||||
cwd: string;
|
||||
onOpen: (url: string) => void;
|
||||
reactions: ReactionSurface;
|
||||
}) {
|
||||
return (
|
||||
<div className="group relative mb-5 pl-12 [contain-intrinsic-block-size:48px] [content-visibility:auto]">
|
||||
{/* Pinned rather than centred: this row grows with a body and a reaction bar, and a
|
||||
centred avatar drifts down beside them instead of sitting by the name. */}
|
||||
<ActorTimelineMarker
|
||||
actors={event.actor ? [event.actor] : []}
|
||||
className="top-6"
|
||||
fallback={<PullRequestReviewOutcomeIcon outcome={outcome} />}
|
||||
/>
|
||||
<div className="flex min-w-0 items-start gap-2 py-1.5">
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-xs">
|
||||
<ActorName actor={event.actor} />
|
||||
{/* The word alone, in the verdict's own colour — green for an approval, red for a
|
||||
request for changes. A verdict overtaken by later commits keeps its word and
|
||||
loses that colour: it still happened, and it no longer speaks for what is on the
|
||||
branch. Lowercased in the styling rather than the string, so what a screen reader
|
||||
announces stays the label every other surface uses. */}
|
||||
<Tooltip disabled={!stale}>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<span
|
||||
className={cn(
|
||||
"font-medium lowercase",
|
||||
stale
|
||||
? "text-muted-foreground opacity-70"
|
||||
: pullRequestReviewOutcomeToneClassName(outcome),
|
||||
)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{pullRequestReviewOutcomeLabel(outcome)}
|
||||
{stale ? <span className="sr-only">, before the latest commits</span> : null}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup>{pullRequestReviewOutcomeStaleLabel(outcome)}</TooltipPopup>
|
||||
</Tooltip>
|
||||
</div>
|
||||
{/* The reaction bar rides this line rather than taking one of its own. Its add button
|
||||
is invisible until hovered but still occupies `h-6`, and under a verdict — usually a
|
||||
single line with no body — a row of that reserved on its own reads as a hole. */}
|
||||
<div className="mt-0.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<PullRequestMetaLine className="flex-wrap text-[11px] text-muted-foreground">
|
||||
<span>{formatRelativeTimeLabel(event.at)}</span>
|
||||
{event.path ? (
|
||||
<span className="inline-flex min-w-0 items-center gap-1">
|
||||
<FileCode2Icon aria-hidden className="size-3 shrink-0" />
|
||||
<span className="truncate">{event.path}</span>
|
||||
</span>
|
||||
) : null}
|
||||
</PullRequestMetaLine>
|
||||
{reactions.canReact || event.reactions.length > 0 ? (
|
||||
<PullRequestReactionBar
|
||||
reactions={event.reactions}
|
||||
canReact={reactions.canReact}
|
||||
subjectId={event.id}
|
||||
environmentId={reactions.environmentId}
|
||||
reference={reactions.reference}
|
||||
onRefresh={reactions.onRefresh}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
{/* An approval usually carries no words. When it does they are the review, so they stay
|
||||
visible rather than being folded away with the ordinary conversation. */}
|
||||
{event.body ? (
|
||||
<TimelineBody body={event.body} markdown={event.markdown} cwd={cwd} />
|
||||
) : null}
|
||||
</div>
|
||||
<OpenOnHostButton url={event.url} onOpen={onOpen} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function PullRequestTimelineTab({
|
||||
detail,
|
||||
environmentId,
|
||||
@@ -427,6 +530,7 @@ export function PullRequestTimelineTab({
|
||||
onRefresh: () => void;
|
||||
}) {
|
||||
const events = buildPullRequestTimeline(detail);
|
||||
const newestCommitAt = newestPullRequestCommitAt(detail.commits);
|
||||
const reactions: ReactionSurface = {
|
||||
canReact: detail.capabilities.reactions === true,
|
||||
environmentId,
|
||||
@@ -468,6 +572,20 @@ export function PullRequestTimelineTab({
|
||||
if (event.kind === "commit") {
|
||||
return <CommitEvent key={event.id} event={event} onOpen={onOpenCommit} />;
|
||||
}
|
||||
const outcome = pullRequestReviewOutcome(event.reviewState);
|
||||
if (outcome !== null) {
|
||||
return (
|
||||
<ReviewVerdictEvent
|
||||
key={event.id}
|
||||
event={event}
|
||||
outcome={outcome}
|
||||
stale={isPullRequestVerdictStale(event.at, newestCommitAt)}
|
||||
cwd={detail.workspaceRoot}
|
||||
onOpen={openOnHost}
|
||||
reactions={reactions}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return <LifecycleEvent key={event.id} event={event} />;
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,10 @@ import {
|
||||
groupPullRequestTimelineConversations,
|
||||
handoffPrompt,
|
||||
handoffReviewComments,
|
||||
isPullRequestVerdictStale,
|
||||
isThreadOwnPullRequest,
|
||||
latestPullRequestReviewOutcomes,
|
||||
newestPullRequestCommitAt,
|
||||
mergePullRequestThreadComments,
|
||||
orderPullRequestComments,
|
||||
pullRequestActionMenuHasGroup,
|
||||
@@ -24,6 +27,7 @@ import {
|
||||
pullRequestComposerTarget,
|
||||
pullRequestFindingKey,
|
||||
pullRequestHandoffLabels,
|
||||
pullRequestReviewOutcome,
|
||||
readableFailure,
|
||||
shouldRefreshPullRequestActivity,
|
||||
resolveBaseFreshness,
|
||||
@@ -177,6 +181,171 @@ describe("ordering comments", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("review verdicts", () => {
|
||||
it("reads the same three verdicts however a host spells them", () => {
|
||||
expect(pullRequestReviewOutcome("APPROVED")).toBe("approved");
|
||||
expect(pullRequestReviewOutcome("approved")).toBe("approved");
|
||||
expect(pullRequestReviewOutcome("CHANGES_REQUESTED")).toBe("changes-requested");
|
||||
expect(pullRequestReviewOutcome("changes_requested")).toBe("changes-requested");
|
||||
expect(pullRequestReviewOutcome("DISMISSED")).toBe("dismissed");
|
||||
});
|
||||
|
||||
it("is not a verdict where the review only carried remarks", () => {
|
||||
expect(pullRequestReviewOutcome("COMMENTED")).toBeNull();
|
||||
expect(pullRequestReviewOutcome("PENDING")).toBeNull();
|
||||
expect(pullRequestReviewOutcome(null)).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps each reviewer's last word, whatever order the host returned them in", () => {
|
||||
const review = (
|
||||
id: string,
|
||||
login: string,
|
||||
reviewState: string,
|
||||
createdAt: string,
|
||||
): PullRequestComment => ({
|
||||
id,
|
||||
kind: "review",
|
||||
author: { login, name: null, avatarUrl: null },
|
||||
body: "",
|
||||
createdAt,
|
||||
url: null,
|
||||
path: null,
|
||||
reviewState,
|
||||
});
|
||||
|
||||
expect(
|
||||
latestPullRequestReviewOutcomes([
|
||||
review("r3", "bilal", "APPROVED", "2026-07-03T00:00:00Z"),
|
||||
review("r1", "bilal", "CHANGES_REQUESTED", "2026-07-01T00:00:00Z"),
|
||||
review("r2", "octocat", "CHANGES_REQUESTED", "2026-07-02T00:00:00Z"),
|
||||
// Not a verdict, so it neither adds a reviewer nor overwrites one.
|
||||
review("r4", "octocat", "COMMENTED", "2026-07-04T00:00:00Z"),
|
||||
]).map((entry) => [entry.actor?.login, entry.outcome]),
|
||||
).toEqual([
|
||||
["bilal", "approved"],
|
||||
["octocat", "changes-requested"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps two deleted accounts apart rather than counting them as one reviewer", () => {
|
||||
expect(
|
||||
latestPullRequestReviewOutcomes([
|
||||
{
|
||||
...TIMELINE_SOURCE.comments[0]!,
|
||||
id: "r1",
|
||||
kind: "review",
|
||||
author: null,
|
||||
reviewState: "APPROVED",
|
||||
createdAt: "2026-07-01T00:00:00Z",
|
||||
},
|
||||
{
|
||||
...TIMELINE_SOURCE.comments[0]!,
|
||||
id: "r2",
|
||||
kind: "review",
|
||||
author: null,
|
||||
reviewState: "APPROVED",
|
||||
createdAt: "2026-07-02T00:00:00Z",
|
||||
},
|
||||
]),
|
||||
).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("gives every entry a key that separates the reviewers it kept apart", () => {
|
||||
const entries = latestPullRequestReviewOutcomes([
|
||||
{
|
||||
...TIMELINE_SOURCE.comments[0]!,
|
||||
id: "r1",
|
||||
kind: "review",
|
||||
author: null,
|
||||
reviewState: "APPROVED",
|
||||
createdAt: "2026-07-01T00:00:00Z",
|
||||
},
|
||||
{
|
||||
...TIMELINE_SOURCE.comments[0]!,
|
||||
id: "r2",
|
||||
kind: "review",
|
||||
author: null,
|
||||
reviewState: "APPROVED",
|
||||
createdAt: "2026-07-01T00:00:00Z",
|
||||
},
|
||||
]);
|
||||
// Same author (none) and the same instant, so only the review's own id tells them apart.
|
||||
expect(new Set(entries.map((entry) => entry.key)).size).toBe(2);
|
||||
});
|
||||
|
||||
it("calls a verdict stale once commits land after it, and current before that", () => {
|
||||
const commits = [
|
||||
{ oid: "c0ffee", messageHeadline: "later work", committedDate: "2026-07-05T00:00:00Z" },
|
||||
];
|
||||
const review = (createdAt: string): PullRequestComment => ({
|
||||
...TIMELINE_SOURCE.comments[0]!,
|
||||
kind: "review",
|
||||
reviewState: "APPROVED",
|
||||
createdAt,
|
||||
});
|
||||
|
||||
expect(
|
||||
latestPullRequestReviewOutcomes([review("2026-07-01T00:00:00Z")], commits)[0]?.stale,
|
||||
).toBe(true);
|
||||
expect(
|
||||
latestPullRequestReviewOutcomes([review("2026-07-06T00:00:00Z")], commits)[0]?.stale,
|
||||
).toBe(false);
|
||||
// Nothing to be overtaken by, so nothing is stale.
|
||||
expect(latestPullRequestReviewOutcomes([review("2026-07-01T00:00:00Z")], [])[0]?.stale).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it("measures staleness against the newest commit, not the last one listed", () => {
|
||||
expect(
|
||||
newestPullRequestCommitAt([
|
||||
{ oid: "a", messageHeadline: "", committedDate: "2026-07-09T00:00:00Z" },
|
||||
{ oid: "b", messageHeadline: "", committedDate: "2026-07-02T00:00:00Z" },
|
||||
]),
|
||||
).toBe("2026-07-09T00:00:00Z");
|
||||
expect(newestPullRequestCommitAt([])).toBeNull();
|
||||
});
|
||||
|
||||
it("orders instants rather than their text, so a UTC offset cannot invert them", () => {
|
||||
// 01:00+02:00 is 23:00 the previous day, so as text it sorts after the Z stamp and in time
|
||||
// it falls well before it.
|
||||
expect(
|
||||
newestPullRequestCommitAt([
|
||||
{ oid: "a", messageHeadline: "", committedDate: "2026-07-05T00:30:00Z" },
|
||||
{ oid: "b", messageHeadline: "", committedDate: "2026-07-05T01:00:00+02:00" },
|
||||
]),
|
||||
).toBe("2026-07-05T00:30:00Z");
|
||||
expect(isPullRequestVerdictStale("2026-07-05T00:30:00Z", "2026-07-05T01:00:00+02:00")).toBe(
|
||||
false,
|
||||
);
|
||||
// A timestamp nothing can parse is not a position, so it settles nothing either way.
|
||||
expect(isPullRequestVerdictStale("2026-07-01T00:00:00Z", "not a date")).toBe(false);
|
||||
expect(
|
||||
newestPullRequestCommitAt([{ oid: "a", messageHeadline: "", committedDate: "not a date" }]),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("shows nothing for a reviewer whose verdict was dismissed", () => {
|
||||
expect(
|
||||
latestPullRequestReviewOutcomes([
|
||||
{
|
||||
...TIMELINE_SOURCE.comments[0]!,
|
||||
kind: "review",
|
||||
reviewState: "APPROVED",
|
||||
createdAt: "2026-07-01T00:00:00Z",
|
||||
},
|
||||
{
|
||||
...TIMELINE_SOURCE.comments[0]!,
|
||||
id: "c2",
|
||||
kind: "review",
|
||||
reviewState: "DISMISSED",
|
||||
createdAt: "2026-07-02T00:00:00Z",
|
||||
},
|
||||
]),
|
||||
).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("pull request timeline", () => {
|
||||
it("orders creation, commits and comments newest first", () => {
|
||||
// What happened last is what the reader opening the tab is asking about.
|
||||
@@ -321,6 +490,47 @@ describe("pull request timeline", () => {
|
||||
["event", "created"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps a verdict out of the collapsed conversation it was submitted in", () => {
|
||||
const events = buildPullRequestTimeline({
|
||||
...TIMELINE_SOURCE,
|
||||
comments: [
|
||||
{ ...TIMELINE_SOURCE.comments[0]!, id: "chatter-1", createdAt: "2026-07-05T00:00:00Z" },
|
||||
{
|
||||
...TIMELINE_SOURCE.comments[0]!,
|
||||
id: "approval",
|
||||
kind: "review",
|
||||
body: "",
|
||||
reviewState: "APPROVED",
|
||||
createdAt: "2026-07-04T00:00:00Z",
|
||||
},
|
||||
{ ...TIMELINE_SOURCE.comments[0]!, id: "chatter-2", createdAt: "2026-07-03T00:00:00Z" },
|
||||
// A review without a verdict is ordinary conversation and still groups.
|
||||
{
|
||||
...TIMELINE_SOURCE.comments[0]!,
|
||||
id: "remark",
|
||||
kind: "review",
|
||||
reviewState: "COMMENTED",
|
||||
createdAt: "2026-07-02T12:00:00Z",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const rows = groupPullRequestTimelineConversations(events);
|
||||
expect(
|
||||
rows.map((row) =>
|
||||
row.kind === "comments"
|
||||
? [row.kind, ...row.events.map((event) => event.id)]
|
||||
: [row.kind, row.event.id],
|
||||
),
|
||||
).toEqual([
|
||||
["comments", "chatter-1"],
|
||||
["event", "approval"],
|
||||
["comments", "chatter-2", "remark"],
|
||||
["event", "1baf7bdcafe"],
|
||||
["event", "created"],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("fix findings handoff", () => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
PullRequestBaseComparison,
|
||||
PullRequestCheck,
|
||||
PullRequestComment,
|
||||
PullRequestCommit,
|
||||
PullRequestDetailView,
|
||||
PullRequestMergeability,
|
||||
PullRequestReaction,
|
||||
@@ -117,6 +118,123 @@ export function orderPullRequestComments<T extends { readonly createdAt: string
|
||||
return order === "newest" ? comments.toReversed() : comments;
|
||||
}
|
||||
|
||||
/** A review that says something about the change itself, rather than only carrying remarks. */
|
||||
export type PullRequestReviewOutcome = "approved" | "changes-requested" | "dismissed";
|
||||
|
||||
/**
|
||||
* Which review states are a verdict. Hosts spell the same three differently — GitHub reports
|
||||
* `CHANGES_REQUESTED`, Bitbucket `changes_requested` — so case and separator are ignored, and
|
||||
* anything else (GitHub's `COMMENTED`, a state no host here reports yet) is not a verdict.
|
||||
*/
|
||||
export function pullRequestReviewOutcome(
|
||||
reviewState: string | null,
|
||||
): PullRequestReviewOutcome | null {
|
||||
switch (reviewState?.trim().toLowerCase().replaceAll("_", "-")) {
|
||||
case "approved":
|
||||
return "approved";
|
||||
case "changes-requested":
|
||||
return "changes-requested";
|
||||
case "dismissed":
|
||||
return "dismissed";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An instant as a number, because the text is not the order. Every host returns ISO-8601 but not
|
||||
* all of them in UTC, and `2026-07-05T01:00:00+02:00` sorts after `2026-07-05T00:30:00Z` as text
|
||||
* while falling an hour and a half before it in time. NaN for anything unparseable, which every
|
||||
* caller treats as "cannot say" rather than as a position.
|
||||
*/
|
||||
function instant(iso: string): number {
|
||||
return Date.parse(iso);
|
||||
}
|
||||
|
||||
/**
|
||||
* The newest commit on the branch, which is what a verdict is current against. Null where the
|
||||
* host reported no commits — or none with a timestamp that parses — since nothing can then be
|
||||
* said to predate them.
|
||||
*/
|
||||
export function newestPullRequestCommitAt(
|
||||
commits: ReadonlyArray<PullRequestCommit>,
|
||||
): string | null {
|
||||
let newest: string | null = null;
|
||||
let newestAt = Number.NEGATIVE_INFINITY;
|
||||
for (const commit of commits) {
|
||||
const at = instant(commit.committedDate);
|
||||
if (Number.isNaN(at) || at <= newestAt) continue;
|
||||
newest = commit.committedDate;
|
||||
newestAt = at;
|
||||
}
|
||||
return newest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a verdict was given before the code it was given on.
|
||||
*
|
||||
* Measured against commit dates, which is the only thing the detail carries. That is a proxy and
|
||||
* not the question: a commit date says when the work was written, not when it reached this change
|
||||
* request, so pushing a branch of older commits after an approval leaves the approval reading as
|
||||
* current, and a rebase re-dates commits a verdict already covered. Answering it exactly needs
|
||||
* the host's own review-to-commit link — GitHub hangs a commit off every review — which no
|
||||
* adapter reads yet. Until one does, this errs towards leaving a verdict alone: it dims only
|
||||
* where the branch plainly moved on.
|
||||
*/
|
||||
export function isPullRequestVerdictStale(at: string, newestCommitAt: string | null): boolean {
|
||||
if (newestCommitAt === null) return false;
|
||||
const verdictAt = instant(at);
|
||||
const commitAt = instant(newestCommitAt);
|
||||
return !Number.isNaN(verdictAt) && !Number.isNaN(commitAt) && verdictAt < commitAt;
|
||||
}
|
||||
|
||||
export interface PullRequestReviewOutcomeEntry {
|
||||
/**
|
||||
* What made this entry its own reviewer. A login where the host reported one, and otherwise the
|
||||
* review's own id — so a surface listing these has a key that separates the same two authorless
|
||||
* verdicts this does, rather than collapsing them back into one row.
|
||||
*/
|
||||
readonly key: string;
|
||||
readonly actor: PullRequestActor | null;
|
||||
readonly outcome: PullRequestReviewOutcome;
|
||||
readonly at: string;
|
||||
/** Commits landed after this verdict, so it speaks for code that is no longer on the branch. */
|
||||
readonly stale: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where each reviewer landed, which is what "is this approved?" actually asks. One entry per
|
||||
* person and only their last word: a host keeps every review somebody ever submitted, and an
|
||||
* approval later followed by a request for changes is not an approval any more. A dismissal is a
|
||||
* verdict taken back, so it leaves nothing to show rather than showing itself.
|
||||
*/
|
||||
export function latestPullRequestReviewOutcomes(
|
||||
comments: ReadonlyArray<PullRequestComment>,
|
||||
/** Left empty by a caller with no commits to hand, which makes no verdict stale. */
|
||||
commits: ReadonlyArray<PullRequestCommit> = [],
|
||||
): ReadonlyArray<PullRequestReviewOutcomeEntry> {
|
||||
const newestCommitAt = newestPullRequestCommitAt(commits);
|
||||
const latest = new Map<string, PullRequestReviewOutcomeEntry>();
|
||||
for (const comment of comments) {
|
||||
const outcome = pullRequestReviewOutcome(comment.reviewState);
|
||||
if (outcome === null) continue;
|
||||
// Two deleted accounts are two reviewers. Keying both as "ghost" would let one overwrite the
|
||||
// other and undercount the verdicts, so a review with no author identity stands alone.
|
||||
const login = comment.author?.login ?? `ghost:${comment.id}`;
|
||||
const current = latest.get(login);
|
||||
// Not every host returns its reviews in order, so the newest wins rather than the last read.
|
||||
if (current !== undefined && instant(current.at) > instant(comment.createdAt)) continue;
|
||||
latest.set(login, {
|
||||
key: login,
|
||||
actor: comment.author,
|
||||
outcome,
|
||||
at: comment.createdAt,
|
||||
stale: isPullRequestVerdictStale(comment.createdAt, newestCommitAt),
|
||||
});
|
||||
}
|
||||
return [...latest.values()].filter((entry) => entry.outcome !== "dismissed");
|
||||
}
|
||||
|
||||
export interface PullRequestTimelineEvent {
|
||||
readonly id: string;
|
||||
readonly at: string;
|
||||
@@ -146,13 +264,20 @@ export type PullRequestTimelineRow =
|
||||
* Consecutive comments are one conversation section. Commits and pull-request lifecycle updates
|
||||
* stay first-class rows and split those sections, so expanding a conversation never hides the
|
||||
* work that happened between two review rounds.
|
||||
*
|
||||
* A verdict is a first-class row too. Whether the change was approved is the question a reader
|
||||
* opens the timeline with, and folding the answer into a collapsed "9 comments" section hides it
|
||||
* behind a press — the one thing on the page that must be readable without one.
|
||||
*/
|
||||
export function groupPullRequestTimelineConversations(
|
||||
events: ReadonlyArray<PullRequestTimelineEvent>,
|
||||
): ReadonlyArray<PullRequestTimelineRow> {
|
||||
const rows: PullRequestTimelineRow[] = [];
|
||||
for (const event of events) {
|
||||
if (event.kind === "comment" || event.kind === "review") {
|
||||
if (
|
||||
(event.kind === "comment" || event.kind === "review") &&
|
||||
pullRequestReviewOutcome(event.reviewState) === null
|
||||
) {
|
||||
const last = rows.at(-1);
|
||||
if (last?.kind === "comments") {
|
||||
rows[rows.length - 1] = { kind: "comments", events: [...last.events, event] };
|
||||
@@ -172,7 +297,7 @@ export function groupPullRequestTimelineConversations(
|
||||
* at all. The stripped text decides that and nothing else: the body itself is passed on whole,
|
||||
* because a comment demonstrating an HTML comment inside a code fence still has to show it.
|
||||
*/
|
||||
function visibleBody(body: string): string | null {
|
||||
export function visibleBody(body: string): string | null {
|
||||
return body.replace(/<!--[\s\S]*?-->/gu, "").trim().length === 0 ? null : body.trim();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ import { Children, isValidElement, type ReactNode } from "react";
|
||||
|
||||
import { cn } from "~/lib/utils";
|
||||
|
||||
import { Badge } from "../ui/badge";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
import type { PullRequestReviewOutcome } from "./pullRequestDetail.logic";
|
||||
|
||||
interface StatePresentation {
|
||||
readonly label: string;
|
||||
@@ -191,6 +193,117 @@ export function pullRequestChecksState(
|
||||
return statuses.includes("success") ? "passing" : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* How a verdict reads, in the one place every surface takes it from. The green is the green a
|
||||
* passing check already wears in the same panel, so "approved" and "all checks passed" cannot
|
||||
* look like two different kinds of good news.
|
||||
*
|
||||
* The ring runs a shade stronger than the text tones. At 16px across it is a thin arc, and the
|
||||
* muted pairing that reads well as a word was barely there as an outline.
|
||||
*/
|
||||
const REVIEW_OUTCOME_PRESENTATION = {
|
||||
approved: {
|
||||
label: "Approved",
|
||||
Icon: CircleCheckIcon,
|
||||
toneClassName: "text-emerald-600 dark:text-emerald-300/90",
|
||||
ringClassName: "ring-2 ring-emerald-500 dark:ring-emerald-400",
|
||||
staleRingClassName:
|
||||
"ring-2 ring-[color-mix(in_srgb,var(--color-emerald-500)_35%,var(--background))] dark:ring-[color-mix(in_srgb,var(--color-emerald-400)_35%,var(--background))]",
|
||||
badgeVariant: "success",
|
||||
},
|
||||
"changes-requested": {
|
||||
label: "Changes requested",
|
||||
Icon: CircleXIcon,
|
||||
toneClassName: "text-destructive",
|
||||
ringClassName: "ring-2 ring-destructive",
|
||||
staleRingClassName: "ring-2 ring-[color-mix(in_srgb,var(--destructive)_35%,var(--background))]",
|
||||
badgeVariant: "error",
|
||||
},
|
||||
dismissed: {
|
||||
label: "Review dismissed",
|
||||
Icon: CircleDashedIcon,
|
||||
toneClassName: "text-muted-foreground/70",
|
||||
ringClassName: "ring-2 ring-muted-foreground/60",
|
||||
staleRingClassName:
|
||||
"ring-2 ring-[color-mix(in_srgb,var(--muted-foreground)_30%,var(--background))]",
|
||||
badgeVariant: "outline",
|
||||
},
|
||||
} as const satisfies Record<
|
||||
PullRequestReviewOutcome,
|
||||
{
|
||||
label: string;
|
||||
Icon: typeof CircleCheckIcon;
|
||||
toneClassName: string;
|
||||
ringClassName: string;
|
||||
staleRingClassName: string;
|
||||
badgeVariant: "success" | "error" | "outline";
|
||||
}
|
||||
>;
|
||||
|
||||
export function pullRequestReviewOutcomeToneClassName(outcome: PullRequestReviewOutcome): string {
|
||||
return REVIEW_OUTCOME_PRESENTATION[outcome].toneClassName;
|
||||
}
|
||||
|
||||
/** Worn by whatever wraps a reviewer's avatar, so their verdict reads without a row of its own. */
|
||||
/**
|
||||
* A faded verdict is mixed into the background rather than made translucent. The ring is the only
|
||||
* separator an avatar carrying one has — the summary drops the opaque `ring-background` where a
|
||||
* verdict is drawn — and the stack overlaps by 4px, so an alpha ring would let the neighbour show
|
||||
* straight through it and the two faces would merge.
|
||||
*/
|
||||
export function pullRequestReviewOutcomeRingClassName(
|
||||
outcome: PullRequestReviewOutcome,
|
||||
stale = false,
|
||||
): string {
|
||||
const presentation = REVIEW_OUTCOME_PRESENTATION[outcome];
|
||||
return stale ? presentation.staleRingClassName : presentation.ringClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* What a superseded verdict says, which is the same word with when it applied added. Commits
|
||||
* landed after it, so it stands for code the branch no longer has.
|
||||
*/
|
||||
export function pullRequestReviewOutcomeStaleLabel(outcome: PullRequestReviewOutcome): string {
|
||||
return `${REVIEW_OUTCOME_PRESENTATION[outcome].label} earlier changes`;
|
||||
}
|
||||
|
||||
/** Decorative: every caller says which verdict this is in words beside it. */
|
||||
export function PullRequestReviewOutcomeIcon({
|
||||
outcome,
|
||||
className,
|
||||
}: {
|
||||
outcome: PullRequestReviewOutcome;
|
||||
className?: string;
|
||||
}) {
|
||||
const presentation = REVIEW_OUTCOME_PRESENTATION[outcome];
|
||||
return (
|
||||
<presentation.Icon
|
||||
aria-hidden
|
||||
className={cn("size-3.5 shrink-0", presentation.toneClassName, className)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function pullRequestReviewOutcomeLabel(outcome: PullRequestReviewOutcome): string {
|
||||
return REVIEW_OUTCOME_PRESENTATION[outcome].label;
|
||||
}
|
||||
|
||||
export function PullRequestReviewOutcomeBadge({
|
||||
outcome,
|
||||
className,
|
||||
}: {
|
||||
outcome: PullRequestReviewOutcome;
|
||||
className?: string;
|
||||
}) {
|
||||
const presentation = REVIEW_OUTCOME_PRESENTATION[outcome];
|
||||
return (
|
||||
<Badge size="sm" variant={presentation.badgeVariant} className={cn("gap-1", className)}>
|
||||
<presentation.Icon aria-hidden className="size-3" />
|
||||
{presentation.label}
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
|
||||
export function PullRequestActorAvatar({
|
||||
actor,
|
||||
className,
|
||||
|
||||
Reference in new issue
Block a user