Skip to content

[CMS Team 3] Sprint 1 #7

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

Merged
merged 83 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
a8d4f7c
MAGETWO-86948: Add Enable Page Builder Configuration Setting
irenelagno Jan 23, 2018
4868df5
Merge branch 'trigger_master' into MAGETWO-71404
irenelagno Jan 29, 2018
7f6ced2
Merge branch 'trigger_master' into MAGETWO-71404_1
irenelagno Jan 29, 2018
d01d65f
Merge remote-tracking branch 'trigger/MAGETWO-71404' into MAGETWO-71404
irenelagno Jan 29, 2018
65549dd
MAGETWO-86948: Add Enable Page Builder Configuration Setting
irenelagno Jan 29, 2018
f4367d0
MAGETWO-86961: Add warning message when disabling PageBuilder
danmooney2 Jan 30, 2018
fba630d
MAGETWO-86961: Add warning message when disabling PageBuilder
danmooney2 Jan 31, 2018
25d86c8
MAGETWO-86961: Add warning message when disabling PageBuilder
danmooney2 Jan 31, 2018
c9eccf1
MAGETWO-86961: Add warning message when disabling PageBuilder
danmooney2 Jan 31, 2018
3a4dabb
MAGETWO-86958: QA Activities for Enable PageBuilder
kieuphan2406 Jan 31, 2018
047325a
MAGETWO-86961: Add warning message when disabling PageBuilder
danmooney2 Feb 1, 2018
7c92238
MAGETWO-86961: Add warning message when disabling PageBuilder
danmooney2 Feb 1, 2018
cfb5793
MAGETWO-86961: Add warning message when disabling PageBuilder
danmooney2 Feb 1, 2018
49a1178
MAGETWO-86950: Create UI Component to display appropriate text editor
irenelagno Jan 31, 2018
0100140
Merge branch 'MAGETWO-71404-QA' into MAGETWO-86965
kieuphan2406 Feb 1, 2018
20fda9f
MAGETWO-86950: Create UI Component to display appropriate text editor
irenelagno Feb 1, 2018
622e6c0
MAGETWO-86963: Support Disabling Page Builder for a field
irenelagno Feb 1, 2018
265ddf9
Merge remote-tracking branch 'trigger/MAGETWO-86314-Disable-Bluefoot'…
irenelagno Feb 2, 2018
82973ec
MAGETWO-86966: Update user documentation
Feb 2, 2018
b8cac1c
Merge remote-tracking branch 'trigger/MAGETWO-86314-Disable-Bluefoot'…
irenelagno Feb 2, 2018
c3755db
MAGETWO-86954: Update CMS pages with new UI component
irenelagno Feb 2, 2018
742958c
Merge remote-tracking branch 'origin/MAGETWO-71404' into MAGETWO-86965
kieuphan2406 Feb 2, 2018
09a455c
MAGETWO-86963: Support Disabling Page Builder for a field
irenelagno Feb 2, 2018
9a562cc
MAGETWO-86963: Support Disabling Page Builder for a field
irenelagno Feb 2, 2018
b1f1d0a
Merge remote-tracking branch 'origin/MAGETWO-71404' into MAGETWO-86965
kieuphan2406 Feb 2, 2018
cf80c24
MAGETWO-87453: Display Wysiwyg on Catalog Product page
irenelagno Feb 5, 2018
80c91f0
Merge remote-tracking branch 'origin/MAGETWO-71404' into MAGETWO-86965
kieuphan2406 Feb 5, 2018
5899136
MAGETWO-87452: [CMS Page] Unable to save content from PageBuilder
irenelagno Feb 5, 2018
08ec99f
MAGETWO-86959: Update user documentation
Feb 5, 2018
f307166
MAGETWO-87397: PageBuilder is not accessible on Category and Product …
Feb 5, 2018
6df233a
Merge remote-tracking branch 'origin/MAGETWO-71404' into MAGETWO-86965
kieuphan2406 Feb 5, 2018
c4b1282
MAGETWO-86959: Update user documentation
Feb 5, 2018
6ed8157
MAGETWO-86965: QA Activities
kieuphan2406 Feb 5, 2018
9575f4a
MAGETWO-86956: Update Category page with Page Builder
irenelagno Feb 6, 2018
4487d1a
MAGETWO-86956: Update Category page with Page Builder
irenelagno Feb 6, 2018
8ead1a1
MAGETWO-86956: Update Category page with Page Builder
irenelagno Feb 7, 2018
072a124
MAGETWO-87453: Display Wysiwyg on Catalog Product page
irenelagno Feb 7, 2018
83a6383
MAGETWO-87460: Disable Page Builder area when switch between scope
Feb 7, 2018
3787df3
MAGETWO-86956: Update Category page with Page Builder
irenelagno Feb 7, 2018
6e59cd0
MAGETWO-86956: Update Category page with Page Builder
irenelagno Feb 7, 2018
5432346
MAGETWO-86954: Update CMS pages with new UI component
irenelagno Feb 7, 2018
2172524
MAGETWO-87561: Stabilize MFTF tests
Feb 7, 2018
68c41ae
MAGETWO-86954: Update CMS pages with new UI component
irenelagno Feb 8, 2018
d11be02
Merge branch 'MAGETWO-71404' into MAGETWO-71404-QA
irenelagno Feb 8, 2018
c9107b2
Merge branch 'MAGETWO-71404' into MAGETWO-86965
irenelagno Feb 8, 2018
bdf4599
MAGETWO-87482: Build stabilization
irenelagno Feb 8, 2018
77f07af
MAGETWO-87482: Build stabilization
irenelagno Feb 8, 2018
b0ed495
Merge remote-tracking branch 'trigger/MAGETWO-86965' into MAGETWO-71404
irenelagno Feb 8, 2018
37715f0
Merge branch 'MAGETWO-71404-QA' into MAGETWO-71404
irenelagno Feb 9, 2018
c23dafc
MAGETWO-87482: Build stabilization
irenelagno Feb 9, 2018
735ba54
Merge branch 'master_main' into MAGETWO-71404
irenelagno Feb 9, 2018
1843615
MAGETWO-87482: Build stabilization
irenelagno Feb 9, 2018
adb1bb4
MAGETWO-87482: Build stabilization
irenelagno Feb 12, 2018
ccd738c
Merge branch 'master_main' into MAGETWO-71404
irenelagno Feb 12, 2018
ce1168e
MAGETWO-87482: Build stabilization
irenelagno Feb 12, 2018
127cdca
MAGETWO-87482: Build stabilization
irenelagno Feb 12, 2018
ff02415
MAGETWO-87561: Stabilize MFTF tests
Feb 13, 2018
73b0b71
MAGETWO-87561: Stabilize MFTF tests
Feb 13, 2018
1c3c2e6
MAGETWO-87482: Build stabilization
irenelagno Feb 13, 2018
c721098
MAGETWO-87482: Build stabilization
irenelagno Feb 13, 2018
a9a77c8
MAGETWO-87482: Build stabilization
irenelagno Feb 13, 2018
cb71bfd
MAGETWO-87482: Build stabilization
irenelagno Feb 13, 2018
84238f3
MAGETWO-87482: Build stabilization
irenelagno Feb 13, 2018
b73363b
MAGETWO-87561: Stabilize MFTF tests
Feb 13, 2018
9f2abd4
MAGETWO-87482: Build stabilization
irenelagno Feb 14, 2018
2ded2dd
MAGETWO-87482: Build stabilization
irenelagno Feb 14, 2018
92e7f2f
MAGETWO-86958: QA Activities
kieuphan2406 Feb 14, 2018
70d130d
MAGETWO-87482: Build stabilization
irenelagno Feb 14, 2018
e266d82
MAGETWO-87561: Stabilize MFTF tests
irenelagno Feb 15, 2018
2a75e13
MAGETWO-87561: Stabilize MFTF tests
irenelagno Feb 15, 2018
208a018
MAGETWO-87942: Fix duplicate step keys in pagebuilder tests
Feb 16, 2018
9b79639
MAGETWO-87482: Build stabilization
irenelagno Feb 16, 2018
f57a030
MAGETWO-87482: Build stabilization
irenelagno Feb 16, 2018
e7e6ae0
MAGETWO-87482: Build stabilization
irenelagno Feb 16, 2018
cb3b8a9
MAGETWO-87942: Fix duplicate step keys in pagebuilder tests
Feb 16, 2018
8ee25e9
MAGETWO-71404: Enabling PageBuilder on Webstore
Feb 16, 2018
e385e9b
Merge remote-tracking branch 'owls/MAGETWO-87942-Fix-duplicate-step-k…
irenelagno Feb 16, 2018
787092c
MAGETWO-87482: Build stabilization
irenelagno Feb 16, 2018
e955d9e
MAGETWO-87482: Build stabilization
irenelagno Feb 16, 2018
ad6f293
MAGETWO-71404: Enabling PageBuilder on Webstore
Feb 16, 2018
85570af
MAGETWO-87482: Build stabilization
irenelagno Feb 17, 2018
08cf85e
MAGETWO-87482: Build stabilization
irenelagno Feb 17, 2018
6111bff
MAGETWO-71404: Enabling PageBuilder on Webstore
Feb 19, 2018
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,74 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\PageBuilder\Block\Adminhtml\System\Config;

