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 Jan 18, 2024
2 parents 4b53790 + a609614 commit 5ca0e4f
Show file tree
Hide file tree
Showing 263 changed files with 2,512 additions and 1,946 deletions.
35 changes: 26 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ version: 2.0
aliases:
- &workspace_root ~/neos-ui-workspace
- &store_yarn_package_cache
key: yarn-cache-v{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }}
key: yarn-cache-v{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn

- &restore_yarn_package_cache
keys:
- yarn-cache-v{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }}
- yarn-cache-v{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ checksum "yarn.lock" }}

- &store_app_cache
key: full-app-cache-v{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}-{{ checksum "Tests/IntegrationTests/TestDistribution/Configuration/Settings.yaml" }}
key: full-app-cache-v{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}-{{ checksum "Tests/IntegrationTests/TestDistribution/Configuration/Settings.yaml" }}
paths:
- /home/circleci/app

- &restore_app_cache
keys:
- full-app-cache-v{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}-{{ checksum "Tests/IntegrationTests/TestDistribution/Configuration/Settings.yaml" }}
- full-app-cache-v{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}-
- full-app-cache-v{{ .Environment.CACHE_VERSION }}-{{ arch }}-
- full-app-cache-v{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}-{{ checksum "Tests/IntegrationTests/TestDistribution/Configuration/Settings.yaml" }}
- full-app-cache-v{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}-
- full-app-cache-v{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ arch }}-

- &save_composer_cache
key: composer-cache-v{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}
key: composer-cache-v{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}
paths:
- /home/circleci/composer/cache-dir

- &restore_composer_cache
keys:
- composer-cache-v{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}
- composer-cache-v{{ .Environment.CACHE_VERSION }}-{{ arch }}-
- composer-cache-v{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ arch }}-{{ checksum "Tests/IntegrationTests/TestDistribution/composer.json" }}
- composer-cache-v{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ arch }}-

- &attach_workspace
at: *workspace_root
Expand Down Expand Up @@ -140,6 +140,20 @@ jobs:
cd /home/circleci/app/
bin/phpunit -c Build/BuildEssentials/PhpUnit/UnitTests.xml Packages/Application/Neos.Neos.Ui/Tests/Unit
php-linting:
docker:
- image: cimg/php:8.2-node
working_directory: *workspace_root
steps:
- attach_workspace: *attach_workspace
- restore_cache: *restore_app_cache

- run: rm -rf /home/circleci/app/Packages/Application/Neos.Neos.Ui
- run: cd /home/circleci/app/Packages/Application && mv ~/neos-ui-workspace Neos.Neos.Ui
- run: |
cd /home/circleci/app/Packages/Application/Neos.Neos.Ui
../../../bin/phpstan analyse
workflows:
version: 2
build_and_test:
Expand All @@ -161,3 +175,6 @@ workflows:
- php-unittests:
requires:
- build_flow_app
- php-linting:
requires:
- build_flow_app
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Build/Jenkins/update-neos-ui-compiled.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ cd tmp_compiled_pkg
git add Resources/Public/
git commit -m "Compile Neos UI - $GIT_SHA1" || true

