Add an optional setting with the link to the cookies policy page

This commit is contained in:
taitus
2024-11-29 10:42:25 +01:00
parent 1958a77842
commit d7f701cc9a
9 changed files with 30 additions and 0 deletions

View File

@@ -2,4 +2,5 @@
<%= render Admin::Settings::TableComponent.new(setting_name: "feature") do %>
<%= render Admin::Settings::RowComponent.new("feature.cookies_consent", type: :feature, tab: tab) %>
<%= render Admin::Settings::RowComponent.new("cookies_consent.more_info_link", type: :text, tab: tab) %>
<% end %>

View File

@@ -1,5 +1,9 @@
<div id="cookies_consent_banner" class="cookies-consent-banner">
<h2><%= t("cookies_consent.title") %></h2>
<p><%= t("cookies_consent.message") %></p>
<% if more_info_link.present? %>
<p><%= link_to t("cookies_consent.more_info_link"), more_info_link %></p>
<% end %>
<button type="button" class="accept-essential-cookies"><%= t("cookies_consent.accept_essential_cookies") %></button>
</div>

View File

@@ -5,6 +5,10 @@ class Layout::CookiesConsent::BannerComponent < ApplicationComponent
feature?(:cookies_consent) && cookies_consent_unset?
end
def more_info_link
Setting["cookies_consent.more_info_link"]
end
private
def cookies_consent_unset?

View File

@@ -161,6 +161,7 @@ class Setting < ApplicationRecord
"related_content_score_threshold": -0.3,
"featured_proposals_number": 3,
"feature.dashboard.notification_emails": nil,
"cookies_consent.more_info_link": "",
"machine_learning.comments_summary": false,
"machine_learning.related_content": false,
"machine_learning.tags": false,

View File

@@ -936,4 +936,5 @@ en:
cookies_consent:
accept_essential_cookies: "Accept essential cookies"
message: "Cookies help us deliver our services. By using our services, you agree to our use of cookies."
more_info_link: "More information about cookies"
title: "Cookies policy"

View File

@@ -228,3 +228,6 @@ en:
budgets_description: Allow participatory budgets to be linked to Sustainable Development Goals
legislation: Related SDG in collaborative legislation
legislation_description: Allow collaborative legislation to be linked to Sustainable Development Goals
cookies_consent:
more_info_link: Link to cookies policy
more_info_link_description: Link shown in the consent banner to the cookie policy page.

View File

@@ -936,4 +936,5 @@ es:
cookies_consent:
accept_essential_cookies: "Aceptar cookies esenciales"
message: "Las cookies nos ayudan a ofrecer nuestros servicios. Al utilizar nuestros servicios, aceptas el uso de cookies."
more_info_link: "Más información sobre cookies"
title: "Política de cookies"

View File

@@ -228,3 +228,6 @@ es:
budgets_description: Permitir alineamiento de los Objetivos de Desarrollo Sostenible en presupuestos participativos
legislation: Alineamiento ODS en legislación colaborativa
legislation_description: Permitir alineamiento de los Objetivos de Desarrollo Sostenible en legislación colaborativa
cookies_consent:
more_info_link: Enlace a la política de cookies
more_info_link_description: Enlace que se muestra en el banner de consentimiento a la página de política de cookies

View File

@@ -20,10 +20,22 @@ describe Layout::CookiesConsent::BannerComponent do
end
it "renders the banner content when feature `cookies_consent` is enabled and cookies were not accepted" do
Setting["cookies_consent.more_info_link"] = "/cookies_policy"
render_inline Layout::CookiesConsent::BannerComponent.new
expect(page).to be_rendered
expect(page).to have_css "h2", text: "Cookies policy"
expect(page).to have_link "More information about cookies", href: "/cookies_policy"
expect(page).to have_button "Accept essential cookies"
end
it "does not render a link when the setting `cookies_consent.more_info_link` is not defined" do
Setting["cookies_consent.more_info_link"] = ""
render_inline Layout::CookiesConsent::BannerComponent.new
expect(page).not_to have_link "More information about cookies"
expect(page).to be_rendered
end
end