mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-14 06:39:40 +01:00
Fix code search input for different views (#30678)
Now only show the "code search" on the repo home page, because it only does global search. So do not show it when viewing file or directory to avoid misleading users (it doesn't search in a directory) (cherry picked from commit 993736d838c36e26951b6cfea9c6a549958addd1)
This commit is contained in:
parent
9ea73fcb09
commit
089e95f250
4 changed files with 12 additions and 7 deletions
|
@ -212,8 +212,6 @@ func SearchCommits(ctx *context.Context) {
|
||||||
|
|
||||||
// FileHistory show a file's reversions
|
// FileHistory show a file's reversions
|
||||||
func FileHistory(ctx *context.Context) {
|
func FileHistory(ctx *context.Context) {
|
||||||
ctx.Data["IsRepoToolbarCommits"] = true
|
|
||||||
|
|
||||||
fileName := ctx.Repo.TreePath
|
fileName := ctx.Repo.TreePath
|
||||||
if len(fileName) == 0 {
|
if len(fileName) == 0 {
|
||||||
Commits(ctx)
|
Commits(ctx)
|
||||||
|
|
|
@ -800,7 +800,6 @@ func CompareDiff(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitID) + separator + base.ShortSha(afterCommitID)
|
ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitID) + separator + base.ShortSha(afterCommitID)
|
||||||
|
|
||||||
ctx.Data["IsRepoToolbarCommits"] = true
|
|
||||||
ctx.Data["IsDiffCompare"] = true
|
ctx.Data["IsDiffCompare"] = true
|
||||||
_, templateErrs := setTemplateIfExists(ctx, pullRequestTemplateKey, pullRequestTemplateCandidates)
|
_, templateErrs := setTemplateIfExists(ctx, pullRequestTemplateKey, pullRequestTemplateCandidates)
|
||||||
|
|
||||||
|
|
|
@ -1436,7 +1436,6 @@ func CompareAndPullRequestPost(ctx *context.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes")
|
ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes")
|
||||||
ctx.Data["PageIsComparePull"] = true
|
ctx.Data["PageIsComparePull"] = true
|
||||||
ctx.Data["IsDiffCompare"] = true
|
ctx.Data["IsDiffCompare"] = true
|
||||||
ctx.Data["IsRepoToolbarCommits"] = true
|
|
||||||
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
|
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
|
||||||
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
|
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
|
||||||
upload.AddUploadContext(ctx, "comment")
|
upload.AddUploadContext(ctx, "comment")
|
||||||
|
|
|
@ -106,7 +106,16 @@
|
||||||
{{ctx.Locale.Tr "repo.use_template"}}
|
{{ctx.Locale.Tr "repo.use_template"}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if (not $isHomepage)}}
|
{{if $isHomepage}}
|
||||||
|
{{/* only show the "code search" on the repo home page, it only does global search,
|
||||||
|
so do not show it when viewing file or directory to avoid misleading users (it doesn't search in a directory) */}}
|
||||||
|
<form class="ignore-dirty" action="{{.RepoLink}}/search" method="get">
|
||||||
|
<div class="ui small action input">
|
||||||
|
<input name="q" placeholder="{{ctx.Locale.Tr "search.code_kind"}}">
|
||||||
|
{{template "shared/search/button"}}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{{else}}
|
||||||
<span class="breadcrumb repo-path tw-ml-1">
|
<span class="breadcrumb repo-path tw-ml-1">
|
||||||
<a class="section" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a>
|
<a class="section" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a>
|
||||||
{{- range $i, $v := .TreeNames -}}
|
{{- range $i, $v := .TreeNames -}}
|
||||||
|
@ -145,7 +154,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{template "repo/cite/cite_modal" .}}
|
{{template "repo/cite/cite_modal" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}}
|
{{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}}
|
||||||
<a class="ui button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">
|
<a class="ui button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">
|
||||||
{{svg "octicon-history" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.file_history"}}
|
{{svg "octicon-history" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.file_history"}}
|
||||||
</a>
|
</a>
|
||||||
|
@ -156,7 +165,7 @@
|
||||||
{{template "repo/view_file" .}}
|
{{template "repo/view_file" .}}
|
||||||
{{else if .IsBlame}}
|
{{else if .IsBlame}}
|
||||||
{{template "repo/blame" .}}
|
{{template "repo/blame" .}}
|
||||||
{{else}}
|
{{else}}{{/* IsViewDirectory */}}
|
||||||
{{template "repo/view_list" .}}
|
{{template "repo/view_list" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue