From 97a0e98fb797ba26c3565250ccdb39fe40124e9f Mon Sep 17 00:00:00 2001 From: Paula Kallert Date: Wed, 23 Oct 2024 11:21:43 +0200 Subject: [PATCH 1/5] Feture: Automatically set nodemove strategy in core --- Classes/Domain/Model/Changes/MoveAfter.php | 2 +- Classes/Domain/Model/Changes/MoveBefore.php | 2 +- Classes/Domain/Model/Changes/MoveInto.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Domain/Model/Changes/MoveAfter.php b/Classes/Domain/Model/Changes/MoveAfter.php index 8f80c28472..d850b51697 100644 --- a/Classes/Domain/Model/Changes/MoveAfter.php +++ b/Classes/Domain/Model/Changes/MoveAfter.php @@ -78,7 +78,7 @@ public function apply(): void $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - RelationDistributionStrategy::STRATEGY_GATHER_ALL, + null, $hasEqualParentNode ? null : $parentNodeOfPreviousSibling->aggregateId, $precedingSibling->aggregateId, $succeedingSibling?->aggregateId, diff --git a/Classes/Domain/Model/Changes/MoveBefore.php b/Classes/Domain/Model/Changes/MoveBefore.php index 879c52fc35..0f5a6baa73 100644 --- a/Classes/Domain/Model/Changes/MoveBefore.php +++ b/Classes/Domain/Model/Changes/MoveBefore.php @@ -74,7 +74,7 @@ public function apply(): void $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - RelationDistributionStrategy::STRATEGY_GATHER_ALL, + null, $hasEqualParentNode ? null : $succeedingSiblingParent->aggregateId, diff --git a/Classes/Domain/Model/Changes/MoveInto.php b/Classes/Domain/Model/Changes/MoveInto.php index 75474d0563..e37d3c27b6 100644 --- a/Classes/Domain/Model/Changes/MoveInto.php +++ b/Classes/Domain/Model/Changes/MoveInto.php @@ -83,7 +83,7 @@ public function apply(): void $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - RelationDistributionStrategy::STRATEGY_GATHER_ALL, + null, $hasEqualParentNode ? null : $parentNode->aggregateId, ) ); From 05f87b0637d2388652b5244e7eb368edfafa13d7 Mon Sep 17 00:00:00 2001 From: Paula Kallert Date: Fri, 15 Nov 2024 07:50:16 +0100 Subject: [PATCH 2/5] Feature: Call moveNodeStrategy in UI --- Classes/Domain/Model/Changes/MoveAfter.php | 6 ++++-- Classes/Domain/Model/Changes/MoveBefore.php | 6 ++++-- Classes/Domain/Model/Changes/MoveInto.php | 5 ++++- Configuration/Settings.yaml | 22 ++++++++++----------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Classes/Domain/Model/Changes/MoveAfter.php b/Classes/Domain/Model/Changes/MoveAfter.php index d850b51697..f50c25d33e 100644 --- a/Classes/Domain/Model/Changes/MoveAfter.php +++ b/Classes/Domain/Model/Changes/MoveAfter.php @@ -73,12 +73,14 @@ public function apply(): void $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); - + $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); + $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); + $strategy = RelationDistributionStrategy::fromName($strategy) ?: throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794);; $command = MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - null, + $strategy, $hasEqualParentNode ? null : $parentNodeOfPreviousSibling->aggregateId, $precedingSibling->aggregateId, $succeedingSibling?->aggregateId, diff --git a/Classes/Domain/Model/Changes/MoveBefore.php b/Classes/Domain/Model/Changes/MoveBefore.php index 0f5a6baa73..14a5176533 100644 --- a/Classes/Domain/Model/Changes/MoveBefore.php +++ b/Classes/Domain/Model/Changes/MoveBefore.php @@ -68,13 +68,15 @@ public function apply(): void ->equals($succeedingSiblingParent->aggregateId); $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); - + $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); + $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); + $strategy = RelationDistributionStrategy::fromName($strategy) ?: throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); $contentRepository->handle( MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - null, + $strategy, $hasEqualParentNode ? null : $succeedingSiblingParent->aggregateId, diff --git a/Classes/Domain/Model/Changes/MoveInto.php b/Classes/Domain/Model/Changes/MoveInto.php index e37d3c27b6..6c9008edb3 100644 --- a/Classes/Domain/Model/Changes/MoveInto.php +++ b/Classes/Domain/Model/Changes/MoveInto.php @@ -78,12 +78,15 @@ public function apply(): void ->equals($parentNode->aggregateId); $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); + $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); + $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); + $strategy = RelationDistributionStrategy::fromName($strategy) ?: throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); $contentRepository->handle( MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - null, + $strategy, $hasEqualParentNode ? null : $parentNode->aggregateId, ) ); diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index cd0906c98a..fbaf142a5e 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -94,7 +94,7 @@ Neos: ################################# # INTERNAL CONFIG (no API) ################################# - frontendDevelopmentMode: false + frontendDevelopmentMode: true nodeTypeRoles: # The ignored types will never have metadata in the UI, they are invisible to the content module. ignored: 'unstructured' @@ -139,7 +139,7 @@ Neos: src: '${Neos.Ui.NodeInfo.previewUri(documentNode, request)}' backgroundColor: '${Configuration.setting(''Neos.Neos.Ui.contentCanvas.backgroundColor'')}' debugMode: false - editPreviewMode: '${q(user).property("preferences.preferences")["contentEditing.editPreviewMode"] || Configuration.setting(''Neos.Neos.userInterface.defaultEditPreviewMode'')}' + editPreviewMode: '${Configuration.setting(''Neos.Neos.userInterface.defaultEditPreviewMode'')}' fullScreen: isFullScreen: false leftSideBar: @@ -158,22 +158,22 @@ Neos: pageTree: isLoading: false hasError: false - focused: '${[q(documentNode).property(''_contextPath'')]}' - active: '${q(documentNode).property(''_contextPath'')}' + focused: false + active: false remote: isSaving: false isPublishing: false isDiscarding: false user: name: - title: '${q(user).property(''name.title'')}' - firstName: '${q(user).property(''name.firstName'')}' - middleName: '${q(user).property(''name.middleName'')}' - lastName: '${q(user).property(''name.lastName'')}' - otherName: '${q(user).property(''name.otherName'')}' - fullName: '${q(user).property(''name.fullName'')}' + title: 'title' + firstName: 'firsname' + middleName: 'middle' + lastName: 'last' + otherName: 'other' + fullName: 'full' preferences: - interfaceLanguage: '${q(user).property(''preferences.interfaceLanguage'') || Configuration.setting(''Neos.Neos.userInterface.defaultLanguage'')}' + interfaceLanguage: '${Configuration.setting(''Neos.Neos.userInterface.defaultLanguage'')}' settings: targetWorkspace: 'live' changes: From f1af9950ef29d7ea5cc7d4eb0e9907ec144ca746 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:40:10 +0100 Subject: [PATCH 3/5] TASK: Reset `Configuration/Settings.yaml` --- Configuration/Settings.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index fbaf142a5e..cd0906c98a 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -94,7 +94,7 @@ Neos: ################################# # INTERNAL CONFIG (no API) ################################# - frontendDevelopmentMode: true + frontendDevelopmentMode: false nodeTypeRoles: # The ignored types will never have metadata in the UI, they are invisible to the content module. ignored: 'unstructured' @@ -139,7 +139,7 @@ Neos: src: '${Neos.Ui.NodeInfo.previewUri(documentNode, request)}' backgroundColor: '${Configuration.setting(''Neos.Neos.Ui.contentCanvas.backgroundColor'')}' debugMode: false - editPreviewMode: '${Configuration.setting(''Neos.Neos.userInterface.defaultEditPreviewMode'')}' + editPreviewMode: '${q(user).property("preferences.preferences")["contentEditing.editPreviewMode"] || Configuration.setting(''Neos.Neos.userInterface.defaultEditPreviewMode'')}' fullScreen: isFullScreen: false leftSideBar: @@ -158,22 +158,22 @@ Neos: pageTree: isLoading: false hasError: false - focused: false - active: false + focused: '${[q(documentNode).property(''_contextPath'')]}' + active: '${q(documentNode).property(''_contextPath'')}' remote: isSaving: false isPublishing: false isDiscarding: false user: name: - title: 'title' - firstName: 'firsname' - middleName: 'middle' - lastName: 'last' - otherName: 'other' - fullName: 'full' + title: '${q(user).property(''name.title'')}' + firstName: '${q(user).property(''name.firstName'')}' + middleName: '${q(user).property(''name.middleName'')}' + lastName: '${q(user).property(''name.lastName'')}' + otherName: '${q(user).property(''name.otherName'')}' + fullName: '${q(user).property(''name.fullName'')}' preferences: - interfaceLanguage: '${Configuration.setting(''Neos.Neos.userInterface.defaultLanguage'')}' + interfaceLanguage: '${q(user).property(''preferences.interfaceLanguage'') || Configuration.setting(''Neos.Neos.userInterface.defaultLanguage'')}' settings: targetWorkspace: 'live' changes: From b0fbcbdcbb00a84656a5e55f06b380ade566428b Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:45:55 +0100 Subject: [PATCH 4/5] TASK: Move `moveNodeStrategy` to Neos UI --- Classes/Domain/Model/Changes/MoveAfter.php | 2 +- Classes/Domain/Model/Changes/MoveBefore.php | 2 +- Classes/Domain/Model/Changes/MoveInto.php | 2 +- Configuration/NodeTypes.yaml | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Classes/Domain/Model/Changes/MoveAfter.php b/Classes/Domain/Model/Changes/MoveAfter.php index f50c25d33e..420644702c 100644 --- a/Classes/Domain/Model/Changes/MoveAfter.php +++ b/Classes/Domain/Model/Changes/MoveAfter.php @@ -75,7 +75,7 @@ public function apply(): void $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); - $strategy = RelationDistributionStrategy::fromName($strategy) ?: throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794);; + $strategy = RelationDistributionStrategy::tryFrom($strategy) ?? throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794);; $command = MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, diff --git a/Classes/Domain/Model/Changes/MoveBefore.php b/Classes/Domain/Model/Changes/MoveBefore.php index 14a5176533..0a57fa693e 100644 --- a/Classes/Domain/Model/Changes/MoveBefore.php +++ b/Classes/Domain/Model/Changes/MoveBefore.php @@ -70,7 +70,7 @@ public function apply(): void $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); - $strategy = RelationDistributionStrategy::fromName($strategy) ?: throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); + $strategy = RelationDistributionStrategy::tryFrom($strategy) ?? throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); $contentRepository->handle( MoveNodeAggregate::create( $subject->workspaceName, diff --git a/Classes/Domain/Model/Changes/MoveInto.php b/Classes/Domain/Model/Changes/MoveInto.php index 6c9008edb3..fe2757751a 100644 --- a/Classes/Domain/Model/Changes/MoveInto.php +++ b/Classes/Domain/Model/Changes/MoveInto.php @@ -80,7 +80,7 @@ public function apply(): void $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); - $strategy = RelationDistributionStrategy::fromName($strategy) ?: throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); + $strategy = RelationDistributionStrategy::tryFrom($strategy) ?? throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); $contentRepository->handle( MoveNodeAggregate::create( $subject->workspaceName, diff --git a/Configuration/NodeTypes.yaml b/Configuration/NodeTypes.yaml index d8d0c108ae..16968ddde1 100644 --- a/Configuration/NodeTypes.yaml +++ b/Configuration/NodeTypes.yaml @@ -24,6 +24,7 @@ factoryClassName: 'Neos\Neos\Ui\Infrastructure\Neos\UriPathSegmentNodeCreationHandlerFactory' promotedElements: factoryClassName: 'Neos\Neos\Ui\Infrastructure\ContentRepository\CreationDialog\PromotedElementsCreationHandlerFactory' + moveNodeStrategy: gatherAll 'Neos.Neos:Content': postprocessors: @@ -34,6 +35,7 @@ nodeCreationHandlers: promotedElements: factoryClassName: 'Neos\Neos\Ui\Infrastructure\ContentRepository\CreationDialog\PromotedElementsCreationHandlerFactory' + moveNodeStrategy: scatter 'Neos.Neos:ContentCollection': ui: From 3c03e53ba33ef223d7f5b900021dd8bce222019f Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:55:31 +0100 Subject: [PATCH 5/5] TASK: Improve errors for `moveNodeStrategy` and adjust to PSR12 code style --- Classes/Domain/Model/Changes/MoveAfter.php | 14 +++++++++----- Classes/Domain/Model/Changes/MoveBefore.php | 13 +++++++++---- Classes/Domain/Model/Changes/MoveInto.php | 13 +++++++++---- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Classes/Domain/Model/Changes/MoveAfter.php b/Classes/Domain/Model/Changes/MoveAfter.php index 420644702c..fadb9bc50d 100644 --- a/Classes/Domain/Model/Changes/MoveAfter.php +++ b/Classes/Domain/Model/Changes/MoveAfter.php @@ -71,16 +71,20 @@ public function apply(): void $hasEqualParentNode = $parentNode->aggregateId ->equals($parentNodeOfPreviousSibling->aggregateId); - $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); - $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); - $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); - $strategy = RelationDistributionStrategy::tryFrom($strategy) ?? throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794);; + $rawMoveNodeStrategy = $this->getNodeType($this->subject)?->getConfiguration('options.moveNodeStrategy'); + if (!is_string($rawMoveNodeStrategy)) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" expected string got %s', $this->subject->nodeTypeName->value, get_debug_type($rawMoveNodeStrategy)), 1732010016); + } + $moveNodeStrategy = RelationDistributionStrategy::tryFrom($rawMoveNodeStrategy); + if ($moveNodeStrategy === null) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" got %s', $this->subject->nodeTypeName->value, $rawMoveNodeStrategy), 1732010011); + } $command = MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - $strategy, + $moveNodeStrategy, $hasEqualParentNode ? null : $parentNodeOfPreviousSibling->aggregateId, $precedingSibling->aggregateId, $succeedingSibling?->aggregateId, diff --git a/Classes/Domain/Model/Changes/MoveBefore.php b/Classes/Domain/Model/Changes/MoveBefore.php index 0a57fa693e..d71d2c7566 100644 --- a/Classes/Domain/Model/Changes/MoveBefore.php +++ b/Classes/Domain/Model/Changes/MoveBefore.php @@ -68,15 +68,20 @@ public function apply(): void ->equals($succeedingSiblingParent->aggregateId); $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); - $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); - $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); - $strategy = RelationDistributionStrategy::tryFrom($strategy) ?? throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); + $rawMoveNodeStrategy = $this->getNodeType($this->subject)?->getConfiguration('options.moveNodeStrategy'); + if (!is_string($rawMoveNodeStrategy)) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" expected string got %s', $this->subject->nodeTypeName->value, get_debug_type($rawMoveNodeStrategy)), 1732010016); + } + $moveNodeStrategy = RelationDistributionStrategy::tryFrom($rawMoveNodeStrategy); + if ($moveNodeStrategy === null) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" got %s', $this->subject->nodeTypeName->value, $rawMoveNodeStrategy), 1732010011); + } $contentRepository->handle( MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - $strategy, + $moveNodeStrategy, $hasEqualParentNode ? null : $succeedingSiblingParent->aggregateId, diff --git a/Classes/Domain/Model/Changes/MoveInto.php b/Classes/Domain/Model/Changes/MoveInto.php index fe2757751a..95dad1c83e 100644 --- a/Classes/Domain/Model/Changes/MoveInto.php +++ b/Classes/Domain/Model/Changes/MoveInto.php @@ -78,15 +78,20 @@ public function apply(): void ->equals($parentNode->aggregateId); $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); - $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); - $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); - $strategy = RelationDistributionStrategy::tryFrom($strategy) ?? throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); + $rawMoveNodeStrategy = $this->getNodeType($this->subject)?->getConfiguration('options.moveNodeStrategy'); + if (!is_string($rawMoveNodeStrategy)) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" expected string got %s', $this->subject->nodeTypeName->value, get_debug_type($rawMoveNodeStrategy)), 1732010016); + } + $moveNodeStrategy = RelationDistributionStrategy::tryFrom($rawMoveNodeStrategy); + if ($moveNodeStrategy === null) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" got %s', $this->subject->nodeTypeName->value, $rawMoveNodeStrategy), 1732010011); + } $contentRepository->handle( MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - $strategy, + $moveNodeStrategy, $hasEqualParentNode ? null : $parentNode->aggregateId, ) );