Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.0' into feature/conflict-resol…
Browse files Browse the repository at this point in the history
…ution-03/rebase-during-publish
  • Loading branch information
mhsdesign committed Oct 17, 2024
2 parents c7c160f + fe52b16 commit b072764
Show file tree
Hide file tree
Showing 46 changed files with 420 additions and 528 deletions.
14 changes: 7 additions & 7 deletions .sauce/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ suites:
- "Tests/IntegrationTests/Fixtures/*/*.e2e.js"
platformName: "Windows 10"
screenResolution: "1280x1024"
- name: "Tests in Firefox on MacOS"
# todo use chrome here and fix ci https://github.com/neos/neos-ui/issues/3591
browserName: "firefox"
src:
- "Tests/IntegrationTests/Fixtures/*/*.e2e.js"
platformName: "macOS 13"
screenResolution: "1440x900"
# todo use chrome here and fix ci https://github.com/neos/neos-ui/issues/3591 (but even firefox fails in ci)
# - name: "Tests in Firefox on MacOS"
# browserName: "firefox"
# src:
# - "Tests/IntegrationTests/Fixtures/*/*.e2e.js"
# platformName: "macOS 13"
# screenResolution: "1440x900"
npm:
dependencies:
- testcafe-react-selectors
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion Classes/Application/ChangeTargetWorkspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
namespace Neos\Neos\Ui\Application;

use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddress;

/**
* The application layer level command DTO to communicate the change of the selected target workspace for publication
Expand Down
2 changes: 0 additions & 2 deletions Classes/Application/ReloadNodes/NodeMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

namespace Neos\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

/**
Expand Down
10 changes: 2 additions & 8 deletions Classes/Application/ReloadNodes/ReloadNodesQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Domain\Workspace\WorkspaceProvider;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

/**
Expand All @@ -36,9 +35,6 @@
#[Flow\Scope("singleton")]
final class ReloadNodesQueryHandler
{
#[Flow\Inject]
protected WorkspaceProvider $workspaceProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

Expand Down Expand Up @@ -152,10 +148,8 @@ public function handle(ReloadNodesQuery $query, ActionRequest $actionRequest): R
- but the logic above mirrors the old behavior better.
https://github.com/neos/neos-ui/issues/3517#issuecomment-2070274053 */

$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

return new ReloadNodesQueryResult(
documentId: $nodeAddressFactory->createFromNode($documentNode),
documentId: NodeAddress::fromNode($documentNode),
nodes: $nodeMapBuilder->build()
);
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Application/ReloadNodes/ReloadNodesQueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

namespace Neos\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddress;

/**
* The application layer level query result containing all nodes the UI needs
Expand All @@ -38,7 +38,7 @@ public function __construct(
public function jsonSerialize(): array
{
return [
'documentId' => $this->documentId->serializeForUri(),
'documentId' => $this->documentId->toJson(),
'nodes' => $this->nodes
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;
use Neos\Neos\Domain\Workspace\WorkspaceProvider;
use Neos\Neos\Domain\Service\WorkspacePublishingService;
use Neos\Neos\Ui\Application\Shared\ConflictsOccurred;
use Neos\Neos\Ui\Infrastructure\ContentRepository\ConflictsFactory;

/**
* The application layer level command handler to for rebasing the workspace
Expand All @@ -34,7 +33,7 @@ final class SyncWorkspaceCommandHandler
protected ContentRepositoryRegistry $contentRepositoryRegistry;

#[Flow\Inject]
protected WorkspaceProvider $workspaceProvider;
protected WorkspacePublishingService $workspacePublishingService;

#[Flow\Inject]
protected NodeLabelGeneratorInterface $nodeLabelGenerator;
Expand All @@ -43,13 +42,11 @@ public function handle(
SyncWorkspaceCommand $command
): SyncingSucceeded|ConflictsOccurred {
try {
$workspace = $this->workspaceProvider->provideForWorkspaceName(
$this->workspacePublishingService->rebaseWorkspace(
$command->contentRepositoryId,
$command->workspaceName
$command->workspaceName,
$command->rebaseErrorHandlingStrategy
);

$workspace->rebase($command->rebaseErrorHandlingStrategy);

return new SyncingSucceeded();
} catch (WorkspaceRebaseFailed $e) {
$conflictsFactory = new ConflictsFactory(
Expand Down
21 changes: 5 additions & 16 deletions Classes/ContentRepository/Service/NeosUiNodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,30 @@
*/


use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
* @internal
* @Flow\Scope("singleton")
*/
class NeosUiNodeService
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

public function findNodeBySerializedNodeAddress(string $serializedNodeAddress, ContentRepositoryId $contentRepositoryId): ?Node
public function findNodeBySerializedNodeAddress(string $serializedNodeAddress): ?Node
{
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
$nodeAddress = NodeAddressFactory::create($contentRepository)->createFromUriString($serializedNodeAddress);
$nodeAddress = NodeAddress::fromJsonString($serializedNodeAddress);
$contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId);

