From 32e2f4f4704cb40bf820120001fef1a8672b367d Mon Sep 17 00:00:00 2001 From: bytedream Date: Sat, 10 May 2025 00:24:45 +0200 Subject: [PATCH] Use NotEditableReason to check if file is editable --- routers/web/repo/editor.go | 4 ---- templates/repo/editor/edit.tmpl | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index 62de825e52..c9785bb1e9 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -173,8 +173,6 @@ func editFile(ctx *context.Context, isNewFile bool) { ctx.Data["FileSize"] = fInfo.fileSize // Only some file types are editable online as text. - ctx.Data["IsFileEditable"] = fInfo.st.IsRepresentableAsText() && !fInfo.isLFSFile && fInfo.fileSize < setting.UI.MaxDisplayFileSize - if fInfo.isLFSFile { ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_lfs_files") } else if !fInfo.st.IsRepresentableAsText() { @@ -195,8 +193,6 @@ func editFile(ctx *context.Context, isNewFile bool) { } else { // Append filename from query, or empty string to allow username the new file. treeNames = append(treeNames, fileName) - - ctx.Data["IsFileEditable"] = true } ctx.Data["TreeNames"] = treeNames diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index d667024bb6..e1bf46d53d 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -28,7 +28,7 @@ - {{if .IsFileEditable}} + {{if not .NotEditableReason}}