aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2024-03-19 11:04:44 +0200
committerArthur Zamarin <arthurzam@gentoo.org>2024-03-19 12:52:44 +0200
commitcd593978cbfde0c945fbb1db5cebdfa94b787537 (patch)
treee21b0702a435ff770f4c1f963e47e4c0d5f47b11
parentupdate/portage: fix removal of removed packages (diff)
downloadsoko-cd593978cbfde0c945fbb1db5cebdfa94b787537.tar.gz
soko-cd593978cbfde0c945fbb1db5cebdfa94b787537.tar.bz2
soko-cd593978cbfde0c945fbb1db5cebdfa94b787537.zip
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 <arthurzam@gentoo.org>
-rw-r--r--pkg/app/handler/maintainer/show.go4
-rw-r--r--pkg/app/handler/packages/components/bugs.templ26
-rw-r--r--pkg/app/handler/packages/show.templ7
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
</ul>
}
-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 + ": <ADD SUMMARY HERE>")
+}
+
+templ Bugs(atom string, generalCount, stabilizationCount, keywordingCount int, bugs []*models.Bug) {
<div class="row">
<div class="col-md-9">
if len(bugs) > 0 {
@@ -44,7 +51,7 @@ templ Bugs(generalCount, stabilizationCount, keywordingCount int, bugs []*models
</div>
<div class="col-md-8 pt-3">
<h2>Good job! There are no bugs.</h2>
- <span>You think something is missing here? <br/> Start with filling a <a href="https://bugs.gentoo.org/enter_bug.cgi">new bug</a>.</span>
+ <span>You think something is missing here? <br/> Start with filling a <a href={ bugAtomLink(atom) }>new bug</a>.</span>
</div>
</div>
}
@@ -59,7 +66,7 @@ templ Bugs(generalCount, stabilizationCount, keywordingCount int, bugs []*models
<span class="text-muted">
Gentoo Bugzilla is where we track bugs of Gentoo and its packages; you are welcome to report, confirm and resolve bugs:
<ul>
- <li><a href="https://bugs.gentoo.org/enter_bug.cgi">File a new Bug</a></li>
+ <li><a href={ bugAtomLink(atom) }>File a new Bug</a></li>
<li><a href="https://bugs.gentoo.org/">Confirm a bug</a></li>
<li><a href="https://wiki.gentoo.org/wiki/Bugday">Participate in our monthly Bugday</a></li>
</ul>
@@ -105,7 +112,14 @@ templ Bugs(generalCount, stabilizationCount, keywordingCount int, bugs []*models
</div>
}
-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 + ": <ADD SUMMARY HERE>")
+}
+
+templ SecurityBugs(atom string, hasSecurityBugs bool, bugs []*models.Bug) {
<div class="row">
<div class="col-md-9">
if hasSecurityBugs {
@@ -117,7 +131,7 @@ templ SecurityBugs(hasSecurityBugs bool, bugs []*models.Bug) {
</div>
<div class="col-md-8 pt-3">
<h2>There are no open security bugs.</h2>
- <span>You think something is missing here? <br/> Start with filling a <a href="https://bugs.gentoo.org/">new security bug</a>.</span>
+ <span>You think something is missing here? <br/> Start with filling a <a href={ securityBugAtomLink(atom) }>new security bug</a>.</span>
</div>
</div>
}
@@ -130,7 +144,7 @@ templ SecurityBugs(hasSecurityBugs bool, bugs []*models.Bug) {
</h4>
<div class="collapse show" id="collapseDescription">
<span class="text-muted">
- Please file new vulnerability reports on <a href="https://bugs.gentoo.org/">Gentoo Bugzilla</a> and assign them to the Gentoo Security product and Vulnerabilities component.
+ Please file new vulnerability reports on <a href={ securityBugAtomLink(atom) }>Gentoo Bugzilla</a> and assign them to the Gentoo Security product and Vulnerabilities component.
</span>
</div>
</div>
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) {
</div>
}
-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) {