mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-18 07:53:04 +00:00
Respect LFS File Lock on UI (#8719)
* update #8687 respect file locking * upate #8687 Add LFS locker information * update #8719 enhance coding style and return error
This commit is contained in:
parent
e7fbc551ab
commit
7bb817e6d1
5 changed files with 61 additions and 6 deletions
|
@ -119,8 +119,19 @@ func RefBlame(ctx *context.Context) {
|
|||
ctx.Data["IsBlame"] = true
|
||||
|
||||
if ctx.Repo.CanEnableEditor() {
|
||||
ctx.Data["CanDeleteFile"] = true
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
|
||||
// Check LFS Lock
|
||||
lfsLock, err := ctx.Repo.Repository.GetTreePathLock(ctx.Repo.TreePath)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTreePathLock", err)
|
||||
return
|
||||
}
|
||||
if lfsLock != nil && lfsLock.OwnerID != ctx.User.ID {
|
||||
ctx.Data["CanDeleteFile"] = false
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.this_file_locked")
|
||||
} else {
|
||||
ctx.Data["CanDeleteFile"] = true
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
|
||||
}
|
||||
} else if !ctx.Repo.IsViewBranch {
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch")
|
||||
} else if !ctx.Repo.CanWrite(models.UnitTypeCode) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue