Repository navigation
Add raw-file-link feature - #1924
Conversation
|
@bfred-it I think I've addressed all your comments! Please have a look. |
|
@idasbiste Can you rebase from master (we enabled TS strict mode) and fix any issues? |
|
Seems to work fine for me otherwise. |
* This feature adds a "View raw" button in the file actions section of each file modified in a commit next to "View file" * This initial commit is WIP as we're not able to directly access the raw content of files from private repositories by simply prepending the raw.githubusercontent.com domain
* Replace 'blob' with 'raw' to allow redirect with token on private repositories
* Change feature/file name * Fix blob-to-raw url function * Fix add 'Raw' button function by selecting the link element directly and use .after() function * Use MutationObserver to check for DOM changes when new PR changed files are added into the page
1a1137c to
ad42074
Compare
|
|
||
| function init() { | ||
| addRawBtn(select('.js-diff-progressive-container:first-child')); | ||
| observer.observe(select('.js-diff-progressive-container:last-child'), childList); |
There was a problem hiding this comment.
Do you mean last child or the last in the dom?
Where did you get this logic from? At some point we’ll want to standardize it
There was a problem hiding this comment.
It is the last child. Please see my comment above #1924 (comment)
There was a problem hiding this comment.
It is the last child
In the HTML you posted I see two :last-child, and I think querySelector will match the first one (level 2), not the one you expect (level 3)
See a6a6e15 for an alternative implementation that avoids this altogether
Also do you know a PR that has more than one level? Because in the biggest PR I can think of (#1783) I'm seeing only one deferred level, not nested:
<div class="js-diff-progressive-container">already here</div>
<div class="js-diff-progressive-container">(content deferred)</div>There was a problem hiding this comment.
I like your approach on the other PR 👍
In the HTML I've posted I was specifically talking about the container that gets updated -- which is the :last-child in the beginning (the one with deferred content). I.e. the HTML will, in the end, have a format of:
<div class="js-diff-progressive-container">already here</div>
<div class="js-diff-progressive-container">
(nested containers)
</div>
| addRawBtn(select('.js-diff-progressive-container:first-child')); | ||
| const lastProgressiveContainer = select('.js-diff-progressive-container:last-child'); | ||
| if (lastProgressiveContainer) { | ||
| observer.observe(lastProgressiveContainer, {childList: true}); |
There was a problem hiding this comment.
Maybe we should turn this into a utility function, like on-new-pr-files.ts
raw-file-link feature
|
I want to merge this but I'm seeing a couple of unrelated RGH bugs on this ( |
Non-referencing commitGraphQL exceptionDidn't want to go off topic but an it is an interesting bug that sometimes bites the GH team too, |
- `show-names` - `add-co-authored-by` Context: #1924 (comment)
|
Thanks Eduardo! 🎯 |


This PR closes #1595
It adds a "View raw" button next to the usual "View file" one.
Without rich diff:

With rich diff:
