Monorepo for Tangled tangled.org
818
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview: issues: filter issues by clicking a label #283

open opened by nove-b.dev targeting master from nove-b.dev/tangled-core: href-issue-label

When contributing to a project, it's common to start by browsing issues with a label like "good-first-issue". Clicking a label to automatically filter issues by that label makes this workflow more convenient.

When a label is clicked, a query parameter is appended to the URL to filter the issue listing.

Closes #499

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:2atly2y5kfyjcj5zap6pv4wd/sh.tangled.repo.pull/3mkpenmah6d22
+33 -24
Diff #0
+13 -9
appview/issues/issues.go
··· 7 7 "fmt" 8 8 "log/slog" 9 9 "net/http" 10 + "regexp" 11 + "strings" 10 12 "time" 11 13 12 14 comatproto "github.com/bluesky-social/indigo/api/atproto" ··· 1002 1004 l.Error("failed to fetch vouch relationships", "err", err) 1003 1005 } 1004 1006 } 1005 - 1007 + stripLabelRe := regexp.MustCompile(`\s*-?label:\S*|\s*-?\w+/\S+`) 1008 + baseFilterQuery := strings.TrimSpace(stripLabelRe.ReplaceAllString(query.String(), "")) 1006 1009 rp.pages.RepoIssues(w, pages.RepoIssuesParams{ 1007 - LoggedInUser: rp.oauth.GetMultiAccountUser(r), 1008 - RepoInfo: repoInfo, 1009 - Issues: issues, 1010 - IssueCount: totalIssues, 1011 - LabelDefs: defs, 1012 - FilterState: filterState, 1013 - FilterQuery: query.String(), 1014 - Page: page, 1010 + LoggedInUser: rp.oauth.GetMultiAccountUser(r), 1011 + RepoInfo: repoInfo, 1012 + Issues: issues, 1013 + IssueCount: totalIssues, 1014 + LabelDefs: defs, 1015 + FilterState: filterState, 1016 + FilterQuery: query.String(), 1017 + BaseFilterQuery: baseFilterQuery, 1018 + Page: page, 1015 1019 VouchRelationships: vouchRelationships, 1016 1020 }) 1017 1021 }
+10 -9
appview/pages/pages.go
··· 1142 1142 } 1143 1143 1144 1144 type RepoIssuesParams struct { 1145 - LoggedInUser *oauth.MultiAccountUser 1146 - RepoInfo repoinfo.RepoInfo 1147 - Active string 1148 - Issues []models.Issue 1149 - IssueCount int 1150 - LabelDefs map[string]*models.LabelDefinition 1151 - Page pagination.Page 1152 - FilterState string 1153 - FilterQuery string 1145 + LoggedInUser *oauth.MultiAccountUser 1146 + RepoInfo repoinfo.RepoInfo 1147 + Active string 1148 + Issues []models.Issue 1149 + IssueCount int 1150 + LabelDefs map[string]*models.LabelDefinition 1151 + Page pagination.Page 1152 + FilterState string 1153 + FilterQuery string 1154 + BaseFilterQuery string 1154 1155 VouchRelationships map[syntax.DID]*models.VouchRelationship 1155 1156 } 1156 1157
+6 -4
appview/pages/templates/labels/fragments/label.html
··· 2 2 {{ $d := .def }} 3 3 {{ $v := .val }} 4 4 {{ $withPrefix := .withPrefix }} 5 + {{ $baseFilterQuery := .baseFilterQuery }} 6 + {{ $basePath := .basePath }} 5 7 6 8 {{ $lhs := printf "%s" $d.Name }} 7 9 {{ $rhs := "" }} ··· 32 34 {{ printf "%s%s" $lhs $rhs }} 33 35 </a> 34 36 {{ else }} 35 - <span class="{{ $chipClasses }}"> 36 - {{ template "repo/fragments/colorBall" (dict "color" $d.GetColor) }} 37 - {{ printf "%s%s" $lhs $rhs }} 38 - </span> 37 + <a href="{{$basePath}}?q={{$baseFilterQuery}}%20label:{{ printf "%s%s" $lhs $rhs }}" class="{{ $chipClasses }}"> 38 + {{ template "repo/fragments/colorBall" (dict "color" $d.GetColor) }} 39 + {{ printf "%s%s" $lhs $rhs }} 40 + </a> 39 41 {{ end }} 40 42 {{ end }} 41 43
+1 -1
appview/pages/templates/repo/issues/fragments/issueListing.html
··· 46 46 {{ $state := .Labels }} 47 47 {{ range $k, $d := $.LabelDefs }} 48 48 {{ range $v, $s := $state.GetValSet $d.AtUri.String }} 49 - {{ template "labels/fragments/label" (dict "def" $d "val" $v "withPrefix" true) }} 49 + {{ template "labels/fragments/label" (dict "def" $d "val" $v "withPrefix" true "baseFilterQuery" $.BaseFilterQuery "basePath" $.BasePath) }} 50 50 {{ end }} 51 51 {{ end }} 52 52 </div>
+3 -1
appview/pages/templates/repo/issues/issues.html
··· 71 71 "RepoPrefix" .RepoInfo.FullName 72 72 "LabelDefs" .LabelDefs 73 73 "VouchRelationships" .VouchRelationships 74 - ) }} 74 + "BaseFilterQuery" $.BaseFilterQuery 75 + "BasePath" (printf "/%s/issues" .RepoInfo.FullName)) 76 + }} 75 77 </div> 76 78 {{if gt .IssueCount .Page.Limit }} 77 79 {{ template "fragments/pagination" (dict

History

1 round 0 comments
sign up or login to add to the discussion
nove-b.dev submitted #0
1 commit
expand
appview: issues: filter issues by label on click
no conflicts, ready to merge
expand 0 comments