|
5 | 5 |
|
6 | 6 | import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'; |
7 | 7 | import { ContextDropdown } from './contextDropdown'; |
8 | | -import { editIcon, quoteIcon, trashIcon } from './icon'; |
| 8 | +import { copyIcon, editIcon, quoteIcon, trashIcon } from './icon'; |
9 | 9 | import { nbsp, Spaced } from './space'; |
10 | 10 | import { Timestamp } from './timestamp'; |
11 | 11 | import { AuthorLink, Avatar } from './user'; |
@@ -48,6 +48,7 @@ export function CommentView(commentProps: Props) { |
48 | 48 | const currentDraft = pr?.pendingCommentDrafts && pr.pendingCommentDrafts[id]; |
49 | 49 | const [inEditMode, setEditMode] = useState(!!currentDraft); |
50 | 50 | const [showActionBar, setShowActionBar] = useState(false); |
| 51 | + const commentUrl = (comment as Partial<IComment | ReviewEvent | CommentEvent>).htmlUrl || (comment as PullRequest).url; |
51 | 52 |
|
52 | 53 | if (inEditMode) { |
53 | 54 | return React.cloneElement(headerInEditMode ? <CommentBox for={comment} /> : <></>, {}, [ |
@@ -96,6 +97,15 @@ export function CommentView(commentProps: Props) { |
96 | 97 | > |
97 | 98 | {quoteIcon} |
98 | 99 | </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} |
99 | 109 | {canEdit ? ( |
100 | 110 | <button title="Edit comment" className="icon-button" onClick={() => setEditMode(true)}> |
101 | 111 | {editIcon} |
|
0 commit comments