From 4eac7adcc994ebffa96659f503dcee2c1d13bf07 Mon Sep 17 00:00:00 2001 From: iamyaash Date: Mon, 11 Aug 2025 20:10:10 +0200 Subject: [PATCH] fix(ui): Make 'Clear milestone' work with HTMX (#8266) Disable the 'clear milestone' button in the issue sidebar when no milestone is set and update this state after a milestone is set or cleared. Fixes #7949 Co-authored-by: Gusted Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8266 Reviewed-by: Gusted Co-authored-by: iamyaash Co-committed-by: iamyaash --- routers/web/repo/issue.go | 1 + templates/htmx/milestone_sidebar.tmpl | 1 + templates/repo/issue/milestone/clear_milestone.tmpl | 3 +++ templates/repo/issue/milestone/select_menu.tmpl | 2 +- templates/repo/issue/milestone/selected.tmpl | 2 +- 5 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 templates/repo/issue/milestone/clear_milestone.tmpl diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 7ab9d62b69..0373d06ea0 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -2414,6 +2414,7 @@ func UpdateIssueMilestone(ctx *context.Context) { ctx.ServerError("GetMilestoneByRepoID", err) return } + ctx.Data["OpenMilestones"] = true } else { issue.Milestone = nil } diff --git a/templates/htmx/milestone_sidebar.tmpl b/templates/htmx/milestone_sidebar.tmpl index 87eb5a7f42..3898ebd058 100644 --- a/templates/htmx/milestone_sidebar.tmpl +++ b/templates/htmx/milestone_sidebar.tmpl @@ -1,3 +1,4 @@ +{{template "repo/issue/milestone/clear_milestone" dict "." . "UseHTMX" true}}
{{template "repo/issue/view_content/comments" .}}
diff --git a/templates/repo/issue/milestone/clear_milestone.tmpl b/templates/repo/issue/milestone/clear_milestone.tmpl new file mode 100644 index 0000000000..eb1b21fbfe --- /dev/null +++ b/templates/repo/issue/milestone/clear_milestone.tmpl @@ -0,0 +1,3 @@ +
+ {{ctx.Locale.Tr "repo.issues.new.clear_milestone"}} +
diff --git a/templates/repo/issue/milestone/select_menu.tmpl b/templates/repo/issue/milestone/select_menu.tmpl index 570acc2eee..19b0049578 100644 --- a/templates/repo/issue/milestone/select_menu.tmpl +++ b/templates/repo/issue/milestone/select_menu.tmpl @@ -6,7 +6,7 @@
{{end}} -
{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}
+{{template "repo/issue/milestone/clear_milestone" dict "." . "UseHTMX" $useHTMX}} {{if and (not .OpenMilestones) (not .ClosedMilestones)}}
{{ctx.Locale.Tr "repo.issues.new.no_items"}} diff --git a/templates/repo/issue/milestone/selected.tmpl b/templates/repo/issue/milestone/selected.tmpl index c5ed4c81af..68acf1023c 100644 --- a/templates/repo/issue/milestone/selected.tmpl +++ b/templates/repo/issue/milestone/selected.tmpl @@ -1,4 +1,4 @@ -
+
{{ctx.Locale.Tr "repo.issues.new.no_milestone"}}
{{if .Issue.Milestone}}