mirror of
https://github.com/go-gitea/gitea.git
synced 2025-10-04 15:29:21 +02:00
Added button to copy file name in PR files (#35509)
The merge request file viewer has a button for copying the file path, but it is not always convenient. Often, you only want to copy the file name, which is currently not possible. This change request adds this capability. --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: a.kiselev <a.kiselev@reglab.ru> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
340aed3982
commit
efc48c36ff
@ -109,6 +109,7 @@ copy_path = Copy path
|
|||||||
copy_success = Copied!
|
copy_success = Copied!
|
||||||
copy_error = Copy failed
|
copy_error = Copy failed
|
||||||
copy_type_unsupported = This file type cannot be copied
|
copy_type_unsupported = This file type cannot be copied
|
||||||
|
copy_filename = Copy filename
|
||||||
|
|
||||||
write = Write
|
write = Write
|
||||||
preview = Preview
|
preview = Preview
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -403,6 +404,14 @@ func (diffFile *DiffFile) GetDiffFileName() string {
|
|||||||
return diffFile.Name
|
return diffFile.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDiffFileBaseName returns the short name of the diff file, or its short old name in case it was deleted
|
||||||
|
func (diffFile *DiffFile) GetDiffFileBaseName() string {
|
||||||
|
if diffFile.Name == "" {
|
||||||
|
return path.Base(diffFile.OldName)
|
||||||
|
}
|
||||||
|
return path.Base(diffFile.Name)
|
||||||
|
}
|
||||||
|
|
||||||
func (diffFile *DiffFile) ShouldBeHidden() bool {
|
func (diffFile *DiffFile) ShouldBeHidden() bool {
|
||||||
return diffFile.IsGenerated || diffFile.IsViewed
|
return diffFile.IsGenerated || diffFile.IsViewed
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,7 @@
|
|||||||
<button class="unescape-button item" data-unicode-content-selector="#diff-{{$file.NameHash}}">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button>
|
<button class="unescape-button item" data-unicode-content-selector="#diff-{{$file.NameHash}}">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button>
|
||||||
<button class="escape-button tw-hidden item" data-unicode-content-selector="#diff-{{$file.NameHash}}">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button>
|
<button class="escape-button tw-hidden item" data-unicode-content-selector="#diff-{{$file.NameHash}}">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<button class="item" data-clipboard-text="{{$file.GetDiffFileBaseName}}">{{ctx.Locale.Tr "copy_filename"}}</button>
|
||||||
{{if not $.PageIsWiki}}
|
{{if not $.PageIsWiki}}
|
||||||
{{if $file.IsDeleted}}
|
{{if $file.IsDeleted}}
|
||||||
<a class="item" rel="nofollow" href="{{$.BeforeSourcePath}}/{{PathEscapeSegments .Name}}">{{ctx.Locale.Tr "repo.diff.view_file"}}</a>
|
<a class="item" rel="nofollow" href="{{$.BeforeSourcePath}}/{{PathEscapeSegments .Name}}">{{ctx.Locale.Tr "repo.diff.view_file"}}</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user