-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Extend issue context popup beyond markdown content #36908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7dacf4b
Show issue/PR context popup on any issue/PR link site-wide
silverwind a5b73c6
Add 300ms hover delay and extract showRefIssuePopup
silverwind 6656acf
improve selector
silverwind 8944b32
Merge remote-tracking branch 'origin/main' into refpop
silverwind bc1cd33
Skip ref-issue popup on issue/PR lists, milestones, and project boards
silverwind 36ea168
Simplify ref-issue popup handler
silverwind 2a79d67
Address review: attribute-based opt-out, use backend html_url
silverwind fb651ea
Switch to opt-in ref-issue popup
silverwind 9c2a776
Cache issue info results instead of in-flight promises
silverwind 1aed218
Early-return on cache hit in getIssueInfo
silverwind b56bc8c
Suppress ancestor title when ref-issue popup shows
silverwind 2dbdf46
Type issueInfoCache exactly
silverwind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import {parseIssueHref} from '../utils.ts'; | ||
| import {GET} from '../modules/fetch.ts'; | ||
| import {createApp} from 'vue'; | ||
| import {createTippy, getAttachedTippyInstance} from '../modules/tippy.ts'; | ||
| import {addDelegatedEventListener} from '../utils/dom.ts'; | ||
|
|
||
| const issueInfoCache = new Map<string, Promise<any>>(); | ||
|
|
||
| function getIssueInfo(url: string): Promise<any> { | ||
| let promise = issueInfoCache.get(url); | ||
| if (!promise) { | ||
| promise = (async () => { | ||
| try { | ||
| const resp = await GET(url); | ||
| if (!resp.ok) throw new Error(resp.statusText || 'Unknown network error'); | ||
| return await resp.json(); | ||
| } catch (err) { | ||
| issueInfoCache.delete(url); | ||
| throw err; | ||
| } | ||
| })(); | ||
| issueInfoCache.set(url, promise); | ||
| } | ||
| return promise; | ||
| } | ||
|
|
||
| async function showRefIssuePopup(link: HTMLAnchorElement) { | ||
| const [data, {default: ContextPopup}] = await Promise.all([ | ||
| getIssueInfo(`${link.pathname}/info`), | ||
| import('../components/ContextPopup.vue'), | ||
| ]); | ||
| const el = document.createElement('div'); | ||
| const app = createApp(ContextPopup, { | ||
| issue: data.convertedIssue, | ||
| renderedLabels: data.renderedLabels, | ||
| }); | ||
| app.mount(el); | ||
| createTippy(link, { | ||
| theme: 'default', | ||
| content: el, | ||
| trigger: 'mouseenter focus', | ||
| placement: 'top-start', | ||
| interactive: true, | ||
| role: 'dialog', | ||
| interactiveBorder: 5, | ||
| onDestroy: () => app.unmount(), | ||
| }).show(); | ||
| } | ||
|
|
||
| export function initRefIssueContextPopup() { | ||
| const selector = 'a[href]:not([data-ref-issue-popup]):not(.ref-external-issue)'; | ||
| addDelegatedEventListener<HTMLAnchorElement, MouseEvent>(document, 'mouseover', selector, (link) => { | ||
| if (!parseIssueHref(link.getAttribute('href')!).ownerName) return; | ||
| if (!link.classList.contains('ref-issue') && !link.closest('[data-ref-issue-container]')) return; | ||
| if (getAttachedTippyInstance(link)) return; | ||
| link.setAttribute('data-ref-issue-popup', ''); | ||
|
|
||
| // delay so a mouse passing over the link doesn't fire a fetch | ||
| let timer: ReturnType<typeof setTimeout>; | ||
| const cancel = () => { | ||
| clearTimeout(timer); | ||
| link.removeAttribute('data-ref-issue-popup'); | ||
| link.removeEventListener('mouseleave', cancel); | ||
| }; | ||
| timer = setTimeout(async () => { | ||
| link.removeEventListener('mouseleave', cancel); | ||
| try { | ||
| await showRefIssuePopup(link); | ||
| } catch (err) { | ||
| console.error('Failed to load issue info:', err); | ||
| link.removeAttribute('data-ref-issue-popup'); | ||
| } | ||
| }, 300); | ||
| link.addEventListener('mouseleave', cancel); | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.