From 971943f1462bdbd769841f5782beb2feec73c8b1 Mon Sep 17 00:00:00 2001 From: Laurent Curau Date: Tue, 21 Apr 2020 17:15:57 +0100 Subject: [PATCH 1/2] Fix beta banner Rendering the govuk component in the view helper breaks the styling because govuk-publishing-components gem relies on said components being rendered from inside a view. --- app/helpers/phase_label_helper.rb | 10 ---------- app/presenters/content_item_presenter.rb | 4 ++++ app/views/layouts/application.html.erb | 4 +++- 3 files changed, 7 insertions(+), 11 deletions(-) delete mode 100644 app/helpers/phase_label_helper.rb diff --git a/app/helpers/phase_label_helper.rb b/app/helpers/phase_label_helper.rb deleted file mode 100644 index e66107fd6..000000000 --- a/app/helpers/phase_label_helper.rb +++ /dev/null @@ -1,10 +0,0 @@ -module PhaseLabelHelper - def render_phase_label(presented_object, message) - if presented_object.respond_to?(:phase) && %w(alpha beta).include?(presented_object.phase) - locals = {} - locals[:message] = message if message.present? - - render "govuk_publishing_components/components/phase_banner", locals.merge(phase: presented_object.phase) - end - end -end diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb index 7c18a4c57..82ce6f8dc 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -81,6 +81,10 @@ def cache_control_public? !content_item.cache_control.private? end + def show_phase_banner? + phase.in?(%w[alpha beta]) + end + private def display_date(timestamp, format = "%-d %B %Y") diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 05bb46a0d..e79b26dc6 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -35,7 +35,9 @@ <% end %>
- <%= render_phase_label @content_item, content_for(:phase_message) %> + <% if @content_item.show_phase_banner? %> + <%= render 'govuk_publishing_components/components/phase_banner', phase: @content_item.phase %> + <% end %> <% if @content_item.try(:back_link) %> <%= render 'govuk_publishing_components/components/back_link', href: @content_item.back_link %> From a100360dabe374bbc0e1c4a5faeab15530e3fb5e Mon Sep 17 00:00:00 2001 From: Laurent Curau Date: Wed, 22 Apr 2020 09:26:47 +0100 Subject: [PATCH 2/2] Import phase banner CSS --- app/assets/stylesheets/application.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 057617338..dab678275 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -29,6 +29,7 @@ $govuk-use-legacy-palette: false; @import 'govuk_publishing_components/components/metadata'; @import 'govuk_publishing_components/components/notice'; @import 'govuk_publishing_components/components/organisation-logo'; +@import 'govuk_publishing_components/components/phase-banner'; @import 'govuk_publishing_components/components/previous-and-next-navigation'; @import 'govuk_publishing_components/components/radio'; @import 'govuk_publishing_components/components/related-navigation';