Commit 36c05b31 authored by Alexis Reigel's avatar Alexis Reigel

convert gpg badge helper methods to partials

parent 084cc718
...@@ -295,6 +295,7 @@ ...@@ -295,6 +295,7 @@
} }
.gpg-badge-popover-title { .gpg-badge-popover-title {
display: inline;
font-weight: normal; font-weight: normal;
} }
......
...@@ -212,90 +212,4 @@ module CommitsHelper ...@@ -212,90 +212,4 @@ module CommitsHelper
[commits, 0] [commits, 0]
end end
end end
def commit_gpg_signature_badge(signature)
if signature.valid_signature?
commit_gpg_valid_signature_badge(signature)
else
commit_gpg_invalid_signature_badge(signature)
end
end
def commit_gpg_valid_signature_badge(signature)
title = capture do
concat content_tag('i', '', class: 'fa fa-check-circle gpg-badge-popover-icon valid', 'aria-hidden' => 'true')
concat 'This commit was signed with a verified signature.'
end
content = capture do
link_to user_path(signature.gpg_key.user), class: 'gpg-badge-popover-user-link' do
concat(
content_tag(:div, class: 'gpg-badge-popover-avatar') do
user_avatar_without_link(user: signature.gpg_key.user, size: 32)
end
)
concat(
content_tag(:div, class: 'gpg-badge-popover-username') do
signature.gpg_key.user.username
end
)
concat(
content_tag(:div) do
signature.gpg_key.user.name
end
)
end
end
commit_gpg_signature_badge_with(signature, label: 'Verified', title: title, content: content, css_classes: ['valid'])
end
def commit_gpg_invalid_signature_badge(signature)
title = capture do
concat content_tag('i', '', class: 'fa fa-question-circle gpg-badge-popover-icon invalid', 'aria-hidden' => 'true')
concat 'This commit was signed with an unverified signature.'
end
commit_gpg_signature_badge_with(signature, label: 'Unverified', title: title, css_classes: ['invalid'])
end
def commit_gpg_signature_badge_with(signature, label:, title: '', content: '', css_classes: [])
css_classes = %w(btn btn-xs gpg-badge) + css_classes
content = capture do
concat(
content_tag(:div, class: 'clearfix') do
content
end
)
concat "GPG key ID: #{signature.gpg_key_primary_keyid}"
concat(
link_to(
'Learn about signing commits',
help_page_path('workflow/gpg_signed_commits/index.md'),
class: 'gpg-badge-popover-help-link'
)
)
end
title = capture do
content_tag 'span', class: 'gpg-badge-popover-title' do
title
end
end
data = {
toggle: 'popover',
html: 'true',
placement: 'auto bottom',
title: title,
content: content
}
content_tag :button, class: css_classes, data: data do
label
end
end
end end
- title = capture do
%i{ class: 'fa fa-question-circle gpg-badge-popover-icon invalid', 'aria-hidden' => 'true' }
This commit was signed with an unverified signature.
- locals = { signature: signature, title: title, label: 'Unverified', css_classes: ['invalid'] }
= render partial: 'projects/commit/signature_badge', locals: locals
- if signature - if signature
= commit_gpg_signature_badge(signature) - if signature.valid_signature?
= render partial: 'projects/commit/valid_signature_badge', locals: { signature: signature }
- else
= render partial: 'projects/commit/invalid_signature_badge', locals: { signature: signature }
- css_classes = %w(btn btn-xs gpg-badge) + css_classes
- title = capture do
.gpg-badge-popover-title
= title
- content = capture do
.clearfix
= content
GPG key ID:
= signature.gpg_key_primary_keyid
= link_to('Learn about signing commits', help_page_path('workflow/gpg_signed_commits/index.md'), class: 'gpg-badge-popover-help-link')
%button{ class: css_classes, data: { toggle: 'popover', html: 'true', placement: 'auto bottom', title: title, content: content } }
= label
- title = capture do
%i{ class: 'fa fa-check-circle gpg-badge-popover-icon valid', 'aria-hidden' => 'true' }
This commit was signed with a verified signature.
- content = capture do
- gpg_key = signature.gpg_key
= link_to user_path(gpg_key.user), class: 'gpg-badge-popover-user-link' do
.gpg-badge-popover-avatar
= user_avatar_without_link(user: signature.gpg_key.user, size: 32)
.gpg-badge-popover-username
= gpg_key.user.username
%div= gpg_key.user.name
- locals = { signature: signature, title: title, content: content, label: 'Verified', css_classes: ['valid'] }
= render partial: 'projects/commit/signature_badge', locals: locals
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment