Skip to content

Commit 3bebcd6

Browse files
committed
AC-12807: Page Design Fix
1 parent 6de22d4 commit 3bebcd6

File tree

3 files changed

+89
-9
lines changed

3 files changed

+89
-9
lines changed

app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/DataProviderTest.php

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
<?php
2-
/***
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
2+
/************************************************************************
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
* ***********************************************************************
515
*/
616
declare(strict_types=1);
717

@@ -18,6 +28,7 @@
1828
use Magento\Ui\Component\Container;
1929
use PHPUnit\Framework\MockObject\MockObject;
2030
use PHPUnit\Framework\TestCase;
31+
use Magento\Cms\Api\Data\PageInterface;
2132

2233
class DataProviderTest extends TestCase
2334
{
@@ -66,6 +77,17 @@ class DataProviderTest extends TestCase
6677
*/
6778
private $requestFieldName = 'id';
6879

80+
/**
81+
* @var array
82+
*/
83+
private array $pageLayoutColumns = [
84+
PageInterface::PAGE_LAYOUT,
85+
PageInterface::CUSTOM_THEME,
86+
PageInterface::CUSTOM_THEME_FROM,
87+
PageInterface::CUSTOM_THEME_TO,
88+
PageInterface::CUSTOM_ROOT_TEMPLATE
89+
];
90+
6991
protected function setUp(): void
7092
{
7193
$this->authorizationMock = $this->getMockBuilder(Authorization::class)
@@ -111,10 +133,15 @@ protected function setUp(): void
111133
*/
112134
public function testPrepareMetadata()
113135
{
114-
$this->authorizationMock->expects($this->once())
136+
$this->authorizationMock->expects($this->exactly(2))
115137
->method('isAllowed')
116-
->with('Magento_Cms::save')
117-
->willReturn(false);
138+
->willReturnMap(
139+
[
140+
['Magento_Cms::save', null, false],
141+
['Magento_Cms::save_design', null, false],
142+
143+
]
144+
);
118145

119146
$metadata = [
120147
'cms_page_columns' => [
@@ -131,6 +158,21 @@ public function testPrepareMetadata()
131158
]
132159
];
133160

161+
foreach ($this->pageLayoutColumns as $column) {
162+
$metadata['cms_page_columns']['children'][$column] = [
163+
'arguments' => [
164+
'data' => [
165+
'config' => [
166+
'editor' => [
167+
'editorType' => false
168+
],
169+
'componentType' => Container::NAME
170+
]
171+
]
172+
]
173+
];
174+
}
175+
134176
$this->assertEquals(
135177
$metadata,
136178
$this->dataProvider->prepareMetadata()

app/code/Magento/Cms/Ui/Component/DataProvider.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
*/
66
namespace Magento\Cms\Ui\Component;
77

8+
use Magento\Cms\Api\Data\PageInterface;
89
use Magento\Framework\Api\Filter;
910
use Magento\Framework\Api\FilterBuilder;
1011
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
1112
use Magento\Framework\App\ObjectManager;
1213
use Magento\Framework\App\RequestInterface;
1314
use Magento\Framework\AuthorizationInterface;
1415
use Magento\Framework\View\Element\UiComponent\DataProvider\Reporting;
16+
use Magento\Ui\Component\Container;
1517

1618
/**
1719
* DataProvider for cms ui.
@@ -28,6 +30,17 @@ class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvi
2830
*/
2931
private $additionalFilterPool;
3032

33+
/**
34+
* @var array
35+
*/
36+
private array $pageLayoutColumns = [
37+
PageInterface::PAGE_LAYOUT,
38+
PageInterface::CUSTOM_THEME,
39+
PageInterface::CUSTOM_THEME_FROM,
40+
PageInterface::CUSTOM_THEME_TO,
41+
PageInterface::CUSTOM_ROOT_TEMPLATE
42+
];
43+
3144
/**
3245
* @param string $name
3346
* @param string $primaryFieldName
@@ -73,6 +86,8 @@ public function __construct(
7386
* Get authorization info.
7487
*
7588
* @deprecated 101.0.7
89+
* @see nothing
90+
*
7691
* @return AuthorizationInterface|mixed
7792
*/
7893
private function getAuthorizationInstance()
@@ -101,21 +116,42 @@ public function prepareMetadata()
101116
'editorConfig' => [
102117
'enabled' => false
103118
],
104-
'componentType' => \Magento\Ui\Component\Container::NAME
119+
'componentType' => Container::NAME
105120
]
106121
]
107122
]
108123
]
109124
];
110125
}
111126

127+
if (!$this->getAuthorizationInstance()->isAllowed('Magento_Cms::save_design')) {
128+
129+
foreach ($this->pageLayoutColumns as $column) {
130+
$metadata['cms_page_columns']['children'][$column] = [
131+
'arguments' => [
132+
'data' => [
133+
'config' => [
134+
'editor' => [
135+
'editorType' => false
136+
],
137+
'componentType' => Container::NAME
138+
]
139+
]
140+
]
141+
];
142+
}
143+
}
144+
112145
return $metadata;
113146
}
114147

115148
/**
116-
* @inheritdoc
149+
* Add Filter
150+
*
151+
* @param Filter $filter
152+
* @return void
117153
*/
118-
public function addFilter(Filter $filter)
154+
public function addFilter(Filter $filter): void
119155
{
120156
if (!empty($this->additionalFilterPool[$filter->getField()])) {
121157
$this->additionalFilterPool[$filter->getField()]->addFilter($this->searchCriteriaBuilder, $filter);

dev/tests/integration/testsuite/Magento/Cms/Ui/Component/DataProviderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Cms\Api\Data\BlockInterface;
1111
use Magento\Cms\Api\Data\PageInterface;
1212
use Magento\Framework\App\RequestInterface;
13+
use Magento\Framework\Exception\LocalizedException;
1314
use Magento\Framework\ObjectManagerInterface;
1415
use Magento\Framework\View\Element\UiComponentFactory;
1516
use Magento\Framework\View\Element\UiComponentInterface;
@@ -93,6 +94,7 @@ private function prepareChildComponents(UiComponentInterface $component): void
9394
*
9495
* @param string $namespace
9596
* @return array
97+
* @throws LocalizedException
9698
*/
9799
private function getComponentProvidedData(string $namespace): array
98100
{

0 commit comments

Comments
 (0)