diff --git a/package.json b/package.json index c26b52a2b..015826480 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "volto-editablefooter": "5.0.1", "volto-feedback": "0.1.5", "volto-form-block": "3.1.0", - "volto-gdpr-privacy": "2.1.0", + "volto-gdpr-privacy": "2.1.1", "volto-google-analytics": "2.0.0", "volto-multilingual-widget": "3.0.0", "volto-querywidget-with-browser": "0.4.0", diff --git a/src/customizations/volto-gdpr-privacy/components/ConditionalEmbed/ConditionalEmbed.jsx b/src/customizations/volto-gdpr-privacy/components/ConditionalEmbed/ConditionalEmbed.jsx deleted file mode 100644 index b0f7326c1..000000000 --- a/src/customizations/volto-gdpr-privacy/components/ConditionalEmbed/ConditionalEmbed.jsx +++ /dev/null @@ -1,135 +0,0 @@ -/* -CUSTOMIZATIONS - - permit render if server, cannot use in history diff otherwise -*/ - -import React, { useEffect, useState } from 'react'; -import { useSelector, useDispatch } from 'react-redux'; -import { useIntl, defineMessages } from 'react-intl'; -import { useLocation } from 'react-router-dom'; -import { - displayBanner, - updateGdprPrivacyConsent, -} from 'volto-gdpr-privacy/actions'; - -import { - usePanelConfigAndPreferences, - GDPRCookies, - getLocaleConf, -} from 'volto-gdpr-privacy/helpers'; - -import 'volto-gdpr-privacy/components/ConditionalEmbed/conditional-embed.css'; - -const messages = defineMessages({ - conditionalEmbedAcceptCookiesDefaultDescription: { - id: 'volto-gdpr-privacy-conditional-embed-default-description', - defaultMessage: - 'Please, accept {cookie_type} cookies to view this content.', - }, - conditionalEmbedAcceptCookiesAcceptMessage: { - id: 'volto-gdpr-privacy-conditional-embed-accept-message', - defaultMessage: '{enable_cookie_button}, or {manage_preferences_button}', - }, - specificCookieLink: { - id: 'volto-gdpr-privacy-conditional-embed-specific-cookie-link', - defaultMessage: 'Enable {cookie_type} cookies', - }, - genericCookieLink: { - id: 'volto-gdpr-privacy-conditional-embed-generic-cookie-link', - defaultMessage: 'manage your cookie preferences', - }, -}); -const ConditionalEmbed = ({ code, url, children }) => { - const intl = useIntl(); - const cookies = new GDPRCookies(); - const embed = code ?? url ?? ''; - const dispatch = useDispatch(); - const location = useLocation(); - - const { defaultPreferences } = usePanelConfigAndPreferences(cookies); - const profilingConfig = useSelector((state) => - state.gdprPrivacyConfig?.config?.profiling?.choices?.filter( - (c) => c?.referenceUrls?.length > 0, - ), - ); - const gdprPreferences = useSelector( - (state) => state.gdprPrivacyConsent.preferences ?? defaultPreferences, - ); - const [urlReferenceConfig, setUrlReferenceConfig] = useState(null); - - useEffect(() => { - if (profilingConfig && !urlReferenceConfig) { - let conditionalConfig = profilingConfig.filter( - (c) => - c.referenceUrls.filter((r) => embed?.indexOf(r) >= 0)?.length > 0, - ); - - setUrlReferenceConfig(conditionalConfig?.[0] ?? null); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [profilingConfig, setUrlReferenceConfig, urlReferenceConfig, embed]); - - //return value - let ret = <>>; - let embedDisabled = true; - - embedDisabled = - urlReferenceConfig != null && - !gdprPreferences[urlReferenceConfig.config_key]; - const isDiffView = location.pathname?.includes('/diff'); - if (__CLIENT__ && !gdprPreferences && !isDiffView) { - return <>>; - } else if (embedDisabled && !isDiffView) { - //embed disabled - const text = getLocaleConf(urlReferenceConfig.text, intl.locale); - const key = urlReferenceConfig.config_key; - ret = ( -