Skip to content

Commit 7bbc913

Browse files
Merge branch 'develop' of github.com:magento/magento2-page-builder into bug-287
2 parents 3190bcf + 1b05a1b commit 7bbc913

File tree

301 files changed

+6537
-4198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

301 files changed

+6537
-4198
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Scope
2+
### Story
3+
<!---
4+
* [<issue_number>](https://jira.corp.magento.com/browse/<issue_number>) <issue_title>
5+
-->
6+
7+
### Bug
8+
<!---
9+
* [<issue_number>](https://jira.corp.magento.com/browse/<issue_number>) <issue_title>
10+
-->
11+
12+
### Task
13+
<!---
14+
* [<issue_number>](https://jira.corp.magento.com/browse/<issue_number>) <issue_title>
15+
-->
16+
17+
### Builds
18+
<!---
19+
[All-User-Requested-Tests](https://m2build-ur.devops.magento.com/job/All-User-Requested-Tests/<build_number>)
20+
-->
21+
22+
### Related Pull Requests
23+
<!---
24+
https://github.com/magento/magento2ce/pull/<related_pr>
25+
-->
26+
<!-- related pull request placeholder -->
27+
28+
### Checklist
29+
- [ ] PR is green on M2 Quality Portal
30+
- [ ] Jira issues have accurate summary, meaningful description and have links to relevant documentation at the story/task level
31+
- [ ] Semantic Version build failure is approved by architect (if build is red) <Architect Name>
32+
- [ ] Pull Request approved by architect <Architect Name>
33+
- [ ] Pull Request quality review performed by <name>
34+
- [ ] All unstable functional acceptance tests are isolated (if any)
35+
- [ ] All linked Zephyr tests are approved by PO and have Ready to Use status
36+
- [ ] Travis CI build is green (for mainline CE only)
37+
- [ ] Jenkins Extended FAT build is green

.stylelintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"selector-combinator-space-before": "always",
2121
"selector-list-comma-newline-after": "always",
2222
"shorthand-property-no-redundant-values": true,
23-
"string-quotes": "single"
23+
"string-quotes": "single",
24+
"function-calc-no-invalid": null
2425
}
2526
}

app/code/Magento/PageBuilder/Block/Adminhtml/Stage/Render.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
/**
1919
* Class Render
20+
*
21+
* @api
2022
*/
2123
class Render extends Template
2224
{
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Controller\Adminhtml\Form\Element;
10+
11+
use Exception;
12+
use Magento\Backend\App\Action;
13+
use Magento\Backend\App\Action\Context;
14+
use Magento\Framework\App\Action\HttpPostActionInterface;
15+
use Magento\Framework\Controller\Result\JsonFactory;
16+
17+
/**
18+
* Returns the number of products that match the provided conditions
19+
*/
20+
class ProductTotals extends Action implements HttpPostActionInterface
21+
{
22+
const ADMIN_RESOURCE = 'Magento_Catalog::products';
23+
24+
/**
25+
* @var \Magento\PageBuilder\Model\Catalog\ProductTotals
26+
*/
27+
private $productTotals;
28+
29+
/**
30+
* @var JsonFactory
31+
*/
32+
private $jsonFactory;
33+
34+
/**
35+
* @param Context $context
36+
* @param \Magento\PageBuilder\Model\Catalog\ProductTotals $productTotals
37+
* @param JsonFactory $jsonFactory
38+
*/
39+
public function __construct(
40+
Context $context,
41+
\Magento\PageBuilder\Model\Catalog\ProductTotals $productTotals,
42+
JsonFactory $jsonFactory
43+
) {
44+
$this->jsonFactory = $jsonFactory;
45+
$this->productTotals = $productTotals;
46+
parent::__construct($context);
47+
}
48+
49+
/**
50+
* @inheritdoc
51+
*/
52+
public function execute()
53+
{
54+
$conditions = $this->getRequest()->getParam('conditionValue');
55+
56+
try {
57+
$totals = $this->productTotals->getProductTotals($conditions);
58+
$response = [
59+
'total' => $totals['total'],
60+
'disabled' => $totals['disabled'],
61+
'notVisible' => $totals['notVisible'],
62+
'outOfStock' => $totals['outOfStock'],
63+
];
64+
} catch (Exception $e) {
65+
$response = [
66+
'total' => 0,
67+
'disabled' => 0,
68+
'notVisible' => 0,
69+
'outOfStock' => 0,
70+
];
71+
}
72+
73+
return $this->jsonFactory->create()->setData($response);
74+
}
75+
}

app/code/Magento/PageBuilder/Controller/Adminhtml/Stage/Render.php

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
namespace Magento\PageBuilder\Controller\Adminhtml\Stage;
99

10+
use Magento\Backend\App\Action\Context;
1011
use Magento\Framework\App\Action\HttpGetActionInterface;
11-
use Magento\RequireJs\Block\Html\Head\Config;
12+
use Magento\Framework\View\Result\PageFactory;
1213

1314
/**
1415
* Class Render
@@ -20,30 +21,31 @@ class Render extends \Magento\Backend\App\Action implements HttpGetActionInterfa
2021
const ADMIN_RESOURCE = 'Magento_Backend::content';
2122

2223
/**
23-
* Render the RequireJS and Page Builder render blocks without any additional layout
24+
* @var \Magento\Framework\View\Result\PageFactory
25+
*/
26+
private $pageFactory;
27+
28+
/**
29+
* Render constructor.
30+
*
31+
* @param Context $context
32+
* @param PageFactory $pageFactory
33+
*/
34+
public function __construct(
35+
Context $context,
36+
PageFactory $pageFactory
37+
) {
38+
$this->pageFactory = $pageFactory;
39+
return parent::__construct($context);
40+
}
41+
42+
/**
43+
* Render route
2444
*
25-
* @return void
45+
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|mixed
2646
*/
2747
public function execute()
2848
{
29-
$layout = $this->_view->getLayout();
30-
$requireJs = $layout->createBlock(
31-
\Magento\Backend\Block\Page\RequireJs::class,
32-
'require.js'
33-
);
34-
$requireJs->setTemplate('Magento_Backend::page/js/require_js.phtml');
35-
/* @var \Magento\PageBuilder\Block\Adminhtml\Stage\Render $renderBlock */
36-
$renderBlock = $layout->createBlock(
37-
\Magento\PageBuilder\Block\Adminhtml\Stage\Render::class,
38-
'stage_render'
39-
);
40-
$renderBlock->setTemplate('Magento_PageBuilder::stage/render.phtml');
41-
$babelPolyfill = $layout->createBlock(
42-
\Magento\PageBuilder\Block\Adminhtml\Html\Head\BabelPolyfill::class,
43-
'pagebuilder.babel.polyfill'
44-
);
45-
$babelPolyfill->setTemplate('Magento_PageBuilder::html/head/babel_polyfill.phtml');
46-
$this->getResponse()->setBody($requireJs->toHtml() . $babelPolyfill->toHtml() . $renderBlock->toHtml());
47-
$this->getResponse()->sendResponse();
49+
return $this->pageFactory->create();
4850
}
4951
}

0 commit comments

Comments
 (0)