diff --git a/appview/issues/issues.go b/appview/issues/issues.go index d4ce37f6..3c167893 100644 --- a/appview/issues/issues.go +++ b/appview/issues/issues.go @@ -7,6 +7,7 @@ import ( "fmt" "log/slog" "net/http" + "strings" "time" comatproto "github.com/bluesky-social/indigo/api/atproto" @@ -1002,7 +1003,16 @@ func (rp *Issues) RepoIssues(w http.ResponseWriter, r *http.Request) { l.Error("failed to fetch vouch relationships", "err", err) } } - + baseFilterParts := make([]string, 0, len(query.Items())) + for _, item := range query.Items() { + if item.Kind == searchquery.KindTagValue { + if item.Key == "label" || !searchquery.KnownTags[item.Key] { + continue + } + } + baseFilterParts = append(baseFilterParts, item.Raw) + } + baseFilterQuery := strings.Join(baseFilterParts, " ") rp.pages.RepoIssues(w, pages.RepoIssuesParams{ LoggedInUser: rp.oauth.GetMultiAccountUser(r), RepoInfo: repoInfo, @@ -1011,6 +1021,7 @@ func (rp *Issues) RepoIssues(w http.ResponseWriter, r *http.Request) { LabelDefs: defs, FilterState: filterState, FilterQuery: query.String(), + BaseFilterQuery: baseFilterQuery, Page: page, VouchRelationships: vouchRelationships, }) diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 84e637fc..2c7038a9 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -1172,6 +1172,7 @@ type RepoIssuesParams struct { Page pagination.Page FilterState string FilterQuery string + BaseFilterQuery string VouchRelationships map[syntax.DID]*models.VouchRelationship } @@ -1335,6 +1336,7 @@ type RepoPullsParams struct { Active string FilterState string FilterQuery string + BaseFilterQuery string Stacks []models.Stack Pipelines map[string]models.Pipeline LabelDefs map[string]*models.LabelDefinition diff --git a/appview/pages/templates/labels/fragments/label.html b/appview/pages/templates/labels/fragments/label.html index 202d1036..b69011eb 100644 --- a/appview/pages/templates/labels/fragments/label.html +++ b/appview/pages/templates/labels/fragments/label.html @@ -2,17 +2,15 @@ {{ $d := .def }} {{ $v := .val }} {{ $withPrefix := .withPrefix }} + {{ $baseFilterQuery := .baseFilterQuery }} + {{ $basePath := .basePath }} {{ $lhs := printf "%s" $d.Name }} {{ $rhs := "" }} - {{ $isDid := false }} - {{ $resolvedVal := "" }} {{ if not $d.ValueType.IsNull }} - {{ $isDid = $d.ValueType.IsDidFormat }} - {{ if $isDid }} - {{ $resolvedVal = resolve $v }} - {{ $v = $resolvedVal }} + {{ if $d.ValueType.IsDidFormat }} + {{ $v = resolve $v }} {{ end }} {{ if not $withPrefix }} @@ -26,8 +24,16 @@ {{ $chipClasses := "w-fit flex items-center gap-2 font-normal normal-case rounded py-1 px-2 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-sm text-inherit" }} - {{ if $isDid }} - + {{ if $basePath }} + {{ $filterToken := printf "label:%s" $d.Name }} + {{ if not $d.ValueType.IsNull }} + {{ $filterToken = printf "%s:%s" $d.Name $v }} + {{ end }} + {{ $fullQuery := $filterToken }} + {{ if ne $baseFilterQuery "" }} + {{ $fullQuery = printf "%s %s" $baseFilterQuery $filterToken }} + {{ end }} + {{ template "repo/fragments/colorBall" (dict "color" $d.GetColor) }} {{ printf "%s%s" $lhs $rhs }} diff --git a/appview/pages/templates/repo/issues/fragments/issueListing.html b/appview/pages/templates/repo/issues/fragments/issueListing.html index f0b9af46..6ccec755 100644 --- a/appview/pages/templates/repo/issues/fragments/issueListing.html +++ b/appview/pages/templates/repo/issues/fragments/issueListing.html @@ -46,7 +46,7 @@ {{ $state := .Labels }} {{ range $k, $d := $.LabelDefs }} {{ range $v, $s := $state.GetValSet $d.AtUri.String }} - {{ template "labels/fragments/label" (dict "def" $d "val" $v "withPrefix" true) }} + {{ template "labels/fragments/label" (dict "def" $d "val" $v "withPrefix" true "baseFilterQuery" $.BaseFilterQuery "basePath" $.BasePath) }} {{ end }} {{ end }} diff --git a/appview/pages/templates/repo/issues/issues.html b/appview/pages/templates/repo/issues/issues.html index 3dbd89f0..bc63e81d 100644 --- a/appview/pages/templates/repo/issues/issues.html +++ b/appview/pages/templates/repo/issues/issues.html @@ -71,7 +71,9 @@ "RepoPrefix" .RepoInfo.FullName "LabelDefs" .LabelDefs "VouchRelationships" .VouchRelationships - ) }} + "BaseFilterQuery" $.BaseFilterQuery + "BasePath" (printf "/%s/issues" .RepoInfo.FullName)) + }} {{if gt .IssueCount .Page.Limit }} {{ template "fragments/pagination" (dict diff --git a/appview/pages/templates/repo/pulls/pulls.html b/appview/pages/templates/repo/pulls/pulls.html index b8bdc2af..3373a8a6 100644 --- a/appview/pages/templates/repo/pulls/pulls.html +++ b/appview/pages/templates/repo/pulls/pulls.html @@ -111,7 +111,7 @@ {{ $state := $topPR.Labels }} {{ range $k, $d := $.LabelDefs }} {{ range $v, $s := $state.GetValSet $d.AtUri.String }} - {{ template "labels/fragments/label" (dict "def" $d "val" $v "withPrefix" true) }} + {{ template "labels/fragments/label" (dict "def" $d "val" $v "withPrefix" true "baseFilterQuery" $.BaseFilterQuery "basePath" (printf "/%s/pulls" $.RepoInfo.FullName)) }} {{ end }} {{ end }}