Skip to content

Commit a96ec74

Browse files
committed
Add 'Copy path' button to file view
Also adds a tooltip which is replicated to the same button in the diff box. Fixes: go-gitea#32583
1 parent 33850a8 commit a96ec74

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

options/locale/locale_en-US.ini

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ copy_url = Copy URL
104104
copy_hash = Copy hash
105105
copy_content = Copy content
106106
copy_branch = Copy branch name
107+
copy_path = Copy path
107108
copy_success = Copied!
108109
copy_error = Copy failed
109110
copy_type_unsupported = This file type cannot be copied

templates/repo/diff/box.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
</div>
131131
<span class="file tw-flex tw-items-center tw-font-mono tw-flex-1"><a class="muted file-link" title="{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}" href="#diff-{{$file.NameHash}}">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}</a>
132132
{{if .IsLFSFile}} ({{ctx.Locale.Tr "repo.stored_lfs"}}){{end}}
133-
<button class="btn interact-fg tw-p-2" data-clipboard-text="{{$file.Name}}">{{svg "octicon-copy" 14}}</button>
133+
<button class="btn interact-fg tw-p-2" data-clipboard-text="{{$file.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_path"}}">{{svg "octicon-copy" 14}}</button>
134134
{{if $file.IsGenerated}}
135135
<span class="ui label">{{ctx.Locale.Tr "repo.diff.generated"}}</span>
136136
{{end}}

templates/repo/home.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
<span class="breadcrumb-divider">/</span>
107107
{{- if eq $i $l -}}
108108
<span class="active section" title="{{$v}}">{{$v}}</span>
109+
<button class="btn interact-fg tw-mx-1" data-clipboard-text="{{$.TreePath}}" data-tooltip-content="{{ctx.Locale.Tr "copy_path"}}">{{svg "octicon-copy" 14}}</button>
109110
{{- else -}}
110111
{{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{$v}}</a></span>
111112
{{- end -}}

0 commit comments

Comments
 (0)