-
Notifications
You must be signed in to change notification settings - Fork 126
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 #2005 from tf/iframe-consent
Consent opt-in for iframe embed element
- Loading branch information
Showing
38 changed files
with
886 additions
and
96 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
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
16 changes: 16 additions & 0 deletions
16
...types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_consent_vendors.json.jbuilder
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,16 @@ | ||
content_element_vendors = | ||
entry_config.content_element_consent_vendors.by_content_element_id(entry) | ||
|
||
json.content_element_consent_vendors(content_element_vendors) | ||
|
||
I18n.with_locale(entry.locale) do | ||
json.consent_vendors do | ||
json.array!(content_element_vendors.values.uniq) do |name| | ||
json.name name | ||
json.display_name t("pageflow_scrolled.consent_vendors.#{name}.name") | ||
json.description t("pageflow_scrolled.consent_vendors.#{name}.description") | ||
json.opt_in_prompt t("pageflow_scrolled.consent_vendors.#{name}.opt_in_prompt") | ||
json.paradigm 'lazy opt-in' | ||
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
16 changes: 16 additions & 0 deletions
16
entry_types/scrolled/config/locales/new/iframe_consent.de.yml
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,16 @@ | ||
de: | ||
pageflow_scrolled: | ||
editor: | ||
content_elements: | ||
iframeEmbed: | ||
attributes: | ||
requireConsent: | ||
label: "Datenschutz-Einwilligung aktivieren" | ||
inline_help: |- | ||
iframe erst laden, nachdem Besucher der | ||
Datenverarbeitung durch die eingebettete Seite | ||
zugestimmt hat. | ||
help_texts: | ||
missingConsentVendor: |- | ||
Für den Anbieter der angegeben URL stehen keine | ||
Datenschutzangaben zur Verfügung. |
15 changes: 15 additions & 0 deletions
15
entry_types/scrolled/config/locales/new/iframe_consent.en.yml
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,15 @@ | ||
en: | ||
pageflow_scrolled: | ||
editor: | ||
content_elements: | ||
iframeEmbed: | ||
attributes: | ||
requireConsent: | ||
label: "Display privacy opt-in" | ||
inline_help: | | ||
Only load iframe after the visitor has given | ||
consent to the data processing by the embedded page. | ||
help_texts: | ||
missingConsentVendor: |- | ||
No privacy policy information available for the provider | ||
of the given URL. |
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
38 changes: 38 additions & 0 deletions
38
entry_types/scrolled/lib/pageflow_scrolled/content_element_consent_vendors.rb
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,38 @@ | ||
module PageflowScrolled | ||
# Register consent vendors based on content element configuration | ||
# data. | ||
class ContentElementConsentVendors | ||
# @api private | ||
def initialize | ||
@callables = {} | ||
end | ||
|
||
# Register callable to determine consent vendor from configuration | ||
# attributes for a content element type. | ||
# | ||
# @param callable [#call] | ||
# Receives configuration keyword argument and returns | ||
# @param content_element_type_name [String] | ||
def register(callable, content_element_type_name:) | ||
@callables[content_element_type_name] = callable | ||
end | ||
|
||
# @api private | ||
def by_content_element_id(entry) | ||
content_elements_with_consent_vendor(entry).each_with_object({}) { |content_element, result| | ||
next unless @callables[content_element.type_name] | ||
|
||
result[content_element.id] = @callables[content_element.type_name].call( | ||
entry: entry, | ||
configuration: content_element.configuration | ||
) | ||
}.compact | ||
end | ||
|
||
private | ||
|
||
def content_elements_with_consent_vendor(entry) | ||
ContentElement.all_for_revision(entry.revision).where(type_name: @callables.keys) | ||
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
18 changes: 18 additions & 0 deletions
18
entry_types/scrolled/package/spec/editor/models/ConsentVendors-spec.js
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,18 @@ | ||
import {ConsentVendors} from 'editor/models/ConsentVendors'; | ||
|
||
describe('ConsentVendors', () => { | ||
describe('fromUrl', () => { | ||
it('detects vendor from seed data host matcher', () => { | ||
const consentVendors = new ConsentVendors({ | ||
hostMatchers: { | ||
'\\.some-vendor.com$': 'someVendor' | ||
} | ||
}); | ||
|
||
expect(consentVendors.fromUrl('https://foo.some-vendor.com/abc')) | ||
.toEqual('someVendor'); | ||
expect(consentVendors.fromUrl('https://other.com/abc')) | ||
.toBeUndefined(); | ||
}); | ||
}) | ||
}) |
33 changes: 33 additions & 0 deletions
33
entry_types/scrolled/package/spec/entryState/consentVendors-spec.js
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,33 @@ | ||
import {useContentElementConsentVendor} from 'entryState'; | ||
|
||
import {renderHookInEntry} from 'support'; | ||
|
||
describe('useContentElementConsentVendor', () => { | ||
it('reads data from seed', () => { | ||
const {result} = renderHookInEntry( | ||
() => useContentElementConsentVendor({contentElementId: 10}), { | ||
seed: { | ||
consentVendors: [{name: 'someVendor', displayName: 'Some Vendor'}], | ||
contentElementConsentVendors: {10: 'someVendor'}, | ||
contentElements: [{id: 10}] | ||
} | ||
} | ||
); | ||
|
||
const data = result.current; | ||
expect(data).toMatchObject({name: 'someVendor', displayName: 'Some Vendor'}); | ||
}); | ||
|
||
it('returns undefined if content element does not have consent vendor', () => { | ||
const {result} = renderHookInEntry( | ||
() => useContentElementConsentVendor({contentElementId: 1}), { | ||
seed: { | ||
contentElements: [{id: 1}] | ||
} | ||
} | ||
); | ||
|
||
const data = result.current; | ||
expect(data).toBeUndefined(); | ||
}); | ||
}); |
Oops, something went wrong.