Skip to content

Commit

Permalink
BUGFIX: Perform search on RELOAD_STATE when node type filter or sea…
Browse files Browse the repository at this point in the history
…rch term is set
  • Loading branch information
grebaldi committed Jul 4, 2024
1 parent 71bd100 commit c0e725f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
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('Reloading the node tree while in preset "blog" results in nothing but page [🗋 Blog]', async (t) => {
test('Reloading the node tree while in preset "blog" results in nothing but page [🗋 Blog]', async (t) => {
await t.click('#btn-ToggleDocumentTreeFilter');
await t.click('#neos-NodeTreeFilter');
await t.click(Selector('[role="button"]').withText('Show Blog only'));
Expand Down
23 changes: 17 additions & 6 deletions packages/neos-ui-sagas/src/CR/NodeOperations/reloadState.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,25 @@ export default function * watchReloadState({configuration}) {
const toggledNodes = yield select($get('ui.pageTree.toggled'));
const siteNodeContextPath = $get('payload.siteNodeContextPath', action) || currentSiteNodeContextPath;
const documentNodeContextPath = yield $get('payload.documentNodeContextPath', action) || select($get('cr.nodes.documentNode'));
const {query: searchQuery, filterNodeType} = yield select(state => state?.ui?.pageTree);
const effectiveFilterNodeType = filterNodeType || configuration.nodeTree.presets.default.baseNodeType;
const isSearch = Boolean(filterNodeType || searchQuery);

yield put(actions.CR.Nodes.setDocumentNode(documentNodeContextPath, currentSiteNodeContextPath));
yield put(actions.UI.PageTree.setAsLoading(currentSiteNodeContextPath));
const nodes = yield q([siteNodeContextPath, documentNodeContextPath]).neosUiDefaultNodes(
configuration.nodeTree.presets.default.baseNodeType,
configuration.nodeTree.loadingDepth,
toggledNodes,
clipboardNodesContextPaths
).getForTree();

let nodes = [];
if (isSearch) {
nodes = yield q(siteNodeContextPath).search(searchQuery, effectiveFilterNodeType).getForTreeWithParents();
} else {
nodes = yield q([siteNodeContextPath, documentNodeContextPath]).neosUiDefaultNodes(
configuration.nodeTree.presets.default.baseNodeType,
configuration.nodeTree.loadingDepth,
toggledNodes,
clipboardNodesContextPaths
).getForTree();
}

const nodeMap = nodes.reduce((nodeMap, node) => {
nodeMap[$get('contextPath', node)] = node;
return nodeMap;
Expand Down

0 comments on commit c0e725f

Please sign in to comment.