Skip to content
代码片段 群组 项目
提交 b8ba4d34 编辑于 作者: Mike Greiling's avatar Mike Greiling
浏览文件

Merge branch 'remove-non-pajamas-alert-from-from' into 'master'

Update form_helper to remove non-pajamas option

See merge request gitlab-org/gitlab!95278
No related branches found
No related tags found
无相关合并请求
# frozen_string_literal: true # frozen_string_literal: true
module FormHelper module FormHelper
def form_errors(model, type: 'form', truncate: [], pajamas_alert: false) def form_errors(model, type: 'form', truncate: [], pajamas_alert: true)
errors = model.errors errors = model.errors
return unless errors.any? return unless errors.any?
...@@ -25,26 +25,17 @@ def form_errors(model, type: 'form', truncate: [], pajamas_alert: false) ...@@ -25,26 +25,17 @@ def form_errors(model, type: 'form', truncate: [], pajamas_alert: false)
tag.li(message) tag.li(message)
end.join.html_safe end.join.html_safe
if pajamas_alert render Pajamas::AlertComponent.new(
render Pajamas::AlertComponent.new( variant: :danger,
variant: :danger, title: headline,
title: headline, dismissible: false,
dismissible: false, alert_options: { id: 'error_explanation', class: 'gl-mb-5' }
alert_options: { id: 'error_explanation', class: 'gl-mb-5' } ) do |c|
) do |c| c.body do
c.body do tag.ul(class: 'gl-pl-5 gl-mb-0') do
tag.ul(class: 'gl-pl-5 gl-mb-0') do messages
messages
end
end end
end end
else
tag.div(class: 'alert alert-danger', id: 'error_explanation') do
tag.h4(headline) <<
tag.ul do
messages
end
end
end end
end end
......
...@@ -89,10 +89,7 @@ ...@@ -89,10 +89,7 @@
it 'renders an appropriately styled alert div' do it 'renders an appropriately styled alert div' do
model = double(errors: errors_stub('Error 1')) model = double(errors: errors_stub('Error 1'))
expect(helper.form_errors(model, pajamas_alert: false)) expect(helper.form_errors(model))
.to include('<div class="alert alert-danger" id="error_explanation">')
expect(helper.form_errors(model, pajamas_alert: true))
.to include( .to include(
'<div class="gl-alert gl-mb-5 gl-alert-danger gl-alert-not-dismissible" id="error_explanation" role="alert">' '<div class="gl-alert gl-mb-5 gl-alert-danger gl-alert-not-dismissible" id="error_explanation" role="alert">'
) )
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册