From cd593978cbfde0c945fbb1db5cebdfa94b787537 Mon Sep 17 00:00:00 2001 From: Arthur Zamarin Date: Tue, 19 Mar 2024 11:04:44 +0200 Subject: app/bugs: improve links for creation of new bugs Based on the impl of the linked PR, but uses the new FE template generation. Closes: https://github.com/gentoo/soko/pull/17 Signed-off-by: Arthur Zamarin --- pkg/app/handler/maintainer/show.go | 4 ++-- pkg/app/handler/packages/components/bugs.templ | 26 ++++++++++++++++++++------ pkg/app/handler/packages/show.templ | 7 ++++--- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/pkg/app/handler/maintainer/show.go b/pkg/app/handler/maintainer/show.go index 42f3cdc..e41d8b2 100644 --- a/pkg/app/handler/maintainer/show.go +++ b/pkg/app/handler/maintainer/show.go @@ -207,7 +207,7 @@ func ShowBugs(w http.ResponseWriter, r *http.Request) { } generalCount, stabilizationCount, keywordingCount := countBugsCategories(bugs) layout.Layout(maintainer.Name, "maintainers", - show(packagesCount, &maintainer, "Bugs", components.Bugs(generalCount, stabilizationCount, keywordingCount, bugs)), + show(packagesCount, &maintainer, "Bugs", components.Bugs("", generalCount, stabilizationCount, keywordingCount, bugs)), ).Render(r.Context(), w) } @@ -233,7 +233,7 @@ func ShowSecurity(w http.ResponseWriter, r *http.Request) { return } layout.Layout(maintainer.Name, "maintainers", - show(packagesCount, &maintainer, "Security", components.SecurityBugs(len(bugs) > 0, bugs)), + show(packagesCount, &maintainer, "Security", components.SecurityBugs("", len(bugs) > 0, bugs)), ).Render(r.Context(), w) } diff --git a/pkg/app/handler/packages/components/bugs.templ b/pkg/app/handler/packages/components/bugs.templ index 30ea7a2..7c5a9e1 100644 --- a/pkg/app/handler/packages/components/bugs.templ +++ b/pkg/app/handler/packages/components/bugs.templ @@ -24,7 +24,14 @@ templ bugsList(title, component string, bugs []*models.Bug, titleClass, id strin } -templ Bugs(generalCount, stabilizationCount, keywordingCount int, bugs []*models.Bug) { +func bugAtomLink(atom string) templ.SafeURL { + if atom == "" { + return templ.URL("https://bugs.gentoo.org/") + } + return templ.URL("https://bugs.gentoo.org/enter_bug.cgi?product=Gentoo Linux&component=Current packages&short_desc=" + atom + ": ") +} + +templ Bugs(atom string, generalCount, stabilizationCount, keywordingCount int, bugs []*models.Bug) {
if len(bugs) > 0 { @@ -44,7 +51,7 @@ templ Bugs(generalCount, stabilizationCount, keywordingCount int, bugs []*models

Good job! There are no bugs.

- You think something is missing here?
Start with filling a new bug.
+ You think something is missing here?
Start with filling a new bug.
} @@ -59,7 +66,7 @@ templ Bugs(generalCount, stabilizationCount, keywordingCount int, bugs []*models Gentoo Bugzilla is where we track bugs of Gentoo and its packages; you are welcome to report, confirm and resolve bugs: @@ -105,7 +112,14 @@ templ Bugs(generalCount, stabilizationCount, keywordingCount int, bugs []*models } -templ SecurityBugs(hasSecurityBugs bool, bugs []*models.Bug) { +func securityBugAtomLink(atom string) templ.SafeURL { + if atom == "" { + return templ.URL("https://bugs.gentoo.org/") + } + return templ.URL("https://bugs.gentoo.org/enter_bug.cgi?product=Gentoo Security&component=Vulnerabilities&short_desc=" + atom + ": ") +} + +templ SecurityBugs(atom string, hasSecurityBugs bool, bugs []*models.Bug) {
if hasSecurityBugs { @@ -117,7 +131,7 @@ templ SecurityBugs(hasSecurityBugs bool, bugs []*models.Bug) {

There are no open security bugs.

- You think something is missing here?
Start with filling a new security bug.
+ You think something is missing here?
Start with filling a new security bug.
} @@ -130,7 +144,7 @@ templ SecurityBugs(hasSecurityBugs bool, bugs []*models.Bug) {
- Please file new vulnerability reports on Gentoo Bugzilla and assign them to the Gentoo Security product and Vulnerabilities component. + Please file new vulnerability reports on Gentoo Bugzilla and assign them to the Gentoo Security product and Vulnerabilities component.
diff --git a/pkg/app/handler/packages/show.templ b/pkg/app/handler/packages/show.templ index 33af701..fd5c673 100644 --- a/pkg/app/handler/packages/show.templ +++ b/pkg/app/handler/packages/show.templ @@ -93,7 +93,8 @@ templ tabbedHeader(pkg *models.Package, currentSubTab string) { } -func collectAllBugs(pkg *models.Package) (generalCount, stabilizationCount, keywordingCount int, bugs []*models.Bug) { +func collectAllBugs(pkg *models.Package) (atom string, generalCount, stabilizationCount, keywordingCount int, bugs []*models.Bug) { + atom = pkg.Atom bugs = make([]*models.Bug, 0, len(pkg.Bugs)) handled := make(map[string]struct{}, len(pkg.Bugs)) for _, bug := range pkg.Bugs { @@ -121,14 +122,14 @@ func collectAllBugs(pkg *models.Package) (generalCount, stabilizationCount, keyw return } -func collectSecurityBugs(pkg *models.Package) (bool, []*models.Bug) { +func collectSecurityBugs(pkg *models.Package) (string, bool, []*models.Bug) { bugs := make([]*models.Bug, 0, len(pkg.Bugs)) for _, bug := range pkg.Bugs { if bug.Component == "Vulnerabilities" { bugs = append(bugs, bug) } } - return len(bugs) > 0, bugs + return pkg.Atom, len(bugs) > 0, bugs } templ show(pkg *models.Package, currentSubTab string, userPreferences models.UserPreferences) { -- cgit v1.2.3-65-gdbad