use Magento\Framework\Data\Form\Element\AbstractElement;

class EnableField extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @var \Magento\Framework\Serialize\Serializer\Json
*/
private $json;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Serialize\Serializer\Json $json
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Serialize\Serializer\Json $json,
array $data = []
) {
parent::__construct($context, $data);
$this->json = $json;
}

/**
* {@inheritdoc}
*/
protected function _getElementHtml(AbstractElement $element)
{
$html = parent::_getElementHtml($element);
$enablePageBuilderSelector = '#cms_pagebuilder_enabled';

$jsString = '<script type="text/x-magento-init"> {"' .
$enablePageBuilderSelector . '": {
"Magento_PageBuilder/js/system/config/enable-field": {"modalTitleText": ' .
$this->json->serialize($this->getModalTitleText()) . ', "modalContentBody": ' .
$this->json->serialize($this->getModalContentBody())
. '}}}</script>';

$html .= $jsString;
return $html;
}

/**
* Get text for the modal title heading when user switches to disable
*
* @return string
*/
private function getModalTitleText()
{
return __('Are You Sure You Want to Turn Off Page Builder?');
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't capitalise each word in this string, it becomes more difficult to read.

I'd propose:

Are you sure you want to turn off Page Builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was requirement from Ievgen and Olena. I will check with them

}

/**
* Get HTML for the modal content body when user switches to disable
*
* @return string
*/
private function getModalContentBody()
{
$templateFileName = $this->getTemplateFile(
'Magento_PageBuilder::system/config/enableField/modalContentBody.phtml'
);

return $this->fetchView($templateFileName);
}
}
68 changes: 64 additions & 4 deletions app/code/Magento/PageBuilder/Block/Element/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@

