Monorepo for Tangled tangled.org

appview: pages: refactor pullStack fragment

break out summarizedHeader and summarizedPullState into resuable
fragments.

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

oppi.li 7e5eabd8 67887f7c

verified
Changed files
+53 -53
appview
+1 -53
appview/pages/templates/repo/pulls/fragments/pullStack.html
··· 8 8 {{ end }} 9 9 {{ end }} 10 10 11 - {{ define "summarizedHeader" }} 12 - <div class="flex text-sm items-center justify-between w-full"> 13 - <div class="flex items-center gap-2 min-w-0 flex-1 pr-2"> 14 - <div class="flex-shrink-0"> 15 - {{ block "summarizedPullState" . }} {{ end }} 16 - </div> 17 - <span class="truncate text-sm text-gray-800 dark:text-gray-200"> 18 - <span class="text-gray-500 dark:text-gray-400">#{{ .PullId }}</span> 19 - {{ .Title }} 20 - </span> 21 - </div> 22 - 23 - <div class="flex-shrink-0"> 24 - {{ $latestRound := .LastRoundNumber }} 25 - {{ $lastSubmission := index .Submissions $latestRound }} 26 - {{ $commentCount := len $lastSubmission.Comments }} 27 - <span> 28 - <div class="inline-flex items-center gap-2"> 29 - {{ i "message-square" "w-3 h-3 md:hidden" }} 30 - {{ $commentCount }} 31 - <span class="hidden md:inline">comment{{if ne $commentCount 1}}s{{end}}</span> 32 - </div> 33 - </span> 34 - <span class="mx-2 before:content-['·'] before:select-none"></span> 35 - <span> 36 - <span class="hidden md:inline">round</span> 37 - <span class="font-mono">#{{ $latestRound }}</span> 38 - </span> 39 - </div> 40 - </div> 41 - {{ end }} 42 - 43 - {{ define "summarizedPullState" }} 44 - {{ $fgColor := "text-gray-600 dark:text-gray-300" }} 45 - {{ $icon := "ban" }} 46 - 47 - {{ if .State.IsOpen }} 48 - {{ $fgColor = "text-green-600 dark:text-green-500" }} 49 - {{ $icon = "git-pull-request" }} 50 - {{ else if .State.IsMerged }} 51 - {{ $fgColor = "text-purple-600 dark:text-purple-500" }} 52 - {{ $icon = "git-merge" }} 53 - {{ else if .State.IsDeleted }} 54 - {{ $fgColor = "text-red-600 dark:text-red-500" }} 55 - {{ $icon = "git-pull-request-closed" }} 56 - {{ end }} 57 - 58 - {{ $style := printf "w-4 h-4 %s" $fgColor }} 59 - 60 - {{ i $icon $style }} 61 - {{ end }} 62 - 63 11 {{ define "pullList" }} 64 12 {{ $list := index . 0 }} 65 13 {{ $root := index . 1 }} ··· 77 25 </div> 78 26 {{ end }} 79 27 <div class="{{ if not $isCurrent }} pl-6 {{ end }} flex-grow min-w-0 w-full py-2"> 80 - {{ block "summarizedHeader" $pull }} {{ end }} 28 + {{ template "repo/pulls/fragments/summarizedHeader" $pull }} 81 29 </div> 82 30 </div> 83 31 </a>
+32
appview/pages/templates/repo/pulls/fragments/summarizedPullHeader.html
··· 1 + {{ define "repo/pulls/fragments/summarizedHeader" }} 2 + <div class="flex text-sm items-center justify-between w-full"> 3 + <div class="flex items-center gap-2 min-w-0 flex-1 pr-2"> 4 + <div class="flex-shrink-0"> 5 + {{ template "repo/pulls/fragments/summarizedPullState" .State }} 6 + </div> 7 + <span class="truncate text-sm text-gray-800 dark:text-gray-200"> 8 + <span class="text-gray-500 dark:text-gray-400">#{{ .PullId }}</span> 9 + {{ .Title }} 10 + </span> 11 + </div> 12 + 13 + <div class="flex-shrink-0"> 14 + {{ $latestRound := .LastRoundNumber }} 15 + {{ $lastSubmission := index .Submissions $latestRound }} 16 + {{ $commentCount := len $lastSubmission.Comments }} 17 + <span> 18 + <div class="inline-flex items-center gap-2"> 19 + {{ i "message-square" "w-3 h-3 md:hidden" }} 20 + {{ $commentCount }} 21 + <span class="hidden md:inline">comment{{if ne $commentCount 1}}s{{end}}</span> 22 + </div> 23 + </span> 24 + <span class="mx-2 before:content-['·'] before:select-none"></span> 25 + <span> 26 + <span class="hidden md:inline">round</span> 27 + <span class="font-mono">#{{ $latestRound }}</span> 28 + </span> 29 + </div> 30 + </div> 31 + {{ end }} 32 +
+20
appview/pages/templates/repo/pulls/fragments/summarizedPullState.html
··· 1 + {{ define "repo/pulls/fragments/summarizedPullState" }} 2 + {{ $fgColor := "text-gray-600 dark:text-gray-300" }} 3 + {{ $icon := "ban" }} 4 + 5 + {{ if .IsOpen }} 6 + {{ $fgColor = "text-green-600 dark:text-green-500" }} 7 + {{ $icon = "git-pull-request" }} 8 + {{ else if .IsMerged }} 9 + {{ $fgColor = "text-purple-600 dark:text-purple-500" }} 10 + {{ $icon = "git-merge" }} 11 + {{ else if .IsDeleted }} 12 + {{ $fgColor = "text-red-600 dark:text-red-500" }} 13 + {{ $icon = "git-pull-request-closed" }} 14 + {{ end }} 15 + 16 + {{ $style := printf "w-4 h-4 %s" $fgColor }} 17 + 18 + {{ i $icon $style }} 19 + {{ end }} 20 +