diff --git a/routers/web/repo/view_file.go b/routers/web/repo/view_file.go
index 09ebb75c1d..5606a8e6ec 100644
--- a/routers/web/repo/view_file.go
+++ b/routers/web/repo/view_file.go
@@ -302,7 +302,9 @@ func prepareToRenderButtons(ctx *context.Context, lfsLock *git_model.LFSLock) {
}
if !ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, ctx.Repo.BranchName) {
+ ctx.Data["CanEditFile"] = true
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.fork_before_edit")
+ ctx.Data["CanDeleteFile"] = true
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_have_write_access")
return
}
diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl
index 8bf6509643..b49818c6b7 100644
--- a/templates/repo/view_file.tmpl
+++ b/templates/repo/view_file.tmpl
@@ -62,8 +62,16 @@
{{end}}
{{if .Repository.CanEnableEditor}}
- {{svg "octicon-pencil"}}
- {{svg "octicon-trash"}}
+ {{if .CanEditFile}}
+ {{svg "octicon-pencil"}}
+ {{else}}
+ {{svg "octicon-pencil"}}
+ {{end}}
+ {{if .CanDeleteFile}}
+ {{svg "octicon-trash"}}
+ {{else}}
+ {{svg "octicon-trash"}}
+ {{end}}
{{end}}
{{else if .EscapeStatus.Escaped}}