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

Add texture in attribute color #36068

Merged
merged 3 commits into from
May 29, 2024

Conversation

tleon
Copy link
Contributor

@tleon tleon commented May 2, 2024

Questions Answers
Branch? develop
Description? The texture box was not doing anyting and seemed no to be migrated from old page..
Type? bug fix
Category? BO
BC breaks? no
Deprecations? no
How to test? See #35591 bug 6
UI Tests https://github.com/tleon/ga.tests.ui.pr/actions/runs/9117701983
Fixed issue or discussion? Fixes #35591
Sponsor company PrestaShop SA

@tleon tleon self-assigned this May 2, 2024
@prestonBot
Copy link
Collaborator

Hi, thanks for this contribution!

I found some issues with the Pull Request description:

  • Your pull request does not seem to fix any issue, consider creating one (see note below) and linking it by writing Fixes #1234.

Would you mind having a look at it? This will help us understand how interesting your contribution is, thank you very much!

About linked issues

Please consider opening an issue before submitting a Pull Request:

  • If it's a bug fix, it helps maintainers verify that the bug is effectively due to a defect in the code, and that it hasn't been fixed already.
  • It can help trigger a discussion about the best implementation path before a single line of code is written.
  • It may lead the Core Product team to mark that issue as a priority, further attracting the maintainers' attention.

(Note: this is an automated message, but answering it will reach a real human)

@prestonBot prestonBot added develop Branch Bug fix Type: Bug fix labels May 2, 2024
@tleon tleon force-pushed the Issue-35591-bug-6-cant-add-texture branch 2 times, most recently from cd6b774 to 8eb24f9 Compare May 2, 2024 13:37
@tleon tleon marked this pull request as ready for review May 2, 2024 14:29
@tleon tleon requested a review from a team as a code owner May 2, 2024 14:29
@tleon tleon changed the title fix(bo): add texture in attribute color Add texture in attribute color May 2, 2024
nicosomb
nicosomb previously approved these changes May 2, 2024
Copy link
Contributor

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

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

Thanks @tleon

all good for the grid part, the format part however shouldn't handle the upload in the controller, it must be the responsibility of the CQRS commands

@tleon tleon force-pushed the Issue-35591-bug-6-cant-add-texture branch 2 times, most recently from 388198d to 8a0bffa Compare May 16, 2024 16:12
@tleon tleon requested review from jolelievre and nicosomb May 20, 2024 07:14
nicosomb
nicosomb previously approved these changes May 20, 2024
Copy link
Contributor

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

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

Thanks @tleon

A few comments here and there. However I have a question, do we need the possibility to remove a texture that was previously uploaded in the form? Because it seems like the command can handle the replacement of an image, but not the removal no?

@tleon tleon force-pushed the Issue-35591-bug-6-cant-add-texture branch from 8a0bffa to 4c6a82f Compare May 20, 2024 13:09
@tleon tleon closed this May 20, 2024
@tleon tleon reopened this May 20, 2024
Copy link
Contributor

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

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

Thanks @tleon

just one last comment about what the responsibility between the handler and the uploader service. And you didn't answer my question about about the removal of a texture is handled?

Copy link
Member

@boherm boherm left a comment

Choose a reason for hiding this comment

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

LGTM, just few comments :)

src/Adapter/File/Uploader/AttributeFileUploader.php Outdated Show resolved Hide resolved
src/Core/Grid/Data/Factory/AttributeGridDataFactory.php Outdated Show resolved Hide resolved
@@ -15,3 +15,5 @@ services:
PrestaShop\PrestaShop\Adapter\Attribute\CommandHandler\EditAttributeHandler: ~
PrestaShop\PrestaShop\Adapter\Attribute\QueryHandler\GetAttributeForEditingHandler: ~
PrestaShop\PrestaShop\Adapter\Attribute\Validate\AttributeValidator: ~
PrestaShop\PrestaShop\Adapter\File\Uploader\AttributeFileUploader: ~
PrestaShop\PrestaShop\Core\Domain\AttributeGroup\Attribute\AttributeFileUploaderInterface: ~
Copy link
Member

Choose a reason for hiding this comment

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

I think this isn't necessary, no?

@tleon tleon force-pushed the Issue-35591-bug-6-cant-add-texture branch from 4c6a82f to aa97822 Compare May 24, 2024 15:00
Copy link
Contributor

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

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

Just a suggestion to use existing const for this folder, not mandatory though

{
try {
if (file_exists($filePath)) {
move_uploaded_file($filePath, _PS_IMG_DIR_ . 'co/' . $id . '.jpg');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
move_uploaded_file($filePath, _PS_IMG_DIR_ . 'co/' . $id . '.jpg');
move_uploaded_file($filePath, _PS_COL_IMG_DIR_ . $id . '.jpg');

Comment on lines +48 to +49
if (file_exists(_PS_IMG_DIR_ . 'co/' . $id . '.jpg')) {
unlink(_PS_IMG_DIR_ . 'co/' . $id . '.jpg');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (file_exists(_PS_IMG_DIR_ . 'co/' . $id . '.jpg')) {
unlink(_PS_IMG_DIR_ . 'co/' . $id . '.jpg');
if (file_exists(_PS_COL_IMG_DIR_ . $id . '.jpg')) {
unlink(_PS_COL_IMG_DIR_ . $id . '.jpg');

private function modifyRecords(array $records): array
{
foreach ($records as &$record) {
if (file_exists(_PS_IMG_DIR_ . 'co/' . (int) $record['id_attribute'] . '.jpg')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (file_exists(_PS_IMG_DIR_ . 'co/' . (int) $record['id_attribute'] . '.jpg')) {
if (file_exists(_PS_COL_IMG_DIR_ . (int) $record['id_attribute'] . '.jpg')) {

Copy link
Contributor

@matks matks left a comment

Choose a reason for hiding this comment

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

LGTM

@ps-jarvis ps-jarvis added the Waiting for QA Status: action required, waiting for test feedback label May 28, 2024
@paulnoelcholot
Copy link

Hello @tleon,

I tested your PR and it's OK for me! 🎉

Thanks!

image

@paulnoelcholot paulnoelcholot added QA ✔️ Status: check done, code approved and removed Waiting for QA Status: action required, waiting for test feedback labels May 29, 2024
@ps-jarvis
Copy link

QA approved, well done! Message to the maintainers: do not forget to milestone it before the merge.

@boherm boherm added this to the 9.0.0 milestone May 29, 2024
@tleon tleon merged commit 444feff into PrestaShop:develop May 29, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug fix Type: Bug fix develop Branch QA ✔️ Status: check done, code approved
Projects
Status: To be tested
Development

Successfully merging this pull request may close these issues.

Regression on the migrated Attributes pages
8 participants