(newCommentBox: HTMLElement)
| 11 | import {getCloseDate, getResolvedText, wasLongAgo} from './netiquette.js'; |
| 12 | |
| 13 | async function addConversationBanner(newCommentBox: HTMLElement): Promise<void> { |
| 14 | // Check inside the observer because React views load after dom-ready |
| 15 | const closingDate = await getCloseDate(); |
| 16 | if (!closingDate || !wasLongAgo(closingDate)) { |
| 17 | features.unload(import.meta.url); |
| 18 | return; |
| 19 | } |
| 20 | |
| 21 | const button = ( |
| 22 | <button |
| 23 | type="button" |
| 24 | className="btn-link" |
| 25 | onClick={() => { |
| 26 | newCommentBox.hidden = false; |
| 27 | |
| 28 | // Keep the banner, make it visible |
| 29 | closestElement('.rgh-bg-none', button).classList.replace('rgh-bg-none', 'flash-error'); |
| 30 | |
| 31 | // Unlink this button |
| 32 | button.replaceWith(button.firstChild!); |
| 33 | |
| 34 | newCommentBox.scrollIntoView({ |
| 35 | behavior: 'smooth', |
| 36 | }); |
| 37 | }} |
| 38 | > |
| 39 | comment |
| 40 | </button> |
| 41 | ); |
| 42 | |
| 43 | const banner = ( |
| 44 | <TimelineItem> |
| 45 | {createBanner({ |
| 46 | classes: ['rgh-bg-none'], |
| 47 | icon: <InfoIcon className="mr-1 tmp-mr-1" />, |
| 48 | text: <> |
| 49 | {getResolvedText(closingDate)} If you want to say something helpful, you can leave a {button}.{' '} |
| 50 | <strong>Do not</strong> report issues here. |
| 51 | </>, |
| 52 | })} |
| 53 | </TimelineItem> |
| 54 | ); |
| 55 | newCommentBox.before(banner); |
| 56 | newCommentBox.hidden = true; |
| 57 | } |
| 58 | |
| 59 | function init(signal: AbortSignal): void | false { |
| 60 | observe( |
nothing calls this directly
no test coverage detected