From d8095c93a457ea642d34f5aef4d4b41667e48d75 Mon Sep 17 00:00:00 2001 From: Divanshu Grover Date: Mon, 28 Oct 2024 20:57:28 +0530 Subject: [PATCH] add checks before showing button Signed-off-by: Divanshu Grover --- routers/web/web.go | 3 +++ templates/repo/diff/blob_excerpt.tmpl | 8 +++++++- templates/repo/diff/section_split.tmpl | 6 +++--- templates/repo/diff/section_unified.tmpl | 6 +++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/routers/web/web.go b/routers/web/web.go index a6ccb7a7924e..c34fd3f4f2d2 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1510,6 +1510,9 @@ func registerRoutes(m *web.Router) { m.Get("/{sha}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.ExcerptBlob) }, func(ctx *context.Context) gocontext.CancelFunc { // FIXME: refactor this function, use separate routes for wiki/code + if ctx.FormBool("pull") { + ctx.Data["PageIsPullFiles"] = true + } if ctx.FormBool("wiki") { ctx.Data["PageIsWiki"] = true repo.MustEnableWiki(ctx) diff --git a/templates/repo/diff/blob_excerpt.tmpl b/templates/repo/diff/blob_excerpt.tmpl index 1aef115d3d58..cbc0bcbd7516 100644 --- a/templates/repo/diff/blob_excerpt.tmpl +++ b/templates/repo/diff/blob_excerpt.tmpl @@ -23,9 +23,11 @@ {{$inlineDiff := $.section.GetComputedInlineDiffFor $line ctx.Locale}}{{/* + */}}{{if and $.SignedUserID $.PageIsPullFiles}}{{/* */}}{{/* + */}}{{end}}{{/* */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}} {{else}} {{$inlineDiff := $.section.GetComputedInlineDiffFor $line ctx.Locale}} @@ -33,9 +35,11 @@ {{if and $line.LeftIdx $inlineDiff.EscapeStatus.Escaped}}{{end}} {{if $line.LeftIdx}}{{end}} {{/* + */}}{{if and $.SignedUserID $.PageIsPullFiles}}{{/* */}}{{/* + */}}{{end}}{{/* */}}{{if $line.LeftIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{else}}{{/* */}}{{/* */}}{{end}}{{/* @@ -44,9 +48,11 @@ {{if and $line.RightIdx $inlineDiff.EscapeStatus.Escaped}}{{end}} {{if $line.RightIdx}}{{end}} {{/* + */}}{{if and $.SignedUserID $.PageIsPullFiles}}{{/* */}}{{/* + */}}{{end}}{{/* */}}{{if $line.RightIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{else}}{{/* */}}{{/* */}}{{end}}{{/* @@ -92,7 +98,7 @@ {{$inlineDiff := $.section.GetComputedInlineDiffFor $line ctx.Locale}} {{if $inlineDiff.EscapeStatus.Escaped}}{{end}} - {{$inlineDiff.Content}} + {{if and $.SignedUserID $.PageIsPullFiles}}{{end}}{{$inlineDiff.Content}} {{if $line.Comments}} diff --git a/templates/repo/diff/section_split.tmpl b/templates/repo/diff/section_split.tmpl index 37b42bcb376a..36a873208c82 100644 --- a/templates/repo/diff/section_split.tmpl +++ b/templates/repo/diff/section_split.tmpl @@ -20,17 +20,17 @@
{{if or (eq $expandDirection 3) (eq $expandDirection 5)}} - {{end}} {{if or (eq $expandDirection 3) (eq $expandDirection 4)}} - {{end}} {{if eq $expandDirection 2}} - {{end}} diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index 708b33329164..893f76b8aa80 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -16,17 +16,17 @@
{{if or (eq $expandDirection 3) (eq $expandDirection 5)}} - {{end}} {{if or (eq $expandDirection 3) (eq $expandDirection 4)}} - {{end}} {{if eq $expandDirection 2}} - {{end}}