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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

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?

@@ -68,6 +70,13 @@ public function handle(AddAttributeCommand $command): AttributeId

$id = $this->attributeRepository->add($attribute);

if (file_exists($command->getTextureFilePath())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be the uploader that checks if the file exists, the handler is only here to check if the data exists (if it's not null) Besides I'm not sure but maybe file_exists doesn't like null input?

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 :)

Comment on lines +37 to +41
try {
move_uploaded_file($filePath, _PS_IMG_DIR_ . 'co/' . $id . '.jpg');
} catch (FileException $e) {
throw new AttributeUploadFailedException(sprintf('Failed to copy the file %s.', $filePath));
}
Copy link
Member

Choose a reason for hiding this comment

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

move_uploaded_file function doesn't throw exceptions and return boolean if it worked or not, but anyway for testing purpose, we can't change the try catch with a condition... So, is ok for now but we need to change all this type of lines!

Comment on lines +39 to +53
/**
* @var GridDataFactoryInterface
*/
private $attributeDataFactory;

private ImageFolderProvider $imageFolderProvider;

/**
* @param GridDataFactoryInterface $attributeDataFactory
*/
public function __construct(GridDataFactoryInterface $attributeDataFactory, ImageFolderProvider $imageFolderProvider)
{
$this->attributeDataFactory = $attributeDataFactory;
$this->imageFolderProvider = $imageFolderProvider;
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we use properties promotion here?

@@ -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?

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
Projects
Status: Reopened
Development

Successfully merging this pull request may close these issues.

Regression on the migrated Attributes pages
5 participants