diff --git a/app/helpers/patternfly_components_helper.rb b/app/helpers/patternfly_components_helper.rb index f00be1bca4..c3901d99c3 100644 --- a/app/helpers/patternfly_components_helper.rb +++ b/app/helpers/patternfly_components_helper.rb @@ -23,21 +23,21 @@ def title_tag(title) end end - def body_tag(body) - tag.div class: 'pf-c-alert__description' do - tag.p body - end - end + def description_tag(description) + return unless description - def pf_inline_alert(title, body, variant: nil) - tag.div class: "pf-c-alert pf-m-#{variant} pf-m-inline" do - icon_tag(variant) + title_tag(title) + body_tag(body) + tag.div class: 'pf-c-alert__description' do + tag.p description end end - def pf_inline_alert_plain(title, variant: nil) - tag.div class: "pf-c-alert pf-m-#{variant} pf-m-inline pf-m-plain" do - icon_tag(variant) + title_tag(title) + def pf_inline_alert(title, **options) + plain_class = options[:plain] ? 'pf-m-plain' : '' + variant = options[:variant] + variant_class = variant ? "pf-m-#{variant}" : '' + classes = "pf-c-alert pf-m-inline #{plain_class} #{variant_class}" + tag.div class: classes do + icon_tag(variant) + title_tag(title) + description_tag(options[:description]) end end end diff --git a/app/views/shared/_annotations.html.slim b/app/views/shared/_annotations.html.slim index 1d0eaf31a4..9b206e9453 100644 --- a/app/views/shared/_annotations.html.slim +++ b/app/views/shared/_annotations.html.slim @@ -1,7 +1,7 @@ - if resource.respond_to?(:managed_by) && resource.managed_by.present? - var = defined?(variant) ? variant : :info - if defined?(plain) - = pf_inline_alert_plain t('.managed_title', value: resource.managed_by), variant: var + = pf_inline_alert t('.managed_title', value: resource.managed_by), variant: var, plain: true - else - - body = (defined?(description) && description) ? t('.managed_description') : nil - = pf_inline_alert t('.managed_title', value: resource.managed_by), body, variant: var + - description = (defined?(description) && description) ? t('.managed_description') : nil + = pf_inline_alert t('.managed_title', value: resource.managed_by), description: description, variant: var