Skip to content

Commit 167d92e

Browse files
Merge branch '#1390' of github.com:ProkopovVitaliy/adobe-stock-integration into #1390
2 parents fa88116 + b94408d commit 167d92e

File tree

21 files changed

+162
-47
lines changed

21 files changed

+162
-47
lines changed

AdobeIms/Block/Adminhtml/SignIn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function getDefaultUserData(): array
188188
'isAuthorized' => false,
189189
'name' => '',
190190
'email' => '',
191-
'image' => $this->config->getDefaultProfileImage(),
191+
'image' => '',
192192
];
193193
}
194194
}

AdobeIms/Model/Config.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class Config implements ConfigInterface
2222
private const XML_PATH_TOKEN_URL = 'adobe_ims/integration/token_url';
2323
private const XML_PATH_AUTH_URL_PATTERN = 'adobe_ims/integration/auth_url_pattern';
2424
private const XML_PATH_LOGOUT_URL_PATTERN = 'adobe_ims/integration/logout_url';
25-
private const XML_PATH_DEFAULT_PROFILE_IMAGE = 'adobe_ims/integration/default_profile_image';
2625
private const XML_PATH_IMAGE_URL_PATTERN = 'adobe_ims/integration/image_url';
2726
private const OAUTH_CALLBACK_URL = 'adobe_ims/oauth/callback';
2827

@@ -127,12 +126,4 @@ public function getProfileImageUrl(): string
127126
$this->scopeConfig->getValue(self::XML_PATH_IMAGE_URL_PATTERN)
128127
);
129128
}
130-
131-
/**
132-
* @inheritdoc
133-
*/
134-
public function getDefaultProfileImage(): string
135-
{
136-
return $this->scopeConfig->getValue(self::XML_PATH_DEFAULT_PROFILE_IMAGE);
137-
}
138129
}

AdobeIms/Model/GetImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function execute(string $accessToken, int $size = 276): string
7373
$result = $this->json->unserialize($curl->getBody());
7474
$image = $result['user']['images'][$size];
7575
} catch (\Exception $exception) {
76-
$image = $this->config->getDefaultProfileImage();
76+
$image = '';
7777
$this->logger->critical($exception);
7878
}
7979

AdobeIms/Test/Unit/Block/Adminhtml/SignInTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class SignInTest extends TestCase
3131
private const PROFILE_URL = 'https://url.test/';
3232
private const LOGOUT_URL = 'https://url.test/';
3333
private const AUTH_URL = '';
34-
private const DEFAULT_PROFILE_IMAGE = 'default_image.png';
3534
private const RESPONSE_REGEXP_PATTERN = 'auth\\[code=(success|error);message=(.+)\\]';
3635
private const RESPONSE_CODE_INDEX = 1;
3736
private const RESPONSE_MESSAGE_INDEX = 2;
@@ -72,8 +71,6 @@ protected function setUp(): void
7271
$configMock->expects($this->once())
7372
->method('getAuthUrl')
7473
->willReturn(self::AUTH_URL);
75-
$configMock->method('getDefaultProfileImage')
76-
->willReturn(self::DEFAULT_PROFILE_IMAGE);
7774

7875
$urlBuilderMock = $this->createMock(UrlInterface::class);
7976
$urlBuilderMock->method('getUrl')
@@ -216,7 +213,7 @@ private function getDefaultUserData(): array
216213
'isAuthorized' => false,
217214
'name' => '',
218215
'email' => '',
219-
'image' => self::DEFAULT_PROFILE_IMAGE,
216+
'image' => '',
220217
];
221218
}
222219

AdobeIms/Test/Unit/Model/ConfigTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,4 @@ public function testGetProfileImageUrl(): void
215215
$this->config->getProfileImageUrl()
216216
);
217217
}
218-
219-
/**
220-
* Test for \Magento\AdobeIms\Model\Config::getDefaultProfileImage
221-
*/
222-
public function testGetDefaultProfileImage(): void
223-
{
224-
$this->scopeConfigMock->method('getValue')
225-
->with(self::XML_PATH_DEFAULT_PROFILE_IMAGE)
226-
->willReturn(self::IMAGE_URL_DEFAULT);
227-
228-
$this->assertEquals(self::IMAGE_URL_DEFAULT, $this->config->getDefaultProfileImage());
229-
}
230218
}

