Skip to content

Commit 5937874

Browse files
ENGCOM-8064: #1760: Media Gallery Page opened successfully if 'Enhanced Media Gallery' disabled #29632
- Merge Pull Request #29632 from jmonteros422/magento2-1:1760-media-gallery-page-and-category-grid-page-opened-successfully-if-enhanced-media-gallery-disabled - Merged commits: 1. afe499d 2. 0994c44 3. 5a70b81 4. 2267021
2 parents 8f39516 + 2267021 commit 5937874

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminPageIs404ActionGroup">
12+
<annotations>
13+
<description>Validates that the '404 Error' message is present in the current Admin Page Header.</description>
14+
</annotations>
15+
16+
<see userInput="404 Error" selector="{{AdminHeaderSection.pageHeading}}" stepKey="see404PageHeading"/>
17+
</actionGroup>
18+
</actionGroups>

app/code/Magento/MediaGalleryUi/Controller/Adminhtml/Media/Index.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use Magento\Framework\App\Action\HttpGetActionInterface;
1313
use Magento\Framework\Controller\ResultFactory;
1414
use Magento\Framework\Controller\ResultInterface;
15+
use Magento\MediaContentApi\Model\Config;
16+
use Magento\Backend\App\Action\Context;
17+
use Magento\Backend\Model\View\Result\Forward;
1518

1619
/**
1720
* Controller serving the media gallery content
@@ -20,13 +23,39 @@ class Index extends Action implements HttpGetActionInterface
2023
{
2124
public const ADMIN_RESOURCE = 'Magento_Cms::media_gallery';
2225

26+
/**
27+
* @var Config
28+
*/
29+
private $config;
30+
31+
/**
32+
* Index constructor.
33+
* @param Context $context
34+
* @param Config $config
35+
*/
36+
public function __construct(
37+
Context $context,
38+
Config $config
39+
) {
40+
parent::__construct($context);
41+
$this->config = $config;
42+
}
43+
2344
/**
2445
* Get the media gallery layout
2546
*
2647
* @return ResultInterface
2748
*/
2849
public function execute(): ResultInterface
2950
{
51+
if (!$this->config->isEnabled()) {
52+
/** @var Forward $resultForward */
53+
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
54+
$resultForward->forward('noroute');
55+
56+
return $resultForward;
57+
}
58+
3059
/** @var Page $resultPage */
3160
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
3261
$resultPage->setActiveMenu('Magento_MediaGalleryUi::media_gallery')
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd">
11+
<suite name="MediaGalleryUiDisabledSuite">
12+
<include>
13+
<group name="media_gallery_ui_disabled"/>
14+
</include>
15+
</suite>
16+
</suites>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminStandaloneMediaGalleryDisabledTest">
11+
<annotations>
12+
<features value="MediaGallery"/>
13+
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1760"/>
14+
<title value="Standalone Media Gallery Page should return 404 if Media Gallery is disabled"/>
15+
<stories value="#1760 Media Gallery Page opened successfully if Enhanced Media Gallery disabled"/>
16+
<testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1337102/scenarios/5106786"/>
17+
<description value="Standalone Media Gallery Page should return 404 if Media Gallery is disabled"/>
18+
<severity value="CRITICAL"/>
19+
<group value="media_gallery_ui_disabled"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
</before>
24+
<actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGallery"/>
25+
<actionGroup ref="AssertAdminPageIs404ActionGroup" stepKey="see404Page"/>
26+
</test>
27+
</tests>

0 commit comments

Comments
 (0)