Skip to content

Commit 32e2f4f

Browse files
committed
Use NotEditableReason to check if file is editable
1 parent 42b7c87 commit 32e2f4f

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

routers/web/repo/editor.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ func editFile(ctx *context.Context, isNewFile bool) {
173173
ctx.Data["FileSize"] = fInfo.fileSize
174174

175175
// Only some file types are editable online as text.
176-
ctx.Data["IsFileEditable"] = fInfo.st.IsRepresentableAsText() && !fInfo.isLFSFile && fInfo.fileSize < setting.UI.MaxDisplayFileSize
177-
178176
if fInfo.isLFSFile {
179177
ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_lfs_files")
180178
} else if !fInfo.st.IsRepresentableAsText() {
@@ -195,8 +193,6 @@ func editFile(ctx *context.Context, isNewFile bool) {
195193
} else {
196194
// Append filename from query, or empty string to allow username the new file.
197195
treeNames = append(treeNames, fileName)
198-
199-
ctx.Data["IsFileEditable"] = true
200196
}
201197

202198
ctx.Data["TreeNames"] = treeNames

templates/repo/editor/edit.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required>
2929
</div>
3030
</div>
31-
{{if .IsFileEditable}}
31+
{{if not .NotEditableReason}}
3232
<div class="field">
3333
<div class="ui top attached header">
3434
<div class="ui compact small menu small-menu-items repo-editor-menu">

0 commit comments

Comments
 (0)