class Editor extends \Magento\Framework\Data\Form\Element\Editor
{
/**
* @var \Magento\PageBuilder\Model\State
*/
private $pageBuilderState;

/**
* Editor constructor.
* @param \Magento\Framework\Data\Form\Element\Factory $factoryElement
* @param \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection
* @param \Magento\Framework\Escaper $escaper
* @param \Magento\PageBuilder\Model\State $pageBuilderState
* @param array $data
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
*/
public function __construct(
\Magento\Framework\Data\Form\Element\Factory $factoryElement,
\Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection,
\Magento\Framework\Escaper $escaper,
\Magento\PageBuilder\Model\State $pageBuilderState,
$data = [],
\Magento\Framework\Serialize\Serializer\Json $serializer = null
) {
$this->pageBuilderState = $pageBuilderState;
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
}

/**
* Return HTML button to toggling WYSIWYG
*
Expand All @@ -16,12 +42,11 @@ class Editor extends \Magento\Framework\Data\Form\Element\Editor
protected function _getToggleButtonHtml($visible = true)
{
$buttonHtml = '';
if ($this->getConfig()->getData('pagebuilder_button') !== false) {
if ($this->getConfig()->getData('pagebuilder_button') === true && $this->isPageBuilderUsed()) {
$buttonHtml .= $this->_getButtonHtml(
[
'title' => $this->translate('Enable Advanced CMS'),
'class' => 'magento-pagebuilder init-magento-pagebuilder action-default scalable action'
. ' action-secondary',
'title' => $this->translate('Edit with Page Builder'),
'class' => 'magento-pagebuilder init-magento-pagebuilder action-default scalable action',
'id' => 'magento-pagebuilder' . $this->getHtmlId()
]
);
Expand All @@ -37,6 +62,17 @@ protected function _getToggleButtonHtml($visible = true)
return $buttonHtml . parent::_getToggleButtonHtml($visible);
}

/**
* {@inheritdoc}
*/
public function isEnabled()
{
if ($this->isPageBuilderUsed()) {
return true;
}
return parent::isEnabled();
}

/**
Copy link
Member

Choose a reason for hiding this comment

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

Not part of your task, but could you please remove this method?

* Is the stage aspect of the system enabled
*
Expand All @@ -46,4 +82,28 @@ protected function isStageEnabled()
{
return true;
}

/**
* {@inheritdoc}
*/
protected function getInlineJs($jsSetupObject, $forceLoad)
{
if ($this->isPageBuilderUsed()) {
return '';
}

return parent::getInlineJs($jsSetupObject, $forceLoad);
}

/**
* Return if page builder will be used instead of wysiwyg editor
*
* @return bool
*/
private function isPageBuilderUsed()
{
$config = $this->getConfig();
Copy link
Member

Choose a reason for hiding this comment

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

Why do we check activeEditorPath?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try to simplify that condition in the feature sprint

return $config->getData('activeEditorPath') === 'Magento_PageBuilder/pageBuilderAdapter'
&& $config->getData('enable_pagebuilder') !== false;
}
}
33 changes: 21 additions & 12 deletions app/code/Magento/PageBuilder/Component/Form/Element/Wysiwyg.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
use Magento\Ui\Component\Wysiwyg\ConfigInterface;
use Magento\Catalog\Api\CategoryAttributeRepositoryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\PageBuilder\Model\State as PageBuilderState;

