(text: string | JSX.Element, signal: AbortSignal)
| 78 | } |
| 79 | |
| 80 | async function addReleaseBanner(text: string | JSX.Element, signal: AbortSignal): Promise<void> { |
| 81 | const [releases] = await getReleasesCount(); |
| 82 | if (releases === 0) { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | const url = createReleaseUrl(); |
| 87 | const bannerContent = { |
| 88 | text, |
| 89 | icon: <TagIcon className="m-0 tmp-m-0" />, |
| 90 | classes: ['rgh-bg-none'], |
| 91 | } satisfies BannerProps; |
| 92 | |
| 93 | if (await userHasPushAccess()) { |
| 94 | Object.assign(bannerContent, { |
| 95 | action: url, |
| 96 | buttonLabel: 'Draft a new release', |
| 97 | }); |
| 98 | } |
| 99 | |
| 100 | // Use observer because GitHub might remove the box |
| 101 | // https://github.com/refined-github/refined-github/issues/9460 |
| 102 | observe(commentBoxHashPr, anchor => { |
| 103 | anchor.before( |
| 104 | <TimelineItem> |
| 105 | {createBanner(bannerContent)} |
| 106 | </TimelineItem>, |
| 107 | ); |
| 108 | }, {signal}); |
| 109 | } |
| 110 | |
| 111 | async function init(signal: AbortSignal): Promise<void> { |
| 112 | const mergeCommit = $(`.TimelineItem.js-details-container.Details a[href^="/${getRepo()!.nameWithOwner}/commit/" i]`); |
no test coverage detected