feat: add label filter to issues and pulls list views
Add a label text input to the filter bar on both issues and pulls list views. The filter is passed through to the Gitea API's native labels query parameter for server-side filtering. Infinite scroll preserves the label filter across page loads. Closes leeworks-agents/gitea-mobile#82 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -249,6 +249,7 @@ func (h *Handler) ListIssues(w http.ResponseWriter, r *http.Request) {
|
||||
Orgs []string
|
||||
SelectedOrg string
|
||||
SelectedState string
|
||||
SelectedLabel string
|
||||
HasMore bool
|
||||
NextPage int
|
||||
Error string
|
||||
@@ -259,6 +260,7 @@ func (h *Handler) ListIssues(w http.ResponseWriter, r *http.Request) {
|
||||
if selectedState == "" {
|
||||
selectedState = "open"
|
||||
}
|
||||
selectedLabel := r.URL.Query().Get("label")
|
||||
page, _ := strconv.Atoi(r.URL.Query().Get("page"))
|
||||
if page < 1 {
|
||||
page = 1
|
||||
@@ -268,6 +270,7 @@ func (h *Handler) ListIssues(w http.ResponseWriter, r *http.Request) {
|
||||
Orgs: orgNames,
|
||||
SelectedOrg: selectedOrg,
|
||||
SelectedState: selectedState,
|
||||
SelectedLabel: selectedLabel,
|
||||
}
|
||||
|
||||
if len(orgNames) == 0 {
|
||||
@@ -279,7 +282,7 @@ func (h *Handler) ListIssues(w http.ResponseWriter, r *http.Request) {
|
||||
queryOrgs = []string{selectedOrg}
|
||||
}
|
||||
|
||||
result, err := h.Client.ListAllIssues(r.Context(), token, queryOrgs, selectedState, page)
|
||||
result, err := h.Client.ListAllIssues(r.Context(), token, queryOrgs, selectedState, page, selectedLabel)
|
||||
if err != nil {
|
||||
slog.Error("failed to list issues", "error", err)
|
||||
data.Error = "Error loading issues."
|
||||
@@ -338,6 +341,7 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
Orgs []string
|
||||
SelectedOrg string
|
||||
SelectedState string
|
||||
SelectedLabel string
|
||||
HasMore bool
|
||||
NextPage int
|
||||
Error string
|
||||
@@ -348,6 +352,7 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
if selectedState == "" {
|
||||
selectedState = "open"
|
||||
}
|
||||
selectedLabel := r.URL.Query().Get("label")
|
||||
page, _ := strconv.Atoi(r.URL.Query().Get("page"))
|
||||
if page < 1 {
|
||||
page = 1
|
||||
@@ -357,6 +362,7 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
Orgs: orgNames,
|
||||
SelectedOrg: selectedOrg,
|
||||
SelectedState: selectedState,
|
||||
SelectedLabel: selectedLabel,
|
||||
}
|
||||
|
||||
if len(orgNames) == 0 {
|
||||
@@ -367,7 +373,7 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
queryOrgs = []string{selectedOrg}
|
||||
}
|
||||
|
||||
result, err := h.Client.ListAllPullRequests(r.Context(), token, queryOrgs, selectedState, page)
|
||||
result, err := h.Client.ListAllPullRequests(r.Context(), token, queryOrgs, selectedState, page, selectedLabel)
|
||||
if err != nil {
|
||||
slog.Error("failed to list pull requests", "error", err)
|
||||
data.Error = "Error loading pull requests."
|
||||
|
||||
Reference in New Issue
Block a user