mautic icon indicating copy to clipboard operation
mautic copied to clipboard

Batch email change category

Open mchojrin opened this issue 1 year ago • 16 comments

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 mautic/user-documentation#...
Related developer documentation PR URL mautic/developer-documentation-new#...
Issue(s) addressed Fixes #...

Description

This PR addresses the feature discussed here:

To allow changing the email category for multiple messages at a time.

The UI looks like this:

image image


📋 Steps to test this PR:

  1. Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs here)
  2. Login
  3. Go to /s/emails
  4. If you don't have any email written create a few and put them in different categories
  5. From the email list, select some
  6. Click on the batch actions menu
  7. Select Change Category
  8. Select a category
  9. Save
  10. Refresh the page
  11. Every previously selected email should belong to the selected category

mchojrin avatar Aug 20 '24 13:08 mchojrin

@mchojrin Hey, is this ready for testing?

andersonjeccel avatar Aug 20 '24 14:08 andersonjeccel

@andersonjeccel I think so... I run the tests and they're all passing. Is there any other requirement prior to testing?

mchojrin avatar Aug 20 '24 19:08 mchojrin

Got it!

The main step to have other devs reviewing is to properly fill the description

yeah, it’s boring but contains the minimum basic they need to know about the code (I’ve been creating ~175 PRs for Mautic in the last 6 months, believe me that it’s needed)

would you be up for that? (then I can assign some people to review and the right labels)

andersonjeccel avatar Aug 20 '24 21:08 andersonjeccel

@andersonjeccel sure, no problem. I'll get to it ;)

mchojrin avatar Aug 21 '24 07:08 mchojrin

There, @andersonjeccel is this good?

mchojrin avatar Aug 21 '24 07:08 mchojrin

@mchojrin Perfect, thanks!


I tested the PR here and got an error, have a look:

https://github.com/user-attachments/assets/4860be2b-a47f-4cef-b527-7f30735b6238

Steps I tried:

  1. Go to Emails, create new and select the theme Brienz
  2. Fill subject and name using Email 16/07/2024, 08:40:24 then Save & Close
  3. Go to Categories, create new and go back to Emails
  4. Select using the Select all checkbox, open the dropdown and click Change category
  5. Select the new category and click Save
  6. The message will appear

Do you have any idea why?

andersonjeccel avatar Aug 21 '24 12:08 andersonjeccel

@andersonjeccel I just tried the exact steps you mentioned and it worked alright... Maybe you need to refresh the cache?

mchojrin avatar Aug 21 '24 14:08 mchojrin

@mchojrin Hm, tried both prod and dev environments... After clearing the cache by manually deleting the cache folder and running ddev exec bin/console cache:clear, it starts showing this way:

image

It's a clean DDEV install (including database)

Then tried on Gitpod:

image

image

What if you try to clear your cache? Perhaps the issue might appear

andersonjeccel avatar Aug 21 '24 14:08 andersonjeccel

@andersonjeccel wow.. ok.. I'll try to test in different environments and get back here.

Thanks!

mchojrin avatar Aug 21 '24 15:08 mchojrin

I hope we can solve, there was a lot of your work on it :) call me if you need something

andersonjeccel avatar Aug 21 '24 16:08 andersonjeccel

Hey @andersonjeccel just tried again clearing the local cache and on a fresh new gitpod and couldn't reproduce.

Here's my video

I did not an unexpected behaviour that I'll address though, the select category modal is showing all available categories instead of only email ones.

I'll leave the gitpod up if you want to try it https://8080-mchojrin-mautic-b5nqmcv3vbe.ws-eu115.gitpod.io/s/emails

mchojrin avatar Aug 22 '24 07:08 mchojrin

I just checked my code and it is applying the filter by email bundle to the categories shown... perhaps it's a problem with \Mautic\CategoryBundle\Entity\CategoryRepository::getCategoryList?

mchojrin avatar Aug 22 '24 07:08 mchojrin

@escopecz @kuzmany Would you like to have a look?

andersonjeccel avatar Aug 22 '24 12:08 andersonjeccel

@escopecz @shinde-rahul nice to see you checking here! thanks for your time

