This repository has no description
0

Configure Feed

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

core / appview / pages / templates / repo / pulls / fragments / pullStepReview.html
28 kB 514 lines
1{{ define "repo/pulls/fragments/pullStepReview" }} 2 <section class="flex flex-col gap-3"> 3 {{ if not .Comparison }} 4 <div class="p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800/30 text-sm text-gray-600 dark:text-gray-400"> 5 {{ if eq .Source "patch" }} 6 Paste a patch above to see a comparison. 7 {{ else }} 8 Pick a source and target above to see a comparison. 9 {{ end }} 10 </div> 11 {{ else }} 12 {{ $commits := .Comparison.FormatPatch }} 13 {{ if $commits }} 14 <div class="flex flex-col gap-2"> 15 <div class="flex items-center justify-between gap-3 min-w-0 text-sm text-gray-500 dark:text-gray-400"> 16 {{ if .IsStacked }} 17 <span class="inline-flex items-center gap-2 flex-shrink-0 text-gray-900 dark:text-gray-100"> 18 {{ i "chevrons-down-up" "w-4 h-4" }} 19 <span>Stack</span> 20 <span class="text-gray-500 dark:text-gray-400">{{ len $commits }} pull request{{ if ne (len $commits) 1 }}s{{ end }}</span> 21 </span> 22 {{ else }} 23 <span class="flex-shrink-0">{{ len $commits }} commit{{ if ne (len $commits) 1 }}s{{ end }}</span> 24 {{ end }} 25 {{ if and .SourceBranch .TargetBranch }} 26 <span class="inline-flex items-center gap-2 font-mono text-gray-600 dark:text-gray-300 truncate"> 27 <span>{{ .TargetBranch }}</span> 28 {{ i "arrow-left-right" "w-4 h-4 flex-shrink-0" }} 29 <span>{{ .SourceBranch }}</span> 30 </span> 31 {{ end }} 32 </div> 33 {{ if .IsStacked }} 34 {{ template "pullReviewStackedCommits" . }} 35 {{ else }} 36 {{ template "pullReviewFlatCommits" . }} 37 {{ end }} 38 </div> 39 {{ else if ne .Source "patch" }} 40 <div class="p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800/30 text-sm text-gray-600 dark:text-gray-400"> 41 {{ if and .SourceBranch .TargetBranch (eq .SourceBranch .TargetBranch) }} 42 Source and target are the same branch, nothing to merge. 43 {{ else }} 44 No commits between target and source. Make sure your source branch has commits not on the target. 45 {{ end }} 46 </div> 47 {{ end }} 48 49 {{ if and .Diff (not .IsStacked) }} 50 {{ template "pullComposeFlatDiff" (list .Diff .DiffOpts) }} 51 {{ end }} 52 53 {{ if and .IsStacked $commits }} 54 {{ template "pullSubmitRow" . }} 55 {{ template "pullStackApplyAllScript" }} 56 {{ end }} 57 {{ end }} 58 </section> 59{{ end }} 60 61{{ define "pullStackApplyAllScript" }} 62 <script> 63 (() => { 64 const checkbox = document.getElementById('stack-apply-all'); 65 if (!checkbox || checkbox.dataset.applyAllWired === '1') return; 66 checkbox.dataset.applyAllWired = '1'; 67 68 const update = () => { 69 const panels = document.querySelectorAll('[data-stack-labels]'); 70 panels.forEach((panel, idx) => { 71 if (idx === 0) return; 72 panel.classList.toggle('hidden', checkbox.checked); 73 }); 74 }; 75 checkbox.addEventListener('change', update); 76 update(); 77 })(); 78 </script> 79{{ end }} 80 81{{ define "pullReviewFlatCommits" }} 82 {{ $commits := .Comparison.FormatPatch }} 83 <ul class="flex flex-col gap-2"> 84 {{ range $commits }} 85 <li class="border border-gray-200 dark:border-gray-700 rounded bg-white dark:bg-gray-800 px-3 py-2 flex items-center gap-3"> 86 <span class="text-gray-700 dark:text-gray-300 flex-shrink-0"> 87 {{ i "git-pull-request-create" "w-4 h-4" }} 88 </span> 89 <span class="flex-1 min-w-0 truncate text-sm dark:text-gray-200">{{ .Title }}</span> 90 {{ template "pullReviewCommitTimestamp" (dict "Patch" .) }} 91 <span class="-my-2 self-stretch w-px bg-gray-200 dark:bg-gray-700"></span> 92 {{ template "pullReviewCommitActions" (dict "Patch" . "RepoInfo" $.RepoInfo) }} 93 </li> 94 {{ end }} 95 </ul> 96{{ end }} 97 98{{ define "pullReviewStackedCommits" }} 99 {{ $root := . }} 100 {{ $commits := .Comparison.FormatPatch }} 101 {{ $hasSidePanel := and $root.LabelDefs $root.RepoInfo.Roles.IsPushAllowed }} 102 <ul class="flex flex-col gap-2"> 103 {{ range $idx, $p := $commits }} 104 {{ $cid := $p.ChangeIdOrEmpty }} 105 {{ $titleOverride := index $root.StackTitles $cid }} 106 {{ $bodyOverride := index $root.StackBodies $cid }} 107 {{ $displayTitle := $p.Title }} 108 {{ if $titleOverride }}{{ $displayTitle = $titleOverride }}{{ end }} 109 {{ $bodyValue := $p.Body }} 110 {{ if $bodyOverride }}{{ $bodyValue = $bodyOverride }}{{ end }} 111 {{ $perDiff := "" }} 112 {{ $perOpts := dict }} 113 {{ if lt $idx (len $root.StackedDiffs) }} 114 {{ $sd := index $root.StackedDiffs $idx }} 115 {{ $perDiff = $sd.Diff }} 116 {{ $perOpts = $sd.Opts }} 117 {{ end }} 118 <li> 119 <details class="group/stacked border border-gray-200 dark:border-gray-700 rounded bg-white dark:bg-gray-800"> 120 <summary class="p-3 cursor-pointer flex items-center gap-3 list-none"> 121 <span class="text-gray-700 dark:text-gray-300 flex-shrink-0"> 122 {{ i "chevron-right" "w-4 h-4 group-open/stacked:hidden inline" }} 123 {{ i "chevron-down" "w-4 h-4 hidden group-open/stacked:inline" }} 124 </span> 125 <span class="-my-3 self-stretch w-px bg-gray-200 dark:bg-gray-700"></span> 126 <span class="text-gray-700 dark:text-gray-300 flex-shrink-0"> 127 {{ i "git-pull-request-create" "w-4 h-4" }} 128 </span> 129 <span class="flex-1 min-w-0 truncate text-sm dark:text-gray-200">{{ $displayTitle }}</span> 130 {{ template "pullReviewCommitTimestamp" (dict "Patch" $p) }} 131 <span class="-my-3 self-stretch w-px bg-gray-200 dark:bg-gray-700"></span> 132 {{ template "pullReviewCommitActions" (dict "Patch" $p "RepoInfo" $root.RepoInfo) }} 133 </summary> 134 {{ if $cid }} 135 <div class="px-3 pb-3 pt-1 flex flex-col gap-3 border-t border-gray-100 dark:border-gray-700"> 136 {{ $titleName := printf "stackTitle[%s]" $cid }} 137 {{ $bodyName := printf "stackBody[%s]" $cid }} 138 <div class="flex flex-col md:flex-row gap-6"> 139 <div class="flex-1 min-w-0 flex flex-col gap-3"> 140 <div class="flex flex-col gap-1"> 141 <label class="text-xs tracking-wide text-gray-800 dark:text-gray-200">Title</label> 142 <input 143 type="text" 144 name="{{ $titleName }}" 145 value="{{ $displayTitle }}" 146 class="w-full dark:bg-gray-800 dark:text-white dark:border-gray-700" 147 placeholder="{{ $p.Title }}" 148 /> 149 </div> 150 {{ template "fragments/markdownEditor" (dict 151 "Name" $bodyName 152 "Value" $bodyValue 153 "Rows" 4 154 "Placeholder" "Describe this pull request. Markdown is supported." 155 ) }} 156 </div> 157 {{ if $hasSidePanel }} 158 <aside data-stack-labels="{{ $cid }}" class="w-full md:w-72 md:flex-shrink-0 flex flex-col gap-4"> 159 {{ $labelState := $root.LabelState }} 160 {{ if $root.StackLabelStates }} 161 {{ $perCid := index $root.StackLabelStates $cid }} 162 {{ if $perCid }}{{ $labelState = $perCid }}{{ end }} 163 {{ end }} 164 {{ $labelCtx := dict "Defs" $root.LabelDefs "State" $labelState "RepoInfo" $root.RepoInfo "Subject" "" "LoggedInUser" $root.LoggedInUser "Prefix" (printf "stackLabel[%s]" $cid) }} 165 {{ template "editBasicLabels" $labelCtx }} 166 {{ template "editKvLabels" $labelCtx }} 167 {{ if eq $idx 0 }} 168 <label class="flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400 self-start"> 169 <input type="checkbox" id="stack-apply-all" name="applyLabelsToAll" autocomplete="off" /> 170 Apply labels and assignees to all PRs in stack 171 </label> 172 {{ end }} 173 </aside> 174 {{ end }} 175 </div> 176 {{ if $perDiff }} 177 <hr class="border-gray-200 dark:border-gray-700 my-1" /> 178 <div id="stack-diff-{{ $cid }}"> 179 <input type="hidden" name="stackSplit[{{ $cid }}]" value="{{ if $perOpts.Split }}split{{ else }}unified{{ end }}" /> 180 {{ template "pullStackedDiffArea" (dict "Diff" $perDiff "DiffOpts" $perOpts "Cid" $cid) }} 181 </div> 182 {{ end }} 183 </div> 184 {{ else }} 185 <div class="px-3 pb-3 pt-1 text-sm text-yellow-700 dark:text-yellow-300 border-t border-gray-100 dark:border-gray-700"> 186 This commit has no <span class="font-mono">Change-Id</span> header and can't be stacked. Set one on the commit and re-push. 187 </div> 188 {{ end }} 189 </details> 190 </li> 191 {{ end }} 192 </ul> 193{{ end }} 194 195{{ define "pullReviewCommitTimestamp" }} 196 {{ $p := .Patch }} 197 {{ if or (not $p.AuthorDate.IsZero) $p.SHA }} 198 <span class="flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400 flex-shrink-0"> 199 {{ if not $p.AuthorDate.IsZero }} 200 {{ template "repo/fragments/shortTimeAgo" $p.AuthorDate }} 201 {{ end }} 202 {{ if $p.SHA }} 203 <span class="font-mono bg-gray-100 dark:bg-gray-900 text-gray-700 dark:text-gray-300 px-2 py-0.5 rounded">{{ slice $p.SHA 0 8 }}</span> 204 {{ end }} 205 </span> 206 {{ end }} 207{{ end }} 208 209{{ define "pullReviewCommitActions" }} 210 {{ $p := .Patch }} 211 {{ $repoInfo := .RepoInfo }} 212 {{ if $p.SHA }} 213 <span class="flex items-center gap-1 text-gray-700 dark:text-gray-300 flex-shrink-0"> 214 <button type="button" 215 class="p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded text-gray-700 dark:text-gray-300" 216 title="Copy SHA" 217 onclick="event.preventDefault(); event.stopPropagation(); navigator.clipboard.writeText('{{ $p.SHA }}'); this.innerHTML=`{{ i "copy-check" "w-4 h-4" }}`; setTimeout(() => this.innerHTML=`{{ i "copy" "w-4 h-4" }}`, 1500)"> 218 {{ i "copy" "w-4 h-4" }} 219 </button> 220 <a href="/{{ $repoInfo.FullName }}/tree/{{ $p.SHA }}" 221 onclick="event.stopPropagation()" 222 class="p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded text-gray-700 dark:text-gray-300" 223 title="Browse repository at this commit"> 224 {{ i "folder-code" "w-4 h-4" }} 225 </a> 226 </span> 227 {{ end }} 228{{ end }} 229 230{{ define "pullStackedDiffArea" }} 231 {{ $diff := .Diff }} 232 {{ $opts := .DiffOpts }} 233 {{ $cid := .Cid }} 234 {{ $togId := printf "stack-%s-filesToggle" $cid }} 235 {{ $colId := printf "stack-%s-collapseToggle" $cid }} 236 {{ $filesId := printf "stack-%s-files" $cid }} 237 {{ $diffAreaId := printf "stack-%s-diff-area" $cid }} 238 {{ $filePrefix := printf "stack-%s-file-" $cid }} 239 {{ $stat := $diff.Stats }} 240 {{ $count := len $diff.ChangedFiles }} 241 242 <style> 243 #{{ $togId }}:checked ~ * label[for="{{ $togId }}"] .show-text { display: none; } 244 #{{ $togId }}:checked ~ * label[for="{{ $togId }}"] .hide-text { display: inline; } 245 #{{ $togId }}:not(:checked) ~ * label[for="{{ $togId }}"] .hide-text { display: none; } 246 #{{ $togId }}:checked ~ * div#{{ $filesId }} { width: fit-content; max-width: 15vw; } 247 #{{ $togId }}:not(:checked) ~ * div#{{ $filesId }} { width: 0; display: none; margin-right: 0; } 248 </style> 249 250 <input type="checkbox" id="{{ $togId }}" class="hidden"/> 251 252 <div id="{{ $diffAreaId }}"> 253 <div class="bg-slate-100 dark:bg-gray-700/50 flex items-center gap-2 h-12 p-2 rounded-t-md border border-b-0 border-gray-200 dark:border-gray-700"> 254 <label title="Toggle filetree panel" for="{{ $togId }}" class="hidden md:inline-flex items-center justify-center rounded cursor-pointer text-normal font-normal normal-case"> 255 <span class="show-text">{{ i "panel-left-open" "size-4" }}</span> 256 <span class="hide-text">{{ i "panel-left-close" "size-4" }}</span> 257 </label> 258 259 {{ template "repo/fragments/diffStatPill" $stat }} 260 <span class="text-xs text-gray-600 dark:text-gray-300 hidden md:inline-flex">{{ $count }} changed file{{ if ne $count 1 }}s{{ end }}</span> 261 262 <div class="flex-grow"></div> 263 264 <label title="Expand/Collapse diffs" for="{{ $colId }}" class="btn font-normal normal-case"> 265 <input type="checkbox" id="{{ $colId }}" class="peer/collapse hidden"/> 266 <span class="peer-checked/collapse:hidden inline-flex items-center gap-2"> 267 {{ i "unfold-vertical" "w-4 h-4" }} 268 <span class="hidden md:inline">Expand all</span> 269 </span> 270 <span class="peer-checked/collapse:inline-flex hidden flex items-center gap-2"> 271 {{ i "fold-vertical" "w-4 h-4" }} 272 <span class="hidden md:inline">Collapse all</span> 273 </span> 274 </label> 275 276 {{ template "repo/fragments/diffOpts" $opts }} 277 </div> 278 279 <div class="flex border border-gray-200 dark:border-gray-700 rounded-b-md"> 280 <div id="{{ $filesId }}" class="hidden md:block overflow-hidden max-h-[60vh] overflow-y-auto border-r border-gray-200 dark:border-gray-700"> 281 <section class="overflow-x-auto text-sm px-3 py-2 w-full mx-auto"> 282 {{ template "repo/fragments/fileTreePrefixed" (dict "Tree" $diff.FileTree "Prefix" $filePrefix) }} 283 </section> 284 </div> 285 286 <div class="flex-1 min-w-0 p-2"> 287 <div class="flex flex-col gap-2"> 288 {{ if eq $count 0 }} 289 <div class="text-center text-gray-500 dark:text-gray-400 py-8"> 290 <p>No differences found.</p> 291 </div> 292 {{ else if le $count 5 }} 293 {{ range $idx, $file := $diff.ChangedFiles }} 294 {{ template "stackedDiffFile" (dict "Idx" $idx "File" $file "IsSplit" $opts.Split "Prefix" $filePrefix) }} 295 {{ end }} 296 {{ else }} 297 {{ range $idx, $file := slice $diff.ChangedFiles 0 5 }} 298 {{ template "stackedDiffFile" (dict "Idx" $idx "File" $file "IsSplit" $opts.Split "Prefix" $filePrefix) }} 299 {{ end }} 300 {{ $remaining := sub $count 5 }} 301 <details class="group/showmore"> 302 <summary class="cursor-pointer text-sm text-gray-700 dark:text-gray-300 py-2 px-1 flex items-center gap-2 select-none hover:text-gray-900 dark:hover:text-gray-100 list-none"> 303 <span class="group-open/showmore:hidden inline-flex items-center gap-2"> 304 {{ i "chevron-right" "w-4 h-4" }} 305 Show {{ $remaining }} more file{{ if ne $remaining 1 }}s{{ end }} 306 </span> 307 <span class="hidden group-open/showmore:inline-flex items-center gap-2"> 308 {{ i "chevron-down" "w-4 h-4" }} 309 Hide {{ $remaining }} file{{ if ne $remaining 1 }}s{{ end }} 310 </span> 311 </summary> 312 <div class="flex flex-col gap-2 mt-2"> 313 {{ range $idx, $file := slice $diff.ChangedFiles 5 }} 314 {{ template "stackedDiffFile" (dict "Idx" (add $idx 5) "File" $file "IsSplit" $opts.Split "Prefix" $filePrefix) }} 315 {{ end }} 316 </div> 317 </details> 318 {{ end }} 319 </div> 320 </div> 321 </div> 322 </div> 323 324 <script> 325 (() => { 326 const cb = document.getElementById('{{ $colId }}'); 327 const area = document.getElementById('{{ $diffAreaId }}'); 328 if (!cb || !area) return; 329 const all = () => area.querySelectorAll('details[id^="{{ $filePrefix }}"]'); 330 cb.addEventListener('change', () => { 331 all().forEach(d => { d.open = cb.checked; }); 332 }); 333 area.addEventListener('toggle', (e) => { 334 if (!e.target.matches('details[id^="{{ $filePrefix }}"]')) return; 335 const dets = Array.from(all()); 336 const allOpen = dets.every(d => d.open); 337 const allClosed = dets.every(d => !d.open); 338 if (allOpen) cb.checked = true; 339 else if (allClosed) cb.checked = false; 340 }, true); 341 })(); 342 </script> 343{{ end }} 344 345{{ define "stackedDiffFile" }} 346 {{ $idx := .Idx }} 347 {{ $file := .File }} 348 {{ $isSplit := .IsSplit }} 349 {{ $prefix := .Prefix }} 350 {{ $isGenerated := false }} 351 {{ $isDeleted := false }} 352 {{ with $file }} 353 {{ $n := .Names }} 354 {{ $isDeleted = and (eq $n.New "") (ne $n.Old "") }} 355 {{ if $n.New }} 356 {{ $isGenerated = isGenerated $n.New }} 357 {{ else if $n.Old }} 358 {{ $isGenerated = isGenerated $n.Old }} 359 {{ end }} 360 <details id="{{ $prefix }}{{ .Id }}" class="group border border-gray-200 dark:border-gray-700 w-full mx-auto rounded bg-white dark:bg-gray-800 drop-shadow-sm" tabindex="{{ add $idx 1 }}"> 361 <summary class="list-none cursor-pointer group-open:border-b border-gray-200 dark:border-gray-700"> 362 <div class="rounded cursor-pointer bg-white dark:bg-gray-800 flex justify-between"> 363 <div class="p-2 flex gap-2 items-center overflow-x-auto"> 364 <span class="group-open:hidden inline">{{ i "chevron-right" "w-4 h-4" }}</span> 365 <span class="hidden group-open:inline">{{ i "chevron-down" "w-4 h-4" }}</span> 366 {{ template "repo/fragments/diffStatPill" .Stats }} 367 <div class="flex gap-2 items-center overflow-x-auto"> 368 {{ if and $n.New $n.Old (ne $n.New $n.Old)}} 369 {{ $n.Old }} {{ i "arrow-right" "w-4 h-4" }} {{ $n.New }} 370 {{ else if $n.New }} 371 {{ $n.New }} 372 {{ else }} 373 {{ $n.Old }} 374 {{ end }} 375 {{ if $isDeleted }} 376 <span class="text-gray-400 dark:text-gray-500" title="Deleted files are collapsed by default"> 377 {{ i "circle-question-mark" "size-4" }} 378 </span> 379 {{ else if $isGenerated }} 380 <span class="text-gray-400 dark:text-gray-500" title="Generated files are collapsed by default"> 381 {{ i "circle-question-mark" "size-4" }} 382 </span> 383 {{ end }} 384 </div> 385 </div> 386 </div> 387 </summary> 388 389 <div class="transition-all duration-700 ease-in-out"> 390 {{ $reason := .CanRender }} 391 {{ if $reason }} 392 <p class="text-center text-gray-400 dark:text-gray-500 p-4">{{ $reason }}</p> 393 {{ else }} 394 {{ if $isSplit }} 395 {{- template "repo/fragments/splitDiff" .Split -}} 396 {{ else }} 397 {{- template "repo/fragments/unifiedDiff" . -}} 398 {{ end }} 399 {{- end -}} 400 </div> 401 </details> 402 {{ end }} 403{{ end }} 404 405{{ define "pullComposeFlatDiff" }} 406 {{ $diff := index . 0 }} 407 {{ $opts := index . 1 }} 408 {{ $files := $diff.ChangedFiles }} 409 {{ $isSplit := $opts.Split }} 410 {{ $count := len $files }} 411 {{ $stat := $diff.Stats }} 412 413 <style> 414 #composeFilesToggle:checked ~ * label[for="composeFilesToggle"] .show-text { display: none; } 415 #composeFilesToggle:checked ~ * label[for="composeFilesToggle"] .hide-text { display: inline; } 416 #composeFilesToggle:not(:checked) ~ * label[for="composeFilesToggle"] .hide-text { display: none; } 417 #composeFilesToggle:checked ~ * div#composeFiles { width: fit-content; max-width: 15vw; } 418 #composeFilesToggle:not(:checked) ~ * div#composeFiles { width: 0; display: none; margin-right: 0; } 419 </style> 420 421 <input type="checkbox" id="composeFilesToggle" class="hidden"/> 422 423 <div id="diff-area"> 424 <div class="bg-slate-100 dark:bg-gray-700/50 flex items-center gap-2 h-12 p-2 rounded-t-md border border-b-0 border-gray-200 dark:border-gray-700"> 425 <label title="Toggle filetree panel" for="composeFilesToggle" class="hidden md:inline-flex items-center justify-center rounded cursor-pointer text-normal font-normal normal-case"> 426 <span class="show-text">{{ i "panel-left-open" "size-4" }}</span> 427 <span class="hide-text">{{ i "panel-left-close" "size-4" }}</span> 428 </label> 429 430 {{ template "repo/fragments/diffStatPill" $stat }} 431 <span class="text-xs text-gray-600 dark:text-gray-300 hidden md:inline-flex">{{ $count }} changed file{{ if ne $count 1 }}s{{ end }}</span> 432 433 <div class="flex-grow"></div> 434 435 <label title="Expand/Collapse diffs" for="composeCollapseToggle" class="btn font-normal normal-case"> 436 <input type="checkbox" id="composeCollapseToggle" class="peer/collapse hidden"/> 437 <span class="peer-checked/collapse:hidden inline-flex items-center gap-2"> 438 {{ i "unfold-vertical" "w-4 h-4" }} 439 <span class="hidden md:inline">Expand all</span> 440 </span> 441 <span class="peer-checked/collapse:inline-flex hidden flex items-center gap-2"> 442 {{ i "fold-vertical" "w-4 h-4" }} 443 <span class="hidden md:inline">Collapse all</span> 444 </span> 445 </label> 446 447 {{ template "repo/fragments/diffOpts" $opts }} 448 </div> 449 450 <div class="flex border border-gray-200 dark:border-gray-700 rounded-b-md"> 451 <div id="composeFiles" class="hidden md:block overflow-hidden max-h-[60vh] overflow-y-auto border-r border-gray-200 dark:border-gray-700"> 452 <section class="overflow-x-auto text-sm px-3 py-2 w-full mx-auto"> 453 {{ template "repo/fragments/fileTree" $diff.FileTree }} 454 </section> 455 </div> 456 457 <div class="flex-1 min-w-0 p-2"> 458 <div class="flex flex-col gap-2"> 459 {{ if eq $count 0 }} 460 <div class="text-center text-gray-500 dark:text-gray-400 py-8"> 461 <p>No differences found.</p> 462 </div> 463 {{ else if le $count 5 }} 464 {{ range $idx, $file := $files }} 465 {{ template "diffFile" (list $idx $file $isSplit true) }} 466 {{ end }} 467 {{ else }} 468 {{ range $idx, $file := slice $files 0 5 }} 469 {{ template "diffFile" (list $idx $file $isSplit true) }} 470 {{ end }} 471 {{ $remaining := sub $count 5 }} 472 <details class="group/showmore"> 473 <summary class="cursor-pointer text-sm text-gray-700 dark:text-gray-300 py-2 px-1 flex items-center gap-2 select-none hover:text-gray-900 dark:hover:text-gray-100 list-none"> 474 <span class="group-open/showmore:hidden inline-flex items-center gap-2"> 475 {{ i "chevron-right" "w-4 h-4" }} 476 Show {{ $remaining }} more file{{ if ne $remaining 1 }}s{{ end }} 477 </span> 478 <span class="hidden group-open/showmore:inline-flex items-center gap-2"> 479 {{ i "chevron-down" "w-4 h-4" }} 480 Hide {{ $remaining }} file{{ if ne $remaining 1 }}s{{ end }} 481 </span> 482 </summary> 483 <div class="flex flex-col gap-2 mt-2"> 484 {{ range $idx, $file := slice $files 5 }} 485 {{ template "diffFile" (list (add $idx 5) $file $isSplit true) }} 486 {{ end }} 487 </div> 488 </details> 489 {{ end }} 490 </div> 491 </div> 492 </div> 493 </div> 494 495 <script> 496 (() => { 497 const checkbox = document.getElementById('composeCollapseToggle'); 498 const diffArea = document.getElementById('diff-area'); 499 if (!checkbox || !diffArea) return; 500 const all = () => diffArea.querySelectorAll('details[id^="file-"]'); 501 checkbox.addEventListener('change', () => { 502 all().forEach(d => { d.open = checkbox.checked; }); 503 }); 504 diffArea.addEventListener('toggle', (e) => { 505 if (!e.target.matches('details[id^="file-"]')) return; 506 const dets = Array.from(all()); 507 const allOpen = dets.every(d => d.open); 508 const allClosed = dets.every(d => !d.open); 509 if (allOpen) checkbox.checked = true; 510 else if (allClosed) checkbox.checked = false; 511 }, true); 512 })(); 513 </script> 514{{ end }}