Skip to content
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

TASK: Neos 9.0 edit preview modes #3618

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -11,6 +11,7 @@
* source code.
*/

use Neos\Neos\Domain\Service\RenderingModeService;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
Expand Down Expand Up @@ -49,6 +50,9 @@ class ReloadContentOutOfBand extends AbstractFeedback
*/
protected $contentRepositoryRegistry;

#[Flow\Inject]
protected RenderingModeService $renderingModeService;

public function setNode(Node $node): void
{
$this->node = $node;
Expand Down Expand Up @@ -131,8 +135,11 @@ protected function renderContent(ControllerContext $controllerContext): string|R
}

if ($this->nodeDomAddress) {
$renderingMode = $this->renderingModeService->findByCurrentUser();

$fusionView = new FusionView();
$fusionView->setControllerContext($controllerContext);
$fusionView->setOption('renderingModeName', $renderingMode->name);

$fusionView->assign('value', $this->node);
$fusionView->setFusionPath($this->nodeDomAddress->getFusionPathForContentRendering());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Neos\Domain\Service\RenderingModeService;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
Expand Down Expand Up @@ -59,6 +60,9 @@ class RenderContentOutOfBand extends AbstractFeedback
*/
protected $contentRepositoryRegistry;

#[Flow\Inject]
protected RenderingModeService $renderingModeService;

public function setNode(Node $node): void
{
$this->node = $node;
Expand Down Expand Up @@ -177,8 +181,11 @@ protected function renderContent(ControllerContext $controllerContext): string|R

$parentDomAddress = $this->getParentDomAddress();
if ($parentDomAddress) {
$renderingMode = $this->renderingModeService->findByCurrentUser();

$fusionView = new FusionView();
$fusionView->setControllerContext($controllerContext);
$fusionView->setOption('renderingModeName', $renderingMode->name);

$fusionView->assign('value', $parentNode);
$fusionView->setFusionPath($parentDomAddress->getFusionPath());
Expand Down
12 changes: 6 additions & 6 deletions Resources/Private/Fusion/Prototypes/Page.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ prototype(Neos.Neos:Page) {

@process.json = ${Json.stringify(value)}
@process.wrapInJsObject = ${'<script>window[\'@Neos.Neos.Ui:DocumentInformation\']=' + value + '</script>'}
@if.inBackend = ${Neos.Node.inBackend(documentNode)}
@if.inBackend = ${renderingMode.isEdit || renderingMode.isPreview}

// We need to ensure the JS backend information is always up to date, especially
// when child nodes change. Otherwise errors like the following might happen:
Expand All @@ -35,11 +35,11 @@ prototype(Neos.Neos:Page) {
entryIdentifier {
jsBackendInfo = 'javascriptBackendInformation'
documentNode = ${Neos.Caching.entryIdentifierForNode(documentNode)}
inBackend = ${Neos.Node.inBackend(documentNode)}
inBackend = ${renderingMode.isEdit || renderingMode.isPreview}
}
entryTags {
1 = ${Neos.Caching.nodeTag(documentNode)}
2 = ${Neos.Node.inBackend(documentNode) ? Neos.Caching.descendantOfTag(documentNode) : null}
2 = ${(renderingMode.isEdit || renderingMode.isPreview) ? Neos.Caching.descendantOfTag(documentNode) : null}
}
}
}
Expand All @@ -51,18 +51,18 @@ prototype(Neos.Neos:Page) {
compiledResourcePackage = ${Neos.Ui.StaticResources.compiledResourcePackage()}

sectionName = 'guestFrameApplication'
@if.inBackend = ${Neos.Node.inBackend(documentNode)}
@if.inBackend = ${renderingMode.isEdit || renderingMode.isPreview}
}
}

neosBackendContainer = '<div id="neos-backend-container"></div>'
neosBackendContainer.@position = 'before closingBodyTag'
neosBackendContainer.@if.inBackend = ${Neos.Node.inBackend(documentNode)}
neosBackendContainer.@if.inBackend = ${renderingMode.isEdit || renderingMode.isPreview}

neosBackendNotification = Neos.Fusion:Template {
@position = 'before closingBodyTag'
templatePath = 'resource://Neos.Neos.Ui/Private/Templates/Backend/GuestNotificationScript.html'
@if.inBackend = ${Neos.Node.inBackend(documentNode)}
@if.inBackend = ${renderingMode.isEdit || renderingMode.isPreview}
}

@exceptionHandler = 'Neos\\Neos\\Ui\\Fusion\\ExceptionHandler\\PageExceptionHandler'
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Fusion/Prototypes/Shortcut.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ prototype(Neos.Neos:Page) {
}

@if {
inBackend = ${Neos.Node.inBackend(documentNode)}
inBackend = ${renderingMode.isEdit || renderingMode.isPreview}
isShortcut = ${q(node).is('[instanceof Neos.Neos:Shortcut]')}
}
}
Expand Down
Loading