Skip to content

Commit

Permalink
Change based on PR suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
danacotoran committed Mar 9, 2022
1 parent 33a5810 commit 2bbe914
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
6 changes: 0 additions & 6 deletions app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class ContentItemsController < ApplicationController

attr_accessor :content_item, :taxonomy_navigation

helper_method :show_email_subscription_success_banner?

def show
load_content_item

Expand Down Expand Up @@ -48,10 +46,6 @@ def service_sign_in_options
end
end

def show_email_subscription_success_banner?
@account_flash.include?("email-subscription-success") || @account_flash.include?("email-unsubscribe-success") || @account_flash.include?("email-subscription-already-subscribed")
end

private

def is_history_page?
Expand Down
15 changes: 15 additions & 0 deletions app/helpers/content_items_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module ContentItemsHelper
def email_subscription_success_banner_heading(account_flash)
if account_flash.include?("email-subscription-success")
sanitize(t("email.subscribe_title"))
elsif account_flash.include?("email-unsubscribe-success")
sanitize(t("email.unsubscribe_title"))
elsif account_flash.include?("email-subscription-already-subscribed")
sanitize(t("email.already_subscribed_title"))
end
end

def show_email_subscription_success_banner?(account_flash)
account_flash.include?("email-subscription-success") || account_flash.include?("email-unsubscribe-success") || account_flash.include?("email-subscription-already-subscribed")
end
end
16 changes: 2 additions & 14 deletions app/views/shared/_email_subscribe_unsubscribe_flash.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
<% banner_heading = capture do %>
<%
if @account_flash.include?("email-subscription-success")
sanitize(t("email.subscribe_title"))
elsif @account_flash.include?("email-unsubscribe-success")
sanitize(t("email.unsubscribe_title"))
elsif @account_flash.include?("email-subscription-already-subscribed")
sanitize(t("email.already_subscribed_title"))
end
%>
<% end %>

<% banner_description = capture do %>
<a class="govuk-link govuk-notification-banner__link" href="/email/manage"><%= t("email.description") %></a>
<% end %>

<% if show_email_subscription_success_banner? %>
<% if show_email_subscription_success_banner?(@account_flash) %>
<div class="govuk-grid-row govuk-!-margin-top-3">
<div class="govuk-grid-column-two-thirds">
<%= render "govuk_publishing_components/components/success_alert", {
message: banner_heading,
message: email_subscription_success_banner_heading(@account_flash),
description: banner_description,
margin_bottom: 0,
} %>
Expand Down

0 comments on commit 2bbe914

Please sign in to comment.