Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.0' into task/90-remove-nodetyp…
Browse files Browse the repository at this point in the history
…emanager-from-node-4515
  • Loading branch information
mhsdesign committed Sep 24, 2023
2 parents 893446c + d632b6a commit 661a1e0
Show file tree
Hide file tree
Showing 73 changed files with 583 additions and 1,316 deletions.
9 changes: 6 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
environment:
COMPOSER_CACHE_DIR: /home/circleci/composer/cache-dir
docker:
- image: cimg/php:8.0-node
- image: cimg/php:8.2-node
steps:
- attach_workspace: *attach_workspace
- run: chmod -R 777 /home/circleci
Expand All @@ -81,8 +81,9 @@ jobs:
e2e:
environment:
FLOW_CONTEXT: Production
DB_HOST: 127.0.0.1
docker:
- image: cimg/php:8.0-node
- image: cimg/php:8.2-node
- image: cimg/mariadb:10.6
environment:
MYSQL_DATABASE: neos
Expand Down Expand Up @@ -113,6 +114,8 @@ jobs:
cd /home/circleci/app/Packages/Application/Neos.Neos.Ui
nvm install
nvm use
echo 127.0.0.1 onedimension.localhost | sudo tee -a /etc/hosts
echo 127.0.0.1 twodimensions.localhost | sudo tee -a /etc/hosts
make test-e2e-saucelabs
- store_artifacts:
path: /home/circleci/app/Data/Logs
Expand All @@ -121,7 +124,7 @@ jobs:
environment:
FLOW_CONTEXT: Production
docker:
- image: cimg/php:8.0-node
- image: cimg/php:8.2-node
- image: cimg/mariadb:10.6
environment:
MYSQL_DATABASE: neos
Expand Down
51 changes: 49 additions & 2 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Factory\ContentRepositoryId;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\DiscardIndividualNodesFromWorkspace;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\Workspace\Workspace;
use Neos\Neos\FrontendRouting\NodeAddress;
Expand All @@ -24,8 +24,8 @@
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Service\UserService as DomainUserService;
use Neos\Neos\PendingChangesProjection\ChangeFinder;
use Neos\Neos\PendingChangesProjection\ChangeProjection;
use Neos\Neos\Service\UserService;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RemoveNode;

/**
* @Flow\Scope("singleton")
Expand Down Expand Up @@ -155,6 +155,53 @@ public function getAllowedTargetWorkspaces(ContentRepository $contentRepository)
return $workspacesArray;
}

public function predictRemoveNodeFeedbackFromDiscardIndividualNodesFromWorkspaceCommand(
DiscardIndividualNodesFromWorkspace $command,
ContentRepository $contentRepository
): array {
$workspace = $contentRepository->getWorkspaceFinder()->findOneByName($command->workspaceName);
if (is_null($workspace)) {
return Nodes::createEmpty();
}

$changeFinder = $contentRepository->projectionState(ChangeFinder::class);
$changes = $changeFinder->findByContentStreamId($workspace->currentContentStreamId);

$handledNodes = [];
$result = [];
foreach ($changes as $change) {
if ($change->created) {
foreach ($command->nodesToDiscard as $nodeToDiscard) {
if (in_array($nodeToDiscard, $handledNodes)) {
continue;
}

if (
$nodeToDiscard->contentStreamId->equals($change->contentStreamId)
&& $nodeToDiscard->nodeAggregateId->equals($change->nodeAggregateId)
&& $nodeToDiscard->dimensionSpacePoint->equals($change->originDimensionSpacePoint)
) {
$subgraph = $contentRepository->getContentGraph()
->getSubgraph(
$nodeToDiscard->contentStreamId,
$nodeToDiscard->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);

$childNode = $subgraph->findNodeById($nodeToDiscard->nodeAggregateId);
$parentNode = $subgraph->findParentNode($nodeToDiscard->nodeAggregateId);
if ($parentNode) {
$result[] = new RemoveNode($childNode, $parentNode);
$handledNodes[] = $nodeToDiscard;
}
}
}
}
}

return $result;
}

private function getClosestDocumentNode(Node $node): ?Node
{
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
Expand Down
21 changes: 15 additions & 6 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,27 @@ public function discardAction(array $nodeContextPaths): void
$nodeAddress->dimensionSpacePoint
);
}
$contentRepository->handle(
DiscardIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToDiscard)
)
)->block();

$command = DiscardIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToDiscard)
);
$removeNodeFeedback = $this->workspaceService
->predictRemoveNodeFeedbackFromDiscardIndividualNodesFromWorkspaceCommand(
$command,
$contentRepository
);

$contentRepository->handle($command)->block();

$success = new Success();
$success->setMessage(sprintf('Discarded %d node(s).', count($nodeContextPaths)));

$updateWorkspaceInfo = new UpdateWorkspaceInfo($contentRepositoryId, $workspaceName);
$this->feedbackCollection->add($success);
foreach ($removeNodeFeedback as $removeNode) {
$this->feedbackCollection->add($removeNode);
}
$this->feedbackCollection->add($updateWorkspaceInfo);
} catch (\Exception $e) {
$error = new Error();
Expand Down
1 change: 0 additions & 1 deletion Classes/Domain/Model/ChangeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* source code.
*/


use Neos\ContentRepository\Core\Projection\ContentGraph\Node;

/**
Expand Down
3 changes: 0 additions & 3 deletions Classes/Domain/Model/Changes/MoveAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ public function apply(): void
$updateParentNodeInfo->setNode($parentNodeOfPreviousSibling);
$this->feedbackCollection->add($updateParentNodeInfo);

$removeNode = new RemoveNode($subject, $parentNodeOfPreviousSibling);
$this->feedbackCollection->add($removeNode);

$this->finish($subject);
}
}
Expand Down
3 changes: 0 additions & 3 deletions Classes/Domain/Model/Changes/MoveBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ public function apply(): void

$this->feedbackCollection->add($updateParentNodeInfo);

$removeNode = new RemoveNode($subject, $succeedingSiblingParent);
$this->feedbackCollection->add($removeNode);

$this->finish($subject);
}
}
Expand Down
3 changes: 0 additions & 3 deletions Classes/Domain/Model/Changes/MoveInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ public function apply(): void
$updateParentNodeInfo->setNode($parentNode);
$this->feedbackCollection->add($updateParentNodeInfo);

$removeNode = new RemoveNode($subject, $parentNode);
$this->feedbackCollection->add($removeNode);

$this->finish($subject);
}
}
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
20 changes: 16 additions & 4 deletions Classes/Domain/Model/Feedback/Operations/RemoveNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
Expand All @@ -25,6 +26,10 @@ class RemoveNode extends AbstractFeedback

protected Node $parentNode;

private NodeAddress $nodeAddress;

private NodeAddress $parentNodeAddress;

/**
* @Flow\Inject
* @var ContentRepositoryRegistry
Expand All @@ -37,6 +42,15 @@ public function __construct(Node $node, Node $parentNode)
$this->parentNode = $parentNode;
}

protected function initializeObject(): void
{
$contentRepository = $this->contentRepositoryRegistry->get($this->node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

$this->nodeAddress = $nodeAddressFactory->createFromNode($this->node);
$this->parentNodeAddress = $nodeAddressFactory->createFromNode($this->parentNode);
}

public function getNode(): Node
{
return $this->node;
Expand Down Expand Up @@ -87,11 +101,9 @@ public function isSimilarTo(FeedbackInterface $feedback)
*/
public function serializePayload(ControllerContext $controllerContext)
{
$contentRepository = $this->contentRepositoryRegistry->get($this->node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
return [
'contextPath' => $nodeAddressFactory->createFromNode($this->node)->serializeForUri(),
'parentContextPath' => $nodeAddressFactory->createFromNode($this->parentNode)->serializeForUri()
'contextPath' => $this->nodeAddress->serializeForUri(),
'parentContextPath' => $this->parentNodeAddress->serializeForUri()
];
}
}
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
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ test-e2e:
bash Tests/IntegrationTests/e2e.sh chrome

## Executes integration tests locally in a docker-compose setup.
#
# Note: On mac os you might need those two additional `/etc/hosts` entries:
# 127.0.0.1 onedimension.localhost
# 127.0.0.1 twodimensions.localhost
test-e2e-docker: build-e2e-testing
@bash Tests/IntegrationTests/e2e-docker.sh $(or $(browser),chrome)

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'
[email protected] = ${Neos.Node.inBackend(documentNode)}
[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.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

0 comments on commit 661a1e0

Please sign in to comment.