fix: 'More actions' (⋯) dropdown from moderation reports overview page (#10339)

Follow-up of !8716 (and !9951)

A _More actions_ (`⋯`) dropdown (where content related actions are available) was added with !8716 for the moderation reports overview page. Until that PR was merged another PR (!9951) changed the structure of JS-less dropdowns and adjusted the CSS rules. This PR adds the missing `.content` container for the dropdown added with !8716

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10339
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: floss4good <floss4good@disroot.org>
Co-committed-by: floss4good <floss4good@disroot.org>
This commit is contained in:
floss4good 2025-12-10 17:09:59 +01:00 committed by Gusted
parent 48c7bda95d
commit 0ef51b24ab
2 changed files with 52 additions and 47 deletions

View file

@ -72,42 +72,44 @@
{{svg "octicon-x"}}
</button>
{{if .ContentReference}} {{/* the reference is missing when the content was already deleted */}}
<details class="item dropdown dir-rtl">
<details class="dropdown item dir-rtl">
<summary class="tw-p-1" data-tooltip-content="{{ctx.Locale.Tr "profile.actions.tooltip"}}">{{svg "octicon-kebab-horizontal"}}</summary>
<ul
hx-target="{{$reportDivSelector}}" hx-indicator="{{$reportDivSelector}}"
hx-vals='{"content_type": {{.ContentType}}, "content_id": {{.ContentID}}}'>
{{if .ReportedContentIsUser}}
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionSuspendAccount}}}' hx-swap="none" class="item">
{{svg "octicon-x"}}{{ctx.Locale.Tr "moderation.action.account.suspend"}}
</a>
</li>
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionDeleteAccount}}, "report_action": {{$.MarkAsHandled}}}' class="item">
{{svg "octicon-trash"}}{{ctx.Locale.Tr "moderation.action.account.delete"}}
</a>
</li>
{{else if .ReportedContentIsRepo}}
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionDeleteRepo}}, "report_action": {{$.MarkAsHandled}}}' class="item">
{{svg "octicon-trash"}}{{ctx.Locale.Tr "moderation.action.repo.delete"}}
</a>
</li>
{{else if .ReportedContentIsIssue}}
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionDeleteIssue}}, "report_action": {{$.MarkAsHandled}}}' class="item">
{{svg "octicon-trash"}}{{ctx.Locale.Tr "moderation.action.issue.delete"}}
</a>
</li>
{{else if .ReportedContentIsComment}}
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionDeleteComment}}, "report_action": {{$.MarkAsHandled}}}' class="item">
{{svg "octicon-trash"}}{{ctx.Locale.Tr "moderation.action.comment.delete"}}
</a>
</li>
{{end}}
</ul>
<div class="content">
<ul
hx-target="{{$reportDivSelector}}" hx-indicator="{{$reportDivSelector}}"
hx-vals='{"content_type": {{.ContentType}}, "content_id": {{.ContentID}}}'>
{{if .ReportedContentIsUser}}
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionSuspendAccount}}}' hx-swap="none" class="item">
{{svg "octicon-x"}}{{ctx.Locale.Tr "moderation.action.account.suspend"}}
</a>
</li>
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionDeleteAccount}}, "report_action": {{$.MarkAsHandled}}}' class="item">
{{svg "octicon-trash"}}{{ctx.Locale.Tr "moderation.action.account.delete"}}
</a>
</li>
{{else if .ReportedContentIsRepo}}
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionDeleteRepo}}, "report_action": {{$.MarkAsHandled}}}' class="item">
{{svg "octicon-trash"}}{{ctx.Locale.Tr "moderation.action.repo.delete"}}
</a>
</li>
{{else if .ReportedContentIsIssue}}
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionDeleteIssue}}, "report_action": {{$.MarkAsHandled}}}' class="item">
{{svg "octicon-trash"}}{{ctx.Locale.Tr "moderation.action.issue.delete"}}
</a>
</li>
{{else if .ReportedContentIsComment}}
<li>
<a hx-post="{{$postURL}}" hx-vals='{"content_action": {{$.ActionDeleteComment}}, "report_action": {{$.MarkAsHandled}}}' class="item">
{{svg "octicon-trash"}}{{ctx.Locale.Tr "moderation.action.comment.delete"}}
</a>
</li>
{{end}}
</ul>
</div>
</details>
{{end}}
</div>

View file

