forked from tangled.org/core
Monorepo for Tangled

appview: pulls: group stacked pulls in all-pulls view

the pull listing should be less noisy now.

Signed-off-by: oppiliappan <me@oppi.li>

authored by oppi.li and committed by Tangled 0e596b62 df45d1e6

Changed files
+61 -1
appview
pages
templates
repo
pulls
pulls
+1
appview/pages/pages.go
··· 721 721 Active string 722 722 DidHandleMap map[string]string 723 723 FilteringBy db.PullState 724 + Stacks map[string]db.Stack 724 725 } 725 726 726 727 func (p *Pages) RepoPulls(w io.Writer, params RepoPullsParams) error {
+37 -1
appview/pages/templates/repo/pulls/pulls.html
··· 46 46 {{ define "repoAfter" }} 47 47 <div class="flex flex-col gap-2 mt-2"> 48 48 {{ range .Pulls }} 49 - <div class="rounded drop-shadow-sm bg-white dark:bg-gray-800 px-6 py-4"> 49 + <div class="rounded bg-white dark:bg-gray-800"> 50 + <div class="px-6 py-4 z-5"> 50 51 <div class="pb-2"> 51 52 <a href="/{{ $.RepoInfo.FullName }}/pulls/{{ .PullId }}" class="dark:text-white"> 52 53 {{ .Title }} ··· 123 124 {{ end }} 124 125 </span> 125 126 </p> 127 + </div> 128 + {{ if .StackId }} 129 + {{ $otherPulls := index $.Stacks .StackId }} 130 + <details class="bg-white dark:bg-gray-800 group"> 131 + <summary class="pb-4 px-6 text-xs list-none cursor-pointer hover:text-gray-500 hover:dark:text-gray-400"> 132 + {{ $s := "s" }} 133 + {{ if eq (len $otherPulls) 1 }} 134 + {{ $s = "" }} 135 + {{ end }} 136 + <div class="group-open:hidden flex items-center gap-2"> 137 + {{ i "chevrons-up-down" "w-4 h-4" }} expand {{ len $otherPulls }} pull{{$s}} in this stack 138 + </div> 139 + <div class="hidden group-open:flex items-center gap-2"> 140 + {{ i "chevrons-down-up" "w-4 h-4" }} hide {{ len $otherPulls }} pull{{$s}} in this stack 141 + </div> 142 + </summary> 143 + {{ block "pullList" (list $otherPulls $) }} {{ end }} 144 + </details> 145 + {{ end }} 126 146 </div> 127 147 {{ end }} 128 148 </div> 129 149 {{ end }} 150 + 151 + {{ define "pullList" }} 152 + {{ $list := index . 0 }} 153 + {{ $root := index . 1 }} 154 + <div class="grid grid-cols-1 rounded-b border-b border-t border-gray-200 dark:border-gray-900 divide-y divide-gray-200 dark:divide-gray-900"> 155 + {{ range $pull := $list }} 156 + <a href="/{{ $root.RepoInfo.FullName }}/pulls/{{ $pull.PullId }}" class="no-underline hover:no-underline hover:bg-gray-100/25 hover:dark:bg-gray-700/25"> 157 + <div class="flex gap-2 items-center px-6"> 158 + <div class="flex-grow min-w-0 w-full py-2"> 159 + {{ template "repo/pulls/fragments/summarizedHeader" $pull }} 160 + </div> 161 + </div> 162 + </a> 163 + {{ end }} 164 + </div> 165 + {{ end }}
+23
appview/pulls/pulls.go
··· 495 495 } 496 496 } 497 497 498 + // we want to group all stacked PRs into just one list 499 + stacks := make(map[string]db.Stack) 500 + n := 0 501 + for _, p := range pulls { 502 + // this PR is stacked 503 + if p.StackId != "" { 504 + // we have already seen this PR stack 505 + if _, seen := stacks[p.StackId]; seen { 506 + stacks[p.StackId] = append(stacks[p.StackId], p) 507 + // skip this PR 508 + } else { 509 + stacks[p.StackId] = nil 510 + pulls[n] = p 511 + n++ 512 + } 513 + } else { 514 + pulls[n] = p 515 + n++ 516 + } 517 + } 518 + pulls = pulls[:n] 519 + 498 520 identsToResolve := make([]string, len(pulls)) 499 521 for i, pull := range pulls { 500 522 identsToResolve[i] = pull.OwnerDid ··· 515 537 Pulls: pulls, 516 538 DidHandleMap: didHandleMap, 517 539 FilteringBy: state, 540 + Stacks: stacks, 518 541 }) 519 542 return 520 543 }