Skip to content

Commit

Permalink
Merge pull request #1602 from gabrieldagama/introduce-enable-store-vi…
Browse files Browse the repository at this point in the history
…ew-filters

Added Content Status and Store View filters
  • Loading branch information
Gabriel da Gama authored Jul 21, 2020
2 parents 36ff032 + 1eefe4c commit 535dbb4
Show file tree
Hide file tree
Showing 14 changed files with 417 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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
{
/**
* @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(
'main_table.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="filterLabel" type="string"/>
<argument name="optionLabel" type="string"/>
</arguments>

<click selector="{{AdminEnhancedMediaGalleryFiltersSection.selectFilter(filterLabel)}}" stepKey="openSelectFilter"/>
<click selector="{{AdminEnhancedMediaGalleryFiltersSection.selectFilterOption(filterLabel, optionLabel)}}" stepKey="selectFilterOption"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 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="AdminOpenMediaGalleryFromPageNoEditorActionGroup">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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="selectFilter" type="button" selector="//label[@class='admin__form-field-label']/span[text()='{{filterLabel}}']/parent::*/parent::div/div[@class='admin__form-field-control']/select" parameterized="true"/>
<element name="selectFilterOption" 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="searchOptionsFilter" type="select" selector="//div[label/span[contains(text(), '{{filterName}}')]]//div[@class='action-select admin__action-multiselect']" parameterized="true" timeout="30"/>
<element name="searchOptionsFilterInput" type="input" selector="//div[label/span[contains(text(), '{{filterName}}')]]//input[@data-role='advanced-select-text']" parameterized="true" timeout="30"/>
<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"/>
Expand Down
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="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="filterLabel" value="Content Status"/>
<argument name="optionLabel" 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="https://studio.cucumber.io/projects/131313/test-plan/folders/1320712/scenarios/4970565"/>
<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="filterLabel" value="Content Status"/>
<argument name="optionLabel" 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,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="AdminMediaGalleryStoreViewCategoryFilterTest">
<annotations>
<features value="MediaGallery"/>
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1464"/>
<title value="User filter asset by category store view"/>
<stories value="Story 57: User filters images by the area they used in"/>
<testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1320712/scenarios/4970870"/>
<description value="User filter asset by category store view"/>
<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"/>
<magentoCLI command="config:set cms/wysiwyg/enabled disabled" stepKey="disableWYSIWYG"/>
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/>
<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="filterLabel" value="Store View"/>
<argument name="optionLabel" 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>
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">
<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="https://studio.cucumber.io/projects/131313/test-plan/folders/1320712/scenarios/4970870"/>
<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="AdminOpenMediaGalleryFromPageNoEditorActionGroup" 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="filterLabel" value="Store View"/>
<argument name="optionLabel" 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;
}
}
Loading

0 comments on commit 535dbb4

Please sign in to comment.