Skip to content

Commit 69ec833

Browse files
authored
feat: Add copy comment link button in PR overview (#8150)
1 parent ccdbe08 commit 69ec833

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

webviews/components/comment.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
77
import { ContextDropdown } from './contextDropdown';
8-
import { editIcon, quoteIcon, trashIcon } from './icon';
8+
import { copyIcon, editIcon, quoteIcon, trashIcon } from './icon';
99
import { nbsp, Spaced } from './space';
1010
import { Timestamp } from './timestamp';
1111
import { AuthorLink, Avatar } from './user';
@@ -48,6 +48,7 @@ export function CommentView(commentProps: Props) {
4848
const currentDraft = pr?.pendingCommentDrafts && pr.pendingCommentDrafts[id];
4949
const [inEditMode, setEditMode] = useState(!!currentDraft);
5050
const [showActionBar, setShowActionBar] = useState(false);
51+
const commentUrl = (comment as Partial<IComment | ReviewEvent | CommentEvent>).htmlUrl || (comment as PullRequest).url;
5152

5253
if (inEditMode) {
5354
return React.cloneElement(headerInEditMode ? <CommentBox for={comment} /> : <></>, {}, [
@@ -96,6 +97,15 @@ export function CommentView(commentProps: Props) {
9697
>
9798
{quoteIcon}
9899
</button>
100+
{commentUrl ? (
101+
<button
102+
title="Copy Comment Link"
103+
className="icon-button"
104+
onClick={() => navigator.clipboard.writeText(commentUrl)}
105+
>
106+
{copyIcon}
107+
</button>
108+
) : null}
99109
{canEdit ? (
100110
<button title="Edit comment" className="icon-button" onClick={() => setEditMode(true)}>
101111
{editIcon}

0 commit comments

Comments
 (0)