From b83825253ed803221b3f78162a638d392534cd47 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 17 Nov 2020 06:02:41 +0100 Subject: [PATCH] Fix label display on new issues (#13590) * Fix label display on new issues PR #13570 broke label rendering for new issues and pulls because missed the fact that the code was relying on the DOM elements being toggled by JavaScript. On top of that, the label rendering for new issues and pull was using an outdated template which I consolidated in a new shared template. * remove wrapper element and style tweaks * style tweaks * use shared template for whole label list Co-authored-by: techknowlogick --- routers/repo/compare.go | 1 + templates/repo/issue/labels/label.tmpl | 9 +++++++++ .../repo/issue/labels/labels_sidebar.tmpl | 9 +++++++++ templates/repo/issue/new_form.tmpl | 14 +------------ .../repo/issue/view_content/sidebar.tmpl | 20 +------------------ web_src/less/_repository.less | 13 +++++------- 6 files changed, 26 insertions(+), 40 deletions(-) create mode 100644 templates/repo/issue/labels/label.tmpl create mode 100644 templates/repo/issue/labels/labels_sidebar.tmpl diff --git a/routers/repo/compare.go b/routers/repo/compare.go index fb6076cbe1..aa4b3191b2 100644 --- a/routers/repo/compare.go +++ b/routers/repo/compare.go @@ -184,6 +184,7 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, * ctx.Data["BaseIsCommit"] = baseIsCommit ctx.Data["BaseIsBranch"] = baseIsBranch ctx.Data["BaseIsTag"] = baseIsTag + ctx.Data["IsPull"] = true // Now we have the repository that represents the base diff --git a/templates/repo/issue/labels/label.tmpl b/templates/repo/issue/labels/label.tmpl new file mode 100644 index 0000000000..d76dc6af73 --- /dev/null +++ b/templates/repo/issue/labels/label.tmpl @@ -0,0 +1,9 @@ + + {{.label.Name | RenderEmoji}} + diff --git a/templates/repo/issue/labels/labels_sidebar.tmpl b/templates/repo/issue/labels/labels_sidebar.tmpl new file mode 100644 index 0000000000..bf6f98c888 --- /dev/null +++ b/templates/repo/issue/labels/labels_sidebar.tmpl @@ -0,0 +1,9 @@ +
+ {{.ctx.i18n.Tr "repo.issues.new.no_label"}} + {{range .ctx.Labels}} + {{template "repo/issue/labels/label" dict "root" $ "label" .}} + {{end}} + {{range .ctx.OrgLabels}} + {{template "repo/issue/labels/label" dict "root" $ "label" .}} + {{end}} +
diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl index e585fc7359..73a3851e17 100644 --- a/templates/repo/issue/new_form.tmpl +++ b/templates/repo/issue/new_form.tmpl @@ -70,19 +70,7 @@ {{end}} -
- {{.i18n.Tr "repo.issues.new.no_label"}} - {{range .Labels}} - {{if .IsChecked}} - {{.Name | RenderEmoji}} - {{end}} - {{end}} - {{range .OrgLabels}} - {{if .IsChecked}} - {{.Name | RenderEmoji}} - {{end}} - {{end}} -
+ {{template "repo/issue/labels/labels_sidebar" dict "root" $ "ctx" .}}
diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 21c7a9d365..55a625ec5f 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -125,25 +125,7 @@ {{end}} -
- {{if not .HasSelectedLabel}} - {{.i18n.Tr "repo.issues.new.no_label"}} - {{end}} - {{range .Labels}} - {{if .IsChecked}} - - {{end}} - {{end}} - {{range .OrgLabels}} - {{if .IsChecked}} - - {{end}} - {{end}} -
+ {{template "repo/issue/labels/labels_sidebar" dict "root" $ "ctx" .}}
diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less index ab5ef21ee4..3058ec0cce 100644 --- a/web_src/less/_repository.less +++ b/web_src/less/_repository.less @@ -133,11 +133,6 @@ max-width: 100px; } } - - .label.color { - padding: 0 8px; - margin-right: 5px; - } } #deadlineForm input { @@ -2985,12 +2980,14 @@ } .labels.list .item { - padding: 0 !important; - margin-bottom: 2px; + padding: .3em .5em !important; + margin-left: 0; + margin-right: 0; + margin-bottom: 3px; } .labels.list .item + .item { - margin-left: 2px; + margin-left: 3px; } tbody.commit-list {