$subgraph = $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph(
$nodeAddress->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
return $subgraph->findNodeById($nodeAddress->nodeAggregateId);
}

public function deserializeNodeAddress(string $serializedNodeAddress, ContentRepositoryId $contentRepositoryId): NodeAddress
{
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
return NodeAddressFactory::create($contentRepository)->createFromUriString($serializedNodeAddress);
return $subgraph->findNodeById($nodeAddress->aggregateId);
}
}
99 changes: 20 additions & 79 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@
* source code.
*/

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Service\UserService as DomainUserService;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Domain\Service\WorkspacePublishingService;
use Neos\Neos\PendingChangesProjection\Change;
use Neos\Neos\PendingChangesProjection\ChangeFinder;
use Neos\Neos\Service\UserService;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
Expand All @@ -44,17 +40,8 @@ class WorkspaceService
#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* @Flow\Inject
* @var UserService
*/
protected $userService;

/**
* @Flow\Inject
* @var DomainUserService
*/
protected $domainUserService;
#[Flow\Inject]
protected WorkspacePublishingService $workspacePublishingService;

/**
* Get all publishable node context paths for a workspace
Expand All @@ -64,36 +51,31 @@ class WorkspaceService
public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepositoryId $contentRepositoryId): array
{
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByName($workspaceName);
if (is_null($workspace) || $workspace->baseWorkspaceName === null) {
return [];
}
$changeFinder = $contentRepository->projectionState(ChangeFinder::class);
$changes = $changeFinder->findByContentStreamId($workspace->currentContentStreamId);
$pendingChanges = $this->workspacePublishingService->pendingWorkspaceChanges($contentRepositoryId, $workspaceName);
/** @var array{contextPath:string,documentContextPath:string,typeOfChange:int}[] $unpublishedNodes */
$unpublishedNodes = [];
foreach ($changes as $change) {
foreach ($pendingChanges as $change) {
if ($change->removalAttachmentPoint) {
$nodeAddress = new NodeAddress(
$change->contentStreamId,
$nodeAddress = NodeAddress::create(
$contentRepositoryId,
$workspaceName,
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
$change->nodeAggregateId,
$workspaceName
$change->nodeAggregateId
);

/**
* See {@see Remove::apply} -> Removal Attachment Point == closest document node.
*/
$documentNodeAddress = new NodeAddress(
$change->contentStreamId,
$documentNodeAddress = NodeAddress::create(
$contentRepositoryId,
$workspaceName,
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
$change->removalAttachmentPoint,
$workspaceName
$change->removalAttachmentPoint
);

$unpublishedNodes[] = [
'contextPath' => $nodeAddress->serializeForUri(),
'documentContextPath' => $documentNodeAddress->serializeForUri(),
'contextPath' => $nodeAddress->toJson(),
'documentContextPath' => $documentNodeAddress->toJson(),
'typeOfChange' => $this->getTypeOfChange($change)
];
} else {
Expand All @@ -106,12 +88,9 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
if ($node instanceof Node) {
$documentNode = $subgraph->findClosestNode($node->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
if ($documentNode instanceof Node) {
$contentRepository = $this->contentRepositoryRegistry->get($documentNode->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$unpublishedNodes[] = [
'contextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
'documentContextPath' => $nodeAddressFactory->createFromNode($documentNode)
->serializeForUri(),
'contextPath' => NodeAddress::fromNode($node)->toJson(),
'documentContextPath' => NodeAddress::fromNode($documentNode)->toJson(),
'typeOfChange' => $this->getTypeOfChange($change)
];
}
Expand All @@ -124,44 +103,6 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
}));
}

/**
* Get allowed target workspaces for current user
*
* @return array<string,array<string,mixed>>
*/
public function getAllowedTargetWorkspaces(ContentRepository $contentRepository): array
{
$user = $this->domainUserService->getCurrentUser();

$workspacesArray = [];
foreach ($contentRepository->getWorkspaceFinder()->findAll() as $workspace) {
// FIXME: This check should be implemented through a specialized Workspace Privilege or something similar
// Skip workspace not owned by current user
if ($workspace->workspaceOwner !== null && $workspace->workspaceOwner !== $user) {
continue;
}
// Skip own personal workspace
if ($workspace->workspaceName->value === $this->userService->getPersonalWorkspaceName()) {
continue;
}

if ($workspace->isPersonalWorkspace()) {
// Skip other personal workspaces
continue;
}

$workspaceArray = [
'name' => $workspace->workspaceName->jsonSerialize(),
'title' => $workspace->workspaceTitle->jsonSerialize(),
'description' => $workspace->workspaceDescription->jsonSerialize(),
'readonly' => !$this->domainUserService->currentUserCanPublishToWorkspace($workspace)
];
$workspacesArray[$workspace->workspaceName->jsonSerialize()] = $workspaceArray;
}

return $workspacesArray;
}

private function getTypeOfChange(Change $change): int
{
$result = 0;
Expand Down
Loading

0 comments on commit b072764

Please sign in to comment.