sindresorhus/refined-github

Make "Edit/delete file" clickable on compare page #2704

jack1142 posted onGitHub

Example URL: https://github.com/Cog-Creators/Red-DiscordBot/compare/V3/develop...jack1142:pr/ghactions?expand=1

"Edit/delete file" links are already there, but they're not active, IMO it would be useful to be able to quickly edit files from there if you notice some error in files: image

Of course that link should only be active when you can edit the head branch.

Edit: I also noticed that "View file" link there doesn't link you to branch but to commit so that makes it take even longer to edit a file.


Where would the file be edited? This could be kind of confusing

posted by fregante about 5 years ago

@fregante What do you mean by where? Cause I just meant for it to be a link to: https://github.com/[ORG_OR_USER]/[REPO_NAME]/edit/[BRANCH]/[FILE_PATH] Same as it works when you're on the PR page: image Or on file page: image

posted by jack1142 about 5 years ago

I meant “which of the 2 branches will receive the edit?”

But yeah this is comparable to a PR view so the right-hand branch will be edited.

This feature is similar to one we recently added so perhaps that one can be extended, it could become enable-file-links-in-compare-view

https://github.com/sindresorhus/refined-github/pull/2529

I remember trying to also “fix” the edit link in that view but it didn’t make sense (I don’t remember why)

posted by fregante about 5 years ago

@fregante and @jack1142

Have this done in https://github.com/yakov116/refined-github/tree/enable-file-links-in-compare-view

But I need to wait for #3138 to be merged first.

posted by yakov116 almost 5 years ago

I remember trying to also “fix” the edit link in that view but it didn’t make sense (I don’t remember why)

I think I remember now. The link only makes sense if you don't compare permalinks (commit, tag), and this information might not be available on compare views. Example: https://github.com/sindresorhus/refined-github/compare/a@b...20.5.27

If you compare 2 commits, the edit and delete links don’t make sense.

@yakov116 can you reliably detect whether the compared reference (right) points to a permalink? If not, this feature should probably be scrapped.

posted by fregante almost 5 years ago

Yes I can except for one case. (I wish I had a fork of your's I can give you a link to test on) https://github.com/yakov116/refined-github/compare/upstream...FloEdelmann:faster-reviews In this case I am comparing a fork to my own repo and I don't have rights to edit the forked repo. Clicking edit/delete will not lead to a 404 rather to the page offering me to fork the repo.

Github gives us an easy detection for permalink's, since it will not give you an option to create a PR if you are comparing a permalink. In that case I only enabled the feature for the view and not the edit/delete. (Link to the branch/tag instead of a commit)

posted by yakov116 almost 5 years ago

I wish I had a fork of your's I can give you a link to test on

I just made this: https://github.com/fregante/refined-github

posted by fregante almost 5 years ago

A suggestion: the button text could be changed to "Edit latest file" to make it clear that it edits the latest file on that branch.

Or to make it clearer which branch it would edit on:

image

The above screenshot requires the <details-menu ... style="width: 185px; ..."> to be changed to <details-menu ... style="width: initial; ...">, otherwise the menu will be too thin:

image

posted by qaisjp almost 5 years ago

Good point. I wonder if that can be displayed any other way since it applies to all of the 3 links.

https://primer.style/css/components/dropdown#headers

<img width="227" alt="" src="https://user-images.githubusercontent.com/1402241/83401479-23c31280-a405-11ea-87d0-22e7dacdaa14.png">

<div class="dropdown-header">Dropdown header</div>

Not a great default style though

posted by fregante almost 5 years ago

I like that idea.

What about the "View file" button? i.e. in the case of https://github.com/fregante/refined-github/compare/a@b...FloEdelmann:faster-reviews, "View file" always views at point of 1ab3f6f and not the latest.

Maybe something like this?

image

(The first "View file" button is GitHub's original button.)


If branch name was shown in the dropdown, this is another edge case to consider: a user might be confused about whether it shows the latest file the left branch vs. the right branch.

i.e. this case, where the base branch name matches the compare branch name.

image

I suppose in that case you could show this (if repo names are different)

image

(if repo names are the same)

image

p.s. the width: initial thing is applied here, but it seems that only the buttons themselves can widen the dropdown, and not the headers. Can't figure out the CSS fix here.

posted by qaisjp almost 5 years ago

Definitely interesting, but I wonder if it’s useful to ever link to the commit from that dropdown. If you can open the branch link, why would you ever open the commit link?

posted by fregante almost 5 years ago

Fund this Issue

$0.00
Funded

Pull requests