diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-05 20:59:17 +0200 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-27 15:43:37 +0200 |
commit | 36c05b311c830aef25ecb7ad4416ac77a5c98651 (patch) | |
tree | 15bac00cb6fbcfc589ca9bdbf01d9e7be61c7265 /app | |
parent | 084cc718f759a37c8fc5535930daeee5e819c30f (diff) | |
download | gitlab-ce-36c05b311c830aef25ecb7ad4416ac77a5c98651.tar.gz |
convert gpg badge helper methods to partials
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/stylesheets/pages/commits.scss | 1 | ||||
-rw-r--r-- | app/helpers/commits_helper.rb | 86 | ||||
-rw-r--r-- | app/views/projects/commit/_invalid_signature_badge.html.haml | 7 | ||||
-rw-r--r-- | app/views/projects/commit/_signature.html.haml | 5 | ||||
-rw-r--r-- | app/views/projects/commit/_signature_badge.html.haml | 17 | ||||
-rw-r--r-- | app/views/projects/commit/_valid_signature_badge.html.haml | 19 |
6 files changed, 48 insertions, 87 deletions
diff --git a/app/assets/stylesheets/pages/commits.scss b/app/assets/stylesheets/pages/commits.scss index 5de98cfc7af..b6e9053fbce 100644 --- a/app/assets/stylesheets/pages/commits.scss +++ b/app/assets/stylesheets/pages/commits.scss @@ -295,6 +295,7 @@ } .gpg-badge-popover-title { + display: inline; font-weight: normal; } diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 60acc1e2f82..d08e346d605 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -212,90 +212,4 @@ module CommitsHelper [commits, 0] 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 diff --git a/app/views/projects/commit/_invalid_signature_badge.html.haml b/app/views/projects/commit/_invalid_signature_badge.html.haml new file mode 100644 index 00000000000..29c787bd324 --- /dev/null +++ b/app/views/projects/commit/_invalid_signature_badge.html.haml @@ -0,0 +1,7 @@ +- 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 diff --git a/app/views/projects/commit/_signature.html.haml b/app/views/projects/commit/_signature.html.haml index 00120a665c5..60fa52557ef 100644 --- a/app/views/projects/commit/_signature.html.haml +++ b/app/views/projects/commit/_signature.html.haml @@ -1,2 +1,5 @@ - 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 } diff --git a/app/views/projects/commit/_signature_badge.html.haml b/app/views/projects/commit/_signature_badge.html.haml new file mode 100644 index 00000000000..2e046c1f684 --- /dev/null +++ b/app/views/projects/commit/_signature_badge.html.haml @@ -0,0 +1,17 @@ +- 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 diff --git a/app/views/projects/commit/_valid_signature_badge.html.haml b/app/views/projects/commit/_valid_signature_badge.html.haml new file mode 100644 index 00000000000..47226466b85 --- /dev/null +++ b/app/views/projects/commit/_valid_signature_badge.html.haml @@ -0,0 +1,19 @@ +- 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 |