Skip to content
Draft
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
5 changes: 5 additions & 0 deletions Classes/Domain/Model/Changes/MoveAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public function apply(): void
);
$contentRepository->handle($command);

if (!$hasEqualParentNode) {
// Remove the node at the old location of moving across nodes; so that we can insert it again at the new location
$this->feedbackCollection->add(new RemoveNode($subject, $parentNode));
}

$updateParentNodeInfo = new UpdateNodeInfo();
$updateParentNodeInfo->setNode($parentNodeOfPreviousSibling);
$this->feedbackCollection->add($updateParentNodeInfo);
Expand Down
5 changes: 5 additions & 0 deletions Classes/Domain/Model/Changes/MoveBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public function apply(): void
)
);

if (!$hasEqualParentNode) {
// Remove the node at the old location of moving across nodes; so that we can insert it again at the new location
$this->feedbackCollection->add(new RemoveNode($subject, $parentNode));
}

$updateParentNodeInfo = new UpdateNodeInfo();
$updateParentNodeInfo->setNode($succeedingSiblingParent);

Expand Down
6 changes: 6 additions & 0 deletions Classes/Domain/Model/Changes/MoveInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Neos\ContentRepository\Core\Feature\NodeMove\Command\MoveNodeAggregate;
use Neos\ContentRepository\Core\Feature\NodeMove\Dto\RelationDistributionStrategy;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RemoveNode;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodeInfo;

/**
Expand Down Expand Up @@ -96,6 +97,11 @@ public function apply(): void
)
);

if (!$hasEqualParentNode) {
// Remove the node at the old location of moving across nodes; so that we can insert it again at the new location
$this->feedbackCollection->add(new RemoveNode($subject, $parentNode));
}

$updateParentNodeInfo = new UpdateNodeInfo();
$updateParentNodeInfo->setNode($parentNode);
$this->feedbackCollection->add($updateParentNodeInfo);
Expand Down
123 changes: 0 additions & 123 deletions Classes/Domain/Model/Feedback/Operations/UpdateNodePath.php

This file was deleted.

21 changes: 0 additions & 21 deletions packages/neos-ui-redux-store/src/CR/Nodes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,6 @@ export const getAllowedNodeTypesTakingAutoCreatedIntoAccount = (baseNode: Node,
return nodeTypesRegistry.getAllowedChildNodeTypes(baseNode.nodeType);
};

//
// Helper function to get parent contextPath from current contextPath
//
// IMPORTANT: The function is used just by the old CR and the can be removed,
// when the event sourced CR is the only way
//
export const parentNodeContextPath = (contextPath: NodeContextPath) => {
if (typeof contextPath !== 'string') {
console.error('`contextPath` must be a string!');
return null;
}
const [path, context] = contextPath.split('@');

if (path.length === 0) {
// We are at top level; so there is no parent anymore!
return null;
}

return `${path.substr(0, path.lastIndexOf('/'))}@${context}`;
};

//
// Helper function to check if the node is collapsed
//
Expand Down
71 changes: 6 additions & 65 deletions packages/neos-ui/src/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import {actions, selectors} from '@neos-project/neos-ui-redux-store';

import {parentNodeContextPath} from '@neos-project/neos-ui-redux-store/src/CR/Nodes/helpers';

import manifest from '@neos-project/neos-ui-extensibility';
import {SynchronousRegistry, SynchronousMetaRegistry} from '@neos-project/neos-ui-extensibility/src/registry';

Expand Down Expand Up @@ -265,69 +263,12 @@
store.dispatch(actions.CR.Nodes.merge(feedbackPayload.byContextPath));
});

//
// When the server has updated node path, apply it to the store
//
serverFeedbackHandlers.set('Neos.Neos.Ui:UpdateNodePath/Main', ({oldContextPath, newContextPath}, {store}) => {
let currentDocumentNodeMoved = false;
const parentContextPath = parentNodeContextPath(oldContextPath);

const state = store.getState();
if (state?.cr?.nodes?.focused?.contextPath === oldContextPath) {
store.dispatch(actions.CR.Nodes.unFocus());
}

if (state?.ui?.pageTree?.isFocused === oldContextPath) {
store.dispatch(actions.UI.PageTree.focus(parentContextPath));
}

// If we are moving the current document node or one of its parents...
const [oldPath] = oldContextPath.split('@');
const currentDocumentNodePath = state?.cr?.nodes?.documentNode;
if (currentDocumentNodePath && (currentDocumentNodePath === oldContextPath || currentDocumentNodePath.split('@')[0].startsWith(oldPath + '/'))) {
currentDocumentNodeMoved = true;
let redirectContextPath = oldContextPath;
let redirectUri = null;
// Determine closest parent that is not being moved
while (!redirectUri) {
redirectContextPath = parentNodeContextPath(redirectContextPath);
// This is an extreme case when even the top node does not exist in the given dimension
// TODO: still find a nicer way to break out of this situation
if (redirectContextPath === false) {
window.location.href = routes?.core?.modules?.defaultModule;
break;
}
redirectUri = state?.cr?.nodes?.byContextPath?.[redirectContextPath]?.uri;
}

// Temporarily set the document node to the moved nodes parent before updating its path
store.dispatch(actions.CR.Nodes.setDocumentNode(redirectContextPath));
}

store.dispatch(actions.CR.Nodes.updatePath(oldContextPath, newContextPath));

// If we moved the current node we have to read the preview uri again and then redirect the content frame
// and also update the selected document node
if (currentDocumentNodeMoved) {
const newState = store.getState();
store.dispatch(actions.UI.ContentCanvas.setSrc(newState?.cr?.nodes?.byContextPath?.[newContextPath]?.uri));
store.dispatch(actions.CR.Nodes.setDocumentNode(newContextPath));
}

// Remove the node from the old position in the dom
if (state?.cr?.nodes?.documentNode !== oldContextPath) {
findAllOccurrencesOfNodeInGuestFrame(oldContextPath).forEach(el => {
const closestContentCollection = el.closest('.neos-contentcollection');
el.remove();

createEmptyContentCollectionPlaceholderIfMissing(closestContentCollection);

dispatchCustomEvent('Neos.NodeRemoved', 'Node was removed.', {
element: el
});
});
}
});
// TODO
/*if (currentDocumentNodeMoved) {

Check failure on line 267 in packages/neos-ui/src/manifest.js

View workflow job for this annotation

GitHub Actions / Code style

Expected space or tab before '*/' in comment

Check failure on line 267 in packages/neos-ui/src/manifest.js

View workflow job for this annotation

GitHub Actions / Code style

Expected exception block, space or tab after '/*' in comment
const newState = store.getState();
store.dispatch(actions.UI.ContentCanvas.setSrc(newState?.cr?.nodes?.byContextPath?.[newContextPath]?.uri));
store.dispatch(actions.CR.Nodes.setDocumentNode(newContextPath));
}*/

//
// When the server has removed a node, remove it as well from the store amd the dom
Expand Down
Loading