mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-20 12:38:28 +02:00
Use NotEditableReason to check if file is editable
This commit is contained in:
parent
42b7c87288
commit
32e2f4f470
@ -173,8 +173,6 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
|||||||
ctx.Data["FileSize"] = fInfo.fileSize
|
ctx.Data["FileSize"] = fInfo.fileSize
|
||||||
|
|
||||||
// Only some file types are editable online as text.
|
// 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 {
|
if fInfo.isLFSFile {
|
||||||
ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_lfs_files")
|
ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_lfs_files")
|
||||||
} else if !fInfo.st.IsRepresentableAsText() {
|
} else if !fInfo.st.IsRepresentableAsText() {
|
||||||
@ -195,8 +193,6 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
|||||||
} else {
|
} else {
|
||||||
// Append filename from query, or empty string to allow username the new file.
|
// Append filename from query, or empty string to allow username the new file.
|
||||||
treeNames = append(treeNames, fileName)
|
treeNames = append(treeNames, fileName)
|
||||||
|
|
||||||
ctx.Data["IsFileEditable"] = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["TreeNames"] = treeNames
|
ctx.Data["TreeNames"] = treeNames
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required>
|
<input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{if .IsFileEditable}}
|
{{if not .NotEditableReason}}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="ui top attached header">
|
<div class="ui top attached header">
|
||||||
<div class="ui compact small menu small-menu-items repo-editor-menu">
|
<div class="ui compact small menu small-menu-items repo-editor-menu">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user