Use NotEditableReason to check if file is editable

This commit is contained in:
bytedream 2025-05-10 00:24:45 +02:00
parent 42b7c87288
commit 32e2f4f470
2 changed files with 1 additions and 5 deletions

View File

@ -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

View File

@ -28,7 +28,7 @@
<input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required>
</div>
</div>
{{if .IsFileEditable}}
{{if not .NotEditableReason}}
<div class="field">
<div class="ui top attached header">
<div class="ui compact small menu small-menu-items repo-editor-menu">