Skip to content

Commit 89f9ccc

Browse files
authored
Merge pull request #1777 from Nazar65/ASI-1766
Update is_downloaded for displayed record that was applied from related or series tab
2 parents 51ce7a5 + c667352 commit 89f9ccc

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

AdobeStockImageAdminUi/Controller/Adminhtml/Asset/GetMediaGalleryAsset.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\Controller\ResultFactory;
1414
use Psr\Log\LoggerInterface;
1515
use Magento\AdobeStockImageAdminUi\Model\Asset\GetMediaGalleryAssetByAdobeId;
16+
use Magento\Framework\Exception\NoSuchEntityException;
1617

1718
/**
1819
* Backend controller for retrieving asset information by adobeId
@@ -61,7 +62,6 @@ public function execute()
6162
{
6263
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
6364
try {
64-
6565
$params = $this->getRequest()->getParams();
6666
$adobeId = isset($params['adobe_id']) ? $params['adobe_id'] : null;
6767

@@ -78,6 +78,9 @@ public function execute()
7878

7979
$responseCode = self::HTTP_OK;
8080
$responseContent = $this->getAssetByAdobeId->execute((int) $adobeId);
81+
} catch (NoSuchEntityException $execption) {
82+
$responseCode = self::HTTP_OK;
83+
$responseContent = [];
8184
} catch (\Exception $exception) {
8285
$responseCode = self::HTTP_INTERNAL_ERROR;
8386
$this->logger->critical($exception);

AdobeStockImageAdminUi/Model/Asset/GetMediaGalleryAssetByAdobeId.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface;
1313
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
1414
use Magento\Framework\Reflection\DataObjectProcessor;
15+
use Magento\Framework\Exception\NoSuchEntityException;
1516

1617
/**
1718
* Return media gallery asset by adobe id
@@ -55,10 +56,22 @@ public function __construct(
5556
*
5657
* @param int $adobeId
5758
* @return array
59+
* @throws NoSuchEntityException
5860
*/
5961
public function execute(int $adobeId): array
6062
{
61-
$mediaGalleryId = $this->getAssetByAdobeId->execute([$adobeId])[$adobeId]->getMediaGalleryId();
63+
$mediaGalleryAsset = $this->getAssetByAdobeId->execute([$adobeId]);
64+
65+
if (!isset($mediaGalleryAsset[$adobeId])) {
66+
throw new NoSuchEntityException(
67+
__(
68+
'Media Gallery asset with adobe id %id does not exist.',
69+
['id' => $adobeId]
70+
)
71+
);
72+
}
73+
74+
$mediaGalleryId = $mediaGalleryAsset[$adobeId]->getMediaGalleryId();
6275
$asset = $this->getMediaGalleryAssetsById->execute([$mediaGalleryId]);
6376

6477
return $this->objectProcessor->buildOutputDataArray(current($asset), AssetInterface::class);

AdobeStockImageAdminUi/view/adminhtml/web/css/source/_module.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
&-preview {
4747
position: fixed;
48-
z-index: 299;
48+
z-index: 289;
4949

5050
.container {
5151
padding-top: 0;

AdobeStockImageAdminUi/view/adminhtml/web/js/components/grid/column/preview/actions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ define([
170170

171171
this.mediaGalleryListingFilters().clear();
172172
this.getAssetDetails(imageId).then(function (assetDetails) {
173+
if (assetDetails.length === 0) {
174+
return;
175+
}
173176
this.mediaGallerySearchInput().apply(assetDetails.title);
174177
path = assetDetails.path;
175178
path = path.substring(0, path.lastIndexOf('/'));

0 commit comments

Comments
 (0)