-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
link to file from its history #27354
Conversation
Also fixes #26707 which might be duplicate. |
Can we label the column "Actions" like I did in #26998? |
Co-authored-by: silverwind <me@silverwind.io>
@silverwind I applied the suggested changes |
Can we move the "Copy SHA" button to Operations as well? Same styling and all. Wrap it in a |
templates/repo/commits_list.tmpl
Outdated
<th class="two wide right aligned">{{ctx.Locale.Tr "repo.commits.date"}}</th> | ||
<th class="one wide right aligned">{{ctx.Locale.Tr "repo.commit.operations"}}</th> |
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.
Sounds a bit weird to waste so much space simply because of the column title (that isn't even particularly helpful).
What about leaving it empty instead?
<th class="one wide right aligned">{{ctx.Locale.Tr "repo.commit.operations"}}</th> | |
<th class="one wide right aligned"></th> |
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 was thinking about getting rid of the whole table header. For example, branch list is without header as well.
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.
Is this tiny PR just being blown up to a full commit list redesign? 😆
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 the first action is simply not including this column header.
The rest can be left for other PRs.
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 guess it looks alright even without the header here.
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 in the future we should get rid of the HTML table completely. For now - I'm fine with leaving the title empty.
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.
The "View File" name is inaccurate when viewing a directory's history. Maybe we should use the same or similar string that GitHub does? "View at this point in the history", I would omit the |
@silverwind Where did you push your changes? 😆 |
Could you please update the screenshot in the PR description? |
I'd wait for the tweaks by silverwind as they change the appearance a bit |
templates/repo/commits_list.tmpl
Outdated
@@ -76,6 +76,10 @@ | |||
{{else}} | |||
<td class="text right aligned">{{TimeSince .Author.When ctx.Locale}}</td> | |||
{{end}} | |||
<td class="text right aligned"> | |||
<button class="btn interact-bg" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button> | |||
{{if $.FileName}}<a class="btn interact-bg" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.view_file"}}" href="{{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) $.FileName}}">{{svg "octicon-file-code"}}</a>{{end}} |
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 $.FileName}}<a class="btn interact-bg" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.view_file"}}" href="{{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) $.FileName}}">{{svg "octicon-file-code"}}</a>{{end}} | |
{{if $.FileName}}<a class="btn interact-bg" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.view_file"}}" href="{{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) $.FileName}}">{{svg "octicon-file-code"}}</a>{{end}} |
could you shift this to backend {{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) $.FileName}}
, we don't want regression.
Date column header can be |
Ah it seems it did not push, I was getting "remote rejected", will check. |
Seems I still can not push (is collaboration enabled on this PR?):
Here is the patch: diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 8667e77a89..ec37d64fec 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -96,8 +96,9 @@ disabled = Disabled
locked = Locked
copy = Copy
copy_url = Copy URL
+copy_hash = Copy hash
copy_content = Copy content
copy_branch = Copy branch name
copy_success = Copied!
copy_error = Copy failed
diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl
index c5003af4ae..db658de3e7 100644
--- a/templates/repo/commits_list.tmpl
+++ b/templates/repo/commits_list.tmpl
@@ -75,11 +75,13 @@
<td class="text right aligned">{{TimeSince .Committer.When ctx.Locale}}</td>
{{else}}
<td class="text right aligned">{{TimeSince .Author.When ctx.Locale}}</td>
{{end}}
- <td class="text right aligned">
- <button class="btn interact-bg" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button>
- {{if $.FileName}}<a class="btn interact-bg" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.view_file"}}" href="{{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) $.FileName}}">{{svg "octicon-file-code"}}</a>{{end}}
+ <td class="gt-pt-0 gt-pb-0">
+ <div class="gt-df gt-je">
+ <button class="btn interact-bg gt-p-3" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button>
+ {{if $.FileName}}<a class="btn interact-bg gt-p-3" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.view_file"}}" href="{{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) $.FileName}}">{{svg "octicon-file-code"}}</a>{{end}}
+ </div>
</td>
</tr>
{{end}}
</tbody> |
I like |
@delvh @silverwind I pushed the changes and updated the screenshot. |
Need the flexbox to vertically center and for the gap. Text-based layout is not suitable for these tasks. |
@@ -1283,6 +1284,7 @@ commits.signed_by_untrusted_user = Signed by untrusted user | |||
commits.signed_by_untrusted_user_unmatched = Signed by untrusted user who does not match committer | |||
commits.gpg_key_id = GPG Key ID | |||
commits.ssh_key_fingerprint = SSH Key Fingerprint | |||
commits.view_path=View at this point in history |
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 there is a ini linter, I would make it lint for spaces around =
😆
<td class="gt-pt-0 gt-pb-0"> | ||
<div class="gt-df gt-je"> | ||
<button class="btn interact-bg gt-p-3" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button> | ||
{{if $.FileName}}<a class="btn interact-bg gt-p-3" data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_path"}}" href="{{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) $.FileName}}">{{svg "octicon-file-code"}}</a>{{end}} |
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 $.FileName
needs to be escaped to URL parameter. Otherwise C++
or C#
breaks the URL.
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, likely PathEscape
.
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.
-> Improve file history UI and fix URL escaping bug #27531
Follow #27354 Major changes: 1. The `right aligned` in `<th class="one wide right aligned">` is a no-op because it doesn't have any content 2. The `gt-df` in `<td class="sha gt-df">` was wrong, it causes UI misalignment, a table cell shouldn't be "flex" 3. Use `gt-py-0` for `gt-pt-0 gt-pb-0` 4. Simplify the layout for buttons, because the `text right aligned` is widely used and good enough, it doesn't make sense to introduce the `<div class="gt-df gt-je">` 5. Escape the `$.FileName` correctly Before: ![image](https://github.com/go-gitea/gitea/assets/2114189/eb2ced3f-1dad-4149-9ed2-aee4c0663621) After: ![image](https://github.com/go-gitea/gitea/assets/2114189/08244b61-416b-4279-b495-029bc0a96f67)
Fixes #3852
Fixes #26707
Add a button on file history which directs you to the file at the selected commit.
Co-authored-by: silverwind me@silverwind.io