Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fa7d3f868 |
@@ -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."
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
{{end}}
|
||||
{{if .HasMore}}
|
||||
<div class="scroll-sentinel" hx-get="/pulls?page={{.NextPage}}&org={{.SelectedOrg}}" hx-trigger="revealed" hx-swap="outerHTML" hx-target="this">
|
||||
<div class="scroll-sentinel" hx-get="/pulls?page={{.NextPage}}&org={{.SelectedOrg}}&state={{.SelectedState}}" hx-trigger="revealed" hx-swap="outerHTML" hx-target="this">
|
||||
<div class="spinner htmx-indicator"></div>
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -27,18 +27,22 @@
|
||||
<h1>Pull Requests</h1>
|
||||
|
||||
<div class="filter-bar">
|
||||
<select name="org" hx-get="/pulls" hx-trigger="change" hx-target="#main-content" hx-swap="innerHTML" hx-push-url="true">
|
||||
<select name="org" hx-get="/pulls" hx-trigger="change" hx-target="#main-content" hx-swap="innerHTML" hx-push-url="true" hx-include="[name='state']">
|
||||
<option value="">All orgs</option>
|
||||
{{range .Orgs}}
|
||||
<option value="{{.}}" {{if eq . $.SelectedOrg}}selected{{end}}>{{.}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<select name="state" hx-get="/pulls" hx-trigger="change" hx-target="#main-content" hx-swap="innerHTML" hx-push-url="true" hx-include="[name='org']">
|
||||
<option value="open" {{if eq .SelectedState "open"}}selected{{end}}>Open</option>
|
||||
<option value="closed" {{if eq .SelectedState "closed"}}selected{{end}}>Closed</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{if .Error}}
|
||||
<p class="empty">{{.Error}}</p>
|
||||
{{else if not .Pulls}}
|
||||
<p class="empty">No open pull requests found.</p>
|
||||
<p class="empty">No {{.SelectedState}} pull requests found.</p>
|
||||
{{else}}
|
||||
<div id="pull-list">
|
||||
{{template "cards" .}}
|
||||
|
||||
Reference in New Issue
Block a user