Repository navigation
Harder better faster stronger new-or-deleted-file
#6702
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import React from 'dom-chef'; | ||
| import select from 'select-dom'; | ||
| import * as pageDetect from 'github-url-detection'; | ||
|
|
||
| import features from '../feature-manager.js'; | ||
| import observe from '../helpers/selector-observer.js'; | ||
|
|
||
| function add(filename: HTMLAnchorElement): void { | ||
| const list = select('ul[aria-label="File Tree"]'); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feature used to use this dropdown:
but it only appears on PRs and it's actually been relegated to small screens, because the whole dropdown is hidden/duplicate of the sidebar on large screens. It seems that the sidebar is actually part of the original HTML, so we don't even need to wait for it to load (at least some times)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ended up not using the API because I figured we'd still have trouble figuring out the exact changes/api to consider in case of single commits and multi-PR-commits. The sidebar is recent enough, hopefully it will last a while. |
||
| if (!list && pageDetect.isCommit()) { | ||
| // Silence error, single-file commits don't have the file list | ||
| return; | ||
| } | ||
|
|
||
| const fileInList = select(`[href="${filename.hash}"]`, list); | ||
| if (!fileInList) { | ||
| features.log.error(import.meta.url, 'Could not find file in sidebar, is the sidebar loaded?'); | ||
| features.unload(import.meta.url); | ||
| return; | ||
| } | ||
|
|
||
| const icon = select('.octicon-diff-removed, .octicon-diff-added', fileInList) | ||
| ?.cloneNode(true); | ||
| if (icon) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a bunch of conditions to have clear errors in case filelists are deferred in big PRs. I can drop the |
||
| // `span` needed for native vertical alignment | ||
| filename.parentElement!.append(<span className="ml-1">{icon}</span>); | ||
| } | ||
| } | ||
|
|
||
| async function init(signal: AbortSignal): Promise<void> { | ||
| // Link--primary excludes CODEOWNERS icon #5565 | ||
| observe('.file-info a.Link--primary', add, {signal}); | ||
| } | ||
|
|
||
| void features.add(import.meta.url, { | ||
| include: [ | ||
| pageDetect.isPRFiles, | ||
| pageDetect.isCommit, | ||
| ], | ||
| init, | ||
| }); | ||
|
|
||
| /* | ||
|
|
||
| ## Test URLs | ||
|
|
||
| Commit: https://github.com/refined-github/sandbox/commit/a00694ff7370d46b5f6d723a0b39141903dae45a | ||
| PR: https://github.com/refined-github/sandbox/pull/71/files | ||
| PR with CODEOWNERS: https://github.com/dotnet/winforms/pull/6028/files | ||
|
|
||
| Note: Not possible with 1-file commits: https://github.com/refined-github/sandbox/commit/1ed862e3abd13004009927b26355a51a109d6855 | ||
|
|
||
| */ | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New name ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't find it as clear as the old one. Maybe
new-or-deleted-file-diff-indicator?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature names should no longer be fully descriptive, I'm only renaming long feature names because they're impossible to mention in commits or to remember. See also the other recent renames in
options-storageThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #6707
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still think that we should include the word highlight
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we're back to square one:
highlight-new-or-delete-fileis 5-words long and I don’t think it helps much;. The feature search also includes the description so we can always try to add more keywords there (but it already includes the wordindicates, likegithub-actions-indicatorsdoes)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the new name isn't very descriptive, but between descriptiveness and brevity we should prefer the latter, as described in #6707.
Alternative short names are welcome; names that are only slightly shorter than what we have aren't enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file-diff-type-indicator?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While that sounds correct, it gives me even less information about what the indicator is about. "diff type" == ?
Maybe
mark-new-or-deleted-filebut that's so long too.