-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix profile-hotkey
on Gist pages
#3661
Conversation
source/features/profile-hotkey.tsx
Outdated
@@ -5,7 +5,7 @@ import features from '.'; | |||
import {getUsername} from '../github-helpers'; | |||
|
|||
function init(): false | void { | |||
const menuItem = select(`a[href="/${getUsername()}"]`); | |||
const menuItem = select.last(`[aria-label="View profile and more"] ~ details-menu a[href$="/${getUsername()}"]`); |
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.
Can this be?
const menuItem = select.last(`[aria-label="View profile and more"] ~ details-menu a[href$="/${getUsername()}"]`); | |
const menuItem = select.last(`[aria-label="View profile and more"] ~ details-menu a[href^="/${getUsername()}"]`); |
I mean, both work, but I'm a bit inclined towards ^
for no specific reason.
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.
No. The url on the gist page is https://github.com/yakov116
/${getUsername()
= https://gist.github.com/yakov116
Which is the link it was catching until not. Hence this PR.
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.
Updated the PR description
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
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.
But in reality this was pretty simple:
const menuItem = select.last(`[aria-label="View profile and more"] ~ details-menu a[href$="/${getUsername()}"]`); | |
select('a[data-ga-click$="text:your profile"]')!.dataset.hotkey = 'g m'; |
We don't even need the check. All users have a profile. RG is only expected to work on logged in users.
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.
RG is only expected to work on logged in users.
Yes, but at least we can fail gracefully. Would help us as well, if all of a sudden GitHub decides to change class names and other stuff, we can still fail gracefully.
BUT that would beg the question of how we would be able to detect a failure. Errors is how we get most of the reports from users, raising issues.
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.
But in reality this was pretty simple:
OMG how did I not catch that?!
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.
Yes, but at least we can fail gracefully.
Nah. Do you really wanna check all the features on logged out pages? I don’t. That’s why we display a warning in that case.
if all of a sudden GitHub decides to change class names and other stuff, we can still fail gracefully.
Unless a feature has the potential to lose data or break native functionality, we don’t need that. At most we display an alert if the feature is a complex action like restore-files
In this case, the previous code silently failed until Yakov went testing all the features; it’s better it let the error appear in the console so someone fixes it.
profile-hotkey
on Gist pagesprofile-hotkey
on Gist pages
Co-authored-by: Federico <me@fregante.com>
do ga's work on enterprise? |
That’s a good question. We use them in a few features and nobody complained though |
Let's merge this in the meanwhile. We can decide later what we can do about GHE support (if anything) |
LINKED ISSUES:
None
TEST URLS:
https://gist.github.com/yakov116
SCREENSHOT:
None
It did not work there since
/${getUsername()
leads to theYour gists
button