feat: add repo-level filter to issues and pulls list views
Add a repo dropdown to the filter bar that appears when an org is selected. The dropdown lists all repos in the selected org and filters issues/pulls to the chosen repo. Changing the org resets the repo filter. Infinite scroll preserves the repo filter. Closes leeworks-agents/gitea-mobile#83 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -250,6 +250,8 @@ func (h *Handler) ListIssues(w http.ResponseWriter, r *http.Request) {
|
||||
SelectedOrg string
|
||||
SelectedState string
|
||||
SelectedLabel string
|
||||
SelectedRepo string
|
||||
Repos []string
|
||||
HasMore bool
|
||||
NextPage int
|
||||
Error string
|
||||
@@ -261,6 +263,7 @@ func (h *Handler) ListIssues(w http.ResponseWriter, r *http.Request) {
|
||||
selectedState = "open"
|
||||
}
|
||||
selectedLabel := r.URL.Query().Get("label")
|
||||
selectedRepo := r.URL.Query().Get("repo")
|
||||
page, _ := strconv.Atoi(r.URL.Query().Get("page"))
|
||||
if page < 1 {
|
||||
page = 1
|
||||
@@ -271,6 +274,7 @@ func (h *Handler) ListIssues(w http.ResponseWriter, r *http.Request) {
|
||||
SelectedOrg: selectedOrg,
|
||||
SelectedState: selectedState,
|
||||
SelectedLabel: selectedLabel,
|
||||
SelectedRepo: selectedRepo,
|
||||
}
|
||||
|
||||
if len(orgNames) == 0 {
|
||||
@@ -280,9 +284,19 @@ func (h *Handler) ListIssues(w http.ResponseWriter, r *http.Request) {
|
||||
queryOrgs := orgNames
|
||||
if selectedOrg != "" {
|
||||
queryOrgs = []string{selectedOrg}
|
||||
|
||||
// Populate repo list for the selected org.
|
||||
repos, err := h.Client.ListOrgRepos(r.Context(), token, selectedOrg)
|
||||
if err != nil {
|
||||
slog.Warn("failed to list repos for org filter", "error", err, "org", selectedOrg)
|
||||
} else {
|
||||
for _, repo := range repos {
|
||||
data.Repos = append(data.Repos, repo.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result, err := h.Client.ListAllIssues(r.Context(), token, queryOrgs, selectedState, page, selectedLabel)
|
||||
result, err := h.Client.ListAllIssues(r.Context(), token, queryOrgs, selectedState, page, selectedLabel, selectedRepo)
|
||||
if err != nil {
|
||||
slog.Error("failed to list issues", "error", err)
|
||||
data.Error = "Error loading issues."
|
||||
@@ -342,6 +356,8 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
SelectedOrg string
|
||||
SelectedState string
|
||||
SelectedLabel string
|
||||
SelectedRepo string
|
||||
Repos []string
|
||||
HasMore bool
|
||||
NextPage int
|
||||
Error string
|
||||
@@ -353,6 +369,7 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
selectedState = "open"
|
||||
}
|
||||
selectedLabel := r.URL.Query().Get("label")
|
||||
selectedRepo := r.URL.Query().Get("repo")
|
||||
page, _ := strconv.Atoi(r.URL.Query().Get("page"))
|
||||
if page < 1 {
|
||||
page = 1
|
||||
@@ -363,6 +380,7 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
SelectedOrg: selectedOrg,
|
||||
SelectedState: selectedState,
|
||||
SelectedLabel: selectedLabel,
|
||||
SelectedRepo: selectedRepo,
|
||||
}
|
||||
|
||||
if len(orgNames) == 0 {
|
||||
@@ -371,9 +389,19 @@ func (h *Handler) ListPulls(w http.ResponseWriter, r *http.Request) {
|
||||
queryOrgs := orgNames
|
||||
if selectedOrg != "" {
|
||||
queryOrgs = []string{selectedOrg}
|
||||
|
||||
// Populate repo list for the selected org.
|
||||
repos, err := h.Client.ListOrgRepos(r.Context(), token, selectedOrg)
|
||||
if err != nil {
|
||||
slog.Warn("failed to list repos for org filter", "error", err, "org", selectedOrg)
|
||||
} else {
|
||||
for _, repo := range repos {
|
||||
data.Repos = append(data.Repos, repo.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result, err := h.Client.ListAllPullRequests(r.Context(), token, queryOrgs, selectedState, page, selectedLabel)
|
||||
result, err := h.Client.ListAllPullRequests(r.Context(), token, queryOrgs, selectedState, page, selectedLabel, selectedRepo)
|
||||
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