Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AdobeStockAsset/Model/GetAssetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function execute(SearchCriteriaInterface $searchCriteria): SearchResultIn
} catch (AuthenticationException $exception) {
throw new LocalizedException(
__(
'Failed to authenticate to Adobe Stock API. Please correct the API credentials in '
'Failed to authenticate to Adobe Stock API. <br> Please correct the API credentials in '
. '<a href="%1">Configuration → System → Adobe Stock Integration.</a>',
$this->url->getUrl('adminhtml/system_config/edit/section/system')
)
Expand Down
34 changes: 24 additions & 10 deletions AdobeStockImageAdminUi/Model/Listing/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvi

/**
* DataProvider constructor.
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param ReportingInterface $reporting
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param ReportingInterface $reporting
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param RequestInterface $request
* @param FilterBuilder $filterBuilder
* @param RequestInterface $request
* @param FilterBuilder $filterBuilder
* @param GetImageListInterface $getImageList
* @param array $meta
* @param array $data
* @param array $meta
* @param array $data
*/
public function __construct(
string $name,
Expand Down Expand Up @@ -67,8 +67,22 @@ public function __construct(

/**
* @inheritdoc
*
* @throws LocalizedException
*/
public function getData()
{
try {
return $this->searchResultToOutput($this->getSearchResult());
} catch (LocalizedException $exception) {
return [
'items' => [],
'totalRecords' => 0,
'errorMessage' => $exception->getMessage()
];
}
}

/**
* @inheritdoc
*/
public function getSearchResult(): SearchResultInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<click selector="{{CmsPagesPageActionsSection.addNewPageButton}}" stepKey="clickAddNewPage"/>
<click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickExpandContent"/>
<waitForElementVisible selector="{{CmsWYSIWYGSection.ShowHideBtn}}" stepKey="waitForShowHideButton" />
<click selector="{{CmsWYSIWYGSection.ShowHideBtn}}" stepKey="HideEditor" />
<conditionalClick selector="{{CmsWYSIWYGSection.ShowHideBtn}}" dependentSelector="{{CmsWYSIWYGSection.InsertImageBtn}}" visible="false" stepKey="HideEditor" />
<waitForElementVisible selector="{{CmsWYSIWYGSection.InsertImageBtn}}" stepKey="waitForInsertImageButton" />
<click selector="{{CmsWYSIWYGSection.InsertImageBtn}}" stepKey="clickInsertImage" />
<waitForPageLoad stepKey="waitForMediaGallery"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Magento\Framework\Api\Search\SearchCriteria;
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -113,6 +114,33 @@ public function testGetData(array $itemsData): void
$this->assertEquals($data, $this->dataProvider->getData());
}

/**
* Verify LocalizedExceptions messages are returned in errorMessage data node
*/
public function testGetDataException(): void
{
$searchCriteria = $this->createMock(SearchCriteria::class);
$searchCriteria->expects($this->once())
->method('setRequestName')
->with('adobe_stock_images_listing_data_source');

$this->searchCriteriaBuilder->expects($this->once())
->method('create')
->willReturn($searchCriteria);

$this->getImageListMock->expects($this->once())
->method('execute')
->willThrowException(new LocalizedException(__('Localized error')));

$data = [
'items' => [],
'totalRecords' => 0,
'errorMessage' => 'Localized error'
];

$this->assertEquals($data, $this->dataProvider->getData());
}

/**
* @param array $itemsData
* @return SearchResultInterface|MockObject
Expand Down
3 changes: 2 additions & 1 deletion AdobeUi/view/adminhtml/web/css/source/_module.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
margin: @admin__masonry_grid_image__space/2 -(@admin__masonry_grid_image__space/2);
overflow: hidden;

.no-data-message-container {
.no-data-message-container,
.error-message-container {
font-size: @data-grid__no-records__font-size;
padding: @data-grid__no-records__padding;
text-align: center;
Expand Down
15 changes: 13 additions & 2 deletions AdobeUi/view/adminhtml/web/js/components/grid/masonry.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ define([
defaults: {
template: 'Magento_AdobeUi/grid/masonry',
imports: {
rows: '${ $.provider }:data.items'
rows: '${ $.provider }:data.items',
errorMessage: '${ $.provider }:data.errorMessage'
},
listens: {
'rows': 'initComponent'
Expand Down Expand Up @@ -57,7 +58,8 @@ define([
initObservable: function () {
this._super()
.observe([
'rows'
'rows',
'errorMessage'
]);

return this;
Expand Down Expand Up @@ -245,6 +247,15 @@ define([
*/
hasData: function () {
return !!this.rows() && !!this.rows().length;
},

/**
* Returns error message returned by the data provider
*
* @returns {String|null}
*/
getErrorMessage: function () {
return this.errorMessage();
}
});
});
5 changes: 4 additions & 1 deletion AdobeUi/view/adminhtml/web/template/grid/masonry.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
<div class="masonry-image-column" repeat="foreach: rows, item: '$row'">
<div outerfasteach="data: getVisible(), as: '$col'" template="getBody()"/>
</div>
<div ifnot="hasData()" class="no-data-message-container">
<div if="!hasData() && !getErrorMessage()" class="no-data-message-container">
<span translate="'We couldn\'t find any records.'"/>
</div>
<div if="getErrorMessage()" class="error-message-container">
<span data-bind="html: getErrorMessage()"/>
</div>
</div>