Skip to content

Commit

Permalink
TASK: Add rudimentary support for EditPreviewModes in 9.0
Browse files Browse the repository at this point in the history
With this change, the UI will default to the default inPlace edit mode,
regardless of user-side selection.

Actual full-blown support for EditPreviewModes will require deeper changes
over the entire code base.
  • Loading branch information
grebaldi committed Jul 10, 2023
1 parent 1375319 commit ce395ca
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,20 @@ protected function renderContent(ControllerContext $controllerContext): string|R

if ($this->nodeDomAddress) {
$fusionView = new FusionView();
$fusionView->setControllerContext($controllerContext);

$fakeActionRequest = clone $controllerContext->getRequest();
$fakeActionRequest->setControllerPackageKey('Neos.Neos');
$fakeActionRequest->setControllerName('Frontend\\Node');
$fakeActionRequest->setControllerActionName('edit');

$fakeControllerContext = new ControllerContext(
$fakeActionRequest,
$controllerContext->getResponse(),
$controllerContext->getArguments(),
$controllerContext->getUriBuilder(),
);

$fusionView->setControllerContext($fakeControllerContext);

$fusionView->assign('value', $this->node);
$fusionView->setFusionPath($this->nodeDomAddress->getFusionPathForContentRendering());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,20 @@ protected function renderContent(ControllerContext $controllerContext): string|R
$parentDomAddress = $this->getParentDomAddress();
if ($parentDomAddress) {
$fusionView = new FusionView();
$fusionView->setControllerContext($controllerContext);

$fakeActionRequest = clone $controllerContext->getRequest();
$fakeActionRequest->setControllerPackageKey('Neos.Neos');
$fakeActionRequest->setControllerName('Frontend\\Node');
$fakeActionRequest->setControllerActionName('edit');

$fakeControllerContext = new ControllerContext(
$fakeActionRequest,
$controllerContext->getResponse(),
$controllerContext->getArguments(),
$controllerContext->getUriBuilder(),
);

$fusionView->setControllerContext($fakeControllerContext);

$fusionView->assign('value', $parentNode);
$fusionView->setFusionPath($parentDomAddress->getFusionPath());
Expand Down
10 changes: 9 additions & 1 deletion Classes/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected function getUriInformation(Node $node, ControllerContext $controllerCo
if (!$node->nodeType->isOfType($this->documentNodeTypeRole)) {
return $nodeInfo;
}
$nodeInfo['uri'] = $this->previewUri($node, $controllerContext);
$nodeInfo['uri'] = $this->editUri($node, $controllerContext);
return $nodeInfo;
}

Expand Down Expand Up @@ -442,6 +442,14 @@ public function uri(Node|NodeAddress $nodeAddress, ControllerContext $controller
return (string)NodeUriBuilder::fromRequest($controllerContext->getRequest())->uriFor($nodeAddress);
}

public function editUri(Node $node, ControllerContext $controllerContext): string
{
$contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$nodeAddress = $nodeAddressFactory->createFromNode($node);
return (string)NodeUriBuilder::fromRequest($controllerContext->getRequest())->editUriFor($nodeAddress);
}

public function previewUri(Node $node, ControllerContext $controllerContext): string
{
$contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId);
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Neos:
personalWorkspace: '${Neos.Ui.Workspace.getPersonalWorkspace(contentRepositoryId)}'
ui:
contentCanvas:
src: '${Neos.Ui.NodeInfo.uri(documentNode, controllerContext)}'
src: '${Neos.Ui.NodeInfo.editUri(documentNode, controllerContext)}'
backgroundColor: '${Configuration.setting(''Neos.Neos.Ui.contentCanvas.backgroundColor'')}'
debugMode: false
editPreviewMode: '${q(user).property("preferences.preferences")["contentEditing.editPreviewMode"] || Configuration.setting(''Neos.Neos.userInterface.defaultEditPreviewMode'')}'
Expand Down
3 changes: 2 additions & 1 deletion Tests/IntegrationTests/TestDistribution/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"patches": {
"neos/neos-development-collection": {
"!!!FEATURE: (Neos.Neos) Track created nodes in PendingChangesProjection": "https://github.com/neos/neos-development-collection/pull/4393.patch",
"BUGFIX: (Neos.Neos) Restore show action of ContentDimensionsController": "https://github.com/neos/neos-development-collection/pull/4395.patch"
"BUGFIX: (Neos.Neos) Restore show action of ContentDimensionsController": "https://github.com/neos/neos-development-collection/pull/4395.patch",
"FEATURE: Edit preview mode support for Neos 9": "https://github.com/neos/neos-development-collection/pull/4067.patch"
}
}
},
Expand Down

0 comments on commit ce395ca

Please sign in to comment.