Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing Merge button from Add New Company View #13679

Open
wants to merge 3 commits into
base: 5.x
Choose a base branch
from

Conversation

nishant-s7
Copy link

Q A
Bug fix? (use the a.b branch) [x]
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/mautic-documentation#...
Related developer documentation PR URL mautic/developer-documentation#...
Issue(s) addressed Fixes #13416

Description:

This PR removes the redundant Merge button when creating a new company, which makes sure the incorrect modal with "New" button (as mentioned in the issue) is not displayed.
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. Go to Companies and click on New.
  3. In the top-right toolbar, verify that the Merge button is not displayed when creating a new company, but, it is visible once the company is saved, showing the correct modal on clicking it.

@nishant-s7 nishant-s7 changed the title Removing **Merge** button from Add New Company View Removing Merge button from Add New Company View Apr 20, 2024
Copy link
Contributor

@andersonjeccel andersonjeccel left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this! 👍🏻

@andersonjeccel andersonjeccel added T1 Low difficulty to fix (issue) or test (PR) bug Issues or PR's relating to bugs ready-to-test PR's that are ready to test code-review-needed PR's that require a code review before merging user-experience Anything related to related to workflows, feedback, and navigation companies Anything related to companies labels Apr 20, 2024
@@ -209,7 +209,7 @@ public function newAction(Request $request, $entity = null)
$leadFieldModel = $this->getModel('lead.field');
\assert($leadFieldModel instanceof FieldModel);
$fields = $leadFieldModel->getPublishedFieldArrays('company');
$form = $model->createForm($entity, $this->formFactory, $action, ['fields' => $fields, 'update_select' => $updateSelect]);
$form = $model->createForm($entity, $this->formFactory, $action, ['fields' => $fields, 'update_select' => $updateSelect, 'hide_extra_buttons' => true]);
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

  1. Let's call it what it really does.
  2. Let's avoid double negatives as those are hard to comprehend and break my brain (like hide = false)
Suggested change
$form = $model->createForm($entity, $this->formFactory, $action, ['fields' => $fields, 'update_select' => $updateSelect, 'hide_extra_buttons' => true]);
$form = $model->createForm($entity, $this->formFactory, $action, ['fields' => $fields, 'update_select' => $updateSelect, 'show_merge_button' => false]);

Or, perhaps we could avoid this extra config option altogether if we'd base the condition if the company ID exists or not?

Copy link
Author

Choose a reason for hiding this comment

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

Yes! I'll do the change

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.30%. Comparing base (714ba98) to head (01a42f4).
Report is 11 commits behind head on 5.x.

❗ Current head 01a42f4 differs from pull request most recent head 36fb957. Consider uploading reports for the commit 36fb957 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                5.x   #13679      +/-   ##
============================================
- Coverage     61.39%   61.30%   -0.09%     
+ Complexity    34034    34006      -28     
============================================
  Files          2240     2238       -2     
  Lines        101714   101652      -62     
============================================
- Hits          62443    62318     -125     
- Misses        39271    39334      +63     
Files Coverage Δ
...undles/LeadBundle/Controller/CompanyController.php 48.06% <100.00%> (ø)
app/bundles/LeadBundle/Form/Type/CompanyType.php 86.66% <100.00%> (+0.95%) ⬆️

... and 23 files with indirect coverage changes

Copy link
Contributor

@shinde-rahul shinde-rahul left a comment

Choose a reason for hiding this comment

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

]
),

if (null === $options['data']->id) {
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Are you sure this will work? On the line 117 I can see it's accessed as $options['data']->getId()

Copy link
Author

Choose a reason for hiding this comment

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

It did work when I logged it, I also checked for the expected behavior and it worked fine. Should I change it to getId() to be on the safer side?

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

There is some Twig magic where it looks if the property exists, if not it tries if getId() exists and if so it will use that. I'd prefer to use directly the entity method than the magic.

Suggested change
if (null === $options['data']->id) {
if (null === $options['data']->getId()) {

Copy link
Member

@kuzmany kuzmany left a comment

Choose a reason for hiding this comment

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

Works for me 👍

@LordRembo LordRembo added pending-test-confirmation PR's that require one test before they can be merged and removed ready-to-test PR's that are ready to test labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs code-review-needed PR's that require a code review before merging companies Anything related to companies pending-test-confirmation PR's that require one test before they can be merged T1 Low difficulty to fix (issue) or test (PR) user-experience Anything related to related to workflows, feedback, and navigation
Projects
Status: 🚨 Developer revision needed
Status: Done
Development

Successfully merging this pull request may close these issues.

[UX] Redundant “New” button in Companies Merge modal
6 participants