(reviewersSection: Element)
| 76 | } |
| 77 | |
| 78 | async function addSidebarReviewButtons(reviewersSection: Element): Promise<void> { |
| 79 | // Occasionally this button appears before "Reviewers", so let's wait a bit longer |
| 80 | await delay(300); |
| 81 | |
| 82 | const quickReview = ( |
| 83 | <span className="text-normal color-fg-muted"> |
| 84 | {'– '} |
| 85 | {tooltipped( |
| 86 | { |
| 87 | label: 'Review now', |
| 88 | shortcut: 'v', |
| 89 | }, |
| 90 | <a |
| 91 | // TODO [2027-01-01]: Change path to "changes" once Legacy PR files view is removed |
| 92 | href={`${location.pathname}/files#${openReviewMenuDeepLink}`} |
| 93 | className="rgh-quick-review btn-link Link--muted Link--inTextBlock" |
| 94 | data-turbo-frame="repo-content-turbo-frame" |
| 95 | data-hotkey="v" |
| 96 | onMouseEnter={preloadPrFilesTab} |
| 97 | > |
| 98 | review now |
| 99 | </a>, |
| 100 | )} |
| 101 | </span> |
| 102 | ); |
| 103 | |
| 104 | reviewersSection.append(quickReview); |
| 105 | |
| 106 | // Can't approve own PRs and closed PRs |
| 107 | // API required for this action |
| 108 | if ( |
| 109 | getLoggedInUser() === $('.author').textContent |
| 110 | || pageDetect.isClosedConversation() |
| 111 | || !(await getToken()) |
| 112 | ) { |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | quickReview.append( |
| 117 | ' – ', |
| 118 | tooltipped( |
| 119 | {label: 'Hold alt to approve without confirmation', direction: 'nw'}, |
| 120 | <button |
| 121 | type="button" |
| 122 | className="btn-link Link--muted Link--inTextBlock rgh-quick-approve" |
| 123 | > |
| 124 | approve now |
| 125 | </button>, |
| 126 | ), |
| 127 | ); |
| 128 | } |
| 129 | |
| 130 | async function initSidebarReviewButton(signal: AbortSignal): Promise<void> { |
| 131 | observe('#reviewers-select-menu .discussion-sidebar-heading', addSidebarReviewButtons, {signal}); |
nothing calls this directly
no test coverage detected