-
-
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
Add tree links to issue timestamps #741
Add tree links to issue timestamps #741
Conversation
@jgierer12 Oh shoot, I didn't notice you assigned it to yourself and worked on it. I worked on this too 😬. What should I do now? |
I thought a lot and sent duplicate pull anyway mentioning the same. You can have a look. 😄 |
Thanks, sorry again! |
Design concepts I have so far:
|
I like option 3. Can you show it with more detail on how it would show on the page |
src/content.js
Outdated
@@ -645,6 +646,7 @@ async function onDomReady() { | |||
if (pageDetect.isPR() || pageDetect.isIssue()) { | |||
safely(linkifyIssuesInTitles); | |||
observeEl('.new-discussion-timeline', addOPLabels, {childList: true, subtree: true}); | |||
observeEl('.new-discussion-timeline', addTimestampTreeLinks, {childList: true, subtree: true}); |
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.
Since these are identical, can you merge them?
src/libs/timestamp-tree-links.js
Outdated
return; | ||
} | ||
|
||
location.href = `https://github.com/${ownerName}/${repoName}/tree/${sha}`; |
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.
Drop protocol and hostname to support GHEnterprise
src/libs/timestamp-tree-links.js
Outdated
const timestampValue = select('relative-time', timestampLink).attributes.datetime.value; | ||
|
||
const openTree = async ({target}) => { | ||
target.replaceChild(icons.clock(), target.firstChild); |
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.
All replaceChild instances can be replaced by firstChild.replaceWith
src/libs/timestamp-tree-links.js
Outdated
export default async () => { | ||
const newTimestamps = select.all(`.new-discussion-timeline .timestamp:not(.refined-github-comment-browse-files)`); | ||
|
||
newTimestamps.forEach(async timestampLink => { |
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.
async
is not needed here, this loop can be replaced with for of
src/libs/timestamp-tree-links.js
Outdated
const {ownerName, repoName} = getOwnerAndRepo(); | ||
|
||
const getSHABeforeTimestamp = async timestamp => { | ||
const url = `https://api.github.com/repos/${ownerName}/${repoName}/commits?until=${timestamp}&per_page=1`; |
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.
If we’re positive we can’t do this without the API, we still need to support /api
instead of the subdomain, for GHE. You might want to pack it up as a getApiUrl
function because we’ll probably need the same logic again in the future.
It would match "edited" times and it would fail.
8c005f5
to
580e563
Compare
Note: if we settle for the https://github.com/sindresorhus/refined-github/commits/master?until=2017-08-09T22:24:21Z |
95ed917
to
7041a9e
Compare
426c437
to
668182e
Compare
@bfred-it Can you fix the merge conflict? Is this PR done? |
Yep it's done |
export default endpoint => { | ||
const api = location.hostname === 'github.com' ? 'https://api.github.com/' : `${location.origin}/api/`; | ||
return fetch(api + endpoint).then(res => res.json()); | ||
}; |
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.
This file looks unused?
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.
Currently, yes, but it's not being included at the moment. I feel it's a start for whenever the API materializes.
extension/content.css
Outdated
padding: 0; | ||
} | ||
:root .rgh-timestamp-button .octicon { | ||
vertical-align: sub; |
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 think this should be sub
=> middle
. It looks slightly vertically unaligned now.
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.
Actually for some reason this isn't being applied at all so it defaults to middle
(which isn't aligned)
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.
baseline
is the default, not middle
.
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.
When I manually applied middle
in devtools it looked ok.
Created by @jgierer12 and @bfred-it
Great work @jgierer12 and @bfred-it. This is a very useful feature. And thanks for suggesting it @ianstormtaylor 👌 |
Just noticed this feature while looking through a giant PR at work, and was so excited when I saw it. Thanks for doing this! |
Fixes #732
@ianstormtaylor @sindresorhus is this what you had in mind functionality-wise?
This still needs a lot of work:
Currently making a few conceptsSee Add tree links to issue timestamps #741 (comment), Add tree links to issue timestamps #741 (comment)GitHub Enterprise support (cc @busches) andprivate repo support