class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
{
/**
* Constructor
* Wysiwyg constructor.
*
* @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
* @param \Magento\Framework\Data\FormFactory $formFactory
* @param \Magento\Ui\Component\Wysiwyg\ConfigInterface $wysiwygConfig
* @param \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $attrRepository
* @param ContextInterface $context
* @param FormFactory $formFactory
* @param ConfigInterface $wysiwygConfig
* @param CategoryAttributeRepositoryInterface $attrRepository
* @param PageBuilderState $pageBuilderState
* @param array $components
* @param array $data
* @param array $config
Expand All @@ -29,10 +31,12 @@ public function __construct(
FormFactory $formFactory,
ConfigInterface $wysiwygConfig,
CategoryAttributeRepositoryInterface $attrRepository,
PageBuilderState $pageBuilderState,
array $components = [],
array $data = [],
array $config = []
) {
$wysiwygConfigData = isset($config['wysiwygConfigData']) ? $config['wysiwygConfigData'] : [];
// If a dataType is present we're dealing with an attribute
if (isset($config['dataType'])) {
try {
Expand All @@ -43,14 +47,19 @@ public function __construct(
// This model is used by non product attributes
}
}
$isEnablePageBuilder = isset($wysiwygConfigData['enable_pagebuilder'])
&& !$wysiwygConfigData['enable_pagebuilder']
|| false;
if (!$pageBuilderState->isPageBuilderInUse($isEnablePageBuilder)) {
// This is not done using definition.xml due to https://github.com/magento/magento2/issues/5647
$data['config']['component'] = 'Magento_PageBuilder/js/form/element/wysiwyg';

// This is not done using definition.xml due to https://github.com/magento/magento2/issues/5647
$data['config']['component'] = 'Magento_PageBuilder/js/form/element/wysiwyg';

// Override the templates to include our KnockoutJS code
$data['config']['template'] = 'Magento_PageBuilder/wysiwyg';
$data['config']['elementTmpl'] = 'Magento_PageBuilder/wysiwyg';

// Override the templates to include our KnockoutJS code
$data['config']['template'] = 'Magento_PageBuilder/wysiwyg';
$data['config']['elementTmpl'] = 'Magento_PageBuilder/wysiwyg';
$wysiwygConfigData['activeEditorPath'] = 'Magento_PageBuilder/pageBuilderAdapter';
$config['wysiwygConfigData'] = $wysiwygConfigData;
}
parent::__construct($context, $formFactory, $wysiwygConfig, $components, $data, $config);
}
}
29 changes: 26 additions & 3 deletions app/code/Magento/PageBuilder/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,31 @@
*/
namespace Magento\PageBuilder\Model;

use Magento\Framework\App\Config\ScopeConfigInterface;

class Config extends \Magento\Framework\Config\Data implements \Magento\PageBuilder\Model\Config\ConfigInterface
{
const IS_PAGEBUILDER_ENABLED = 'cms/pagebuilder/enabled';

/**
* Constructor
*
* @param \Magento\PageBuilder\Model\Config\Reader $reader
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* Config constructor.
* @param Config\Reader $reader
* @param \Magento\Framework\Config\CacheInterface $cache
* @param ScopeConfigInterface $scopeConfig
* @param string $cacheId
*/
public function __construct(
\Magento\PageBuilder\Model\Config\Reader $reader,
\Magento\Framework\Config\CacheInterface $cache,
ScopeConfigInterface $scopeConfig,
$cacheId = 'gene_bluefoot_content_types'
) {
$this->scopeConfig = $scopeConfig;
parent::__construct($reader, $cache, $cacheId);
}

Expand Down Expand Up @@ -59,4 +70,16 @@ public function getContentType($name)
{
return $this->get('types/' . $name);
}

/**
* Returns config setting if page builder enabled
*
* @return int
*/
public function isEnabled()
{
return (int)$this->scopeConfig->getValue(
\Magento\PageBuilder\Model\Config::IS_PAGEBUILDER_ENABLED
);
}
}
35 changes: 35 additions & 0 deletions app/code/Magento/PageBuilder/Model/State.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/


namespace Magento\PageBuilder\Model;

class State
{
/**
* @var \Magento\PageBuilder\Model\Config
*/
private $config;

/**
* State constructor.
* @param Config $config
*/
public function __construct(Config $config)
{
$this->config = $config;
}

/**
* Returns information if use page builder based on system configuration and xml configuration
* @param $isPageBuilderUsed
* @return bool
*/
public function isPageBuilderInUse($isPageBuilderUsed)
{
return $isPageBuilderUsed || !$this->config->isEnabled();
}
}
49 changes: 48 additions & 1 deletion app/code/Magento/PageBuilder/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
Magento_PageBuilder module provides an alternative interface for building content.
# Magento_PageBuilder module

The Magento_PageBuilder module provides an enhancement for the default Magento WYSIWYG editor. It installs an alternative editor in the Admin area for building content.

The PageBuilder editor can be used on the following content pages:

* Category Pages
* CMS Pages
* CMS Blocks
* Dynamic Blocks

## Enable the module

The PageBuilder module and the editor is enabled by default after installation.

The editor itself is enabled globally in the Admin area under *Stores > Configuration > Content Management > Advanced Content Tool > Enable Page Builder*.
This setting determines the `is_pagebuilder_enabled` configuration value.

## Disable the module

You can disable the PageBuilder module for a specific field by adding the following entry to a field configuration in an XML configuration file:

```
<item name="wysiwygConfigData" xsi:type="array">
<item name="enable_pagebuilder" xsi:type="boolean">false</item>
</item>
```

### Example

The following example disables the PageBuilder editor for the content field.

```
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="content" sortOrder="10">
<field name="content" formElement="wysiwyg">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="source" xsi:type="string">page</item>
<item name="wysiwygConfigData" xsi:type="array">
<item name="enable_pagebuilder" xsi:type="boolean">false</item>
</item>
</item>
</argument>
</field>
</fieldset>
</form>
```

**Note:** Disabling the editor this way overrides the value of `is_pagebuilder_enabled` for the specified field.
1 change: 1 addition & 0 deletions app/code/Magento/PageBuilder/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"magento/module-backend": "100.3.*",
"magento/module-cms": "101.2.0-dev",
"magento/module-catalog": "101.2.0-dev",
"magento/module-config": "100.3.*",
"magento/module-ui": "100.3.*",
"magento/module-search": "100.3.*",
"magento/module-newsletter": "100.3.*",
Expand Down
Loading