Skip to content
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

Added Content Status and Store View filters #1602

Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\MediaGalleryUi\Model\SearchCriteria\CollectionProcessor\FilterProcessor;

use Magento\Framework\Api\Filter;
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor\CustomFilterInterface;
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\MediaContentApi\Api\GetAssetIdsByContentFieldInterface;

/**
* Class responsible to filter a content field
*/
class ContentField implements CustomFilterInterface
{
private const TABLE_ALIAS = 'main_table';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of inconsistency: there is a constant for the table name but no constant for id field name. I'd have both on none


/**
* @var GetAssetIdsByContentFieldInterface
*/
private $getAssetIdsByContentStatus;

/**
* ContentField constructor.
*
* @param GetAssetIdsByContentFieldInterface $getAssetIdsByContentStatus
*/
public function __construct(
GetAssetIdsByContentFieldInterface $getAssetIdsByContentStatus
) {
$this->getAssetIdsByContentStatus = $getAssetIdsByContentStatus;
}

/**
* @inheritDoc
*/
public function apply(Filter $filter, AbstractDb $collection): bool
{
$collection->addFieldToFilter(
self::TABLE_ALIAS . '.id',
['in' => $this->getAssetIdsByContentStatus->execute($filter->getField(), $filter->getValue())]
);

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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="AdminMediaGalleryApplySelectFilterActionGroup">
<annotations>
<description>Applies select filter to the media gallery grid</description>
</annotations>
<arguments>
<argument name="selectLabel" type="string"/>
<argument name="selectOption" type="string"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filterLabel and optionLabel argument names would be more descriptive for a developer

</arguments>

<click selector="{{AdminEnhancedMediaGalleryFiltersSection.selectFilterInput(selectLabel)}}" stepKey="openSelectFilter"/>
<click selector="{{AdminEnhancedMediaGalleryFiltersSection.selectFilterInputOption(selectLabel, selectOption)}}" stepKey="selectFilterOption"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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="AdminOpenMediaGalleryForExistingPageNoEditorActionGroup">
gabrieldagama marked this conversation as resolved.
Show resolved Hide resolved
<click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickExpandContent"/>
<waitForElementVisible selector="{{CmsWYSIWYGSection.InsertImageBtn}}" stepKey="waitForInsertImageButton" />
<click selector="{{CmsWYSIWYGSection.InsertImageBtn}}" stepKey="clickInsertImage" />
<!-- wait for initial media gallery load, where the gallery chrome loads (and triggers loading modal) -->
<waitForPageLoad stepKey="waitForMediaGalleryInitialLoad"/>
<!-- wait for second media gallery load, where the gallery images load (and triggers loading modal once more) -->
<waitForPageLoad stepKey="waitForMediaGallerySecondaryLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<element name="usedInSelectDropdown" type="text" selector="//label[@class='admin__form-field-label']/span[text()='Show Images Used In']/parent::*/parent::div/div//div[@class='admin__action-multiselect-text' and text()='Select...']"/>
<element name="usedInEntityType" type="text" selector="//label[@class='admin__action-multiselect-label']/span[text()='{{entityType}}']" parameterized="true"/>
<element name="usedInDoneButton" type="button" selector="//div[@class='admin__action-multiselect-actions-wrap']/button/span[text()='Done']"/>
<element name="duplicatedFilterCheckbox" type="button" selector="//input[@name='duplicated']"/>

<element name="selectFilterInput" type="button" selector="//label[@class='admin__form-field-label']/span[text()='{{filterLabel}}']/parent::*/parent::div/div[@class='admin__form-field-control']/select" parameterized="true"/>
gabrieldagama marked this conversation as resolved.
Show resolved Hide resolved
<element name="selectFilterInputOption" type="button" selector="//label[@class='admin__form-field-label']/span[text()='{{filterLabel}}']/parent::*/parent::div/div[@class='admin__form-field-control']/select/option[@data-title='{{optionLabel}}']" parameterized="true"/>
<element name="duplicatedFilterCheckbox" type="button" selector="//input[@name='duplicated']"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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="AdminMediaGalleryDisabledContentFilterTest">
<annotations>
<features value="MediaGallery"/>
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1464"/>
<title value="User filter asset by disabled content"/>
<stories value="Story 57: User filters images by the area they used in"/>
<testCaseId value="to-be-added"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<testCaseId value="to-be-added"/>
<testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1320712/scenarios/4970565"/>

<description value="User filter asset by disabled content"/>
<severity value="CRITICAL"/>
<group value="media_gallery_ui"/>
</annotations>
<before>
<createData entity="SimpleSubCategory" stepKey="category"/>
<magentoCLI command="config:set cms/wysiwyg/enabled enabled" stepKey="enableWYSIWYG"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminEnhancedMediaGalleryImageDeleteActionGroup" stepKey="deleteImage"/>
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/>
<magentoCLI command="config:set cms/wysiwyg/enabled disabled" stepKey="disableWYSIWYG"/>
<deleteData createDataKey="category" stepKey="deleteCategory"/>
</after>
<actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openCategoryPage"/>
<actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="openCategory">
<argument name="category" value="$$category$$"/>
</actionGroup>
<actionGroup ref="AdminOpenMediaGalleryTinyMce4ActionGroup" stepKey="openMediaGalleryFromWysiwyg"/>
<actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage">
<argument name="image" value="ImageUpload"/>
</actionGroup>
<actionGroup ref="AdminMediaGalleryClickImageInGridActionGroup" stepKey="selectImageInGrid">
<argument name="imageName" value="{{ImageUpload.file}}"/>
</actionGroup>
<actionGroup ref="AdminMediaGalleryClickAddSelectedActionGroup" stepKey="clickAddSelectedImage"/>
<actionGroup ref="AdminMediaGalleryClickOkButtonTinyMce4ActionGroup" stepKey="clickOkButton"/>
<scrollToTopOfPage stepKey="scrollToTop"/>
<actionGroup ref="AdminEnableCategoryActionGroup" stepKey="disableCategory"/>
<actionGroup ref="AdminSaveCategoryActionGroup" stepKey="saveCategory"/>
<actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGallery"/>
<actionGroup ref="AdminEnhancedMediaGalleryExpandFilterActionGroup" stepKey="expandFilters"/>
<actionGroup ref="AdminMediaGalleryApplySelectFilterActionGroup" stepKey="selectFilterOption">
<argument name="selectLabel" value="Content Status"/>
<argument name="selectOption" value="Disabled"/>
</actionGroup>
<actionGroup ref="AdminEnhancedMediaGalleryApplyFiltersActionGroup" stepKey="applyFilters"/>
<actionGroup ref="AdminMediaGalleryAssertImageInGridActionGroup" stepKey="assertImageInGrid">
<argument name="image" value="ImageUpload"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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="AdminMediaGalleryEnabledContentFilterTest">
<annotations>
<features value="MediaGallery"/>
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1464"/>
<title value="User filter asset by enabled content"/>
<stories value="Story 57: User filters images by the area they used in"/>
<testCaseId value="to-be-added"/>
<description value="User filter asset by enabled content"/>
<severity value="CRITICAL"/>
<group value="media_gallery_ui"/>
</annotations>
<before>
<createData entity="SimpleSubCategory" stepKey="category"/>
<magentoCLI command="config:set cms/wysiwyg/enabled enabled" stepKey="enableWYSIWYG"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminEnhancedMediaGalleryImageDeleteActionGroup" stepKey="deleteImage"/>
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/>
<magentoCLI command="config:set cms/wysiwyg/enabled disabled" stepKey="disableWYSIWYG"/>
<deleteData createDataKey="category" stepKey="deleteCategory"/>
</after>
<actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openCategoryPage"/>
<actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="openCategory">
<argument name="category" value="$$category$$"/>
</actionGroup>
<actionGroup ref="AdminOpenMediaGalleryTinyMce4ActionGroup" stepKey="openMediaGalleryFromWysiwyg"/>
<actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage">
<argument name="image" value="ImageUpload"/>
</actionGroup>
<actionGroup ref="AdminMediaGalleryClickImageInGridActionGroup" stepKey="selectImageInGrid">
<argument name="imageName" value="{{ImageUpload.file}}"/>
</actionGroup>
<actionGroup ref="AdminMediaGalleryClickAddSelectedActionGroup" stepKey="clickAddSelectedImage"/>
<actionGroup ref="AdminMediaGalleryClickOkButtonTinyMce4ActionGroup" stepKey="clickOkButton"/>
<actionGroup ref="AdminSaveCategoryActionGroup" stepKey="saveCategory"/>
<actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGallery"/>
<actionGroup ref="AdminEnhancedMediaGalleryExpandFilterActionGroup" stepKey="expandFilters"/>
<actionGroup ref="AdminMediaGalleryApplySelectFilterActionGroup" stepKey="selectFilterOption">
<argument name="selectLabel" value="Content Status"/>
<argument name="selectOption" value="Enabled"/>
</actionGroup>
<actionGroup ref="AdminEnhancedMediaGalleryApplyFiltersActionGroup" stepKey="applyFilters"/>
<actionGroup ref="AdminMediaGalleryAssertImageInGridActionGroup" stepKey="assertImageInGrid">
<argument name="image" value="ImageUpload"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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="AdminMediaGalleryStoreViewContentFilterTest">
gabrieldagama marked this conversation as resolved.
Show resolved Hide resolved
<annotations>
<features value="MediaGallery"/>
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1464"/>
<title value="User filter asset by content store view"/>
<stories value="Story 57: User filters images by the area they used in"/>
<testCaseId value="to-be-added"/>
<description value="User filter asset by content store view"/>
<severity value="CRITICAL"/>
<group value="media_gallery_ui"/>
</annotations>
<before>
<createData entity="_defaultCmsPage" stepKey="createCMSPage" />
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminEnhancedMediaGalleryImageDeleteActionGroup" stepKey="deleteImage"/>
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/>
<deleteData createDataKey="createCMSPage" stepKey="deleteCmsPage"/>
</after>
<actionGroup ref="NavigateToCreatedCMSPageActionGroup" stepKey="navigateToCreatedCMSPage">
<argument name="CMSPage" value="$$createCMSPage$$"/>
</actionGroup>
<actionGroup ref="AdminOpenMediaGalleryForExistingPageNoEditorActionGroup" stepKey="openMediaGallery"/>
<actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage">
<argument name="image" value="ImageUpload"/>
</actionGroup>
<actionGroup ref="AdminMediaGalleryClickImageInGridActionGroup" stepKey="selectImageInGrid">
<argument name="imageName" value="{{ImageUpload.file}}"/>
</actionGroup>
<actionGroup ref="AdminMediaGalleryClickAddSelectedActionGroup" stepKey="clickAddSelectedImage"/>
<scrollToTopOfPage stepKey="scrollToTop"/>
<click selector="{{CmsNewPagePageActionsSection.saveAndContinueEdit}}" stepKey="clickSavePage"/>
<waitForPageLoad stepKey="waitForPageSave"/>
<actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGallery"/>
<actionGroup ref="AdminEnhancedMediaGalleryExpandFilterActionGroup" stepKey="expandFilters"/>
<actionGroup ref="AdminMediaGalleryApplySelectFilterActionGroup" stepKey="selectFilterOption">
<argument name="selectLabel" value="Store View"/>
<argument name="selectOption" value="Main Website/Main Website Store/Default Store View"/>
</actionGroup>
<actionGroup ref="AdminEnhancedMediaGalleryApplyFiltersActionGroup" stepKey="applyFilters"/>
<actionGroup ref="AdminMediaGalleryAssertImageInGridActionGroup" stepKey="assertImageInGrid">
<argument name="image" value="ImageUpload"/>
</actionGroup>
</test>
</tests>
27 changes: 27 additions & 0 deletions MediaGalleryUi/Ui/Component/Listing/Filters/Options/Status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\MediaGalleryUi\Ui\Component\Listing\Filters\Options;

use Magento\Framework\Data\OptionSourceInterface;

/**
* Status filter options
*/
class Status implements OptionSourceInterface
{
/**
* @inheritdoc
*/
public function toOptionArray(): array
{
return [
['value' => '1', 'label' => __('Enabled')],
['value' => '0', 'label' => __('Disabled')]
];
}
}
42 changes: 42 additions & 0 deletions MediaGalleryUi/Ui/Component/Listing/Filters/Options/Store.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\MediaGalleryUi\Ui\Component\Listing\Filters\Options;

use Magento\Store\Ui\Component\Listing\Column\Store\Options as StoreOptions;

/**
* Store Options for content field
*/
class Store extends StoreOptions
{
/**
* All Store Views value
*/
const ALL_STORE_VIEWS = '0';

/**
* Get options
*
* @return array
*/
public function toOptionArray()
{
if ($this->options !== null) {
return $this->options;
}

$this->currentOptions['All Store Views']['label'] = __('All Store Views');
$this->currentOptions['All Store Views']['value'] = self::ALL_STORE_VIEWS;

$this->generateCurrentOptions();

$this->options = array_values($this->currentOptions);

return $this->options;
}
}
8 changes: 7 additions & 1 deletion MediaGalleryUi/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\MediaGalleryUi\Model\SearchCriteria\CollectionProcessor\FilterProcessor\ContentField">
<arguments>
<argument name="getAssetIdsByContentStatus" xsi:type="object">Magento\MediaContentApi\Api\GetAssetIdsByContentFieldInterface</argument>
</arguments>
</type>
<virtualType name="Magento\MediaGalleryUi\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor">
<arguments>
<argument name="customFilters" xsi:type="array">
<item name="path" xsi:type="object">Magento\MediaGalleryUi\Model\SearchCriteria\CollectionProcessor\FilterProcessor\Directory</item>
<item name="fulltext" xsi:type="object">Magento\MediaGalleryUi\Model\SearchCriteria\CollectionProcessor\FilterProcessor\Keyword</item>
<item name="entity_type" xsi:type="object">Magento\MediaGalleryUi\Model\SearchCriteria\CollectionProcessor\FilterProcessor\EntityType</item>
<item name="duplicated" xsi:type="object">Magento\MediaGalleryUi\Model\SearchCriteria\CollectionProcessor\FilterProcessor\Duplicated</item>
<item name="content_status" xsi:type="object">Magento\MediaGalleryUi\Model\SearchCriteria\CollectionProcessor\FilterProcessor\ContentField</item>
<item name="store_id" xsi:type="object">Magento\MediaGalleryUi\Model\SearchCriteria\CollectionProcessor\FilterProcessor\ContentField</item>
</argument>
</arguments>
</virtualType>
<virtualType name="Magento\MediaGalleryUi\Model\Api\SearchCriteria\CollectionProcessor\SortingProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\SortingProcessor" />
<virtualType name="Magento\MediaGalleryUi\Model\Api\SearchCriteria\CollectionProcessor\PaginationProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\PaginationProcessor" />
<virtualType name="Magento\MediaGalleryUi\Model\Api\SearchCriteria\CollectionProcessor\JoinProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\JoinProcessor" />

<virtualType name="Magento\MediaGalleryUi\Model\Api\SearchCriteria\CollectionProcessor" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor">
<arguments>
<argument name="processors" xsi:type="array">
Expand Down
Loading