forked from gitea/gitea
Merge branch 'master' into refactor_issues-subscription
This commit is contained in:
commit
13879f863b
|
@ -2810,3 +2810,19 @@ func (repo *Repository) GetOriginalURLHostname() string {
|
||||||
|
|
||||||
return u.Host
|
return u.Host
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTreePathLock returns LSF lock for the treePath
|
||||||
|
func (repo *Repository) GetTreePathLock(treePath string) (*LFSLock, error) {
|
||||||
|
if setting.LFS.StartServer {
|
||||||
|
locks, err := GetLFSLockByRepoID(repo.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, lock := range locks {
|
||||||
|
if lock.Path == treePath {
|
||||||
|
return lock, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
|
@ -703,6 +703,7 @@ editor.preview_changes = Preview Changes
|
||||||
editor.cannot_edit_lfs_files = LFS files cannot be edited in the web interface.
|
editor.cannot_edit_lfs_files = LFS files cannot be edited in the web interface.
|
||||||
editor.cannot_edit_non_text_files = Binary files cannot be edited in the web interface.
|
editor.cannot_edit_non_text_files = Binary files cannot be edited in the web interface.
|
||||||
editor.edit_this_file = Edit File
|
editor.edit_this_file = Edit File
|
||||||
|
editor.this_file_locked = File is locked
|
||||||
editor.must_be_on_a_branch = You must be on a branch to make or propose changes to this file.
|
editor.must_be_on_a_branch = You must be on a branch to make or propose changes to this file.
|
||||||
editor.fork_before_edit = You must fork this repository to make or propose changes to this file.
|
editor.fork_before_edit = You must fork this repository to make or propose changes to this file.
|
||||||
editor.delete_this_file = Delete File
|
editor.delete_this_file = Delete File
|
||||||
|
|
|
@ -119,8 +119,19 @@ func RefBlame(ctx *context.Context) {
|
||||||
ctx.Data["IsBlame"] = true
|
ctx.Data["IsBlame"] = true
|
||||||
|
|
||||||
if ctx.Repo.CanEnableEditor() {
|
if ctx.Repo.CanEnableEditor() {
|
||||||
|
// 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["CanDeleteFile"] = true
|
||||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
|
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
|
||||||
|
}
|
||||||
} else if !ctx.Repo.IsViewBranch {
|
} else if !ctx.Repo.IsViewBranch {
|
||||||
ctx.Data["DeleteFileTooltip"] = 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.CanWrite(models.UnitTypeCode) {
|
} else if !ctx.Repo.CanWrite(models.UnitTypeCode) {
|
||||||
|
|
|
@ -265,6 +265,17 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
||||||
ctx.Data["RawFileLink"] = fmt.Sprintf("%s%s.git/info/lfs/objects/%s/%s", setting.AppURL, ctx.Repo.Repository.FullName(), meta.Oid, filenameBase64)
|
ctx.Data["RawFileLink"] = fmt.Sprintf("%s%s.git/info/lfs/objects/%s/%s", setting.AppURL, ctx.Repo.Repository.FullName(), meta.Oid, filenameBase64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check LFS Lock
|
||||||
|
lfsLock, err := ctx.Repo.Repository.GetTreePathLock(ctx.Repo.TreePath)
|
||||||
|
ctx.Data["LFSLock"] = lfsLock
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetTreePathLock", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if lfsLock != nil {
|
||||||
|
ctx.Data["LFSLockOwner"] = lfsLock.Owner.DisplayName()
|
||||||
|
ctx.Data["LFSLockHint"] = ctx.Tr("repo.editor.this_file_locked")
|
||||||
|
}
|
||||||
|
|
||||||
// Assume file is not editable first.
|
// Assume file is not editable first.
|
||||||
if isLFSFile {
|
if isLFSFile {
|
||||||
|
@ -334,8 +345,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
||||||
}
|
}
|
||||||
if !isLFSFile {
|
if !isLFSFile {
|
||||||
if ctx.Repo.CanEnableEditor() {
|
if ctx.Repo.CanEnableEditor() {
|
||||||
|
if lfsLock != nil && lfsLock.OwnerID != ctx.User.ID {
|
||||||
|
ctx.Data["CanEditFile"] = false
|
||||||
|
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.this_file_locked")
|
||||||
|
} else {
|
||||||
ctx.Data["CanEditFile"] = true
|
ctx.Data["CanEditFile"] = true
|
||||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.edit_this_file")
|
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.edit_this_file")
|
||||||
|
}
|
||||||
} else if !ctx.Repo.IsViewBranch {
|
} else if !ctx.Repo.IsViewBranch {
|
||||||
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch")
|
ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch")
|
||||||
} else if !ctx.Repo.CanWrite(models.UnitTypeCode) {
|
} else if !ctx.Repo.CanWrite(models.UnitTypeCode) {
|
||||||
|
@ -368,8 +384,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Repo.CanEnableEditor() {
|
if ctx.Repo.CanEnableEditor() {
|
||||||
|
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["CanDeleteFile"] = true
|
||||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
|
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
|
||||||
|
}
|
||||||
} else if !ctx.Repo.IsViewBranch {
|
} else if !ctx.Repo.IsViewBranch {
|
||||||
ctx.Data["DeleteFileTooltip"] = 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.CanWrite(models.UnitTypeCode) {
|
} else if !ctx.Repo.CanWrite(models.UnitTypeCode) {
|
||||||
|
|
|
@ -50,17 +50,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ten wide right aligned column">
|
<div class="ten wide right aligned column">
|
||||||
<div class="ui secondary filter stackable menu">
|
<div class="ui secondary filter stackable menu labels">
|
||||||
<!-- Label -->
|
<!-- Label -->
|
||||||
<div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item" style="margin-left: auto">
|
<div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item label-filter" style="margin-left: auto">
|
||||||
<span class="text">
|
<span class="text">
|
||||||
{{.i18n.Tr "repo.issues.filter_label"}}
|
{{.i18n.Tr "repo.issues.filter_label"}}
|
||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
</span>
|
</span>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
|
<span class="info">{{.i18n.Tr "repo.issues.filter_label_exclude" | Safe}}</span>
|
||||||
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&assignee={{$.AssigneeID}}">{{.i18n.Tr "repo.issues.filter_label_no_select"}}</a>
|
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&assignee={{$.AssigneeID}}">{{.i18n.Tr "repo.issues.filter_label_no_select"}}</a>
|
||||||
{{range .Labels}}
|
{{range .Labels}}
|
||||||
<a class="item has-emoji" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.ID}}&assignee={{$.AssigneeID}}"><span class="octicon {{if eq $.SelectLabels .ID}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}</a>
|
<a class="item has-emoji label-filter-item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.ID}}&assignee={{$.AssigneeID}}" data-label-id="{{.ID}}"><span class="octicon {{if .IsExcluded}}octicon-circle-slash{{else if eq $.SelectLabels .ID}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,6 +16,12 @@
|
||||||
{{FileSize .FileSize}}{{if .IsLFSFile}} ({{.i18n.Tr "repo.stored_lfs"}}){{end}}
|
{{FileSize .FileSize}}{{if .IsLFSFile}} ({{.i18n.Tr "repo.stored_lfs"}}){{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{if .LFSLock}}
|
||||||
|
<div class="file-info-entry">
|
||||||
|
<i class="fa fa-lock poping up disabled" data-content="{{.LFSLockHint}}" data-position="bottom center" data-variation="tiny inverted"></i>
|
||||||
|
<a href="{{AppSubUrl}}/{{.LFSLock.Owner.Name}}">{{.LFSLockOwner}}</a>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue