Skip to content

Conversation

nileshlohar
Copy link
Contributor

Q A
Bug fix? (use the a.b branch)
New feature/enhancement? (use the a.x branch) ✔️
Deprecations?
BC breaks? (use the c.x branch)
Automated tests included? ✔️
Related user documentation PR URL
Related developer documentation PR URL
Issue(s) addressed

Description

Adds new type field in DWC with options as text and html, based on this selection, the content can either be Text or HTML.

It also adds below validations:

  • While saving an email with a DWC token in subject line, validates if the token is of Text type. If not, thros an error in UI and does not allow to save.
  • Adds a validation while Creating/Updating a DWC that all the variations with same slot name need to be of the same type.

📋 Steps to test this PR:

  1. Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs here)
  2. New field Type should be available in add/edit DWC form
  3. New field value should be saved properly at time of Add/Edit
  4. In email subject only text type DWC token (when added in format - {dwc=slot-name}) should be supported otherwise error message should be displayed.
  5. On DWC create/edit form test a validation to make sure All Dynamic Contents with the same slot name must be of the same type.

@nileshlohar nileshlohar requested a review from Copilot March 19, 2025 12:23
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new "Type" field in Dynamic Web Content to differentiate between text and HTML content and adds validations and UI behavior based on the selected type.

  • Added a toggleContentEditor function in dynamicContent.js to initialize or destroy CKEditor instances based on the type field.
  • Updated CKEditor toolbar configuration in 1a.content.js to use a globally defined MauticVars.maxButtons array.

Reviewed Changes

Copilot reviewed 5 out of 23 changed files in this pull request and generated no comments.

File Description
app/bundles/DynamicContentBundle/Assets/js/dynamicContent.js Added toggleContentEditor to handle CKEditor initialization/destroying.
app/bundles/CoreBundle/Assets/js/1a.content.js Refactored toolbar configuration to use the global MauticVars.maxButtons.
Files not reviewed (18)
  • app/bundles/DynamicContentBundle/Config/config.php: Language not supported
  • app/bundles/DynamicContentBundle/DynamicContent/TypeList.php: Language not supported
  • app/bundles/DynamicContentBundle/Entity/DynamicContent.php: Language not supported
  • app/bundles/DynamicContentBundle/Form/Type/DynamicContentType.php: Language not supported
  • app/bundles/DynamicContentBundle/Model/DynamicContentModel.php: Language not supported
  • app/bundles/DynamicContentBundle/Resources/views/DynamicContent/form.html.twig: Language not supported
  • app/bundles/DynamicContentBundle/Tests/Form/Type/DynamicContentTypeTest.php: Language not supported
  • app/bundles/DynamicContentBundle/Tests/Validator/Constraints/SlotNameTypeValidatorTest.php: Language not supported
  • app/bundles/DynamicContentBundle/Translations/en_US/messages.ini: Language not supported
  • app/bundles/DynamicContentBundle/Translations/en_US/validators.ini: Language not supported
  • app/bundles/DynamicContentBundle/Validator/Constraints/SlotNameType.php: Language not supported
  • app/bundles/DynamicContentBundle/Validator/Constraints/SlotNameTypeValidator.php: Language not supported
  • app/bundles/DynamicContentBundle/Validator/Constraints/TypeChoice.php: Language not supported
  • app/bundles/DynamicContentBundle/Validator/Constraints/TypeChoiceValidator.php: Language not supported
  • app/bundles/EmailBundle/Config/config.php: Language not supported
  • app/bundles/EmailBundle/Entity/Email.php: Language not supported
  • app/bundles/EmailBundle/Tests/Controller/EmailControllerFunctionalTest.php: Language not supported
  • app/bundles/EmailBundle/Translations/en_US/validators.ini: Language not supported
Comments suppressed due to low confidence (2)

app/bundles/DynamicContentBundle/Assets/js/dynamicContent.js:147

  • Ensure that the global variable ckEditors is defined before checking its size to prevent potential runtime errors if the load order of scripts changes.
if (ckEditors.size > 0) {

app/bundles/DynamicContentBundle/Assets/js/dynamicContent.js:148

  • [nitpick] Consider using an arrow function instead of a traditional function expression for consistency with ES6 syntax throughout the codebase.
ckEditors.forEach(function(value, key, map){

Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 93.05556% with 5 lines in your changes missing coverage. Please review.

Project coverage is 64.94%. Comparing base (bad47fb) to head (c116e44).
Report is 267 commits behind head on 7.x.

Files with missing lines Patch % Lines
...le/Validator/Constraints/SlotNameTypeValidator.php 86.66% 2 Missing ⚠️
...ndle/Validator/TextOnlyDynamicContentValidator.php 84.61% 2 Missing ⚠️
...DynamicContentBundle/Model/DynamicContentModel.php 92.30% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                7.x   #14759      +/-   ##
============================================
+ Coverage     64.77%   64.94%   +0.16%     
- Complexity    34831    34847      +16     
============================================
  Files          2289     2293       +4     
  Lines        103954   103932      -22     
============================================
+ Hits          67340    67497     +157     
+ Misses        36614    36435     -179     
Files with missing lines Coverage Δ
...s/DynamicContentBundle/DynamicContent/TypeList.php 100.00% <100.00%> (ø)
...les/DynamicContentBundle/Entity/DynamicContent.php 85.54% <100.00%> (+10.70%) ⬆️
...amicContentBundle/Form/Type/DynamicContentType.php 96.29% <100.00%> (+0.50%) ⬆️
...ntentBundle/Validator/Constraints/SlotNameType.php 100.00% <100.00%> (ø)
app/bundles/EmailBundle/Entity/Email.php 92.05% <100.00%> (+0.01%) ⬆️
...DynamicContentBundle/Model/DynamicContentModel.php 77.20% <92.30%> (+1.59%) ⬆️
...le/Validator/Constraints/SlotNameTypeValidator.php 86.66% <86.66%> (ø)
...ndle/Validator/TextOnlyDynamicContentValidator.php 84.61% <84.61%> (ø)

... and 47 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nileshlohar nileshlohar requested review from a team, fedys and dadarya0 and removed request for a team March 19, 2025 12:28
Copy link
Member

@fedys fedys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nileshlohar! Please see my suggestions.

@nileshlohar nileshlohar requested a review from fedys March 21, 2025 11:15
@escopecz escopecz added enhancement Any improvement to an existing feature or functionality dynamic-content unforking Used for PRs in the Acquia's unforking initiative ready-to-test PR's that are ready to test labels Mar 23, 2025
Copy link
Member

@fedys fedys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nileshlohar for addressing my suggestions!

@escopecz escopecz added pending-test-confirmation PR's that require one test before they can be merged code-review-passed PRs which have passed code review and removed ready-to-test PR's that are ready to test labels Mar 27, 2025
@escopecz escopecz moved this to ⏳︎ Needs 1 more test in Open Source Fridays Mar 27, 2025
@dadarya0
Copy link
Contributor

Tested , working fine.
New field type is available and working fine on add/update Dynamic web content.
image

@dadarya0 dadarya0 added ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged and removed pending-test-confirmation PR's that require one test before they can be merged labels Mar 27, 2025
@escopecz escopecz merged commit 622a33f into mautic:7.x Mar 27, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this from ⏳︎ Needs 1 more test to 🥳 Done in Open Source Fridays Mar 27, 2025
@escopecz escopecz added this to the 7.0.0-alpha milestone Mar 27, 2025
@andersonjeccel
Copy link
Contributor

I found some potential issues with this implementation:

  1. When you first create a DC using type HTML, if you edit it to change to Text, it won't allow you (why?)
  2. When you pick Text type, all options for inserting into website keeps visible on details view (is this supposed to be this way? will it work?)
  3. There's no documentation explaining how these types work, I'd appreciate information to help me start improving UX

@escopecz @nileshlohar @dadarya0 @fedys Could you clarify how the feature works?

@nileshlohar
Copy link
Contributor Author

Hi @andersonjeccel,

  1. When you first create a DC using type HTML, if you edit it to change to Text, it won't allow you (why?)

This issue was fixed in - #14901

  1. When you pick Text type, all options for inserting into website keeps visible on details view (is this supposed to be this way? will it work?)

Which options you mean? Can you share more info or perhaps a screenshot ?

  1. There's no documentation explaining how these types work, I'd appreciate information to help me start improving UX

The Type field was introduced to differentiate Text Only DC, which can be used particularly in cases where it is embedded—for example, in an email subject.

@andersonjeccel
Copy link
Contributor

@nileshlohar Re. 1, got it

Re. 2:
When you create a Dynamic Content non-campaign-based currently, a slot generator appears when viewing its details for copy-pasting in your website (as the feature was previously about Web only)
This generator was introduced some months ago, before your PR

image

Questions that come in my mind:

  • Can text type be used on a website too, or only in emails?
  • Can the HTML type be used in emails, or should this be restricted for web use only?

Depending on the answers, we might need to update display conditions to avoid showing the generator for something users cannot use on the website (or maybe offer an additional option, the token, so they can insert in emails etc)

I'm just trying to understand how these types work and differ before making any UX changes

@escopecz
Copy link
Member

@andersonjeccel We have more PRs implementing DWC into emails that will be pushed soon if not already. There will be special token to add to emails. We should expand this UI with that new token in the PR that is adding it.

Both the text and HTML type can be used in both emails and pages. The text type is there for special cases like email subject that should not have any HTML markup as Nilesh pointed out.

@RCheesley
Copy link
Member

Hi @nileshlohar I am not seeing any documentation here for end-users or developers. We'll need to have the relevant changes made please. End user would be highest priority, we haven't ported over the dev docs quite yet (cc @mautic/education-team-leaders FYI).

Here's the end-user repo: https://github.com/mautic/user-documentation (I think this page is the most appropriate: https://docs.mautic.org/en/7.0/components/dynamic_web_content.html perhaps?)

Here's the developer docs repo: https://github.com/mautic/developer-documentation-new - I think we haven't brought over the DWC content yet, looks like this is the old docs: https://developer.mautic.org/#dynamic-content.

@RCheesley RCheesley added the needs-documentation PR's that need documentation before they can be merged label Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-review-passed PRs which have passed code review dynamic-content enhancement Any improvement to an existing feature or functionality needs-documentation PR's that need documentation before they can be merged ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged unforking Used for PRs in the Acquia's unforking initiative
Projects
Status: 🥳 Done
Development

Successfully merging this pull request may close these issues.

6 participants