if [[ "$GIT_BRANCH" == "origin/7.3" || "$GIT_BRANCH" == "origin/8.0" || "$GIT_BRANCH" == "origin/8.1" || "$GIT_BRANCH" == "origin/8.2" || "$GIT_BRANCH" == "origin/8.3" || "$GIT_BRANCH" == "origin/9.0" ]]; then
if [[ "$GIT_BRANCH" == "origin/7.3" || "$GIT_BRANCH" == "origin/8.0" || "$GIT_BRANCH" == "origin/8.1" || "$GIT_BRANCH" == "origin/8.2" || "$GIT_BRANCH" == "origin/8.3" || "$GIT_BRANCH" == "origin/8.4" || "$GIT_BRANCH" == "origin/9.0" ]]; then
echo "Git branch $GIT_BRANCH found, pushing to this branch."
git push origin HEAD:${GIT_BRANCH#*/}
fi
Expand Down
7 changes: 3 additions & 4 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\DiscardIndividualNodesFromWorkspace;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\Workspace\Workspace;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
Expand Down Expand Up @@ -99,7 +98,7 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
$node = $subgraph->findNodeById($change->nodeAggregateId);

if ($node instanceof Node) {
$documentNode = $subgraph->findClosestNode($node->nodeAggregateId, FindClosestNodeFilter::create(nodeTypeConstraints: NodeTypeNameFactory::NAME_DOCUMENT));
$documentNode = $subgraph->findClosestNode($node->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
if ($documentNode instanceof Node) {
$contentRepository = $this->contentRepositoryRegistry->get($documentNode->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
Expand Down Expand Up @@ -128,7 +127,6 @@ public function getAllowedTargetWorkspaces(ContentRepository $contentRepository)
$user = $this->domainUserService->getCurrentUser();

$workspacesArray = [];
/** @var Workspace $workspace */
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
Expand Down Expand Up @@ -157,6 +155,7 @@ public function getAllowedTargetWorkspaces(ContentRepository $contentRepository)
return $workspacesArray;
}

/** @return list<RemoveNode> */
public function predictRemoveNodeFeedbackFromDiscardIndividualNodesFromWorkspaceCommand(
DiscardIndividualNodesFromWorkspace $command,
ContentRepository $contentRepository
Expand Down Expand Up @@ -192,7 +191,7 @@ public function predictRemoveNodeFeedbackFromDiscardIndividualNodesFromWorkspace

$childNode = $subgraph->findNodeById($nodeToDiscard->nodeAggregateId);
$parentNode = $subgraph->findParentNode($nodeToDiscard->nodeAggregateId);
if ($parentNode) {
if ($childNode && $parentNode) {
$result[] = new RemoveNode($childNode, $parentNode);
$handledNodes[] = $nodeToDiscard;
}
Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ public function indexAction(string $node = null)
);
$rootNode = $rootNodeAggregate->getNodeByCoveredDimensionSpacePoint($defaultDimensionSpacePoint);

$siteNode = $subgraph->findChildNodeConnectedThroughEdgeName(
$rootNode->nodeAggregateId,
$siteDetectionResult->siteNodeName->toNodeName()
$siteNode = $subgraph->findNodeByPath(
$siteDetectionResult->siteNodeName->toNodeName(),
$rootNode->nodeAggregateId
);

if (!$nodeAddress) {
Expand Down
90 changes: 62 additions & 28 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\PublishIndividualNodesFromWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Dto\NodeIdsToPublishOrDiscard;
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Dto\NodeIdToPublishOrDiscard;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Command\RebaseWorkspace;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateCurrentlyDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Eel\FlowQuery\Operations\GetOperation;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\ActionResponse;
Expand All @@ -39,7 +41,6 @@
use Neos\Neos\Service\UserService;
use Neos\Neos\Ui\ContentRepository\Service\NeosUiNodeService;
use Neos\Neos\Ui\ContentRepository\Service\WorkspaceService;
use Neos\Neos\Ui\Domain\Model\ChangeCollection;
use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Error;
use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Info;
use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Success;
Expand All @@ -50,13 +51,14 @@
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;
use Neos\Neos\Ui\Fusion\Helper\WorkspaceHelper;
use Neos\Neos\Ui\Service\NodeClipboard;
use Neos\Neos\Ui\Service\NodePolicyService;
use Neos\Neos\Ui\Service\PublishingService;
use Neos\Neos\Ui\TypeConverter\ChangeCollectionConverter;
use Neos\Neos\Utility\NodeUriPathSegmentGenerator;

class BackendServiceController extends ActionController
{
use TranslationTrait;

/**
* @var array<int,string>
*/
Expand Down Expand Up @@ -103,12 +105,6 @@ class BackendServiceController extends ActionController
*/
protected $userService;

/**
* @Flow\Inject
* @var NodePolicyService
*/
protected $nodePolicyService;

/**
* @Flow\Inject
* @var ChangeCollectionConverter
Expand Down Expand Up @@ -157,15 +153,13 @@ protected function initializeController(ActionRequest $request, ActionResponse $

/**
* Apply a set of changes to the system
* @psalm-param list<array<string,mixed>> $changes
*/
/** @phpstan-ignore-next-line */
public function changeAction(array $changes): void
{
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;

/** @param array<int,array<string,mixed>> $changes */
$changes = $this->changeCollectionConverter->convert($changes, $contentRepositoryId);
/** @var ChangeCollection $changes */
try {
$count = $changes->count();
$changes->apply();
Expand Down Expand Up @@ -208,9 +202,8 @@ public function publishAllAction(): void
/**
* Publish nodes
*
* @param array $nodeContextPaths
* @psalm-param list<string> $nodeContextPaths
*/
/** @phpstan-ignore-next-line */
public function publishAction(array $nodeContextPaths, string $targetWorkspaceName): void
{
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
Expand Down Expand Up @@ -267,9 +260,8 @@ public function publishAction(array $nodeContextPaths, string $targetWorkspaceNa
/**
* Discard nodes
*
* @param array $nodeContextPaths
* @psalm-param list<string> $nodeContextPaths
*/
/** @phpstan-ignore-next-line */
public function discardAction(array $nodeContextPaths): void
{
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
Expand Down Expand Up @@ -417,12 +409,11 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d
/**
* Persists the clipboard node on copy
*
* @param array $nodes
* @psalm-param list<string> $nodes
* @return void
* @throws \Neos\Flow\Property\Exception
* @throws \Neos\Flow\Security\Exception
*/
/** @phpstan-ignore-next-line */
public function copyNodesAction(array $nodes): void
{
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
Expand Down Expand Up @@ -450,11 +441,10 @@ public function clearClipboardAction()
/**
* Persists the clipboard node on cut
*
* @param array $nodes
* @psalm-param list<string> $nodes
* @throws \Neos\Flow\Property\Exception
* @throws \Neos\Flow\Security\Exception
*/
/** @phpstan-ignore-next-line */
public function cutNodesAction(array $nodes): void
{
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
Expand Down Expand Up @@ -489,8 +479,8 @@ public function initializeGetAdditionalNodeMetadataAction(): void

/**
* Fetches all the node information that can be lazy-loaded
* @psalm-param list<string> $nodes
*/
/** @phpstan-ignore-next-line */
public function getAdditionalNodeMetadataAction(array $nodes): void
{
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
Expand All @@ -513,7 +503,13 @@ public function getAdditionalNodeMetadataAction(array $nodes): void
}, $node->getOtherNodeVariants())));*/
if (!is_null($node)) {
$result[$nodeAddress->serializeForUri()] = [
'policy' => $this->nodePolicyService->getNodePolicyInformation($node),
// todo reimplement nodePolicyService
'policy' => [
'disallowedNodeTypes' => [],
'canRemove' => true,
'canEdit' => true,
'disallowedProperties' => []
]
//'dimensions' => $this->getCurrentDimensionPresetIdentifiersForNode($node),
//'otherNodeVariants' => $otherNodeVariants
];
Expand All @@ -532,7 +528,7 @@ public function initializeGetPolicyInformationAction(): void
}

/**
* @param array<NodeAddress> $nodes
* @psalm-param list<NodeAddress> $nodes
*/
public function getPolicyInformationAction(array $nodes): void
{
Expand All @@ -549,7 +545,13 @@ public function getPolicyInformationAction(array $nodes): void
$node = $subgraph->findNodeById($nodeAddress->nodeAggregateId);
if (!is_null($node)) {
$result[$nodeAddress->serializeForUri()] = [
'policy' => $this->nodePolicyService->getNodePolicyInformation($node)
// todo reimplement nodePolicyService
'policy' => [
'disallowedNodeTypes' => [],
'canRemove' => true,
'canEdit' => true,
'disallowedProperties' => []
]
];
}
}
Expand All @@ -560,28 +562,28 @@ public function getPolicyInformationAction(array $nodes): void
/**
* Build and execute a flow query chain
*
* @param array $chain
* @psalm-param list<array{type: string, payload: array<string|int, mixed>}> $chain
*/
/** @phpstan-ignore-next-line */
public function flowQueryAction(array $chain): string
{
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;

$createContext = array_shift($chain);
$finisher = array_pop($chain);

/** @var array<int,mixed> $payload */
$payload = $createContext['payload'] ?? [];
$flowQuery = new FlowQuery(array_map(
fn ($envelope) => $this->nodeService->findNodeBySerializedNodeAddress($envelope['$node'], $contentRepositoryId),
$payload
));

foreach ($chain as $operation) {
// @phpstan-ignore-next-line
$flowQuery = call_user_func_array([$flowQuery, $operation['type']], $operation['payload']);
$flowQuery = $flowQuery->__call($operation['type'], $operation['payload']);
}

/** @see GetOperation */
assert(is_callable([$flowQuery, 'get']));

$nodeInfoHelper = new NodeInfoHelper();
$type = $finisher['type'] ?? null;
$result = match ($type) {
Expand Down Expand Up @@ -619,4 +621,36 @@ public function generateUriPathSegmentAction(string $contextNode, string $text):
$slug = $this->nodeUriPathSegmentGenerator->generateUriPathSegment($contextNode, $text);
$this->view->assign('value', $slug);
}

/**
* Rebase user workspace to current workspace
*
* @param string $targetWorkspaceName
* @return void
*/
public function rebaseWorkspaceAction(string $targetWorkspaceName): void
{
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);

$command = RebaseWorkspace::create(WorkspaceName::fromString($targetWorkspaceName));
try {
$contentRepository->handle($command)->block();
} catch (\Exception $exception) {
$error = new Error();
$error->setMessage($error->getMessage());

$this->feedbackCollection->add($error);
$this->view->assign('value', $this->feedbackCollection);
return;
}

$success = new Success();
$success->setMessage(
$this->getLabel('workspaceSynchronizationApplied', ['workspaceName' => $targetWorkspaceName])
);
$this->feedbackCollection->add($success);

$this->view->assign('value', $this->feedbackCollection);
}
}
Loading

0 comments on commit 5ca0e4f

Please sign in to comment.