Skip to content

Commit 6a8d537

Browse files
authored
ENGCOM-8194: Fix saving default directory in the default bookmark of media gallery #29959
2 parents 4ae0f74 + 915e684 commit 6a8d537

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminMediaGalleryDefaultViewWithoutFiltersTest">
12+
<annotations>
13+
<features value="AdminMediaGalleryDefaultViewWithoutFiltersTest"/>
14+
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1813"/>
15+
<title value="User shouldn't see applied filters if media gallery switched to Default View"/>
16+
<stories value="Media gallery default directory"/>
17+
<testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1320712/scenarios/5199870"/>
18+
<description value="No filters should be applied if Default View selected"/>
19+
<severity value="CRITICAL"/>
20+
<group value="media_gallery_ui"/>
21+
</annotations>
22+
<before>
23+
<createData entity="SimpleSubCategory" stepKey="category"/>
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25+
</before>
26+
<after>
27+
<deleteData createDataKey="category" stepKey="deleteCategory"/>
28+
</after>
29+
30+
<!-- Open category page -->
31+
<actionGroup ref="AdminOpenCategoryGridPageActionGroup" stepKey="openCategoryPage"/>
32+
<actionGroup ref="AdminEditCategoryInGridPageActionGroup" stepKey="editCategoryItem">
33+
<argument name="categoryName" value="$category.name$"/>
34+
</actionGroup>
35+
36+
<!-- Open media gallery folder -->
37+
<actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGallery"/>
38+
<actionGroup ref="AdminEnhancedMediaGallerySelectCustomBookmarksViewActionGroup" stepKey="selectDefaultView">
39+
<argument name="selectView" value="Default View"/>
40+
</actionGroup>
41+
42+
<!-- Asset folder is empty -->
43+
<actionGroup ref="AdminEnhancedMediaGalleryAssertNoActiveFiltersAppliedActionGroup" stepKey="assertEmptyFolder"/>
44+
</test>
45+
</tests>

app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/directory/directoryTree.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ define([
1919
defaults: {
2020
allowedActions: [],
2121
filterChipsProvider: 'componentType = filters, ns = ${ $.ns }',
22+
bookmarkProvider: 'componentType = bookmark, ns = ${ $.ns }',
2223
directoryTreeSelector: '#media-gallery-directory-tree',
2324
getDirectoryTreeUrl: 'media_gallery/directories/gettree',
2425
createDirectoryUrl: 'media_gallery/directories/create',
2526
deleteDirectoryUrl: 'media_gallery/directories/delete',
2627
jsTreeReloaded: null,
2728
modules: {
29+
bookmarks: '${ $.bookmarkProvider }',
2830
directories: '${ $.name }_directories',
2931
filterChips: '${ $.filterChipsProvider }'
3032
},
@@ -259,6 +261,15 @@ define([
259261
return;
260262
}
261263

264+
if (!_.isUndefined(this.bookmarks())) {
265+
if (!_.size(this.bookmarks().getViewData(this.bookmarks().defaultIndex))) {
266+
setTimeout(function () {
267+
this.updateSelectedDirectory();
268+
}.bind(this), 500);
269+
270+
return;
271+
}
272+
}
262273
currentTreePath = this.isFilterApplied(currentFilterPath) || _.isNull(requestedDirectory) ?
263274
currentFilterPath : requestedDirectory;
264275

0 commit comments

Comments
 (0)