Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/8.3' into 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed May 14, 2024
2 parents 95a5583 + a1c1f62 commit c263cb5
Show file tree
Hide file tree
Showing 47 changed files with 909 additions and 584 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install
run: make install
run: make install-and-verify
- name: Lint
run: make lint

Expand All @@ -32,7 +32,7 @@ jobs:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install
run: make install
run: make install-and-verify
- name: Build
run: make build-production
- name: Test
Expand Down
6 changes: 2 additions & 4 deletions Build/Jenkins/release-neos-ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ make test
VERSION=$VERSION make bump-version
VERSION=$VERSION NPM_TOKEN=$NPM_TOKEN make publish-npm

# add changes to git and push
git add .
git commit -m "Updating composer dependency and npm versions for release of $VERSION"
# we do not commit our working dir (the changes to the `version` field, as they will cause conflicts)
# see https://github.com/neos/neos-ui/issues/3778

git push origin HEAD:$BRANCH
git tag -a -m "$VERSION" $VERSION
git push origin $VERSION
20 changes: 19 additions & 1 deletion Classes/ContentRepository/Service/NodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function getNodeFromContextPath($contextPath, Site $site = null, Domain $
if ($includeAll === true) {
$contextProperties['invisibleContentShown'] = true;
$contextProperties['removedContentShown'] = true;
$contextProperties['inaccessibleContentShown'] = true;
}

$context = $this->contextFactory->create(
Expand All @@ -128,11 +129,28 @@ public function getNodeFromContextPath($contextPath, Site $site = null, Domain $
* @return boolean
*/
public function nodeExistsInWorkspace(NodeInterface $node, Workspace $workspace)
{
return $this->getNodeInWorkspace($node, $workspace) !== null;
}

/**
* Get the variant of the given node in the given workspace
*
* @param NodeInterface $node
* @param Workspace $workspace
* @return NodeInterface|null
*/
public function getNodeInWorkspace(NodeInterface $node, Workspace $workspace): ?NodeInterface
{
$context = ['workspaceName' => $workspace->getName()];
$flowQuery = new FlowQuery([$node]);

return $flowQuery->context($context)->count() > 0;
$result = $flowQuery->context($context);
if ($result->count() > 0) {
return $result->get(0);
} else {
return null;
}
}

/**
Expand Down
45 changes: 26 additions & 19 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ public function discardAction(array $nodeContextPaths): void
try {
foreach ($nodeContextPaths as $contextPath) {
$node = $this->nodeService->getNodeFromContextPath($contextPath, null, null, true);
if (!$node) {
$error = new Error();
$error->setMessage(sprintf('Could not find node for context path "%s"', $contextPath));

$this->feedbackCollection->add($error);
continue;
}

if ($node->isRemoved() === true) {
// When discarding node removal we should re-create it
$updateNodeInfo = new UpdateNodeInfo();
Expand All @@ -297,7 +305,19 @@ public function discardAction(array $nodeContextPaths): void
$reloadDocument = new ReloadDocument();
$this->feedbackCollection->add($reloadDocument);
}
} elseif (!$this->nodeService->nodeExistsInWorkspace($node, $node->getWorkSpace()->getBaseWorkspace())) {
} elseif ($nodeInBaseWorkspace = $this->nodeService->getNodeInWorkspace($node, $node->getWorkSpace()->getBaseWorkspace())) {
$nodeHasBeenMoved = $node->getPath() !== $nodeInBaseWorkspace->getPath();
if ($nodeHasBeenMoved) {
$removeNode = new RemoveNode();
$removeNode->setNode($node);
$this->feedbackCollection->add($removeNode);

$updateNodeInfo = new UpdateNodeInfo();
$updateNodeInfo->setNode($nodeInBaseWorkspace);
$updateNodeInfo->recursive();
$this->feedbackCollection->add($updateNodeInfo);
}
} else {
// If the node doesn't exist in the target workspace, tell the UI to remove it
$removeNode = new RemoveNode();
$removeNode->setNode($node);
Expand Down Expand Up @@ -345,6 +365,9 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, NodeInter
throw new Exception('Your personal workspace currently contains unpublished changes. In order to switch to a different target workspace you need to either publish or discard pending changes first.', 1582800654);
}

$sitePath = $documentNode->getContext()->getCurrentSiteNode()->getPath();
$originalNodePath = $documentNode->getPath();

$userWorkspace->setBaseWorkspace($targetWorkspace);
$this->workspaceRepository->update($userWorkspace);

Expand All @@ -356,25 +379,9 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, NodeInter
$updateWorkspaceInfo->setWorkspace($userWorkspace);
$this->feedbackCollection->add($updateWorkspaceInfo);

// Construct base workspace context
$originalContext = $documentNode->getContext();
$contextProperties = $documentNode->getContext()->getProperties();
$contextProperties['workspaceName'] = $targetWorkspaceName;
$contentContext = $this->contextFactory->create($contextProperties);

// If current document node doesn't exist in the base workspace, traverse its parents to find the one that exists
$redirectNode = $documentNode;
while (true) {
$redirectNodeInBaseWorkspace = $contentContext->getNodeByIdentifier($redirectNode->getIdentifier());
if ($redirectNodeInBaseWorkspace) {
break;
} else {
$redirectNode = $redirectNode->getParent();
if (!$redirectNode) {
throw new Exception(sprintf('Wasn\'t able to locate any valid node in rootline of node %s in the workspace %s.', $documentNode->getContextPath(), $targetWorkspaceName), 1458814469);
}
}
}
$nodesOnPath = $documentNode->getContext()->getNodesOnPath($sitePath, $originalNodePath);
$redirectNode = array_pop($nodesOnPath) ?? $documentNode->getContext()->getCurrentSiteNode();

// If current document node exists in the base workspace, then reload, else redirect
if ($redirectNode === $documentNode) {
Expand Down
12 changes: 10 additions & 2 deletions Classes/Domain/Model/Changes/CopyInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,16 @@ public function getMode()
public function apply()
{
if ($this->canApply()) {
$nodeName = $this->generateUniqueNodeName($this->getParentNode());
$node = $this->getSubject()->copyInto($this->getParentNode(), $nodeName);
$parentNode = $this->getParentNode();
$nodeName = $this->generateUniqueNodeName($parentNode);
// If the parent node has children, we copy the node after the last child node to prevent the copied nodes
// from being mixed with the existing ones due the duplication of their relative indices.
if ($parentNode->hasChildNodes()) {
$lastChildNode = array_slice($parentNode->getChildNodes(), -1, 1)[0];
$node = $this->getSubject()->copyAfter($lastChildNode, $nodeName);
} else {
$node = $this->getSubject()->copyInto($parentNode, $nodeName);
}
$this->finish($node);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function build(array $resourceArrayToSort, \Closure $builderForLine)
$hash = substr(md5_file($resourceExpression), 0, 8);
$resourceExpression = $this->resourceManager->getPublicPackageResourceUriByPath($resourceExpression);
}
$finalUri = $hash ? $resourceExpression . '?' . $hash : $resourceExpression;
$finalUri = $hash ? $resourceExpression . (str_contains($resourceExpression, '?') ? '&' : '?') . $hash : $resourceExpression;
$additionalAttributes = array_merge(
// legacy first level 'defer' attribute
isset($element['defer']) ? ['defer' => $element['defer']] : [],
Expand Down
2 changes: 1 addition & 1 deletion Classes/TypeConverter/ChangeCollectionConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected function convertChangeData($changeData)
$changeClassInstance->injectPersistenceManager($this->persistenceManager);

$subjectContextPath = $changeData['subject'];
$subject = $this->nodeService->getNodeFromContextPath($subjectContextPath);
$subject = $this->nodeService->getNodeFromContextPath($subjectContextPath, null, null, true);

if ($subject instanceof Error) {
return $subject;
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ check-requirements:
install: ## Install dependencies
yarn install

install-and-verify:
# Validate this project because were using Zero-Installs (slightly safer as we accept external PRs)
yarn install --immutable --immutable-cache --check-cache

setup: check-requirements install build ## Run a clean setup
@echo Please remember to set frontendDevelopmentMode \
to true in your Settings.yaml.
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Translations/en/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@
<trans-unit id="collapseAll" xml:space="preserve">
<source>Collapse All</source>
</trans-unit>
<trans-unit id="copyNodeTypeNameToClipboard" xml:space="preserve">
<source>Copy node type to clipboard</source>
</trans-unit>
</body>
</file>
</xliff>
Loading

0 comments on commit c263cb5

Please sign in to comment.