From 5709359d55cf5a0b1d7d36bdcecf822306ec5f74 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 14 Jul 2024 05:38:45 +0200 Subject: [PATCH] [UI] Remove unnecessary vertical space in empty labels list - Don't show the labels-list element, if no labels are selected. - The labels-list was taking up vertical space, even if no labels were selected which caused an inconsistency in how the sidebar looked. - Adds integration test (cherry picked from commit 013b89eb13f4a87e521381072853d253137c1da5) --- .../repo/issue/labels/labels_sidebar.tmpl | 18 +++++++----- tests/integration/issue_test.go | 29 +++++++++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/templates/repo/issue/labels/labels_sidebar.tmpl b/templates/repo/issue/labels/labels_sidebar.tmpl index be30baba92..d39c2133a7 100644 --- a/templates/repo/issue/labels/labels_sidebar.tmpl +++ b/templates/repo/issue/labels/labels_sidebar.tmpl @@ -1,11 +1,13 @@
{{ctx.Locale.Tr "repo.issues.new.no_label"}} - - {{range .root.Labels}} - {{template "repo/issue/labels/label" dict "root" $.root "label" .}} - {{end}} - {{range .root.OrgLabels}} - {{template "repo/issue/labels/label" dict "root" $.root "label" .}} - {{end}} - + {{if .root.HasSelectedLabel}} + + {{range .root.Labels}} + {{template "repo/issue/labels/label" dict "root" $.root "label" .}} + {{end}} + {{range .root.OrgLabels}} + {{template "repo/issue/labels/label" dict "root" $.root "label" .}} + {{end}} + + {{end}}
diff --git a/tests/integration/issue_test.go b/tests/integration/issue_test.go index 2450a1d60f..bb16cbbc44 100644 --- a/tests/integration/issue_test.go +++ b/tests/integration/issue_test.go @@ -1126,3 +1126,32 @@ func TestIssueUnsubscription(t *testing.T) { session.MakeRequest(t, req, http.StatusOK) }) } + +func TestIssueLabelList(t *testing.T) { + defer tests.PrepareTestEnv(t)() + labelListSelector := ".labels.list .labels-list" + hiddenClass := "tw-hidden" + + t.Run("Show label list", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req := NewRequest(t, "GET", "/user2/repo1/issues/1") + resp := MakeRequest(t, req, http.StatusOK) + htmlDoc := NewHTMLParser(t, resp.Body) + + htmlDoc.AssertElement(t, labelListSelector, true) + htmlDoc.AssertElement(t, ".labels.list .no-select.item."+hiddenClass, true) + }) + + t.Run("Show no label list", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + session := loginUser(t, "user2") + + req := NewRequest(t, "GET", "/user2/repo2/issues/1") + resp := session.MakeRequest(t, req, http.StatusOK) + htmlDoc := NewHTMLParser(t, resp.Body) + + htmlDoc.AssertElement(t, labelListSelector, false) + htmlDoc.AssertElement(t, ".labels.list .no-select.item:not([class*='"+hiddenClass+"'])", true) + }) +}