is the PR test working for you? even after those changes, I still get the same 500 Internal Server Error - PHP Warning - Undefined property: Mautic\EmailBundle\Model\EmailModel::$getRepository

  • Tried to run composer install again
  • Cleared cache manually
  • Removed var/cache completely

All with no success :/ I'm using PHP Version 8.3.10

andersonjeccel avatar Aug 23 '24 12:08 andersonjeccel

Ok, I think I fixed every point if anyone else wants to take a look

mchojrin avatar Aug 25 '24 13:08 mchojrin

image

It's working now, showing only email-specific categories for selection and the change is visible immediately after applying!

@mchojrin Tell me when the PR is finished (probably needs only the PHPUnit test to finish as John said)

andersonjeccel avatar Aug 26 '24 12:08 andersonjeccel

Codecov Report

Attention: Patch coverage is 30.35714% with 39 lines in your changes missing coverage. Please review.

Project coverage is 62.88%. Comparing base (a994b57) to head (e0e9f9e). Report is 2 commits behind head on 5.x.

Files with missing lines Patch % Lines
...es/EmailBundle/Controller/BatchEmailController.php 0.00% 23 Missing :warning:
...undles/EmailBundle/Form/Type/BatchCategoryType.php 0.00% 15 Missing :warning:
...bundles/EmailBundle/Controller/EmailController.php 0.00% 1 Missing :warning:
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                5.x   #14067      +/-   ##
============================================
- Coverage     62.90%   62.88%   -0.02%     
- Complexity    34417    34435      +18     
============================================
  Files          2264     2267       +3     
  Lines        102966   103020      +54     
============================================
+ Hits          64770    64789      +19     
- Misses        38196    38231      +35     
Files with missing lines Coverage Δ
app/bundles/EmailBundle/Model/EmailActionModel.php 100.00% <100.00%> (ø)
app/bundles/EmailBundle/Model/EmailModel.php 53.29% <100.00%> (ø)
...bundles/EmailBundle/Controller/EmailController.php 59.08% <0.00%> (ø)
...undles/EmailBundle/Form/Type/BatchCategoryType.php 0.00% <0.00%> (ø)
...es/EmailBundle/Controller/BatchEmailController.php 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

codecov[bot] avatar Sep 13 '24 11:09 codecov[bot]

Hey @escopecz I had some issues with ddev, I think I got it all sorted out now so hopefully I'll be able to fix the test soon

mchojrin avatar Sep 19 '24 07:09 mchojrin

I fixed the E2E test, it broke because of changes to the UI... I tried to use element ids as much as possible to avoid this problem but I'm afraid I'll still happen for those elements that don't have one (Such as the batch action menu for emails).

Github is reporting a conflict in the app/bundles/LeadBundle/Translations/en_US/messages.ini that I'm not sure how to solve...

mchojrin avatar Sep 19 '24 08:09 mchojrin

I resolved the conflict by keeping the translation for both branches.

escopecz avatar Sep 19 '24 10:09 escopecz

BTW, if there is an ID or a class missing on an HTML element, feel free to add it. It helps not only to have more stable tests but also the UI team as they can target that HTML element.

escopecz avatar Sep 19 '24 10:09 escopecz

BTW, if there is an ID or a class missing on an HTML element, feel free to add it. It helps not only to have more stable tests but also the UI team as they can target that HTML element.

Makes sense :)

I guess I'll keep that in mind moving forward so this PR can finally be integrated.

Thanks!

mchojrin avatar Sep 19 '24 10:09 mchojrin

@all-contributors please add @mchojrin for code.

Thanks so much for the contribution @mchojrin and welcome to the community!

In the future it'd be nice to add this kind of behaviour to our user docs but at present we don't have anything about working with list view even, so we're good to merge without it for now.

RCheesley avatar Sep 27 '24 14:09 RCheesley

@RCheesley

I've put up a pull request to add @mchojrin! :tada:

allcontributors[bot] avatar Sep 27 '24 14:09 allcontributors[bot]

@mchojrin could you please validate a bug that these changes might have introduced? https://github.com/mautic/mautic/issues/14323

escopecz avatar Dec 05 '24 13:12 escopecz