Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copy Commit ID button in commits list #17759

Merged
merged 11 commits into from
Nov 23, 2021
35 changes: 25 additions & 10 deletions templates/repo/commits_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
{{end}}
</td>
<td class="sha">
{{$class_wrapper := "ui"}}
{{$class := "ui sha label"}}
{{$clipboard := "clipboard"}}
{{if .Signature}}
{{$class = (printf "%s%s" $class " isSigned")}}
{{$clipboard = (printf "%s%s" $clipboard " isSigned")}}
{{if .Verification.Verified}}
{{if eq .Verification.TrustStatus "trusted"}}
{{$class = (printf "%s%s" $class " isVerified")}}
Expand All @@ -40,21 +43,33 @@
{{end}}
{{end}}
{{if $.PageIsWiki}}
<a href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/wiki/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
<span class="{{$class_wrapper}}">
{{else if $.Reponame}}
<a href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
<span class="{{$class_wrapper}}">
{{else}}
<span class="{{$class}}">
<span>
{{end}}
<span class="shortsha">{{ShortSha .ID.String}}</span>
{{if .Signature}}
{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}
{{if $.PageIsWiki}}
<a href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/wiki/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
{{else if $.Reponame}}
<a href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
{{end}}
{{if $.Reponame}}
<span class="shortsha">{{ShortSha .ID.String}}</span>
{{if .Signature}}
{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}
{{end}}
{{if $.PageIsWiki}}
</a>
{{else if $.Reponame}}
</a>
{{end}}
{{$commitID := .ID.String}}
<a class="{{$clipboard}}"
data-clipboard-text="{{.ID}}"
>
{{svg "octicon-copy"}}
</a>
{{else}}
</span>
{{end}}
</span>
</td>
<td class="message">
<span class="message-wrapper">
Expand Down
12 changes: 11 additions & 1 deletion web_src/less/_repository.less
Original file line number Diff line number Diff line change
Expand Up @@ -1330,10 +1330,20 @@
text-align: center;
}

width: 175px;
width: 190px;
}
}

td.sha .clipboard {
margin-left: 2px;
vertical-align: text-bottom;
}

td.sha .clipboard.isSigned {
margin-left: 2px;
vertical-align: text-bottom;
}

td.sha .sha.label {
margin: 0;
}
Expand Down