-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Custom Privacy Text Option to CTAs (#12293)
* Update CTA model to add richtext privacy_text * Update templates to take advantage of new privacy_text when referencing a cta, or provide empty string if default * Create new privacy notice js module * Update newsletter signup component to render custom privacy text or default privacy text if no custom privacy text found * CSS tweak to sync formassembly styling of richtext custom privacy text on petition pages * Change to quotes * Though not necessary to abstract to form-specific-style.js, we can reduce duplicate code a bit * linting * additional formatting * Fix richtext filter * Move tailwind classes to formassembly override scss * Move conditional block and remove duplicate line * Add data-cta-privacy-notice attribute or empty where possible, single quote for rich text filter * Switch to | escape * Remove stray quote, update migration to account for merge with main * Move label logic to privacy-notice.jsx * Update documentation for formassembly
- Loading branch information
1 parent
2629ad3
commit fcb5f03
Showing
19 changed files
with
117 additions
and
13 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
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
30 changes: 30 additions & 0 deletions
30
...i/networkapi/wagtailpages/migrations/0137_blogsignup_privacy_notice_cta_privacy_notice.py
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,30 @@ | ||
# Generated by Django 4.2.11 on 2024-05-28 18:33 | ||
|
||
import wagtail.fields | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("wagtailpages", "0136_alter_donationmodal_body_richtext"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="blogsignup", | ||
name="privacy_notice", | ||
field=wagtail.fields.RichTextField( | ||
blank=True, | ||
help_text="This optional privacy notice field will overwrite the default privacy notice text. If this field is left blank, the default privacy notice text is used.", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="cta", | ||
name="privacy_notice", | ||
field=wagtail.fields.RichTextField( | ||
blank=True, | ||
help_text="This optional privacy notice field will overwrite the default privacy notice text. If this field is left blank, the default privacy notice text is used.", | ||
), | ||
), | ||
] |
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
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
32 changes: 32 additions & 0 deletions
32
source/js/components/newsletter-signup/atoms/privacy-notice.jsx
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,32 @@ | ||
import React from "react"; | ||
import { getText } from "../../petition/locales"; | ||
import PropTypes from "prop-types"; | ||
|
||
const PrivacyNotice = ({ content, classes }) => { | ||
//[TODO] Investigate removing the legacy richtext template which renders an empty rich-text div wrapper | ||
// Jira TP1-601 / Github Issue #12285 https://github.com/MozillaFoundation/foundation.mozilla.org/issues/12285 | ||
if (!content || content == "<div class='rich-text'></div>") { | ||
content = getText( | ||
`I'm okay with Mozilla handling my info as explained in this Privacy Notice` | ||
); | ||
} | ||
if (typeof content === "string") { | ||
return ( | ||
<span | ||
dangerouslySetInnerHTML={{ | ||
__html: content, | ||
}} | ||
className={classes} | ||
/> | ||
); | ||
} | ||
|
||
return <span className={classes}>{content}</span>; | ||
}; | ||
|
||
PrivacyNotice.propTypes = { | ||
content: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired, | ||
classes: PropTypes.string, | ||
}; | ||
|
||
export default PrivacyNotice; |
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