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
Allow removing locales #15026
Allow removing locales #15026
Conversation
3eeac41
to
e54d117
Compare
I don't really see a point in limiting it only to CLI, UX-wise. The situation would be completely different if we actually allowed deleting locales that are used, which we don't. I'd be for changing this to solution 2, but without the conditional showing of the button, and just keeping it in line with other resources that sometimes cannot be deleted (show an error flash and leave the resource be) |
I have not commented before, but after thinking about it and the comment from @NoResponseMate, I would also favour the second option. To add the ability to delete only unused locales in the admin panel, I don't really see any real benefit from adding this functionality to the CLI only 🤔 I am also interested in other opinions |
Refactored 👯♂️. I see behats are failing, but you can still review 🕺🏻. |
7a953bc
to
49fa194
Compare
src/Sylius/Bundle/AdminBundle/Resources/config/services/controller.xml
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/AdminBundle/Controller/Locale/DeleteLocaleAction.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Controller/Locale/DeleteLocaleAction.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/services/controller_locale.xml
Outdated
Show resolved
Hide resolved
$repository = $this->entityManager->getRepository($translationEntityInterface); | ||
|
||
return $repository->count(['locale' => $localeCode]) > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a lot of additional queries for simple delete. We would request up to n queries equal to the number of translatable entities in the system. Can't we base it on ForeignKeyConstraintViolationException
or something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no foreign key to sylius_locale
.
I know it might seem like many queries, but:
- Removing a locale is not a standard action for e-commerce (usually, store administrators don't delete a locale every morning)
- This operation might be performed by a small group of people
- In the best scenario it'd be only 1 query, at worst a number of
*Translation
entities.
I believe it won't affect any store.
@lchrusciel all changed applied. |
7395a6e
to
1c20c54
Compare
@@ -56,6 +56,7 @@ api_platform: | |||
Sylius\Bundle\ApiBundle\Exception\ShippingMethodCannotBeRemoved: 422 | |||
Sylius\Bundle\ApiBundle\Exception\ZoneCannotBeRemoved: 422 | |||
Sylius\Bundle\ApiBundle\Exception\CannotRemoveMenuTaxonException: 409 | |||
Sylius\Bundle\LocaleBundle\Checker\Exception\LocaleIsUsedException: 422 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt?
Sylius\Bundle\LocaleBundle\Checker\Exception\LocaleIsUsedException: 422 | |
Sylius\Bundle\LocaleBundle\Checker\Exception\LocaleInUseException: 422 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we don't have any standard for this, I don't have any strong opinion. I guess both names are correct.
I left the initial name, but I'm leaving this suggestion unresolved for any other opinions.
f53491e
to
13c5655
Compare
13c5655
to
fb9da05
Compare
Thank you, Jacob! 🎉 |
Only unused locales can be removed. If a locale appears in any translation, automatically, it cannot be removed.