diff --git a/appview/pages/pages.go b/appview/pages/pages.go --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -1428,6 +1428,10 @@ ResubmitCheck ResubmitResult BranchDeleteStatus *models.BranchDeleteStatus Stack models.Stack + + // renders buttons in a pre-check state and attaches the hx-trigger="load" + // that fetches the real, checked fragment + Loading bool } func (p *Pages) PullActionsFragment(w io.Writer, params PullActionsParams) error { diff --git a/appview/pulls/single.go b/appview/pulls/single.go --- a/appview/pulls/single.go +++ b/appview/pulls/single.go @@ -58,11 +58,16 @@ return } - mergeCheckResponse := s.mergeCheck(r, f, pull, stack) + // only the last round's buttons and banners use merge/resubmit checks + isLastRound := roundNumber == pull.LastRoundNumber() branchDeleteStatus := s.branchDeleteStatus(r, f, pull) + mergeCheckResponse := types.MergeCheckResponse{} resubmitResult := pages.Unknown - if user.Did == pull.OwnerDid { - resubmitResult = s.resubmitCheck(r, f, pull, stack) + if isLastRound { + mergeCheckResponse = s.mergeCheck(r, f, pull, stack) + if user != nil && user.Did == pull.OwnerDid { + resubmitResult = s.resubmitCheck(r, f, pull, stack) + } } s.pages.PullActionsFragment(w, pages.PullActionsParams{ @@ -144,13 +149,6 @@ // can be nil if this pull is not stacked stack, _ := r.Context().Value("stack").(models.Stack) - - mergeCheckResponse := s.mergeCheck(r, f, pull, stack) - branchDeleteStatus := s.branchDeleteStatus(r, f, pull) - resubmitResult := pages.Unknown - if user != nil && user.Did == pull.OwnerDid { - resubmitResult = s.resubmitCheck(r, f, pull, stack) - } m := make(map[string]models.Pipeline) @@ -256,9 +254,9 @@ Pull: pull, Stack: stack, Backlinks: backlinks, - BranchDeleteStatus: branchDeleteStatus, - MergeCheck: mergeCheckResponse, - ResubmitCheck: resubmitResult, + BranchDeleteStatus: nil, + MergeCheck: types.MergeCheckResponse{}, + ResubmitCheck: pages.Unknown, Pipelines: m, Diff: diff, DiffOpts: diffOpts, diff --git a/appview/pages/templates/repo/pulls/pull.html b/appview/pages/templates/repo/pulls/pull.html --- a/appview/pages/templates/repo/pulls/pull.html +++ b/appview/pages/templates/repo/pulls/pull.html @@ -311,7 +311,14 @@ {{ template "submissionCommits" $ }} {{ template "submissionPipeline" $ }} {{ if eq $lastIdx $round }} - {{ block "mergeCheck" $root }} {{ end }} +
+ {{ if $root.Pull.State.IsOpen }} +
+ {{ i "loader-circle" "w-4 h-4 animate-spin" }} + Checking mergeability… +
+ {{ end }} +
{{ end }} @@ -444,51 +451,6 @@ {{ end }} {{ end }} -{{ define "mergeCheck" }} - {{ $isOpen := .Pull.State.IsOpen }} - {{ if and $isOpen .MergeCheck .MergeCheck.Error }} -
- {{ i "triangle-alert" "w-4 h-4" }} - {{ .MergeCheck.Error }} -
- {{ else if and $isOpen .MergeCheck .MergeCheck.IsConflicted }} -
- -
- {{ i "triangle-alert" "w-4 h-4" }} - Merge conflicts detected -
- Expand - -
-
-
- {{ if gt (len .MergeCheck.Conflicts) 0 }} - - {{ end }} -
- {{ else if and $isOpen .MergeCheck }} -
- {{ i "check" "w-4 h-4" }} - No conflicts, ready to merge -
- {{ end }} -{{ end }} - {{ define "mergeStatus" }} {{ if .Pull.State.IsClosed }}
@@ -511,17 +473,6 @@
{{ i "git-pull-request-closed" "w-4 h-4" }} This pull has been deleted (possibly by jj abandon or jj squash) -
-
- {{ end }} -{{ end }} - -{{ define "resubmitStatus" }} - {{ if .ResubmitCheck.Yes }} -
-
- {{ i "triangle-alert" "w-4 h-4" }} - This branch has been updated, consider resubmitting
{{ end }} @@ -612,24 +563,25 @@
{{ if eq $lastIdx $item.RoundNumber }} {{ block "mergeStatus" $root }} {{ end }} - {{ block "resubmitStatus" $root }} {{ end }} +
{{ end }}
{{ if $root.LoggedInUser }} - {{ template "repo/pulls/fragments/pullActions" - (dict - "LoggedInUser" $root.LoggedInUser - "Pull" $root.Pull - "RepoInfo" $root.RepoInfo - "RoundNumber" $item.RoundNumber - "MergeCheck" $root.MergeCheck - "ResubmitCheck" $root.ResubmitCheck - "BranchDeleteStatus" $root.BranchDeleteStatus - "Stack" $root.Stack) }} {{ end }} + {{ template "repo/pulls/fragments/pullActions" + (dict + "LoggedInUser" $root.LoggedInUser + "Pull" $root.Pull + "RepoInfo" $root.RepoInfo + "RoundNumber" $item.RoundNumber + "MergeCheck" $root.MergeCheck + "ResubmitCheck" $root.ResubmitCheck + "BranchDeleteStatus" $root.BranchDeleteStatus + "Stack" $root.Stack + "Loading" (eq $lastIdx $item.RoundNumber)) }}
{{ end }} diff --git a/appview/pages/templates/repo/pulls/fragments/pullActions.html b/appview/pages/templates/repo/pulls/fragments/pullActions.html --- a/appview/pages/templates/repo/pulls/fragments/pullActions.html +++ b/appview/pages/templates/repo/pulls/fragments/pullActions.html @@ -2,6 +2,7 @@ {{ $lastIdx := sub (len .Pull.Submissions) 1 }} {{ $roundNumber := .RoundNumber }} {{ $stack := .Stack }} + {{ $loading := .Loading }} {{ $totalPulls := sub 0 1 }} {{ $below := sub 0 1 }} @@ -22,16 +23,24 @@ {{ $isLastRound := eq $roundNumber $lastIdx }} {{ $isSameRepoBranch := .Pull.IsBranchBased }} {{ $isUpToDate := .ResubmitCheck.No }} -
- - {{ if .BranchDeleteStatus }} - {{ end }} @@ -67,21 +80,28 @@ hx-disabled-elt="#resubmitBtn" class="btn-flat p-2 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed group" - {{ if $isUpToDate }} + {{ if $loading }} + title="Checking for updates…" + disabled + {{ else if $isUpToDate }} title="Update this branch to resubmit this pull request" disabled {{ else }} title="Resubmit this pull request" {{ end }} > - {{ i "rotate-ccw" "w-4 h-4 inline group-[.htmx-request]:hidden" }} - {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} + {{ if $loading }} + {{ i "loader-circle" "w-4 h-4 animate-spin" }} + {{ else }} + {{ i "rotate-ccw" "w-4 h-4 inline group-[.htmx-request]:hidden" }} + {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} + {{ end }} Resubmit {{ end }} {{ if and (or $isPullAuthor $isPushAllowed) $isOpen $isLastRound }} - {{ end }}
+ + {{ if and (not $loading) $isLastRound }} +
{{ template "mergeCheck" . }}
+
{{ template "resubmitStatus" . }}
+ {{ end }} +{{ end }} + +{{ define "mergeCheck" }} + {{ $isOpen := .Pull.State.IsOpen }} + {{ if and $isOpen .MergeCheck .MergeCheck.Error }} +
+ {{ i "triangle-alert" "w-4 h-4" }} + {{ .MergeCheck.Error }} +
+ {{ else if and $isOpen .MergeCheck .MergeCheck.IsConflicted }} +
+ +
+ {{ i "triangle-alert" "w-4 h-4" }} + Merge conflicts detected +
+ Expand + +
+
+
+ {{ if gt (len .MergeCheck.Conflicts) 0 }} + + {{ end }} +
+ {{ else if and $isOpen .MergeCheck }} +
+ {{ i "check" "w-4 h-4" }} + No conflicts, ready to merge +
+ {{ end }} +{{ end }} + +{{ define "resubmitStatus" }} + {{ if .ResubmitCheck.Yes }} +
+
+ {{ i "triangle-alert" "w-4 h-4" }} + This branch has been updated, consider resubmitting +
+
+ {{ end }} {{ end }}