AdobeIms/etc/config.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<token_url>https://ims-na1.adobelogin.com/ims/token</token_url>
1515
<logout_url><![CDATA[https://ims-na1.adobelogin.com/ims/logout?access_token=#{access_token}&redirect_uri=#{redirect_uri}]]></logout_url>
1616
<image_url><![CDATA[https://cc-api-behance.adobe.io/v2/users/me?api_key=#{api_key}]]></image_url>
17-
<default_profile_image>https://a5.behance.net/27000444e0c8b62c56deff3fc491e1a92d07f0cb/img/profile/no-image-276.png</default_profile_image>
1817
<auth_url_pattern><![CDATA[https://ims-na1.adobelogin.com/ims/authorize?client_id=#{client_id}&redirect_uri=#{redirect_uri}&locale=#{locale}&scope=openid,creative_sdk&response_type=code]]></auth_url_pattern>
1918
</integration>
2019
</adobe_ims>

AdobeIms/view/adminhtml/web/js/signIn.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ define([
1414
defaults: {
1515
profileUrl: 'adobe_ims/user/profile',
1616
logoutUrl: 'adobe_ims/user/logout',
17-
defaultProfileImage:
18-
'https://a5.behance.net/27000444e0c8b62c56deff3fc491e1a92d07f0cb/img/profile/no-image-276.png',
1917
user: {
2018
isAuthorized: false,
2119
name: '',
@@ -128,7 +126,7 @@ define([
128126
isAuthorized: false,
129127
name: '',
130128
email: '',
131-
image: this.defaultProfileImage
129+
image: ''
132130
});
133131
}.bind(this),
134132

AdobeImsApi/Api/ConfigInterface.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,4 @@ public function getLogoutUrl(string $accessToken, string $redirectUrl = ''): str
6565
* @return string
6666
*/
6767
public function getProfileImageUrl(): string;
68-
69-
/**
70-
* Returns default profile image.
71-
*
72-
* @return string
73-
*/
74-
public function getDefaultProfileImage(): string;
7568
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
9+
<test name="AdminStandaloneMediaGallerySearchByKeywordTest">
10+
<annotations>
11+
<features value="MediaGallery"/>
12+
<stories value="User searches for an image using search by keyword from standalone media gallery"/>
13+
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1121"/>
14+
<testCaseId value=" https://studio.cucumber.io/projects/131313/test-plan/folders/1337102/scenarios/4503803"/>
15+
<title value="User searches for an image using search by keyword from standalone media gallery"/>
16+
<description value="User searches for an image using search by keyword from standalone media gallery"/>
17+
<severity value="CRITICAL"/>
18+
<group value="adobe_stock_media_gallery"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
<actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openMediaGalleryForPage"/>
24+
</before>
25+
<after>
26+
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/>
27+
<actionGroup ref="AdminEnhancedMediaGalleryImageDeleteActionGroup" stepKey="deleteImage"/>
28+
</after>
29+
<actionGroup ref="AdminEnhancedMediaGallerySearchAdobeStockActionGroup" stepKey="openAdobeStockGrid"/>
30+
<actionGroup ref="AdminAdobeStockExpandImagePreviewActionGroup" stepKey="expandImagePreview"/>
31+
<grabTextFrom selector="{{AdminAdobeStockImagePreviewSection.firstKeyword}}" stepKey="grabKeyword"/>
32+
<grabAttributeFrom selector="{{AdminAdobeStockImagePreviewSection.image}}" userInput="alt" stepKey="grabImageName"/>
33+
<click selector="{{AdminAdobeStockImagePreviewSection.savePreview}}" stepKey="clickSavePreviewButton"/>
34+
<waitForPageLoad stepKey="waitForPromptModal"/>
35+
<grabValueFrom selector="{{AdminAdobeStockImagePreviewSection.imageNameField}}" stepKey="grabImageFileName"/>
36+
<click selector="{{AdminAdobeStockImagePreviewSection.confirm}}" stepKey="clickOnPopupConfirm"/>
37+
<waitForPageLoad stepKey="waitForMediaGalleryOpen"/>
38+
<actionGroup ref="SearchStandaloneMediaGalleryAdminDataGridByKeywordActionGroup" stepKey="searchImage">
39+
<argument name="keyword" value="$grabImageName"/>
40+
</actionGroup>
41+
<actionGroup ref="AdminAssertImageInStandaloneMediaGalleryActionGroup" stepKey="assertImageIsAvailableInStandaloneGridUsingImageName">
42+
<argument name="imageName" value="$grabImageFileName"/>
43+
</actionGroup>
44+
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/>
45+
<actionGroup ref="SearchStandaloneMediaGalleryAdminDataGridByKeywordActionGroup" stepKey="searchImageByKeyword">
46+
<argument name="keyword" value="$grabKeyword"/>
47+
</actionGroup>
48+
<actionGroup ref="AdminAssertImageInStandaloneMediaGalleryActionGroup" stepKey="assertImageIsAvailableInStandaloneGridUsingKeyword">
49+
<argument name="imageName" value="$grabImageFileName"/>
50+
</actionGroup>
51+
</test>
52+
</tests>

AdobeStockImageAdminUi/view/adminhtml/web/js/components/grid/column/image-preview.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ define([
6060
initialize: function () {
6161
this._super().initView();
6262
$(window).on('fileDeleted.enhancedMediaGallery', this.reloadAdobeGrid.bind(this));
63+
$(window).on('folderDeleted.enhancedMediaGallery', this.reloadAdobeGrid.bind(this));
6364

6465
return this;
6566
},

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ define([
66
'uiComponent',
77
'uiRegistry',
88
'jquery',
9+
'underscore',
910
'Magento_AdobeStockImageAdminUi/js/action/save',
1011
'Magento_AdobeStockImageAdminUi/js/action/savePreview',
1112
'Magento_AdobeStockImageAdminUi/js/action/saveLicensed',
@@ -17,6 +18,7 @@ define([
1718
Component,
1819
uiRegistry,
1920
$,
21+
_,
2022
saveAction,
2123
savePreviewAction,
2224
saveLicensedAction,
@@ -340,8 +342,7 @@ define([
340342
if (this.isMediaBrowser()) {
341343
activeNode = this.getMageMediaBrowserData().activeNode;
342344

343-
activeNodePath = $('[data-id="' + activeNode.id + '"]').length === 0 ||
344-
activeNode.id === 'root' ? '' : activeNode.path;
345+
activeNodePath = _.isUndefined(activeNode.path) ? '' : activeNode.path;
345346
} else {
346347
activeNodePath = this.imageDirectory().activeNode() || '';
347348
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ define([
253253
* Scrolls user window to the filter bookmarks
254254
*/
255255
scrollToFilter: function () {
256-
$(this.filterBookmarksSelector).get(0).scrollIntoView({
256+
$(this.preview().adobeStockModalSelector + ' ' + this.filterBookmarksSelector).get(0).scrollIntoView({
257257
behavior: 'smooth',
258258
block: 'center',
259259
inline: 'nearest'

AdobeStockImageAdminUi/view/adminhtml/web/js/media-gallery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ define([
5858
imageFolder = $('.jstree li[data-id="' + pathId + '"]').children('a');
5959

6060
if (!imageFolder.length) {
61-
imageFolder = $('.jstree li[data-id="' + this.jsTreeRootFolderName + '"]')
61+
imageFolder = $('.jstree li[data-id="' + this.jsTreeRootFolderId + '"]')
6262
.children('a');
6363
}
6464

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminAssertImageInStandaloneMediaGalleryActionGroup">
11+
<annotations>
12+
<description>Validates that the provided image is present and correct in the standalone media gallery.</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="imageName" type="string"/>
16+
</arguments>
17+
18+
<seeElement selector="{{AdminEnhancedMediaGalleryActionsSection.imageSrc(imageName)}}"
19+
stepKey="checkFirstImageAfterSearch"/>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="SearchStandaloneMediaGalleryAdminDataGridByKeywordActionGroup" extends="SearchAdminDataGridByKeywordActionGroup">
12+
<annotations>
13+
<description>EXTENDS: SearchAdminDataGridByKeywordActionGroup. Fills 'Search by keyword' on an Standalone Media Gallery Admin Grid page. Clicks on Submit Search.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="keyword" type="string" defaultValue=""/>
17+
</arguments>
18+
</actionGroup>
19+
</actionGroups>

MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryActionsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<element name="cancel" type="button" selector="[data-ui-id='cancel-button']"/>
1313
<element name="createFolder" type="button" selector="[data-ui-id='create-folder-button']"/>
1414
<element name="deleteFolder" type="button" selector="[data-ui-id='delete-folder-button']"/>
15+
<element name="imageSrc" type="text" selector="//div[@class='masonry-image-column' and contains(@data-repeat-index, '0')]//img[contains(@src,'{{src}}')]" parameterized="true"/>
1516
</section>
1617
</sections>

MediaGalleryUi/view/adminhtml/ui_component/media_gallery_listing.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
class="Magento\MediaGalleryUi\Ui\Component\DirectoriesTree"
156156
template="Magento_MediaGalleryUi/grid/directories/directoryTree"
157157
component="Magento_MediaGalleryUi/js/directory/directoryTree"/>
158-
<columns name="media_gallery_columns" component="Magento_Ui/js/grid/masonry">
158+
<columns name="media_gallery_columns" component="Magento_MediaGalleryUi/js/grid/masonry">
159159
<argument name="data" xsi:type="array">
160160
<item name="config" xsi:type="array">
161161
<item name="containerId" xsi:type="string">media-gallery-masonry-grid</item>

MediaGalleryUi/view/adminhtml/ui_component/standalone_media_gallery_listing.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
class="Magento\MediaGalleryUi\Ui\Component\DirectoriesTree"
143143
template="Magento_MediaGalleryUi/grid/directories/directoryTree"
144144
component="Magento_MediaGalleryUi/js/directory/directoryTree"/>
145-
<columns name="media_gallery_columns" component="Magento_Ui/js/grid/masonry">
145+
<columns name="media_gallery_columns" component="Magento_MediaGalleryUi/js/grid/masonry">
146146
<argument name="data" xsi:type="array">
147147
<item name="config" xsi:type="array">
148148
<item name="containerId" xsi:type="string">media-gallery-masonry-grid</item>

MediaGalleryUi/view/adminhtml/web/js/directory/directories.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ define([
4646
*/
4747
initEvents: function () {
4848
$(this.deleteButtonSelector).on('delete_folder', function () {
49-
this.getComfirmationPopupDeleteFolder();
49+
this.getConfirmationPopupDeleteFolder();
5050
}.bind(this));
5151

5252
$(this.createFolderButtonSelector).on('create_folder', function () {
@@ -134,7 +134,7 @@ define([
134134
/**
135135
* Confirmation popup for delete folder action.
136136
*/
137-
getComfirmationPopupDeleteFolder: function () {
137+
getConfirmationPopupDeleteFolder: function () {
138138
confirm({
139139
title: $.mage.__('Are you sure you want to delete this folder?'),
140140
modalClass: 'delete-folder-confirmation-popup',
@@ -152,6 +152,7 @@ define([
152152
).then(function () {
153153
this.directoryTree().removeNode();
154154
this.directoryTree().selectStorageRoot();
155+
$(window).trigger('folderDeleted.enhancedMediaGallery');
155156
}.bind(this)).fail(function (error) {
156157
uiAlert({
157158
content: error

MediaGalleryUi/view/adminhtml/web/js/directory/directoryTree.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ define([
172172
* @param {String} path
173173
*/
174174
folderExistsInTree: function (path) {
175-
return $('#' + path.replace(/\//g, '\\/')).length === 1;
175+
if (!_.isUndefined(path)) {
176+
return $('#' + path.replace(/\//g, '\\/')).length === 1;
177+
}
178+
179+
return false;
176180
},
177181

178182
/**
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'Magento_Ui/js/grid/masonry',
8+
'jquery'
9+
], function (Masonry, $) {
10+
'use strict';
11+
12+
return Masonry.extend({
13+
defaults: {
14+
modules: {
15+
provider: '${ $.provider }'
16+
}
17+
},
18+
19+
/**
20+
* Init component
21+
*
22+
* @return {Object}
23+
*/
24+
initialize: function () {
25+
this._super();
26+
this.initEvents();
27+
28+
return this;
29+
},
30+
31+
/**
32+
* Initialize events
33+
*/
34+
initEvents: function () {
35+
$(window).on('folderDeleted.enhancedMediaGallery', this.reloadGrid.bind(this));
36+
},
37+
38+
/**
39+
* Reload grid
40+
*/
41+
reloadGrid: function () {
42+
var provider = this.provider(),
43+
dataStorage = provider.storage();
44+
45+
dataStorage.clearRequests();
46+
provider.reload();
47+
}
48+
});
49+
});

0 commit comments

Comments
 (0)