forked from tangled.org/core
this repo has no description

move actions closer to the submission round

Changed files
+111 -25
appview
pages
templates
repo
pulls
state
+109 -25
appview/pages/templates/repo/pulls/pull.html
··· 66 66 </div> 67 67 </section> 68 68 69 - {{ $isPullAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }} 70 - {{ $isPushAllowed := .RepoInfo.Roles.IsPushAllowed }} 71 - 72 - {{ if and $isPullAuthor (not .Pull.State.IsMerged) }} 73 - <section id="update-card" class="mt-8 space-y-4 relative"> 74 - {{ block "resubmitCard" . }} {{ end }} 75 - </section> 76 - {{ end }} 77 - 78 - <section id="merge-card" class="mt-8 space-y-4 relative"> 79 - {{ if .Pull.State.IsMerged }} 80 - {{ block "alreadyMergedCard" . }} {{ end }} 81 - {{ else if .MergeCheck }} 82 - {{ if .MergeCheck.IsConflicted }} 83 - {{ block "isConflictedCard" $ }} {{ end }} 84 - {{ else }} 85 - {{ block "noConflictsCard" $ }} {{ end }} 86 - {{ end }} 87 - {{ end }} 88 - </section> 89 - 90 69 <div id="pull-close"></div> 91 70 <div id="pull-reopen"></div> 92 71 {{ end }} ··· 100 79 {{ with $item }} 101 80 {{ $oneIndexedRound := add .RoundNumber 1 }} 102 81 <details {{ if eq $idx $lastIdx }}open{{ end }}> 103 - <summary id="round-#{{ $oneIndexedRound }}" class="list-none cursor-pointer text-sm"> 82 + <summary id="round-#{{ $oneIndexedRound }}" class="list-none cursor-pointer"> 104 83 <div class="flex gap-2 items-center"> 105 84 <div class="rounded bg-white drop-shadow-sm p-3"> 106 85 #{{ $oneIndexedRound }} ··· 110 89 {{ $owner := index $.DidHandleMap $.Pull.OwnerDid }} 111 90 submitted by <a href="/{{ $owner }}">{{ $owner }}</a> 112 91 <span class="select-none before:content-['\00B7']"></span> 113 - <a href="#round-#{{ $oneIndexedRound }}"><time>{{ .Created | timeFmt }}</time></a> 92 + <a class="text-gray-500 hover:text-gray-500" href="#round-#{{ $oneIndexedRound }}"><time>{{ .Created | timeFmt }}</time></a> 114 93 <span class="select-none before:content-['·']"></span> 115 94 {{ $s := "s" }} 116 95 {{ if eq (len .Comments) 1 }} ··· 138 117 </div> 139 118 </div> 140 119 {{ end }} 141 - {{ block "newComment" (list $ .ID) }} {{ end }} 120 + 121 + {{ block "mergeStatus" $ }} {{ end }} 122 + 123 + {{ if $.LoggedInUser }} 124 + {{ block "actions" (list $ .ID) }} {{ end }} 125 + {{ else }} 126 + <div class="bg-white rounded drop-shadow-sm px-6 py-4 w-fit"> 127 + <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300"></div> 128 + <a href="/login" class="underline">login</a> to join the discussion 129 + </div> 130 + {{ end }} 142 131 </div> 143 132 </details> 144 - <hr /> 145 133 {{ end }} 134 + {{ end }} 135 + {{ end }} 136 + 137 + {{ define "mergeStatus" }} 138 + {{ if .Pull.State.IsMerged }} 139 + <div class="bg-purple-50 border border-purple-500 rounded drop-shadow-sm px-6 py-2 relative w-fit"> 140 + <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300"></div> 141 + <div class="flex items-center gap-2 text-purple-500"> 142 + <i data-lucide="git-merge" class="w-4 h-4"></i> 143 + <span class="font-medium">pull request successfully merged</span 144 + > 145 + </div> 146 + </div> 147 + {{ else if and .MergeCheck .MergeCheck.IsConflicted }} 148 + <div class="bg-red-50 border border-red-500 rounded drop-shadow-sm px-6 py-2 relative w-fit"> 149 + <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300"></div> 150 + <div class="flex items-center gap-2 text-red-500"> 151 + <i data-lucide="alert-triangle" class="w-4 h-4"></i> 152 + <span class="font-medium">merge conflicts detected</span> 153 + <ul class="text-sm space-y-1"> 154 + {{ range .MergeCheck.Conflicts }} 155 + {{ if .Filename }} 156 + <li class="flex items-center"> 157 + <i 158 + data-lucide="file-warning" 159 + class="w-3 h-3 mr-1.5 text-red-500" 160 + ></i> 161 + <span class="font-mono">{{ slice .Filename 0 (sub (len .Filename) 2) }}</span> 162 + </li> 163 + {{ end }} 164 + {{ end }} 165 + </ul> 166 + </div> 167 + </div> 168 + {{ else if .MergeCheck }} 169 + <div class="bg-green-50 border border-green-500 rounded drop-shadow-sm px-6 py-2 relative w-fit"> 170 + <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300"></div> 171 + <div class="flex items-center gap-2 text-green-500"> 172 + <i data-lucide="check-circle" class="w-4 h-4"></i> 173 + <span class="font-medium">no conflicts, ready to merge</span> 174 + </div> 175 + </div> 176 + {{ end }} 177 + {{ end }} 178 + 179 + {{ define "actions" }} 180 + {{ $rootObj := index . 0 }} 181 + {{ $submissionId := index . 1 }} 182 + 183 + {{ with $rootObj }} 184 + {{ $isPushAllowed := .RepoInfo.Roles.IsPushAllowed }} 185 + {{ $isMerged := .Pull.State.IsMerged }} 186 + {{ $isClosed := .Pull.State.IsClosed }} 187 + {{ $isOpen := .Pull.State.IsOpen }} 188 + {{ $isConflicted := and .MergeCheck .MergeCheck.IsConflicted }} 189 + {{ $isPullAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }} 190 + <div class="relative w-fit"> 191 + <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300"></div> 192 + <div class="flex flex-wrap gap-2"> 193 + <button href="#" class="btn p-2 flex items-center gap-2 no-underline hover:no-underline"> 194 + <i data-lucide="message-square-plus" class="w-4 h-4"></i> 195 + <span>comment</span> 196 + </button> 197 + {{ if and $isPushAllowed $isOpen }} 198 + {{ $disabled := "" }} 199 + {{ if $isConflicted }} 200 + {{ $disabled = "disabled" }} 201 + {{ end }} 202 + <button href="#" class="btn p-2 flex items-center gap-2 no-underline hover:no-underline" {{ $disabled }}> 203 + <i data-lucide="git-merge" class="w-4 h-4"></i> 204 + <span>merge</span> 205 + </button> 206 + {{ end }} 207 + 208 + {{ if and $isPullAuthor $isOpen }} 209 + <button href="#" class="btn p-2 flex items-center gap-2 no-underline hover:no-underline"> 210 + <i data-lucide="rotate-ccw" class="w-4 h-4"></i> 211 + <span>resubmit</span> 212 + </button> 213 + {{ end }} 214 + 215 + {{ if and $isPullAuthor $isPushAllowed $isOpen }} 216 + <button href="#" class="btn p-2 flex items-center gap-2 no-underline hover:no-underline"> 217 + <i data-lucide="ban" class="w-4 h-4"></i> 218 + <span>close</span> 219 + </button> 220 + {{ end }} 221 + 222 + {{ if and $isPullAuthor $isPushAllowed $isClosed }} 223 + <button href="#" class="btn p-2 flex items-center gap-2 no-underline hover:no-underline"> 224 + <i data-lucide="circle-dot" class="w-4 h-4"></i> 225 + <span>reopen</span> 226 + </button> 227 + {{ end }} 228 + </div> 229 + </div> 146 230 {{ end }} 147 231 {{ end }} 148 232
+2
appview/state/pull.go
··· 94 94 } 95 95 } 96 96 97 + log.Println(mergeCheckResponse) 98 + 97 99 s.pages.RepoSinglePull(w, pages.RepoSinglePullParams{ 98 100 LoggedInUser: user, 99 101 RepoInfo: f.RepoInfo(s, user),