mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-20 23:28:28 +02:00
Make LFS file paths editable
This commit is contained in:
parent
96bbf81700
commit
5dc082a2ad
@ -165,10 +165,16 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||
ctx.Data["FileSize"] = blob.Size()
|
||||
|
||||
// Only some file types are editable online as text.
|
||||
ctx.Data["IsFileEditable"] = fInfo.isTextFile && !fInfo.isLFSFile
|
||||
ctx.Data["IsFileEditable"] = fInfo.isTextFile && !fInfo.isLFSFile && blob.Size() < setting.UI.MaxDisplayFileSize
|
||||
|
||||
if fInfo.isLFSFile {
|
||||
ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_lfs_files")
|
||||
} else if !fInfo.isTextFile {
|
||||
ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.binary_file_not_editable")
|
||||
}
|
||||
|
||||
if blob.Size() >= setting.UI.MaxDisplayFileSize {
|
||||
ctx.Data["IsFileTooLarge"] = true
|
||||
ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.file_too_large_not_editable")
|
||||
} else {
|
||||
d, _ := io.ReadAll(dataRc)
|
||||
|
||||
|
@ -285,35 +285,23 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) {
|
||||
}
|
||||
}
|
||||
|
||||
if fInfo.isLFSFile {
|
||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.cannot_edit_lfs_files")
|
||||
} else {
|
||||
if ctx.Repo.CanEnableEditor(ctx, ctx.Doer) {
|
||||
if lfsLock != nil && lfsLock.OwnerID != ctx.Doer.ID {
|
||||
ctx.Data["CanEditFile"] = false
|
||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.this_file_locked")
|
||||
} else {
|
||||
ctx.Data["CanEditFile"] = true
|
||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.edit_this_file")
|
||||
}
|
||||
} else if !ctx.Repo.RefFullName.IsBranch() {
|
||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch")
|
||||
} else if !ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, ctx.Repo.BranchName) {
|
||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.fork_before_edit")
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.Repo.CanEnableEditor(ctx, ctx.Doer) {
|
||||
if lfsLock != nil && lfsLock.OwnerID != ctx.Doer.ID {
|
||||
ctx.Data["CanEditFile"] = false
|
||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.this_file_locked")
|
||||
ctx.Data["CanDeleteFile"] = false
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.this_file_locked")
|
||||
} else {
|
||||
ctx.Data["CanEditFile"] = true
|
||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.edit_this_file")
|
||||
ctx.Data["CanDeleteFile"] = true
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
|
||||
}
|
||||
} else if !ctx.Repo.RefFullName.IsBranch() {
|
||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch")
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch")
|
||||
} else if !ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, ctx.Repo.BranchName) {
|
||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.fork_before_edit")
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_have_write_access")
|
||||
}
|
||||
}
|
||||
|
@ -54,17 +54,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{else if .IsFileTooLarge}}
|
||||
<div class="field">
|
||||
<div class="ui segment tw-text-center">
|
||||
<h4 class="tw-font-semibold tw-mb-2">{{ctx.Locale.Tr "repo.editor.file_too_large_not_editable"}}</h4>
|
||||
<p>{{ctx.Locale.Tr "repo.editor.file_not_editable_hint"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="field">
|
||||
<div class="ui segment tw-text-center">
|
||||
<h4 class="tw-font-semibold tw-mb-2">{{ctx.Locale.Tr "repo.editor.binary_file_not_editable"}}</h4>
|
||||
<h4 class="tw-font-semibold tw-mb-2">{{.NotEditableReason}}</h4>
|
||||
<p>{{ctx.Locale.Tr "repo.editor.file_not_editable_hint"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user