Skip to content
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

Show outdated comments in files changed tab #24936

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2dac9ba
Add octicon-alert-fill svg
sebastian-sauer May 25, 2023
f7be42e
Show outdated comments in files changed view
sebastian-sauer May 25, 2023
86fb8bf
Fix unit tests
sebastian-sauer May 25, 2023
a348922
Use outdated label and address review comments
sebastian-sauer May 27, 2023
562d785
Move outdated label after Show original
sebastian-sauer May 27, 2023
a8babc5
various tweaks
silverwind May 27, 2023
aade1ff
remove label
silverwind May 27, 2023
f03e6e8
use more neutral 'Content'
silverwind May 27, 2023
49b2a60
Improve display of outdated
sebastian-sauer May 27, 2023
5cd73b1
Remove show Original button and add link to label
sebastian-sauer May 27, 2023
9c17297
Fix lint
sebastian-sauer May 27, 2023
13d5699
Remove unused locale
sebastian-sauer May 27, 2023
6449331
remove separate translation with click
silverwind May 28, 2023
08d0c1b
various tweaks to code comment header
silverwind May 28, 2023
c9b4b7d
remove outdated styles
silverwind May 28, 2023
a4d45a5
remove obsolete style
silverwind May 28, 2023
9625369
remove unused svg
silverwind May 28, 2023
fb3be28
Fix link to original comment
sebastian-sauer May 29, 2023
7ceacee
Revert changes in conversation.tmpl
sebastian-sauer May 31, 2023
2aa382c
Merge remote-tracking branch 'origin/main' into feature/24913_show_ou…
sebastian-sauer May 31, 2023
feebb5e
Add user setting / option to show outdated comments in PR
sebastian-sauer May 31, 2023
7582ac9
Fix integration tests
sebastian-sauer May 31, 2023
18a3196
Merge branch 'main' into feature/24913_show_outdated_comments
sebastian-sauer Jun 20, 2023
8aec147
Fix format of web.go
sebastian-sauer Jun 20, 2023
d77ab8a
Add comments for conversation.tmpl
sebastian-sauer Jun 20, 2023
593e075
Fix indentation in conversation.tmpl
sebastian-sauer Jun 20, 2023
fbbb87a
Always add all query params to url
sebastian-sauer Jun 20, 2023
9557893
Make all query params have same order
sebastian-sauer Jun 20, 2023
95d56c5
Merge remote-tracking branch 'origin/main' into feature/24913_show_ou…
sebastian-sauer Jun 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions models/issues/comment_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"

"xorm.io/builder"
)

// CodeComments represents comments on code by using this structure: FILENAME -> LINE (+ == proposed; - == previous) -> COMMENTS
Expand Down Expand Up @@ -53,9 +51,6 @@ func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issu
review = &Review{ID: 0}
}
conds := opts.ToConds()
if review.ID == 0 {
conds = conds.And(builder.Eq{"invalidated": false})
}
e := db.GetEngine(ctx)
if err := e.Where(conds).
Asc("comment.created_unix").
Expand Down
2 changes: 2 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,8 @@ issues.review.show_outdated = Show outdated
issues.review.hide_outdated = Hide outdated
issues.review.show_resolved = Show resolved
issues.review.hide_resolved = Hide resolved
issues.review.comment_points_to_modified_line = Points to a modified code fragment.
sebastian-sauer marked this conversation as resolved.
Show resolved Hide resolved
issues.review.show_original_comment = Show original
sebastian-sauer marked this conversation as resolved.
Show resolved Hide resolved
issues.review.resolve_conversation = Resolve conversation
issues.review.un_resolve_conversation = Unresolve conversation
issues.review.resolved_by = marked this conversation as resolved
Expand Down
2 changes: 1 addition & 1 deletion services/gitdiff/gitdiff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ func TestDiff_LoadComments(t *testing.T) {
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
diff := setupDefaultDiff()
assert.NoError(t, diff.LoadComments(db.DefaultContext, issue, user))
assert.Len(t, diff.Files[0].Sections[0].Lines[0].Comments, 2)
assert.Len(t, diff.Files[0].Sections[0].Lines[0].Comments, 3)
}

