From 98190d0024b32c946454792c8094435e96c08d70 Mon Sep 17 00:00:00 2001
From: Lunny Xiao <xiaolunwen@gmail.com>
Date: Mon, 8 Aug 2022 21:42:36 +0800
Subject: [PATCH] Fix disable download button (#20701)

---
 modules/context/context.go      | 2 +-
 templates/repo/branch/list.tmpl | 2 +-
 templates/repo/home.tmpl        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/context/context.go b/modules/context/context.go
index 8824911619..0b9898acef 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -224,7 +224,7 @@ func (ctx *Context) HTML(status int, name base.TplName) {
 	ctx.Data["TemplateLoadTimes"] = func() string {
 		return strconv.FormatInt(time.Since(tmplStartTime).Nanoseconds()/1e6, 10) + "ms"
 	}
-	if err := ctx.Render.HTML(ctx.Resp, status, string(name), ctx.Data); err != nil {
+	if err := ctx.Render.HTML(ctx.Resp, status, string(name), templates.BaseVars().Merge(ctx.Data)); err != nil {
 		if status == http.StatusInternalServerError && name == base.TplName("status/500") {
 			ctx.PlainText(http.StatusInternalServerError, "Unable to find status/500 template")
 			return
diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl
index 4a85692a83..09799fbece 100644
--- a/templates/repo/branch/list.tmpl
+++ b/templates/repo/branch/list.tmpl
@@ -112,7 +112,7 @@
 												{{svg "octicon-git-branch"}}
 											</div>
 										{{end}}
-										{{if (not .IsDeleted)}}
+										{{if and (not .IsDeleted) (not $.DisableDownloadSourceArchives)}}
 											<div class="ui basic jump dropdown icon button tooltip" data-content="{{$.locale.Tr "repo.branch.download" (.Name)}}" data-position="top right">
 												{{svg "octicon-download"}}
 												<div class="menu">
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index 74eaa6ab32..1ff2ec5bc5 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -120,7 +120,7 @@
 					<div class="ui action tiny input" id="clone-panel">
 					{{template "repo/clone_buttons" .}}
 					{{template "repo/clone_script" .}}
-					{{if not .DisableDownloadSourceArchives}}
+					{{if not $.DisableDownloadSourceArchives}}
 						<button id="download-btn" class="ui basic small compact jump dropdown icon button tooltip" data-content="{{.locale.Tr "repo.download_archive"}}" data-position="top right">
 							{{svg "octicon-download"}}
 							<div class="menu">