feat: add open/closed state filter to PR list view
Mirror the existing issues state filter pattern: read state query param (default "open"), pass it to ListAllPullRequests instead of hardcoded "open", and add a state select widget to the pulls filter bar with proper hx-include for HTMX partial reloads and infinite scroll. Closes leeworks-agents/gitea-mobile#72 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -320,23 +320,29 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
orgNames := h.getUserOrgs(r)
|
||||
|
||||
type pullsData struct {
|
||||
Pulls []giteaclient.PullRequest
|
||||
Orgs []string
|
||||
SelectedOrg string
|
||||
HasMore bool
|
||||
NextPage int
|
||||
Error string
|
||||
Pulls []giteaclient.PullRequest
|
||||
Orgs []string
|
||||
SelectedOrg string
|
||||
SelectedState string
|
||||
HasMore bool
|
||||
NextPage int
|
||||
Error string
|
||||
}
|
||||
|
||||
selectedOrg := r.URL.Query().Get("org")
|
||||
selectedState := r.URL.Query().Get("state")
|
||||
if selectedState == "" {
|
||||
selectedState = "open"
|
||||
}
|
||||
page, _ := strconv.Atoi(r.URL.Query().Get("page"))
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
|
||||
data := pullsData{
|
||||
Orgs: orgNames,
|
||||
SelectedOrg: selectedOrg,
|
||||
Orgs: orgNames,
|
||||
SelectedOrg: selectedOrg,
|
||||
SelectedState: selectedState,
|
||||
}
|
||||
|
||||
if len(orgNames) == 0 {
|
||||
@@ -347,7 +353,7 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
queryOrgs = []string{selectedOrg}
|
||||
}
|
||||
|
||||
result, err := h.Client.ListAllPullRequests(r.Context(), token, queryOrgs, "open", page)
|
||||
result, err := h.Client.ListAllPullRequests(r.Context(), token, queryOrgs, selectedState, page)
|
||||
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