Skip to content

Switching between Media Gallery bookmarks does not change the selected folder #29411

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

Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8020a01
Merge branch '2.4-develop' of github.com:magento/magento2 into ASI-15…
Aug 5, 2020
8e1e390
magento/adobe-stock-integration#1523: Switching between Views does no…
Aug 5, 2020
ee2ab23
magento/adobe-stock-integration#1523: Switching between Views does no…
Aug 5, 2020
e94ffe6
Merge branch '2.4-develop' of github.com:magento/magento2 into ASI-15…
Aug 6, 2020
3396cfd
Merge branch '2.4-develop' of github.com:magento/magento2 into ASI-15…
Aug 6, 2020
20dc815
magento/adobe-stock-integration#1523: Switching between Views does no…
Aug 6, 2020
58efb76
magento/adobe-stock-integration#1523: Switching between Views does no…
Aug 7, 2020
60da76c
magento/magento2#29411: Directory Tree refactoring
sivaschenko Aug 13, 2020
a516ee5
magento/magento2#29411: Naming update
sivaschenko Aug 18, 2020
0d0aa22
Merge branch '2.4-develop' of github.com:magento/magento2 into ASI-15…
sivaschenko Aug 18, 2020
eb1f0bb
magento/magento2#29411: Updated requested directory selection behaviour
sivaschenko Aug 18, 2020
36074a9
magento/magento2#29411: Formatting fixes
sivaschenko Aug 18, 2020
9a69a6a
magento/magento2#29411: Fixed static tests
sivaschenko Aug 18, 2020
79c8386
magento/magento2#29411: Fixed MFTF test
sivaschenko Aug 24, 2020
4a354da
Merge branch '2.4-develop' into ASI-1523-switching-between-views-does…
sivaschenko Aug 24, 2020
ae61599
Fixed static tests
sivaschenko Aug 24, 2020
a68bbbd
Fixed static tests
sivaschenko Aug 25, 2020
e533396
Fixed static tests
sivaschenko Aug 25, 2020
218c017
Merge branch '2.4-develop' into ASI-1523-switching-between-views-does…
sivaschenko Aug 25, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function execute(array $paths): void
if (!empty($failedPaths)) {
throw new CouldNotSaveException(
__(
'Could not save directories: %paths',
'Could not create directories: %paths',
[
'paths' => implode(' ,', $failedPaths)
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertFolderIsChangedActionGroup">
<annotations>
<description>Assert that folder is changed</description>
</annotations>
<arguments>
<argument name="newSelectedFolder" type="string"/>
<argument name="oldSelectedFolder" type="string" defaultValue="{{AdminMediaGalleryFolderData.name}}"/>
</arguments>

<assertNotEquals stepKey="assertNotEqual">
<actualResult type="string">{{newSelectedFolder}}</actualResult>
<expectedResult type="string">{{oldSelectedFolder}}</expectedResult>
</assertNotEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminMediaGallerySwitchingBetweenViewsTest">
<annotations>
<features value="MediaGallery"/>
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1523"/>
<title value="User switches between Views and checks if the folder is changed"/>
<stories value="User switches between Views and checks if the folder is changed"/>
<testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1337102/scenarios/5060037"/>
<description value="User switches between Views and checks if the folder is changed"/>
<severity value="CRITICAL"/>
<group value="media_gallery_ui"/>
</annotations>
<before>
<createData entity="SimpleSubCategory" stepKey="category"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/>
<actionGroup ref="AdminEnhancedMediaGalleryDeleteGridViewActionGroup" stepKey="deleteView">
<argument name="viewToDelete" value="New View"/>
</actionGroup>
<actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectFolderForDelete"/>
<actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteFolder"/>
<actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertFolderWasDeleted"/>
<deleteData createDataKey="category" stepKey="deleteCategory"/>
</after>
<actionGroup ref="AdminOpenCreateNewCMSPageActionGroup" stepKey="openNewPage"/>
<actionGroup ref="AdminOpenMediaGalleryFromPageNoEditorActionGroup" stepKey="openMediaGalleryForPage"/>
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilters"/>
<actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openNewFolderForm"/>
<actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createNewFolder"/>
<actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertNewFolderCreated"/>
<waitForLoadingMaskToDisappear stepKey="waitForFolderContents"/>
<actionGroup ref="AdminEnhancedMediaGallerySaveCustomViewActionGroup" stepKey="saveCustomView">
<argument name="viewName" value="New View"/>
</actionGroup>
<actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openCategoryPage"/>
<actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="openCategory">
<argument name="category" value="$$category$$"/>
</actionGroup>
<actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGalleryFromImageUploader"/>
<actionGroup ref="AdminEnhancedMediaGallerySelectCustomBookmarksViewActionGroup" stepKey="selectDefaultView">
<argument name="selectView" value="Default View"/>
</actionGroup>
<actionGroup ref="AssertFolderIsChangedActionGroup" stepKey="assertFolderIsChanged">
<argument name="newSelectedFolder" value="category" />
</actionGroup>
<actionGroup ref="AdminEnhancedMediaGallerySelectCustomBookmarksViewActionGroup" stepKey="switchBackToNewView">
<argument name="selectView" value="New View"/>
</actionGroup>
<actionGroup ref="AdminEnhancedMediaGalleryAssertActiveFiltersActionGroup" stepKey="assertFilterApplied">
<argument name="resultValue" value="{{AdminMediaGalleryFolderData.name}}"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Directories tree component
*/
class DirectoriesTree extends Container
class DirectoryTree extends Container
{
/**
* @var UrlInterface
Expand Down Expand Up @@ -50,9 +50,9 @@ public function prepare(): void
array_replace_recursive(
(array) $this->getData('config'),
[
'getDirectoryTreeUrl' => $this->url->getUrl("media_gallery/directories/gettree"),
'deleteDirectoryUrl' => $this->url->getUrl("media_gallery/directories/delete"),
'createDirectoryUrl' => $this->url->getUrl("media_gallery/directories/create")
'getDirectoryTreeUrl' => $this->url->getUrl('media_gallery/directories/gettree'),
'deleteDirectoryUrl' => $this->url->getUrl('media_gallery/directories/delete'),
'createDirectoryUrl' => $this->url->getUrl('media_gallery/directories/create')
]
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
</container>
</listingToolbar>
<container name="media_gallery_directories"
class="Magento\MediaGalleryUi\Ui\Component\DirectoriesTree"
class="Magento\MediaGalleryUi\Ui\Component\DirectoryTree"
template="Magento_MediaGalleryUi/grid/directories/directoryTree"
component="Magento_MediaGalleryUi/js/directory/directoryTree"/>
<columns name="media_gallery_columns" component="Magento_MediaGalleryUi/js/grid/masonry">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
</container>
</listingToolbar>
<container name="media_gallery_directories"
class="Magento\MediaGalleryUi\Ui\Component\DirectoriesTree"
class="Magento\MediaGalleryUi\Ui\Component\DirectoryTree"
template="Magento_MediaGalleryUi/grid/directories/directoryTree"
component="Magento_MediaGalleryUi/js/directory/directoryTree"/>
<columns name="media_gallery_columns" component="Magento_MediaGalleryUi/js/grid/masonry">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,24 @@ define([
* @param {String} deleteImageUrl
*/
deleteImageAction: function (recordsIds, imageDetailsUrl, deleteImageUrl) {
var confirmationContent = $t('%1 Are you sure you want to delete "%2" image(s)?')
var confirmationContent = $t('%1Are you sure you want to delete "%2" image(s)?')
.replace('%2', Object.keys(recordsIds).length),
deferred = $.Deferred();

getDetails(imageDetailsUrl, recordsIds)
.then(function (imageDetails) {
getDetails(imageDetailsUrl, recordsIds).then(function (images) {
confirmationContent = confirmationContent.replace(
'%1',
this.getRecordRelatedContentMessage(imageDetails)
this.getRecordRelatedContentMessage(images) + ' '
);
}.bind(this)).fail(function () {
confirmationContent = confirmationContent.replace('%1', '');
}).always(function () {
deleteImages(recordsIds, deleteImageUrl, confirmationContent).then(function (status) {
deferred.resolve(status);
}).fail(function (error) {
deferred.reject(error);
});
});
confirmationContent = confirmationContent.replace('%1', '');
}).always(function () {
deleteImages(recordsIds, deleteImageUrl, confirmationContent).then(function (status) {
deferred.resolve(status);
}).fail(function (error) {
deferred.reject(error);
});
});

return deferred.promise();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ define([
deleteButtonSelector: '#delete_folder',
createFolderButtonSelector: '#create_folder',
messageDelay: 5,
selectedFolder: null,
messagesName: 'media_gallery_listing.media_gallery_listing.messages',
modules: {
directoryTree: '${ $.parentName }.media_gallery_directories',
Expand All @@ -47,51 +48,57 @@ define([
*/
initEvents: function () {
$(this.deleteButtonSelector).on('delete_folder', function () {
this.getConfirmationPopupDeleteFolder();
this.deleteFolder();
}.bind(this));

$(this.createFolderButtonSelector).on('create_folder', function () {
this.getPrompt({
title: $t('New Folder Name:'),
content: '',
actions: {
/**
* Confirm action
*/
confirm: function (folderName) {
createDirectory(
this.directoryTree().createDirectoryUrl,
[this.getNewFolderPath(folderName)]
).then(function () {
this.directoryTree().reloadJsTree().then(function () {
$(this.directoryTree().directoryTreeSelector).on('loaded.jstree', function () {
this.directoryTree().locateNode(this.getNewFolderPath(folderName));
}.bind(this));
}.bind(this));
this.createFolder();
}.bind(this));
},

}.bind(this)).fail(function (error) {
uiAlert({
content: error
});
/**
* Show confirmation popup and create folder based on user input
*/
createFolder: function () {
this.getPrompt({
title: $t('New Folder Name:'),
content: '',
actions: {
/**
* Confirm action
*/
confirm: function (folderName) {
createDirectory(
this.directoryTree().createDirectoryUrl,
[this.getNewFolderPath(folderName)]
).then(function () {
this.directoryTree().reloadJsTree().then(function () {
$(this.directoryTree().directoryTreeSelector).on('loaded.jstree', function () {
this.directoryTree().locateNode(this.getNewFolderPath(folderName));
}.bind(this));
}.bind(this));
}.bind(this)).fail(function (error) {
uiAlert({
content: error
});
}.bind(this)
},
buttons: [{
text: $t('Cancel'),
class: 'action-secondary action-dismiss',
});
}.bind(this)
},
buttons: [{
text: $t('Cancel'),
class: 'action-secondary action-dismiss',

/**
* Close modal
*/
click: function () {
this.closeModal();
}
}, {
text: $t('Confirm'),
class: 'action-primary action-accept'
}]
});
}.bind(this));
/**
* Close modal
*/
click: function () {
this.closeModal();
}
}, {
text: $t('Confirm'),
class: 'action-primary action-accept'
}]
});
},

/**
Expand All @@ -101,11 +108,11 @@ define([
* @returns {String}
*/
getNewFolderPath: function (folderName) {
var selectedFolder = _.isUndefined(this.selectedFolder()) ||
_.isNull(this.selectedFolder()) ? '/' : this.selectedFolder(),
folderToCreate = selectedFolder !== '/' ? selectedFolder + '/' + folderName : folderName;
if (_.isUndefined(this.selectedFolder()) || _.isNull(this.selectedFolder())) {
return folderName;
}

return folderToCreate;
return this.selectedFolder() + '/' + folderName;
},

/**
Expand Down Expand Up @@ -136,7 +143,7 @@ define([
/**
* Confirmation popup for delete folder action.
*/
getConfirmationPopupDeleteFolder: function () {
deleteFolder: function () {
confirm({
title: $t('Are you sure you want to delete this folder?'),
modalClass: 'delete-folder-confirmation-popup',
Expand Down
Loading