-
Notifications
You must be signed in to change notification settings - Fork 90
#359: added Locate button for saved preview images #406
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
#359: added Locate button for saved preview images #406
Conversation
Hi @vovsky thanks for your contribution!
|
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.
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); |
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.
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.
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.
@sivaschenko agree. I have made the changes, thank you. Locate feature works now
/** | ||
* Class AddIsDownloadedToSearchResult | ||
*/ | ||
class AddIsDownloadedToSearchResult |
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.
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
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.
@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
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.
@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) { |
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 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 |
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.
I'd extract a couple of private functions to make this class easier to read
…into 359-locate-saved-preview-image
Hi @vovsky can you please sign the Adobe CLA |
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
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.
Hi @vovsky , thanks for the updates! Please see my review comments.
} | ||
|
||
if (count($itemIds)) { | ||
$connection = $this->resourceConnection->getConnection(); |
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.
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
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.
It would also be great if you could cover these files with unit tests
* @param record | ||
*/ | ||
locate: function (record) { | ||
$.ajaxSetup({async: false}); |
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.
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) {
...
}
}
}
Hi @vovsky, thank you for your contribution! |
Description (*)
This PR adds ability to locate downloaded image in a file browser
Fixed Issues (if relevant)