Skip to content

Conversation

vovsky
Copy link
Contributor

@vovsky vovsky commented Aug 31, 2019

Description (*)

This PR adds ability to locate downloaded image in a file browser

Fixed Issues (if relevant)

  1. Locate saved preview image in Magento media gallery #359: Locate saved preview image in Magento media gallery

@magento-cicd2
Copy link

magento-cicd2 commented Aug 31, 2019

CLA assistant check
All committers have signed the CLA.

@vovsky vovsky changed the title #359: added Locate button for saved preview images #359: added Locate button for saved preview images (draft) Aug 31, 2019
@diazwatson
Copy link
Contributor

Hi @vovsky thanks for your contribution!
Could you please fix the static tests?

FILE: ...r/magento/module-adobe-stock-asset/Model/AddIsDownloadedToSearchResult.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 46 | ERROR | [x] Missing short description
 47 | ERROR | [x] There must be exactly one blank line before tags
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Hi @vovsky , welcome to Adobe Stock Integration project and thank you for your pull request!

I have an improvement suggestion regarding the attribute passed from backend to frontend to identify that image is downloaded, please take a look at my review comments.

Feel free to contact me on slack for more details

$attribute->setValue((int)in_array($item->getId(), $downloadedIds));

$customAttributes[self::ATTRIBUTE_CODE_IS_DOWNLOADED] = $attribute;
$item->setCustomAttributes($customAttributes);
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to add the downloaded path as a custom attribute and use this attribute to open the corresponding folder in media gallery during locate operation.

Copy link
Contributor Author

@vovsky vovsky Sep 11, 2019

Choose a reason for hiding this comment

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

@sivaschenko agree. I have made the changes, thank you. Locate feature works now

/**
* Class AddIsDownloadedToSearchResult
*/
class AddIsDownloadedToSearchResult
Copy link
Member

Choose a reason for hiding this comment

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

I would be good to use generic name for this service like AppendAttributes as later it could be reused to add additional information like is_licensed etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sivaschenko agree. I have made the changes, thank you

# Conflicts:
#	AdobeStockImageAdminUi/view/adminhtml/web/js/components/grid/column/image-preview.js
#	AdobeStockImageAdminUi/view/adminhtml/web/template/grid/column/image-preview.html
Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

@vovsky thanks for updates! Looks great! However, there is a specific case that is not handled by the implemented locate functionality. Please take a look at my comments

*
* @param record
*/
locate: function (record) {
Copy link
Member

Choose a reason for hiding this comment

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

that implementation considers only the filename. Images can be saved to different directories in the media gallery.

So after modal is closed it's needed to:

  • Divide the record.path to directory path and filename
  • Use directory path to open corresponding folder in media gallery
  • Use filename to select corresponding image

* @param SearchResultInterface $searchResult
* @return SearchResultInterface
*/
public function execute(SearchResultInterface $searchResult): SearchResultInterface
Copy link
Member

Choose a reason for hiding this comment

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

I'd extract a couple of private functions to make this class easier to read

@sivaschenko
Copy link
Member

Hi @vovsky can you please sign the Adobe CLA

@filmaj
Copy link
Contributor

filmaj commented Sep 25, 2019

FYI this can be done at opensource.adobe.com/cla.html

…obe-stock-integration into 359-locate-saved-preview-image

# Conflicts:
#	AdobeStockImageAdminUi/view/adminhtml/web/js/components/grid/column/image-preview.js
@vovsky vovsky changed the title #359: added Locate button for saved preview images (draft) #359: added Locate button for saved preview images Sep 27, 2019
Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Hi @vovsky , thanks for the updates! Please see my review comments.

}

if (count($itemIds)) {
$connection = $this->resourceConnection->getConnection();
Copy link
Member

Choose a reason for hiding this comment

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

Can you please move this select from adobe_stock_asset table to a separate class to be able to reuse that, and place this class in the ResourceModel namespace in order to indicate the access to the database. I'd suggest moving to \Magento\AdobeStockAsset\Model\ResourceModel\Asset\Load::execute(array $ids): array

Copy link
Member

Choose a reason for hiding this comment

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

It would also be great if you could cover these files with unit tests

* @param record
*/
locate: function (record) {
$.ajaxSetup({async: false});
Copy link
Member

Choose a reason for hiding this comment

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

Can you please extract this method to a separate JS file (image-preview.js is becoming a really long file and we are trying to limit it's responsibility to image preview rendering only).

I'd create AdobeStockImageAdminUi/view/adminhtml/web/js/media-gallery.js returning simple object:

define([
...
], function (...) {
        'use strict';

        return {
            jsTreeRootFolderName: 'Storage Root',
            jsTreeFolderNameMaxLength: 20,
           selectImage: function (path) {
              ...
           }
        }
    }

sivaschenko
sivaschenko previously approved these changes Oct 1, 2019
@sivaschenko sivaschenko merged commit 3568f81 into magento:develop Oct 1, 2019
@ghost
Copy link

ghost commented Oct 1, 2019

Hi @vovsky, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants