Skip to content

Commit 1d46874

Browse files
ENGCOM-8019: Fix ui-select options placeholders for url-filter-applier #29429
2 parents 13e26b2 + 6a58043 commit 1d46874

File tree

13 files changed

+266
-144
lines changed

13 files changed

+266
-144
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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="AssertAdminMediaGalleryAssetFilterPlaceHolderActionGroup">
11+
<annotations>
12+
<description>Assert asset filter placeholder value</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="filterPlaceholder" type="string"/>
16+
</arguments>
17+
18+
<seeElement selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.activeFilterPlaceholder(filterPlaceholder)}}" stepKey="assertFilterPLaceHolder" />
19+
</actionGroup>
20+
</actionGroups>

app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminMediaGalleryCatalogUiCategoryGridSection">
12+
<element name="activeFilterPlaceholder" type="text" selector="//div[@class='admin__current-filters-list-wrap']//li//span[contains(text(), '{{filterPlaceholder}}')]" parameterized="true"/>
1213
<element name="path" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Path')]/preceding-sibling::th)]" parameterized="true"/>
1314
<element name="name" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Name')]/preceding-sibling::th) +1 ]//*[text()='{{categoryName}}']" parameterized="true"/>
1415
<element name="displayMode" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Display Mode')]/preceding-sibling::th) +1 ]//*[text()='{{productsText}}']" parameterized="true"/>

app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,20 @@
6262
<actionGroup ref="AdminMediaGalleryAssertImageInGridActionGroup" stepKey="assertImageInGrid">
6363
<argument name="title" value="ImageMetadata.title"/>
6464
</actionGroup>
65+
66+
<wait time="10" stepKey="waitForBookmarkToSaveView"/>
67+
<reloadPage stepKey="reloadPage"/>
68+
<waitForPageLoad stepKey="waitForGridReloaded"/>
69+
<actionGroup ref="AdminAssertMediaGalleryFilterPlaceholderActionGroup" stepKey="assertFilterApplied">
70+
<argument name="filterPlaceholder" value="$$product.name$$"/>
71+
</actionGroup>
72+
6573
<actionGroup ref="AdminEnhancedMediaGalleryEnableMassActionModeActionGroup" stepKey="enableMassActionToDeleteImages"/>
6674
<actionGroup ref="AdminEnhancedMediaGallerySelectImageForMassActionActionGroup" stepKey="selectFirstImageToDelete">
6775
<argument name="imageName" value="{{ImageMetadata.title}}"/>
6876
</actionGroup>
6977
<actionGroup ref="AdminEnhancedMediaGalleryClickDeleteImagesButtonActionGroup" stepKey="clikDeleteSelectedButton"/>
7078
<actionGroup ref="AdminEnhancedMediaGalleryConfirmDeleteImagesActionGroup" stepKey="deleteImages"/>
71-
79+
7280
</test>
7381
</tests>

app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
<actionGroup ref="AdminEnhancedMediaGalleryClickEntityUsedInActionGroup" stepKey="clickUsedInCategories">
5555
<argument name="entityName" value="Categories"/>
5656
</actionGroup>
57+
<actionGroup ref="AssertAdminMediaGalleryAssetFilterPlaceHolderActionGroup" stepKey="assertFilterApplied">
58+
<argument name="filterPlaceholder" value="{{UpdatedImageDetails.title}}"/>
59+
</actionGroup>
5760
<actionGroup ref="AdminMediaGalleryAssertCategoryNameInCategoryGridActionGroup" stepKey="assertCategoryInGrid">
5861
<argument name="categoryName" value="$$category.name$$"/>
5962
</actionGroup>

