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

appview: fix pull header template

Changed files
+40 -37
appview
db
pages
templates
repo
pulls
state
+12
appview/db/pulls.go
···
return nil, err
}
+
var pullSourceRepo *Repo
+
if pull.PullSource != nil {
+
if pull.PullSource.RepoAt != nil {
+
pullSourceRepo, err = GetRepoByAtUri(e, pull.PullSource.RepoAt.String())
+
if err != nil {
+
log.Printf("failed to get repo by at uri: %v", err)
+
} else {
+
pull.PullSource.Repo = pullSourceRepo
+
}
+
}
+
}
+
pull.Submissions = make([]*PullSubmission, len(submissionsMap))
for _, submission := range submissionsMap {
pull.Submissions[submission.RoundNumber] = submission
+7 -8
appview/pages/pages.go
···
}
type RepoSinglePullParams struct {
-
LoggedInUser *auth.User
-
RepoInfo RepoInfo
-
Active string
-
DidHandleMap map[string]string
-
Pull *db.Pull
-
PullSourceRepo *db.Repo
-
MergeCheck types.MergeCheckResponse
-
ResubmitCheck ResubmitResult
+
LoggedInUser *auth.User
+
RepoInfo RepoInfo
+
Active string
+
DidHandleMap map[string]string
+
Pull *db.Pull
+
MergeCheck types.MergeCheckResponse
+
ResubmitCheck ResubmitResult
}
func (p *Pages) RepoSinglePull(w io.Writer, params RepoSinglePullParams) error {
+8 -8
appview/pages/templates/repo/pulls/fragments/pullHeader.html
···
</span>
{{ if not .Pull.IsPatchBased }}
<span>from
-
{{ if not .Pull.IsBranchBased }}
-
<a href="/{{ $owner }}/{{ .PullSourceRepo.Name }}" class="no-underline hover:underline">{{ $owner }}/{{ .PullSourceRepo.Name }}</a>
+
{{ if .Pull.IsForkBased }}
+
{{ if .Pull.PullSource.Repo }}
+
<a href="/{{ $owner }}/{{ .Pull.PullSource.Repo.Name }}" class="no-underline hover:underline">{{ $owner }}/{{ .Pull.PullSource.Repo.Name }}</a>
+
{{ else }}
+
<span class="italic">[deleted fork]</span>
+
{{ end }}
{{ end }}
-
{{ $fullRepo := .RepoInfo.FullName }}
-
{{ if not .Pull.IsBranchBased }}
-
{{ $fullRepo = printf "%s/%s" $owner .PullSourceRepo.Name }}
-
{{ end }}
<span class="text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center">
-
<a href="/{{ $fullRepo }}/tree/{{ .Pull.PullSource.Branch }}" class="no-underline hover:underline">{{ .Pull.PullSource.Branch }}</a>
+
{{ .Pull.PullSource.Branch }}
</span>
</span>
{{ end }}
···
</section>
-
{{ end }}
+
{{ end }}
+7 -3
appview/pages/templates/repo/pulls/pull.html
···
<div class="text-sm text-gray-500 dark:text-gray-400">
{{ if not $.Pull.IsPatchBased }}
{{ $fullRepo := $.RepoInfo.FullName }}
-
{{ if not $.Pull.IsBranchBased }}
-
{{ $fullRepo = printf "%s/%s" $owner $.PullSourceRepo.Name }}
+
{{ if $.Pull.IsForkBased }}
+
{{ if $.Pull.PullSource.Repo }}
+
{{ $fullRepo = printf "%s/%s" $owner $.Pull.PullSource.Repo.Name }}
+
<a href="/{{ $fullRepo }}/commit/{{ .SHA }}" class="font-mono text-gray-500 dark:text-gray-400">{{ slice .SHA 0 8 }}</a>
+
{{ else }}
+
<span class="font-mono">{{ slice .SHA 0 8 }}</span>
+
{{ end }}
{{ end }}
-
<a href="/{{ $fullRepo }}/commit/{{ .SHA }}" class="font-mono text-gray-500 dark:text-gray-400">{{ slice .SHA 0 8 }}</a>
{{ else }}
<span class="font-mono">{{ slice .SHA 0 8 }}</span>
{{ end }}
+6 -18
appview/state/pull.go
···
resubmitResult = s.resubmitCheck(f, pull)
}
-
var pullSourceRepo *db.Repo
-
if pull.PullSource != nil {
-
if pull.PullSource.RepoAt != nil {
-
pullSourceRepo, err = db.GetRepoByAtUri(s.db, pull.PullSource.RepoAt.String())
-
if err != nil {
-
log.Printf("failed to get repo by at uri: %v", err)
-
return
-
}
-
}
-
}
-
s.pages.RepoSinglePull(w, pages.RepoSinglePullParams{
-
LoggedInUser: user,
-
RepoInfo: f.RepoInfo(s, user),
-
DidHandleMap: didHandleMap,
-
Pull: pull,
-
PullSourceRepo: pullSourceRepo,
-
MergeCheck: mergeCheckResponse,
-
ResubmitCheck: resubmitResult,
+
LoggedInUser: user,
+
RepoInfo: f.RepoInfo(s, user),
+
DidHandleMap: didHandleMap,
+
Pull: pull,
+
MergeCheck: mergeCheckResponse,
+
ResubmitCheck: resubmitResult,
})
}