@ -17,7 +17,7 @@ import (
"github.com/stretchr/testify/assert"
)
func testReportDetails(t *testing.T, htmlDoc *HTMLDoc, reportID, contentIcon, contentRef, contentURL, category, reportsNo string) {
func testReportDetails(t *testing.T, htmlDoc *HTMLDoc, reportID, contentIcon, contentRef, contentURL, category, reportsNo string, hasMoreActions bool) {
// Check icon octicon
icon := htmlDoc.Find("#report-" + reportID + " svg." + contentIcon)
assert.Equal(t, 1, icon.Length())
@ -49,6 +49,9 @@ func testReportDetails(t *testing.T, htmlDoc *HTMLDoc, reportID, contentIcon, co
count := htmlDoc.Find("#report-" + reportID + " a span")
assert.Equal(t, 1, count.Length())
assert.Equal(t, reportsNo, count.Text())
// Check 'More actions' (⋯) dropdown
htmlDoc.AssertElement(t, "#report-"+reportID+" > .flex-item-trailing .button-sequence details.dropdown", hasMoreActions)
}
func TestAdminModerationViewReports(t *testing.T) {
@ -92,24 +95,24 @@ func TestAdminModerationViewReports(t *testing.T) {
assert.Equal(t, 11, reports.Length())
// Check details for shown reports.
testReportDetails(t, htmlDoc, "1", "octicon-person", "@SPAM-services", "/SPAM-services", "Illegal content", "1")
testReportDetails(t, htmlDoc, "2", "octicon-repo", "SPAM-services/spammer-Tools", "/SPAM-services/spammer-Tools", "Illegal content", "1")
testReportDetails(t, htmlDoc, "3", "octicon-issue-opened", "SPAM-services/spammer-Tools#1", "/SPAM-services/spammer-Tools/issues/1", "Spam", "1")
testReportDetails(t, htmlDoc, "1", "octicon-person", "@SPAM-services", "/SPAM-services", "Illegal content", "1", true)
testReportDetails(t, htmlDoc, "2", "octicon-repo", "SPAM-services/spammer-Tools", "/SPAM-services/spammer-Tools", "Illegal content", "1", true)
testReportDetails(t, htmlDoc, "3", "octicon-issue-opened", "SPAM-services/spammer-Tools#1", "/SPAM-services/spammer-Tools/issues/1", "Spam", "1", true)
// #4 is combined with #7 and #9
testReportDetails(t, htmlDoc, "4", "octicon-person", "@spammer01", "/spammer01", "Spam", "3")
testReportDetails(t, htmlDoc, "4", "octicon-person", "@spammer01", "/spammer01", "Spam", "3", true)
// #5 is combined with #6
testReportDetails(t, htmlDoc, "5", "octicon-comment", "contributor/first/issues/1#issuecomment-1001", "/contributor/first/issues/1#issuecomment-1001", "Malware", "2")
testReportDetails(t, htmlDoc, "8", "octicon-issue-opened", "contributor/first#1", "/contributor/first/issues/1", "Other violations of platform rules", "1")
testReportDetails(t, htmlDoc, "5", "octicon-comment", "contributor/first/issues/1#issuecomment-1001", "/contributor/first/issues/1#issuecomment-1001", "Malware", "2", true)
testReportDetails(t, htmlDoc, "8", "octicon-issue-opened", "contributor/first#1", "/contributor/first/issues/1", "Other violations of platform rules", "1", true)
// #10 is for a Ghost user
testReportDetails(t, htmlDoc, "10", "octicon-person", "Reported content with type 1 and id 9999 no longer exists", "", "Other violations of platform rules", "1")
testReportDetails(t, htmlDoc, "10", "octicon-person", "Reported content with type 1 and id 9999 no longer exists", "", "Other violations of platform rules", "1", false)
// #11 is for a comment who's poster was deleted
testReportDetails(t, htmlDoc, "11", "octicon-comment", "contributor/first/issues/1#issuecomment-1003", "/contributor/first/issues/1#issuecomment-1003", "Spam", "1")
testReportDetails(t, htmlDoc, "11", "octicon-comment", "contributor/first/issues/1#issuecomment-1003", "/contributor/first/issues/1#issuecomment-1003", "Spam", "1", true)
// #12 is for a comment that was deleted but its poster still exists
testReportDetails(t, htmlDoc, "12", "octicon-comment", "Reported content with type 4 and id 9991 no longer exists", "", "Other violations of platform rules", "1")
testReportDetails(t, htmlDoc, "12", "octicon-comment", "Reported content with type 4 and id 9991 no longer exists", "", "Other violations of platform rules", "1", false)
// #13 is for a comment that was deleted and the poster was also deleted
testReportDetails(t, htmlDoc, "13", "octicon-comment", "Reported content with type 4 and id 9992 no longer exists", "", "Spam", "1")
testReportDetails(t, htmlDoc, "13", "octicon-comment", "Reported content with type 4 and id 9992 no longer exists", "", "Spam", "1", false)
// #14 is for a issue that was deleted but its poster still exists
testReportDetails(t, htmlDoc, "14", "octicon-issue-opened", "Reported content with type 3 and id 9991 no longer exists", "", "Spam", "1")
testReportDetails(t, htmlDoc, "14", "octicon-issue-opened", "Reported content with type 3 and id 9991 no longer exists", "", "Spam", "1", false)
t.Run("reports details page", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()