Skip to content

Commit

Permalink
BUGFIX: Ensure that filtered nodes provide no info about children tha…
Browse files Browse the repository at this point in the history
…t do not match filter
  • Loading branch information
grebaldi committed Jul 4, 2024
1 parent 53edaac commit 479f9df
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ function ($envelope) {

$nodeInfoHelper = new NodeInfoHelper();
$result = [];

switch ($finisher['type']) {
case 'get':
$result = $nodeInfoHelper->renderNodes(array_filter($flowQuery->get()), $this->getControllerContext());
Expand All @@ -553,7 +554,8 @@ function ($envelope) {
$result = $nodeInfoHelper->renderNodes(array_filter($flowQuery->get()), $this->getControllerContext(), true);
break;
case 'getForTreeWithParents':
$result = $nodeInfoHelper->renderNodesWithParents(array_filter($flowQuery->get()), $this->getControllerContext());
$nodeTypeFilter = $finisher['payload']['nodeTypeFilter'] ?? null;
$result = $nodeInfoHelper->renderNodesWithParents(array_filter($flowQuery->get()), $this->getControllerContext(), $nodeTypeFilter);
break;
}

Expand Down
5 changes: 3 additions & 2 deletions Classes/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,10 @@ public function renderNodes(array $nodes, ControllerContext $controllerContext,
/**
* @param array $nodes
* @param ControllerContext $controllerContext
* @param null|string $nodeTypeFilter
* @return array
*/
public function renderNodesWithParents(array $nodes, ControllerContext $controllerContext): array
public function renderNodesWithParents(array $nodes, ControllerContext $controllerContext, ?string $nodeTypeFilter = null): array
{
// For search operation we want to include all nodes, not respecting the "baseNodeType" setting
$baseNodeTypeOverride = $this->documentNodeTypeRole;
Expand All @@ -287,7 +288,7 @@ public function renderNodesWithParents(array $nodes, ControllerContext $controll
foreach ($nodes as $node) {
if (array_key_exists($node->getPath(), $renderedNodes)) {
$renderedNodes[$node->getPath()]['matched'] = true;
} elseif ($renderedNode = $this->renderNodeWithMinimalPropertiesAndChildrenInformation($node, $controllerContext, $baseNodeTypeOverride)) {
} elseif ($renderedNode = $this->renderNodeWithMinimalPropertiesAndChildrenInformation($node, $controllerContext, $nodeTypeFilter ?? $baseNodeTypeOverride)) {
$renderedNode['matched'] = true;
$renderedNodes[$node->getPath()] = $renderedNode;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test('Node tree preset "blog" shows nothing but page [🗋 Blog]', async (t) =>
.ok('[🗋 Blog] did not show up after switching to node tree preset "blog".');
});

test.skip('In node tree preset "blog", page [🗋 Blog] has no toggle handle', async (t) => {
test('In node tree preset "blog", page [🗋 Blog] has no toggle handle', async (t) => {
await t.click('#btn-ToggleDocumentTreeFilter');
await t.click('#neos-NodeTreeFilter');
await t.click(Selector('[role="button"]').withText('Show Blog only'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default () => () => ({
export default () => (nodeTypeFilter = null) => ({
type: 'getForTreeWithParents',
payload: ''
payload: {nodeTypeFilter}
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function * watchReloadState({configuration}) {

let nodes = [];
if (isSearch) {
nodes = yield q(siteNodeContextPath).search(searchQuery, effectiveFilterNodeType).getForTreeWithParents();
nodes = yield q(siteNodeContextPath).search(searchQuery, effectiveFilterNodeType).getForTreeWithParents(effectiveFilterNodeType);
} else {
nodes = yield q([siteNodeContextPath, documentNodeContextPath]).neosUiDefaultNodes(
configuration.nodeTree.presets.default.baseNodeType,
Expand Down
2 changes: 1 addition & 1 deletion packages/neos-ui-sagas/src/UI/PageTree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function * watchSearch({configuration}) {
const query = q(contextPath);

if (isSearch) {
matchingNodes = yield query.search(searchQuery, effectiveFilterNodeType).getForTreeWithParents();
matchingNodes = yield query.search(searchQuery, effectiveFilterNodeType).getForTreeWithParents(effectiveFilterNodeType);
} else {
const clipboardNodeContextPath = yield select($get('cr.nodes.clipboard'));
const toggledNodes = yield select($get('ui.pageTree.toggled'));
Expand Down

0 comments on commit 479f9df

Please sign in to comment.