-
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 #3726 from alphagov/2761-refactor-browsehelper-in-…
…preparation-for-ab-test-m Do not force analytics labels for popular links to be in English and refactor browse helper
- Loading branch information
Showing
70 changed files
with
811 additions
and
314 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
module BrowseHelper | ||
ACTION_LINK_DATA = { | ||
benefits: [ | ||
{ lang: "browse.check_benefits_and_financial_support", href: "/check-benefits-financial-support" }, | ||
], | ||
business: [ | ||
{ lang: "browse.hmrc_online_services", href: "/log-in-register-hmrc-online-services" }, | ||
{ lang: "browse.self_assessment_tax_returns", href: "/self-assessment-tax-returns" }, | ||
{ lang: "browse.pay_employers_paye", href: "/pay-paye-tax" }, | ||
], | ||
}.freeze | ||
|
||
def display_action_links_for_slug?(slug) | ||
ACTION_LINK_DATA.key?(slug.to_sym) | ||
def display_popular_links_for_slug?(slug) | ||
I18n.exists?(slug.to_s, scope: "browse.popular_links") | ||
end | ||
|
||
def action_link_data(slug) | ||
links = ACTION_LINK_DATA[slug.to_sym] | ||
return [] unless links | ||
|
||
links.each_with_index do |link, index| | ||
link[:text] = I18n.t(link[:lang]) | ||
link[:ga4_text] = I18n.t(link[:lang], locale: :en) | ||
link[:index_link] = index + 1 | ||
link[:index_total] = links.length | ||
def popular_links_for_slug(slug) | ||
links = I18n.t(slug.to_s, scope: "browse.popular_links") | ||
count = links.length | ||
links.map.with_index(1) do |link, index| | ||
{ | ||
text: link[:title], | ||
href: link[:url], | ||
data_attributes: { | ||
module: "ga4-link-tracker", | ||
ga4_track_links_only: "", | ||
ga4_link: { | ||
event_name: "navigation", | ||
type: "action", | ||
index_link: index, | ||
index_total: count, | ||
text: link[:title], | ||
}, | ||
}, | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
<%= render "govuk_publishing_components/components/action_link", { | ||
text: locals[:text], | ||
href: locals[:href], | ||
dark_large_icon: true, | ||
margin_bottom: 3, | ||
data_attributes: { | ||
module: "ga4-link-tracker", | ||
ga4_track_links_only: "", | ||
ga4_link: { | ||
event_name: "navigation", | ||
type: "action", | ||
index_link: locals[:index_link], | ||
index_total: locals[:index_total], | ||
text: locals[:ga4_text] | ||
} | ||
} | ||
**link, | ||
} %> |
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,12 +1,19 @@ | ||
--- | ||
ar: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: جميع الفئات | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
az: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: Bütün kateqoriyalar | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
be: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: Усе катэгорыі | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
bg: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: Всички категории | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
bn: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: সকল শ্রেণিবিভাগ | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
cs: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: Všechny kategorie | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
cy: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: Pob categori | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
da: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: Alle kategorier | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
de: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: Alle Kategorien | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
dr: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: تمام کتگوری ها | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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,12 +1,19 @@ | ||
--- | ||
el: | ||
browse: | ||
popular_links: | ||
benefits: | ||
- title: | ||
url: | ||
business: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
- title: | ||
url: | ||
all_categories: Όλες οι κατηγορίες | ||
check_benefits_and_financial_support: | ||
description: | ||
hmrc_online_services: | ||
pay_employers_paye: | ||
popular_tasks: | ||
self_assessment_tax_returns: | ||
title: | ||
topics: |
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
Oops, something went wrong.