Monorepo for Tangled tangled.org
858
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
+46 -26
Interdiff #0 #1
+19 -12
appview/issues/issues.go
··· 7 7 "fmt" 8 8 "log/slog" 9 9 "net/http" 10 - "regexp" 11 10 "strings" 12 11 "time" 13 12 ··· 1004 1003 l.Error("failed to fetch vouch relationships", "err", err) 1005 1004 } 1006 1005 } 1007 - stripLabelRe := regexp.MustCompile(`\s*-?label:\S*|\s*-?\w+/\S+`) 1008 - baseFilterQuery := strings.TrimSpace(stripLabelRe.ReplaceAllString(query.String(), "")) 1006 + baseFilterParts := make([]string, 0, len(query.Items())) 1007 + for _, item := range query.Items() { 1008 + if item.Kind == searchquery.KindTagValue { 1009 + if item.Key == "label" || !searchquery.KnownTags[item.Key] { 1010 + continue 1011 + } 1012 + } 1013 + baseFilterParts = append(baseFilterParts, item.Raw) 1014 + } 1015 + baseFilterQuery := strings.Join(baseFilterParts, " ") 1009 1016 rp.pages.RepoIssues(w, pages.RepoIssuesParams{ 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, 1017 + LoggedInUser: rp.oauth.GetMultiAccountUser(r), 1018 + RepoInfo: repoInfo, 1019 + Issues: issues, 1020 + IssueCount: totalIssues, 1021 + LabelDefs: defs, 1022 + FilterState: filterState, 1023 + FilterQuery: query.String(), 1024 + BaseFilterQuery: baseFilterQuery, 1025 + Page: page, 1019 1026 VouchRelationships: vouchRelationships, 1020 1027 }) 1021 1028 }
+10 -10
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 1154 - BaseFilterQuery 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 1155 1155 VouchRelationships map[syntax.DID]*models.VouchRelationship 1156 1156 } 1157 1157
+17 -4
appview/pages/templates/labels/fragments/label.html
··· 33 33 {{ template "repo/fragments/colorBall" (dict "color" $d.GetColor) }} 34 34 {{ printf "%s%s" $lhs $rhs }} 35 35 </a> 36 - {{ else }} 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 }} 36 + {{ else if $basePath }} 37 + {{ $filterToken := printf "label:%s" $d.Name }} 38 + {{ if not $d.ValueType.IsNull }} 39 + {{ $filterToken = printf "%s:%s" $d.Name $v }} 40 + {{ end }} 41 + {{ $fullQuery := $filterToken }} 42 + {{ if ne $baseFilterQuery "" }} 43 + {{ $fullQuery = printf "%s %s" $baseFilterQuery $filterToken }} 44 + {{ end }} 45 + <a href="{{ $basePath }}?q={{ urlquery $fullQuery }}" class="{{ $chipClasses }}"> 46 + {{ template "repo/fragments/colorBall" (dict "color" $d.GetColor) }} 47 + {{ printf "%s%s" $lhs $rhs }} 40 48 </a> 49 + {{ else }} 50 + <span class="{{ $chipClasses }}"> 51 + {{ template "repo/fragments/colorBall" (dict "color" $d.GetColor) }} 52 + {{ printf "%s%s" $lhs $rhs }} 53 + </span> 41 54 {{ end }} 42 55 {{ end }} 43 56
appview/pages/templates/repo/issues/fragments/issueListing.html

This file has not been changed.

appview/pages/templates/repo/issues/issues.html

This file has not been changed.

History

5 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview: issues: filter issues by label on click
merge conflicts detected
expand
  • appview/issues/issues.go:7
  • appview/pages/pages.go:1172
  • appview/pages/templates/labels/fragments/label.html:2
  • appview/pages/templates/repo/issues/fragments/issueListing.html:46
  • appview/pages/templates/repo/issues/issues.html:71
  • appview/pages/templates/repo/pulls/pulls.html:111
expand 0 comments
1 commit
expand
appview: issues: filter issues by label on click
expand 0 comments
1 commit
expand
appview: issues: filter issues by label on click
expand 0 comments
1 commit
expand
appview: issues: filter issues by label on click
expand 0 comments
1 commit
expand
appview: issues: filter issues by label on click
expand 0 comments