Skip to content

Commit

Permalink
Merge branch 'bugfix/90editPreviewModes' into task/e2e-tests-on-9-0
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Sep 16, 2023
2 parents d0c743c + 7e57498 commit 3bf7dde
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 32 deletions.
11 changes: 3 additions & 8 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,9 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d
$currentAccount->getAccountIdentifier()
)->toContentRepositoryWorkspaceName();

$command = ChangeBaseWorkspace::create($userWorkspaceName, WorkspaceName::fromString($targetWorkspaceName));
try {
$contentRepository->handle(
new ChangeBaseWorkspace(
$userWorkspaceName,
WorkspaceName::fromString($targetWorkspaceName),
$newCOnt = ContentStreamId::create()
)
)->block();
$contentRepository->handle($command)->block();
} catch (WorkspaceIsNotEmptyException $exception) {
$error = new Error();
$error->setMessage('Your personal workspace currently contains unpublished changes.'
Expand All @@ -375,7 +370,7 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d

$subgraph = $contentRepository->getContentGraph()
->getSubgraph(
$newCOnt,
$command->newContentStreamId,
$nodeAddress->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/AbstractCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function createNode(

$nodeAggregateId = NodeAggregateId::create(); // generate a new NodeAggregateId

$command = new CreateNodeAggregateWithNode(
$command = CreateNodeAggregateWithNode::create(
$parentNode->subgraphIdentity->contentStreamId,
$nodeAggregateId,
$nodeTypeName,
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Changes/MoveAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ public function apply(): void
$hasEqualParentNode = $parentNode->nodeAggregateId
->equals($parentNodeOfPreviousSibling->nodeAggregateId);

$command = new MoveNodeAggregate(
$command = MoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode ? null : $parentNodeOfPreviousSibling->nodeAggregateId,
$precedingSibling->nodeAggregateId,
$succeedingSibling?->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL
);

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Changes/MoveBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ public function apply(): void
$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);

$contentRepository->handle(
new MoveNodeAggregate(
MoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode
? null
: $succeedingSiblingParent->nodeAggregateId,
$precedingSibling?->nodeAggregateId,
$succeedingSibling->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL
)
)->block();

Expand Down
6 changes: 2 additions & 4 deletions Classes/Domain/Model/Changes/MoveInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ public function apply(): void

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$contentRepository->handle(
new MoveNodeAggregate(
MoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode ? null : $parentNode->nodeAggregateId,
null,
null,
RelationDistributionStrategy::STRATEGY_GATHER_ALL
)
)->block();

Expand Down
10 changes: 5 additions & 5 deletions Classes/Domain/Model/Changes/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function apply(): void
$originDimensionSpacePoint = OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint);
// if origin dimension space point != current DSP -> translate transparently (matching old behavior)
$contentRepository->handle(
new CreateNodeVariant(
CreateNodeVariant::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint,
Expand All @@ -200,7 +200,7 @@ public function apply(): void
)->block();
}
$commandResult = $contentRepository->handle(
new SetNodeProperties(
SetNodeProperties::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$originDimensionSpacePoint,
Expand All @@ -215,7 +215,7 @@ public function apply(): void
// property starts with "_"
if ($propertyName === '_nodeType') {
$commandResult = $contentRepository->handle(
new ChangeNodeAggregateType(
ChangeNodeAggregateType::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
NodeTypeName::fromString($value),
Expand All @@ -225,7 +225,7 @@ public function apply(): void
} elseif ($propertyName === '_hidden') {
if ($value === true) {
$commandResult = $contentRepository->handle(
new DisableNodeAggregate(
DisableNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint->toDimensionSpacePoint(),
Expand All @@ -235,7 +235,7 @@ public function apply(): void
} else {
// unhide
$commandResult = $contentRepository->handle(
new EnableNodeAggregate(
EnableNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint->toDimensionSpacePoint(),
Expand Down
6 changes: 4 additions & 2 deletions Classes/Domain/Model/Changes/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ public function apply(): void
$this->updateWorkspaceInfo();

$closestDocumentParentNode = $this->findClosestDocumentNode($subject);
$command = new RemoveNodeAggregate(
$command = RemoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$subject->subgraphIdentity->dimensionSpacePoint,
NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS,
$closestDocumentParentNode?->nodeAggregateId
);
if ($closestDocumentParentNode !== null) {
$command = $command->withRemovalAttachmentPoint($closestDocumentParentNode?->nodeAggregateId);
}

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$contentRepository->handle($command)->block();
Expand Down
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
2 changes: 1 addition & 1 deletion Classes/Service/PublishingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function publishWorkspace(ContentRepository $contentRepository, Workspace
)->block();

$contentRepository->handle(
new PublishWorkspace(
PublishWorkspace::create(
$workspaceName
)
)->block();
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.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
@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.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
inBackend = ${renderingMode.isEdit || renderingMode.isPreview}
}
entryTags {
1 = ${Neos.Caching.nodeTag(documentNode)}
2 = ${(Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)) ? 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.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
@if.inBackend = ${renderingMode.isEdit || renderingMode.isPreview}
}
}

neosBackendContainer = '<div id="neos-backend-container"></div>'
neosBackendContainer.@position = 'before closingBodyTag'
[email protected] = ${Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
[email protected] = ${renderingMode.isEdit || renderingMode.isPreview}

neosBackendNotification = Neos.Fusion:Template {
@position = 'before closingBodyTag'
templatePath = 'resource://Neos.Neos.Ui/Private/Templates/Backend/GuestNotificationScript.html'
@if.inBackend = ${Neos.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
@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.Backend.isEditMode(request) || Neos.Backend.isPreviewMode(request)}
inBackend = ${renderingMode.isEdit || renderingMode.isPreview}
isShortcut = ${q(node).is('[instanceof Neos.Neos:Shortcut]')}
}
}
Expand Down

0 comments on commit 3bf7dde

Please sign in to comment.