(links: HTMLAnchorElement[])
| 12 | import {tooltipped} from '../helpers/tooltip.js'; |
| 13 | |
| 14 | async function addIcon(links: HTMLAnchorElement[]): Promise<void> { |
| 15 | const prConfigs = links.map(link => { |
| 16 | const [, owner, name, , prNumber] = link.pathname.split('/'); |
| 17 | const key = api.escapeKey(owner, name, prNumber); |
| 18 | return { |
| 19 | key, |
| 20 | link, |
| 21 | owner, |
| 22 | name, |
| 23 | number: Number(prNumber), |
| 24 | }; |
| 25 | }); |
| 26 | |
| 27 | // Batch queries cannot be exported to .gql files |
| 28 | const batchQuery = prConfigs.map(({key, owner, name, number}) => ` |
| 29 | ${key}: repository(owner: "${owner}", name: "${name}") { |
| 30 | pullRequest(number: ${number}) { |
| 31 | mergeable |
| 32 | state |
| 33 | isDraft |
| 34 | } |
| 35 | } |
| 36 | `).join('\n'); |
| 37 | |
| 38 | const data = await api.v4(batchQuery); |
| 39 | |
| 40 | for (const pr of prConfigs) { |
| 41 | const {mergeable, state, isDraft} = data[pr.key].pullRequest; |
| 42 | if (mergeable === 'CONFLICTING' && (state === 'OPEN' || isDraft)) { |
| 43 | pr.link.after( |
| 44 | tooltipped( |
| 45 | {label: 'This PR has conflicts that must be resolved', direction: 'e'}, |
| 46 | <a |
| 47 | className="rgh-conflict-marker color-fg-muted ml-2 tmp-ml-2" |
| 48 | href={pr.link.pathname + commentBoxHashPr} |
| 49 | > |
| 50 | <AlertIcon className="v-align-middle" /> |
| 51 | </a>, |
| 52 | ), |
| 53 | ); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | async function init(signal: AbortSignal): Promise<void> { |
| 59 | observe(openPrsListLink, batchedFunction(addIcon, {delay: 100}), {signal}); |
nothing calls this directly
no test coverage detected