diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 7e2b6ad379..c672554c31 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1685,9 +1685,9 @@ issues.dependency.issue_close_blocked = You need to close all issues blocking th issues.dependency.issue_batch_close_blocked = "Cannot batch close issues that you choose, because issue #%d still has open dependencies" issues.dependency.pr_close_blocked = You need to close all issues blocking this pull request before you can merge it. issues.dependency.blocks_short = Blocks -issues.dependency.blocks_following = blocks: %s +issues.dependency.blocks_following = blocks: issues.dependency.blocked_by_short = Depends on -issues.dependency.blocked_by_following = depends on: %s +issues.dependency.blocked_by_following = depends on: issues.dependency.remove_header = Remove Dependency issues.dependency.issue_remove_text = This will remove the dependency from this issue. Continue? issues.dependency.pr_remove_text = This will remove the dependency from this pull request. Continue? diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 5e36661753..3925dcdc0a 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -43,6 +43,7 @@ import ( repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/templates/vars" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" @@ -140,27 +141,6 @@ func MustAllowPulls(ctx *context.Context) { } } -func dependenciesToHTML(ctx *context.Context, dependencies []*issues_model.DependencyInfo) template.HTML { - if len(dependencies) == 0 { - return "" - } - - htmlCode := "" - - for index, dependency := range dependencies { - if index != 0 { - htmlCode += `,` - } - anchorClasses := "gt-ml-2 ref-issue" - if dependency.Issue.IsClosed { - anchorClasses += " gt-line-through" - } - htmlCode += fmt.Sprintf(`#%d`, dependency.Issue.Link(), anchorClasses, dependency.Issue.Index) - } - - return template.HTML(htmlCode + "") -} - func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption optional.Option[bool]) { var err error viewType := ctx.FormString("type") @@ -346,29 +326,20 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt if unit, err := repo.GetUnit(ctx, unit.TypePullRequests); err == nil { if config := unit.PullRequestsConfig(); config.ShowDependencies { - blockingDependenciesTemplates := make(map[int64]template.HTML, len(issues)) - blockedByDependenciesTemplates := make(map[int64]template.HTML, len(issues)) - blockingDependenciesMap, err := issues.BlockingDependenciesMap(ctx) if err != nil { ctx.ServerError("BlockingDependenciesMap", err) return } - for i, blockingDependencies := range blockingDependenciesMap { - blockingDependenciesTemplates[i] = dependenciesToHTML(ctx, blockingDependencies) - } blockedByDependenciesMap, err := issues.BlockedByDependenciesMap(ctx) if err != nil { ctx.ServerError("BlockedByDependenciesMap", err) return } - for i, blockedByDependencies := range blockedByDependenciesMap { - blockedByDependenciesTemplates[i] = dependenciesToHTML(ctx, blockedByDependencies) - } - ctx.Data["BlockingDependenciesTemplates"] = blockingDependenciesTemplates - ctx.Data["BlockedByDependenciesTemplates"] = blockedByDependenciesTemplates + ctx.Data["BlockingDependenciesMap"] = blockingDependenciesMap + ctx.Data["BlockedByDependenciesMap"] = blockedByDependenciesMap } } diff --git a/templates/shared/issue_dependency.tmpl b/templates/shared/issue_dependency.tmpl index a1f4d14481..3eef63dd79 100644 --- a/templates/shared/issue_dependency.tmpl +++ b/templates/shared/issue_dependency.tmpl @@ -1,5 +1,9 @@ {{if .Dependencies}}
- {{ctx.Locale.Tr .TitleKey .Dependencies}} + {{ctx.Locale.Tr .TitleKey}} + {{range $i, $dependency := .Dependencies}} + {{if gt $i 0}}, {{end}} + {{template "shared/issue_link" $dependency.Issue}} + {{end}}
{{end}} diff --git a/templates/shared/issue_link.tmpl b/templates/shared/issue_link.tmpl new file mode 100644 index 0000000000..db6de4fbea --- /dev/null +++ b/templates/shared/issue_link.tmpl @@ -0,0 +1 @@ +#{{.Index}} \ No newline at end of file diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index e8286d2f3e..fb8a4432ec 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -118,14 +118,14 @@ {{end}} - {{if $.BlockedByDependenciesTemplates}} + {{if $.BlockedByDependenciesMap}} {{template "shared/issue_dependency" (dict - "Dependencies" (index $.BlockedByDependenciesTemplates .ID) + "Dependencies" (index $.BlockedByDependenciesMap .ID) "TitleKey" "repo.issues.dependency.blocked_by_following")}} {{end}} - {{if $.BlockingDependenciesTemplates}} + {{if $.BlockingDependenciesMap}} {{template "shared/issue_dependency" (dict - "Dependencies" (index $.BlockingDependenciesTemplates .ID) + "Dependencies" (index $.BlockingDependenciesMap .ID) "TitleKey" "repo.issues.dependency.blocks_following")}} {{end}} {{if .IsPull}} diff --git a/web_src/css/helpers.css b/web_src/css/helpers.css index 76077718a4..ebe2e80b0a 100644 --- a/web_src/css/helpers.css +++ b/web_src/css/helpers.css @@ -103,6 +103,7 @@ Gitea's private styles use `g-` prefix. .gt-m-4 { margin: 1rem !important; } .gt-m-5 { margin: 2rem !important; } +.gt-ml--2 { margin-left: -.25rem !important; } .gt-ml-0 { margin-left: 0 !important; } .gt-ml-1 { margin-left: .125rem !important; } .gt-ml-2 { margin-left: .25rem !important; }