app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Filters/UsedInProducts.php

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -80,54 +80,36 @@ public function prepare()
8080
{
8181
$options = [];
8282
$productIds = [];
83-
$bookmarks = $this->bookmarkManagement->loadByNamespace($this->context->getNameSpace())->getItems();
84-
foreach ($bookmarks as $bookmark) {
85-
if ($bookmark->getIdentifier() === 'current') {
86-
$applied = $bookmark->getConfig()['current']['filters']['applied'];
87-
if (isset($applied[$this->getName()])) {
88-
$productIds = $applied[$this->getName()];
89-
}
90-
}
83+
$bookmark = $this->bookmarkManagement->getByIdentifierNamespace(
84+
'current',
85+
$this->context->getNameSpace()
86+
);
87+
if ($bookmark === null) {
88+
parent::prepare();
89+
return;
9190
}
9291

93-
foreach ($productIds as $id) {
94-
$product = $this->productRepository->getById($id);
95-
$options[] = [
96-
'value' => $id,
97-
'label' => $product->getName(),
98-
'is_active' => $product->getStatus(),
99-
'path' => $product->getSku(),
100-
'optgroup' => false
92+
$applied = $bookmark->getConfig()['current']['filters']['applied'];
10193

102-
];
94+
if (isset($applied[$this->getName()])) {
95+
$productIds = $applied[$this->getName()];
10396
}
10497

105-
$this->wrappedComponent = $this->uiComponentFactory->create(
106-
$this->getName(),
107-
parent::COMPONENT,
108-
[
109-
'context' => $this->getContext(),
110-
'options' => $options
111-
]
112-
);
113-
114-
$this->wrappedComponent->prepare();
115-
$productsFilterJsConfig = array_replace_recursive(
116-
$this->getJsConfig($this->wrappedComponent),
117-
$this->getJsConfig($this)
118-
);
119-
$this->setData('js_config', $productsFilterJsConfig);
120-
121-
$this->setData(
122-
'config',
123-
array_replace_recursive(
124-
(array)$this->wrappedComponent->getData('config'),
125-
(array)$this->getData('config')
126-
)
127-
);
128-
129-
$this->applyFilter();
130-
98+
foreach ($productIds as $id) {
99+
try {
100+
$product = $this->productRepository->getById($id);
101+
$options[] = [
102+
'value' => $id,
103+
'label' => $product->getName(),
104+
'is_active' => $product->getStatus(),
105+
'path' => $product->getSku(),
106+
'optgroup' => false
107+
];
108+
} catch (\Exception $e) {
109+
continue;
110+
}
111+
}
112+
$this->optionsProvider = $options;
131113
parent::prepare();
132114
}
133115
}

app/code/Magento/MediaGalleryCmsUi/Ui/Component/Listing/Filters/UsedInBlocks.php

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -80,52 +80,36 @@ public function prepare()
8080
{
8181
$options = [];
8282
$blockIds = [];
83-
$bookmarks = $this->bookmarkManagement->loadByNamespace($this->context->getNameSpace())->getItems();
84-
foreach ($bookmarks as $bookmark) {
85-
if ($bookmark->getIdentifier() === 'current') {
86-
$applied = $bookmark->getConfig()['current']['filters']['applied'];
87-
if (isset($applied[$this->getName()])) {
88-
$blockIds = $applied[$this->getName()];
89-
}
90-
}
91-
}
92-
93-
foreach ($blockIds as $id) {
94-
$block = $this->blockRepository->getById($id);
95-
$options[] = [
96-
'value' => $id,
97-
'label' => $block->getTitle(),
98-
'is_active' => $block->isActive(),
99-
'optgroup' => false
100-
];
83+
$bookmark = $this->bookmarkManagement->getByIdentifierNamespace(
84+
'current',
85+
$this->context->getNameSpace()
86+
);
87+
if ($bookmark === null) {
88+
parent::prepare();
89+
return;
10190
}
10291

103-
$this->wrappedComponent = $this->uiComponentFactory->create(
104-
$this->getName(),
105-
parent::COMPONENT,
106-
[
107-
'context' => $this->getContext(),
108-
'options' => $options
109-
]
110-
);
92+
$applied = $bookmark->getConfig()['current']['filters']['applied'];
11193

112-
$this->wrappedComponent->prepare();
113-
$jsConfig = array_replace_recursive(
114-
$this->getJsConfig($this->wrappedComponent),
115-
$this->getJsConfig($this)
116-
);
117-
$this->setData('js_config', $jsConfig);
118-
119-
$this->setData(
120-
'config',
121-
array_replace_recursive(
122-
(array)$this->wrappedComponent->getData('config'),
123-
(array)$this->getData('config')
124-
)
125-
);
94+
if (isset($applied[$this->getName()])) {
95+
$blockIds = $applied[$this->getName()];
96+
}
12697

127-
$this->applyFilter();
98+
foreach ($blockIds as $id) {
99+
try {
100+
$block = $this->blockRepository->getById($id);
101+
$options[] = [
102+
'value' => $id,
103+
'label' => $block->getTitle(),
104+
'is_active' => $block->isActive(),
105+
'optgroup' => false
106+
];
107+
} catch (\Exception $e) {
108+
continue;
109+
}
110+
}
128111

112+
$this->optionsProvider = $options;
129113
parent::prepare();
130114
}
131115
}

app/code/Magento/MediaGalleryCmsUi/Ui/Component/Listing/Filters/UsedInPages.php

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -80,52 +80,35 @@ public function prepare()
8080
{
8181
$options = [];
8282
$pageIds = [];
83-
$bookmarks = $this->bookmarkManagement->loadByNamespace($this->context->getNameSpace())->getItems();
84-
foreach ($bookmarks as $bookmark) {
85-
if ($bookmark->getIdentifier() === 'current') {
86-
$applied = $bookmark->getConfig()['current']['filters']['applied'];
87-
if (isset($applied[$this->getName()])) {
88-
$pageIds = $applied[$this->getName()];
89-
}
90-
}
91-
}
92-
93-
foreach ($pageIds as $id) {
94-
$page = $this->pageRepository->getById($id);
95-
$options[] = [
96-
'value' => $id,
97-
'label' => $page->getTitle(),
98-
'is_active' => $page->isActive(),
99-
'optgroup' => false
100-
];
101-
}
102-
103-
$this->wrappedComponent = $this->uiComponentFactory->create(
104-
$this->getName(),
105-
parent::COMPONENT,
106-
[
107-
'context' => $this->getContext(),
108-
'options' => $options
109-
]
110-
);
111-
112-
$this->wrappedComponent->prepare();
113-
$pagesFilterjsConfig = array_replace_recursive(
114-
$this->getJsConfig($this->wrappedComponent),
115-
$this->getJsConfig($this)
83+
$bookmark = $this->bookmarkManagement->getByIdentifierNamespace(
84+
'current',
85+
$this->context->getNameSpace()
11686
);
117-
$this->setData('js_config', $pagesFilterjsConfig);
87+
if ($bookmark === null) {
88+
parent::prepare();
89+
return;
90+
}
11891

119-
$this->setData(
120-
'config',
121-
array_replace_recursive(
122-
(array)$this->wrappedComponent->getData('config'),
123-
(array)$this->getData('config')
124-
)
125-
);
92+
$applied = $bookmark->getConfig()['current']['filters']['applied'];
12693

127-
$this->applyFilter();
94+
if (isset($applied[$this->getName()])) {
95+
$pageIds = $applied[$this->getName()];
96+
}
12897

98+
foreach ($pageIds as $id) {
99+
try {
100+
$page = $this->pageRepository->getById($id);
101+
$options[] = [
102+
'value' => $id,
103+
'label' => $page->getTitle(),
104+
'is_active' => $page->isActive(),
105+
'optgroup' => false
106+
];
107+
} catch (\Exception $e) {
108+
continue;
109+
}
110+
}
111+
$this->optionsProvider = $options;
129112
parent::prepare();
130113
}
131114
}

app/code/Magento/MediaGalleryUi/Controller/Adminhtml/Asset/Search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function execute()
139139
$responseContent['options'][] = [
140140
'value' => (string) $asset->getId(),
141141
'label' => $asset->getTitle(),
142-
'path' => $this->storage->getThumbnailUrl($this->images->getStorageRoot() . $asset->getPath())
142+
'src' => $this->storage->getThumbnailUrl($this->images->getStorageRoot() . $asset->getPath())
143143
];
144144
$responseContent['total'] = count($responseContent['options']);
145145
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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="AdminAssertMediaGalleryFilterPlaceholderActionGroup">
11+
<annotations>
12+
<description>Assert asset filter placeholder value</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="filterPlaceholder" type="string"/>
16+
</arguments>
17+
18+
<seeElement selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.activeFilterPlaceholder(filterPlaceholder)}}" stepKey="assertFilterPLaceHolder" />
19+
</actionGroup>
20+
</actionGroups>

app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryFiltersSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
<element name="searchOptionsFilterOption" type="text" selector="//div[label/span[contains(text(), '{{filterName}}')]]//label[@class='admin__action-multiselect-label']/span[text()='{{optionName}}']" parameterized="true" timeout="30"/>
2626
<element name="searchOptionsFilterDone" type="button" selector="//div[label/span[contains(text(), '{{filterName}}')]]//button[@data-action='close-advanced-select']" parameterized="true"/>
2727
<element name="duplicatedFilterCheckbox" type="button" selector="//input[@name='duplicated']"/>
28+
<element name="activeFilterValue" type="text" selector="//div[@class='media-gallery-container']//div[@class='admin__current-filters-list-wrap']//li//span[contains(text(), '{{filterPlaceholder}}')]" parameterized="true"/>
2829
</section>
2930
</sections>

0 commit comments

Comments
 (0)