Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix copy paste across dimensions #3873

Open
wants to merge 3 commits into
base: 9.0
Choose a base branch
from

Conversation

skurfuerst
Copy link
Member

@skurfuerst skurfuerst commented Oct 21, 2024

related neos/neos-development-collection#4614

After thoroughly thinking this through, I decided
that moving nodes across dimensions is effectively a copy followed by
a delete, thus it CHANGES IDENTITIES of nodes then.

This means it will work in all cases, even if the moved node already
existed with the same ID in the target dimension.

Lateron, we additionally need to expose CreateNodeVariant (which creates
connected variants) in the UI as well.

Resolves: #4614

After thoroughly thinking this through, I decided
that moving nodes across dimensions is effectively a copy followed by
a delete, thus it CHANGES IDENTITIES of nodes then.

This means it will work in all cases, even if the moved node already
existed with the same ID in the target dimension.

Lateron, we additionally need to expose CreateNodeVariant (which creates
connected variants) in the UI as well.

Resolves: #4614
@skurfuerst skurfuerst force-pushed the 90-fix-cut-copy-paste-across-dimensions branch from 9819aec to 33df996 Compare October 21, 2024 11:58
@mhsdesign mhsdesign self-requested a review October 28, 2024 20:33
Comment on lines +80 to +120
if (!$precedingSibling->dimensionSpacePoint->equals($subject->dimensionSpacePoint)) {
// WORKAROUND for MOVE ACROSS DIMENSIONS:
// - we want it to work like a copy/paste, followed by an original delete.
// - This is to ensure the user can use it as expected from text editors, where context
// is not preserved during cut/paste.
// - LATERON, we need to expose CreateNodeVariant (which creates connected variants) in the UI as well.
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph($subject->workspaceName)->getSubgraph(
$subject->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
),
$subject->workspaceName,
$subject,
// NOTE: in order to be able to copy/paste across dimensions, we need to use
// the TARGET NODE's DimensionSpacePoint to create the node in the target dimension.
OriginDimensionSpacePoint::fromDimensionSpacePoint($precedingSibling->dimensionSpacePoint),
$parentNodeOfPreviousSibling->aggregateId,
$succeedingSibling?->aggregateId
);

$contentRepository->handle($command);

$command = RemoveNodeAggregate::create(
$subject->workspaceName,
$subject->aggregateId,
$subject->dimensionSpacePoint,
NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS,
);
$contentRepository->handle($command);
} else {
$command = MoveNodeAggregate::create(
$subject->workspaceName,
$subject->dimensionSpacePoint,
$subject->aggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode ? null : $parentNodeOfPreviousSibling->aggregateId,
$precedingSibling->aggregateId,
$succeedingSibling?->aggregateId,
);
$contentRepository->handle($command);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure i understand the full implications of this ... as far as i know is move node super well tested and supports a variety of cases to distribute node aggregates and i dont know if we want to trade that in for the use of this CopyNodesRecursively plus removing the original node?

isnt this supported already by MoveNodeAggregate or do we need to extend the core?

@mhsdesign
Copy link
Member

Found an alternative fix in neos/neos-development-collection#4614 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants