-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3467 from alphagov/remove_email_signup_button
Hide email signup button from pages that do not have an :en locale
- Loading branch information
Showing
19 changed files
with
202 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module DocumentCollection | ||
module SignupLink | ||
def show_email_signup_link? | ||
taxonomy_topic_email_override_base_path.present? && I18n.locale == :en | ||
end | ||
|
||
def taxonomy_topic_email_override_base_path | ||
content_item.dig("links", "taxonomy_topic_email_override", 0, "base_path") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 23 additions & 21 deletions
44
app/views/shared/_single_page_notification_button.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
<% | ||
default_ga4_data_attributes = { | ||
module: "ga4-link-tracker", | ||
ga4_link: { | ||
event_name: "navigation", | ||
type: "subscribe", | ||
index_link: 1, | ||
index_total: 2, | ||
section: "Top" | ||
<% if @content_item.display_single_page_notification_button? %> | ||
<% | ||
default_ga4_data_attributes = { | ||
module: "ga4-link-tracker", | ||
ga4_link: { | ||
event_name: "navigation", | ||
type: "subscribe", | ||
index_link: 1, | ||
index_total: 2, | ||
section: "Top" | ||
} | ||
} | ||
} | ||
%> | ||
%> | ||
|
||
<% ga4_data_attributes = ga4_data_attributes || default_ga4_data_attributes %> | ||
<% skip_account = skip_account || "false" %> | ||
<% ga4_data_attributes = ga4_data_attributes || default_ga4_data_attributes %> | ||
<% skip_account = skip_account || "false" %> | ||
|
||
<%= render 'govuk_publishing_components/components/single_page_notification_button', { | ||
base_path: @content_item.base_path, | ||
js_enhancement: @has_govuk_account, | ||
ga4_data_attributes: ga4_data_attributes, | ||
margin_bottom: 6, | ||
button_location: "top", | ||
skip_account: skip_account, | ||
} if @content_item.has_single_page_notifications? %> | ||
<%= render 'govuk_publishing_components/components/single_page_notification_button', { | ||
base_path: @content_item.base_path, | ||
js_enhancement: @has_govuk_account, | ||
ga4_data_attributes: ga4_data_attributes, | ||
margin_bottom: 6, | ||
button_location: "top", | ||
skip_account: skip_account, | ||
} %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require "test_helper" | ||
|
||
class DocumentCollectionSignupLinkTest < ActiveSupport::TestCase | ||
class DummyContentItem | ||
include DocumentCollection::SignupLink | ||
attr_accessor :content_item | ||
|
||
def initialize | ||
@content_item = {} | ||
@content_item["links"] = {} | ||
end | ||
end | ||
|
||
test "taxonomy_topic_email_override_base_path returns nil if field is empty" do | ||
item = DummyContentItem.new | ||
assert_nil item.taxonomy_topic_email_override_base_path | ||
end | ||
|
||
test "show_email_signup_link? returns false if there is no linked taxonomy_topic_email_override" do | ||
item = DummyContentItem.new | ||
assert_equal false, item.show_email_signup_link? | ||
end | ||
|
||
test "show_email_signup_link? returns false if the locale is not en" do | ||
I18n.with_locale("fr") do | ||
item = DummyContentItem.new | ||
item.content_item["links"]["taxonomy_topic_email_override"] = [ | ||
{ | ||
"base_path" => "/a-taxonomy-topic", | ||
}, | ||
] | ||
assert_equal false, item.show_email_signup_link? | ||
end | ||
end | ||
|
||
test "show_email_signup_link? returns true if there is a linked taxonomy_topic_email_override and the locale is en" do | ||
I18n.with_locale("en") do | ||
item = DummyContentItem.new | ||
item.content_item["links"]["taxonomy_topic_email_override"] = [ | ||
{ | ||
"base_path" => "/a-taxonomy-topic", | ||
}, | ||
] | ||
assert item.show_email_signup_link? | ||
end | ||
end | ||
end |
Oops, something went wrong.