Open History to see the last commit
1import { MessageCircle, X } from "lucide-react";
2
3import {
4 COMPOSER_INLINE_CHIP_CLASS_NAME,
5 COMPOSER_INLINE_CHIP_DISMISS_BUTTON_CLASS_NAME,
6 COMPOSER_INLINE_CHIP_ICON_CLASS_NAME,
7 COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME,
8} from "../composerInlineChip";
9import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
10import type { ReviewCommentContext } from "~/reviewCommentContext";
11import { cn } from "~/lib/utils";
12
13interface ComposerPendingReviewCommentsProps {
14 comments: ReadonlyArray<ReviewCommentContext>;
15 onRemove: (commentId: string) => void;
16 className?: string;
17}
18
19export function ComposerPendingReviewComments({
20 comments,
21 onRemove,
22 className,
23}: ComposerPendingReviewCommentsProps) {
24 if (comments.length === 0) return null;
25
26 return (
27 <div className={cn("flex flex-wrap gap-1.5", className)}>
28 {comments.map((comment) => {
29 const label = `${comment.filePath} ${comment.rangeLabel}`;
30 return (
31 <Tooltip key={comment.id}>
32 <TooltipTrigger
33 render={
34 <span className={cn(COMPOSER_INLINE_CHIP_CLASS_NAME, "pr-1")}>
35 <MessageCircle className={cn(COMPOSER_INLINE_CHIP_ICON_CLASS_NAME, "size-3.5")} />
36 <span className={COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME}>{label}</span>
37 <button
38 type="button"
39 aria-label={`Remove comment on ${label}`}
40 className={COMPOSER_INLINE_CHIP_DISMISS_BUTTON_CLASS_NAME}
41 onClick={(event) => {
42 event.preventDefault();
43 event.stopPropagation();
44 onRemove(comment.id);
45 }}
46 >
47 <X className="size-3" aria-hidden />
48 </button>
49 </span>
50 }
51 />
52 <TooltipPopup side="top" className="max-w-96 whitespace-pre-wrap leading-tight">
53 {comment.text}
54 </TooltipPopup>
55 </Tooltip>
56 );
57 })}
58 </div>
59 );
60}