Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.0' into feature/improveNodeCre…
Browse files Browse the repository at this point in the history
…ationHandlerInterface
  • Loading branch information
mhsdesign committed Mar 14, 2024
2 parents d4c0bf5 + 1d9df94 commit 554879b
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 54 deletions.
4 changes: 2 additions & 2 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ public function predictRemoveNodeFeedbackFromDiscardIndividualNodesFromWorkspace
}

if (
$nodeToDiscard->contentStreamId->equals($change->contentStreamId)
$nodeToDiscard->workspaceName->equals($workspace->workspaceName)
&& $nodeToDiscard->nodeAggregateId->equals($change->nodeAggregateId)
&& $nodeToDiscard->dimensionSpacePoint->equals($change->originDimensionSpacePoint)
) {
$subgraph = $contentRepository->getContentGraph()
->getSubgraph(
$nodeToDiscard->contentStreamId,
$workspace->currentContentStreamId,
$nodeToDiscard->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function publishAction(array $nodeContextPaths, string $targetWorkspaceNa
foreach ($nodeContextPaths as $contextPath) {
$nodeAddress = $nodeAddressFactory->createFromUriString($contextPath);
$nodeIdentifiersToPublish[] = new NodeIdToPublishOrDiscard(
$nodeAddress->contentStreamId,
$workspaceName,
$nodeAddress->nodeAggregateId,
$nodeAddress->dimensionSpacePoint
);
Expand Down Expand Up @@ -279,7 +279,7 @@ public function discardAction(array $nodeContextPaths): void
foreach ($nodeContextPaths as $contextPath) {
$nodeAddress = $nodeAddressFactory->createFromUriString($contextPath);
$nodeIdentifiersToDiscard[] = new NodeIdToPublishOrDiscard(
$nodeAddress->contentStreamId,
$workspaceName,
$nodeAddress->nodeAggregateId,
$nodeAddress->dimensionSpacePoint
);
Expand Down
12 changes: 10 additions & 2 deletions Classes/Domain/Model/Changes/AbstractCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,24 @@ protected function createNode(

$nodeAggregateId = $this->getNodeAggregateId() ?? NodeAggregateId::create(); // generate a new NodeAggregateId

$contentRepository = $this->contentRepositoryRegistry->get($parentNode->subgraphIdentity->contentRepositoryId);
$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($parentNode->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $parentNode->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}
$command = CreateNodeAggregateWithNode::create(
$parentNode->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$nodeAggregateId,
$nodeTypeName,
OriginDimensionSpacePoint::fromDimensionSpacePoint($parentNode->subgraphIdentity->dimensionSpacePoint),
$parentNode->nodeAggregateId,
$succeedingSiblingNodeAggregateId,
$nodeName
);
$contentRepository = $this->contentRepositoryRegistry->get($parentNode->subgraphIdentity->contentRepositoryId);

$commands = $this->applyNodeCreationHandlers(
NodeCreationCommands::fromFirstCommand(
Expand Down
5 changes: 5 additions & 0 deletions Classes/Domain/Model/Changes/CopyAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@ public function apply(): void
$targetNodeName = NodeName::fromString(uniqid('node-'));

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception('Could not find workspace for content stream', 1699004343);
}
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph()->getSubgraph(
$subject->subgraphIdentity->contentStreamId,
$subject->subgraphIdentity->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
),
$workspace->workspaceName,
$subject,
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
$parentNodeOfPreviousSibling->nodeAggregateId,
Expand Down
5 changes: 5 additions & 0 deletions Classes/Domain/Model/Changes/CopyBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ public function apply(): void
$targetNodeName = NodeName::fromString(uniqid('node-'));

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception('Could not find workspace for content stream', 1699004343);
}
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph()->getSubgraph(
$subject->subgraphIdentity->contentStreamId,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->subgraphIdentity->visibilityConstraints
),
$workspace->workspaceName,
$subject,
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
$parentNodeOfSucceedingSibling->nodeAggregateId,
Expand Down
5 changes: 5 additions & 0 deletions Classes/Domain/Model/Changes/CopyInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,17 @@ public function apply(): void
$targetNodeName = NodeName::fromString(uniqid('node-'));

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception('Could not find workspace for content stream', 1699004343);
}
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph()->getSubgraph(
$subject->subgraphIdentity->contentStreamId,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->subgraphIdentity->visibilityConstraints
),
$workspace->workspaceName,
$subject,
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
$parentNode->nodeAggregateId,
Expand Down
15 changes: 12 additions & 3 deletions Classes/Domain/Model/Changes/MoveAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,26 @@ public function apply(): void
$hasEqualParentNode = $parentNode->nodeAggregateId
->equals($parentNodeOfPreviousSibling->nodeAggregateId);


$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $subject->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}

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

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$contentRepository->handle($command)->block();

$updateParentNodeInfo = new UpdateNodeInfo();
Expand Down
10 changes: 9 additions & 1 deletion Classes/Domain/Model/Changes/MoveBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,18 @@ public function apply(): void
->equals($succeedingSiblingParent->nodeAggregateId);

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $subject->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}

$contentRepository->handle(
MoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
Expand Down
11 changes: 9 additions & 2 deletions Classes/Domain/Model/Changes/MoveInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Neos\ContentRepository\Core\Feature\NodeMove\Command\MoveNodeAggregate;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Feature\NodeMove\Dto\RelationDistributionStrategy;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RemoveNode;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodeInfo;

/**
Expand Down Expand Up @@ -84,9 +83,17 @@ public function apply(): void
->equals($parentNode->nodeAggregateId);

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $subject->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}
$contentRepository->handle(
MoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
Expand Down
24 changes: 15 additions & 9 deletions Classes/Domain/Model/Changes/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
use Neos\Neos\Ui\Domain\Service\NodePropertyConversionService;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/** @codingStandardsIgnoreStart */
/** @codingStandardsIgnoreEnd */

/**
* Changes a property on a node
* @internal These objects internally reflect possible operations made by the Neos.Ui.
Expand Down Expand Up @@ -158,6 +155,15 @@ public function apply(): void

$propertyType = $this->getNodeType($subject)->getPropertyType($propertyName);

$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $subject->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}

// Use extra commands for reference handling
if ($propertyType === 'reference' || $propertyType === 'references') {
$value = $this->getValue();
Expand All @@ -180,7 +186,7 @@ public function apply(): void

$commandResult = $contentRepository->handle(
SetNodeReferences::create(
$subject->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint,
ReferenceName::fromString($propertyName),
Expand All @@ -200,7 +206,7 @@ public function apply(): void
// if origin dimension space point != current DSP -> translate transparently (matching old behavior)
$contentRepository->handle(
CreateNodeVariant::create(
$subject->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint,
$originDimensionSpacePoint
Expand All @@ -209,7 +215,7 @@ public function apply(): void
}
$commandResult = $contentRepository->handle(
SetNodeProperties::create(
$subject->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$subject->nodeAggregateId,
$originDimensionSpacePoint,
PropertyValuesToWrite::fromArray(
Expand All @@ -224,7 +230,7 @@ public function apply(): void
if ($propertyName === '_nodeType') {
$commandResult = $contentRepository->handle(
ChangeNodeAggregateType::create(
$subject->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$subject->nodeAggregateId,
NodeTypeName::fromString($value),
NodeAggregateTypeChangeChildConstraintConflictResolutionStrategy::STRATEGY_DELETE
Expand All @@ -234,7 +240,7 @@ public function apply(): void
if ($value === true) {
$commandResult = $contentRepository->handle(
DisableNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint->toDimensionSpacePoint(),
NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS
Expand All @@ -244,7 +250,7 @@ public function apply(): void
// unhide
$commandResult = $contentRepository->handle(
EnableNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint->toDimensionSpacePoint(),
NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS
Expand Down
10 changes: 9 additions & 1 deletion Classes/Domain/Model/Changes/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ public function apply(): void

$subgraph = $this->contentRepositoryRegistry->subgraphForNode($this->subject);
$closestDocumentParentNode = $subgraph->findClosestNode($this->subject->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $subject->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}
$command = RemoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$workspace->workspaceName,
$subject->nodeAggregateId,
$subject->subgraphIdentity->dimensionSpacePoint,
NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS,
Expand Down
24 changes: 24 additions & 0 deletions packages/neos-ui/src/Containers/Drawer/UserDropDown/UserImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';

import style from './style.module.css';

@connect(state => ({
userFirstName: state?.user?.name?.firstName,
userLastName: state?.user?.name?.lastName
}))

export default class UserImage extends PureComponent {
static propTypes = {
userFirstName: PropTypes.string,
userLastName: PropTypes.string
};

render() {
const userInitials = this.props.userFirstName?.charAt(0) + this.props.userLastName?.charAt(0);
return (
<div className={style.user__image}>{userInitials}</div>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {connect} from 'react-redux';

import {neos} from '@neos-project/neos-ui-decorators';
import {Icon, DropDown} from '@neos-project/react-ui-components';
import UserImage from './UserImage';
import RestoreButtonItem from './RestoreButtonItem';

import I18n from '@neos-project/neos-ui-i18n';
Expand All @@ -28,10 +29,16 @@ export default class UserDropDown extends PureComponent {
<div className={style.wrapper}>
<DropDown className={style.dropDown}>
<DropDown.Header className={style.dropDown__btn}>
<Icon className={style.dropDown__btnIcon} icon="user"/>
<UserImage />
<span className={style.dropDown__userName}>{this.props.userName}</span>
</DropDown.Header>
<DropDown.Contents className={style.dropDown__contents}>
<li className={style.dropDown__item}>
<a title="User Settings" href={userSettingsUri}>
<Icon icon="wrench" aria-hidden="true" className={style.dropDown__itemIcon}/>
<I18n id="userSettings.label" sourceName="Modules" packageKey="Neos.Neos" fallback="User Settings"/>
</a>
</li>
<li className={style.dropDown__item}>
<form title="Logout" action={logoutUri} method="post" role="presentation">
<input type="hidden" name="__csrfToken" value={csrfToken}/>
Expand All @@ -41,12 +48,6 @@ export default class UserDropDown extends PureComponent {
</button>
</form>
</li>
<li className={style.dropDown__item}>
<a title="User Settings" href={userSettingsUri}>
<Icon icon="wrench" aria-hidden="true" className={style.dropDown__itemIcon}/>
<I18n id="userSettings.label" sourceName="Modules" packageKey="Neos.Neos" fallback="User Settings"/>
</a>
</li>
{this.props.impersonateStatus === true ? (
<RestoreButtonItem />
) : null}
Expand Down
Loading

0 comments on commit 554879b

Please sign in to comment.