Skip to content

Commit d5fbf9c

Browse files
silverwindrichmahn
authored andcommitted
Add 'Copy path' button to file view (#32584)
Also adds a tooltip which is replicated to the same button in the diff box. Fixes: go-gitea/gitea#32583
1 parent 2f21da8 commit d5fbf9c

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
@@ -128,6 +128,7 @@
128128
<span class="breadcrumb-divider">/</span>
129129
{{- if eq $i $l -}}
130130
<span class="active section" title="{{$v}}">{{$v}}</span>
131+
<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>
131132
{{- else -}}
132133
{{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{$v}}</a></span>
133134
{{- end -}}

0 commit comments

Comments
 (0)