func TestDiffLine_CanComment(t *testing.T) {
Expand Down
34 changes: 27 additions & 7 deletions templates/repo/diff/conversation.tmpl
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
{{$resolved := (index .comments 0).IsResolved}}
{{$invalid := (index .comments 0).Invalidated}}
{{$resolveDoer := (index .comments 0).ResolveDoer}}
{{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}}
{{$referenceUrl := printf "%s#%s" $.Issue.Link (index .comments 0).HashTag}}
<div class="conversation-holder" data-path="{{(index .comments 0).TreePath}}" data-side="{{if lt (index .comments 0).Line 0}}left{{else}}right{{end}}" data-idx="{{(index .comments 0).UnsignedLine}}">
{{if $resolved}}
{{if or $invalid $resolved}}
<div class="ui attached header resolved-placeholder gt-df gt-ac gt-sb">
<div class="ui grey text">
silverwind marked this conversation as resolved.
Show resolved Hide resolved
{{svg "octicon-check" 16 "icon gt-mr-2"}}
<b>{{$resolveDoer.Name}}</b> {{$.locale.Tr "repo.issues.review.resolved_by"}}
{{if $resolved}}
sebastian-sauer marked this conversation as resolved.
Show resolved Hide resolved
{{svg "octicon-check" 16 "icon gt-mr-2"}}
<b>{{$resolveDoer.Name}}</b> {{$.locale.Tr "repo.issues.review.resolved_by"}}
{{end}}
{{if $invalid}}
sebastian-sauer marked this conversation as resolved.
Show resolved Hide resolved
{{if $resolved}}
|
{{else}}
{{svg "octicon-alert-fill" 16 "icon gt-mr-2"}}
{{end}}
{{$.locale.Tr "repo.issues.review.comment_points_to_modified_line"}} <a href="{{AppSubUrl}}{{$referenceUrl}}">{{$.locale.Tr "repo.issues.review.show_original_comment"}}</a>
{{end}}
</div>
<div>
<button id="show-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="ui tiny labeled button show-outdated gt-df gt-ac">
<button id="show-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="{{if not $resolved}}gt-hidden {{end}}ui tiny labeled button show-outdated gt-df gt-ac">
silverwind marked this conversation as resolved.
Show resolved Hide resolved
{{svg "octicon-unfold" 16 "gt-mr-3"}}
{{$.locale.Tr "repo.issues.review.show_resolved"}}
{{if $resolved}}
{{$.locale.Tr "repo.issues.review.show_resolved"}}
{{else}}
{{$.locale.Tr "repo.issues.review.show_outdated"}}
{{end}}
</button>
<button id="hide-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="ui tiny labeled button hide-outdated gt-df gt-ac gt-hidden">
<button id="hide-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="{{if $resolved}}gt-hidden {{end}}ui tiny labeled button hide-outdated gt-df gt-ac">
sebastian-sauer marked this conversation as resolved.
Show resolved Hide resolved
{{svg "octicon-fold" 16 "gt-mr-3"}}
{{$.locale.Tr "repo.issues.review.hide_resolved"}}
{{if $resolved}}
{{$.locale.Tr "repo.issues.review.hide_resolved"}}
{{else}}
{{$.locale.Tr "repo.issues.review.hide_outdated"}}
{{end}}
</button>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions web_src/js/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import giteaDoubleChevronLeft from '../../public/img/svg/gitea-double-chevron-le
import giteaDoubleChevronRight from '../../public/img/svg/gitea-double-chevron-right.svg';
import giteaEmptyCheckbox from '../../public/img/svg/gitea-empty-checkbox.svg';
import giteaExclamation from '../../public/img/svg/gitea-exclamation.svg';
import octiconAlertFill from '../../public/img/svg/octicon-alert-fill.svg';
import octiconArchive from '../../public/img/svg/octicon-archive.svg';
import octiconArrowSwitch from '../../public/img/svg/octicon-arrow-switch.svg';
import octiconBlocked from '../../public/img/svg/octicon-blocked.svg';
Expand Down Expand Up @@ -71,6 +72,7 @@ const svgs = {
'gitea-double-chevron-right': giteaDoubleChevronRight,
'gitea-empty-checkbox': giteaEmptyCheckbox,
'gitea-exclamation': giteaExclamation,
'octicon-alert-fill': octiconAlertFill,
'octicon-archive': octiconArchive,
'octicon-arrow-switch': octiconArrowSwitch,
'octicon-blocked': octiconBlocked,
Expand Down