mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-20 16:50:28 -05:00
ui: remove New pull request button from repo content browsing
This commit is contained in:
parent
376a2e19ea
commit
69ad9243c4
3 changed files with 14 additions and 17 deletions
|
@ -58,18 +58,6 @@
|
||||||
<div class="repo-button-row">
|
<div class="repo-button-row">
|
||||||
<div class="tw-flex tw-items-center tw-gap-y-2">
|
<div class="tw-flex tw-items-center tw-gap-y-2">
|
||||||
{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mr-1"}}
|
{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mr-1"}}
|
||||||
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
|
|
||||||
{{$cmpBranch := ""}}
|
|
||||||
{{if ne .Repository.ID .BaseRepo.ID}}
|
|
||||||
{{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}}
|
|
||||||
{{end}}
|
|
||||||
{{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}}
|
|
||||||
{{$compareLink := printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}}
|
|
||||||
<a id="new-pull-request" role="button" class="ui compact basic button" href="{{$compareLink}}"
|
|
||||||
data-tooltip-content="{{if .PullRequestCtx.Allowed}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}">
|
|
||||||
{{svg "octicon-git-pull-request"}}
|
|
||||||
</a>
|
|
||||||
{{end}}
|
|
||||||
<!-- Show go to file and breadcrumbs if not on home page -->
|
<!-- Show go to file and breadcrumbs if not on home page -->
|
||||||
{{if $isHomepage}}
|
{{if $isHomepage}}
|
||||||
<a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button">{{ctx.Locale.Tr "repo.find_file.go_to_file"}}</a>
|
<a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button">{{ctx.Locale.Tr "repo.find_file.go_to_file"}}</a>
|
||||||
|
|
|
@ -21,7 +21,16 @@
|
||||||
{{if .PageIsIssueList}}
|
{{if .PageIsIssueList}}
|
||||||
<a class="ui small primary button issue-list-new" href="{{.RepoLink}}/issues/new{{if .NewIssueChooseTemplate}}/choose{{end}}">{{ctx.Locale.Tr "repo.issues.new"}}</a>
|
<a class="ui small primary button issue-list-new" href="{{.RepoLink}}/issues/new{{if .NewIssueChooseTemplate}}/choose{{end}}">{{ctx.Locale.Tr "repo.issues.new"}}</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a class="ui small primary button new-pr-button issue-list-new{{if not .PullRequestCtx.Allowed}} disabled{{end}}" href="{{if .PullRequestCtx.Allowed}}{{.Repository.Link}}/compare/{{.Repository.DefaultBranch | PathEscapeSegments}}...{{if ne .Repository.Owner.Name .PullRequestCtx.BaseRepo.Owner.Name}}{{PathEscape .Repository.Owner.Name}}:{{end}}{{.Repository.DefaultBranch | PathEscapeSegments}}{{end}}">{{ctx.Locale.Tr "repo.pulls.new"}}</a>
|
{{$compareLink := ""}}
|
||||||
|
{{if .PullRequestCtx.Allowed}}
|
||||||
|
{{$cmpBranch := ""}}
|
||||||
|
{{if ne .Repository.ID .BaseRepo.ID}}
|
||||||
|
{{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}}
|
||||||
|
{{end}}
|
||||||
|
{{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}}
|
||||||
|
{{$compareLink = printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}}
|
||||||
|
{{end}}
|
||||||
|
<a class="ui small primary button new-pr-button issue-list-new{{if not .PullRequestCtx.Allowed}} disabled{{end}}" href="{{$compareLink}}">{{ctx.Locale.Tr "repo.pulls.new"}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if not .PageIsIssueList}}
|
{{if not .PageIsIssueList}}
|
||||||
|
|
|
@ -31,12 +31,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func testPullCreate(t *testing.T, session *TestSession, user, repo string, toSelf bool, targetBranch, sourceBranch, title string) *httptest.ResponseRecorder {
|
func testPullCreate(t *testing.T, session *TestSession, user, repo string, toSelf bool, targetBranch, sourceBranch, title string) *httptest.ResponseRecorder {
|
||||||
req := NewRequest(t, "GET", path.Join(user, repo))
|
req := NewRequest(t, "GET", path.Join(user, repo, "pulls"))
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
// Click the PR button to create a pull
|
// Click the PR button to create a pull
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
link, exists := htmlDoc.doc.Find("#new-pull-request").Attr("href")
|
link, exists := htmlDoc.doc.Find(".new-pr-button").Attr("href")
|
||||||
assert.True(t, exists, "The template has changed")
|
assert.True(t, exists, "The template has changed")
|
||||||
|
|
||||||
targetUser := strings.Split(link, "/")[1]
|
targetUser := strings.Split(link, "/")[1]
|
||||||
|
@ -158,12 +158,12 @@ func TestPullCreateWithPullTemplate(t *testing.T) {
|
||||||
testPullPreview := func(t *testing.T, session *TestSession, user, repo, message string) {
|
testPullPreview := func(t *testing.T, session *TestSession, user, repo, message string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
req := NewRequest(t, "GET", path.Join(user, repo))
|
req := NewRequest(t, "GET", path.Join(user, repo, "pulls"))
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
// Click the PR button to create a pull
|
// Click the PR button to create a pull
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
link, exists := htmlDoc.doc.Find("#new-pull-request").Attr("href")
|
link, exists := htmlDoc.doc.Find(".new-pr-button").Attr("href")
|
||||||
assert.True(t, exists, "The template has changed")
|
assert.True(t, exists, "The template has changed")
|
||||||
|
|
||||||
// Load the pull request preview
|
// Load the pull request preview
|
||||||
|
|
Loading…
Add table
Reference in a new issue