Skip to content

Commit

Permalink
Enhanced navigation reducer in Volto (#5817)
Browse files Browse the repository at this point in the history
Co-authored-by: Your Name <you@example.com>
Co-authored-by: David Glick <david@glicksoftware.com>
  • Loading branch information
3 people committed Apr 4, 2024
1 parent f406464 commit 0630a6e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/volto/news/5772.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enhanced navigation reducer in Volto to keep items extra-data sent from the navigation endpoint @Hrittik20
3 changes: 1 addition & 2 deletions packages/volto/src/reducers/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ const initialState = {
*/
function getRecursiveItems(items) {
return map(items, (item) => ({
title: item.title,
description: item.description,
url: flattenToAppURL(item['@id']),
...item,
...(item.items && { items: getRecursiveItems(item.items) }),
}));
}
Expand Down
6 changes: 6 additions & 0 deletions packages/volto/src/reducers/navigation/navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('Navigation reducer', () => {
error: null,
items: [
{
'@id': 'http://localhost:8080/Plone/front-page',
title: 'Welcome to Plone!',
description:
'Congratulations! You have successfully installed Plone.',
Expand Down Expand Up @@ -91,17 +92,20 @@ describe('Navigation reducer', () => {
error: null,
items: [
{
'@id': 'http://localhost:8080/Plone/front-page',
title: 'Welcome to Plone!',
description:
'Congratulations! You have successfully installed Plone.',
url: '/front-page',
},
{
'@id': 'http://localhost:8080/Plone/folder1',
title: 'Folder1',
description: 'Folder description',
url: '/folder1',
items: [
{
'@id': 'http://localhost:8080/Plone/folderinfolder1',
title: 'FolderInFolder1',
description: 'Sub-folder description',
url: '/folderinfolder1',
Expand Down Expand Up @@ -162,6 +166,7 @@ describe('Navigation reducer (NAVIGATION)GET_CONTENT', () => {
error: null,
items: [
{
'@id': 'http://localhost:8080/Plone/front-page',
title: 'Welcome to Plone!',
description:
'Congratulations! You have successfully installed Plone.',
Expand Down Expand Up @@ -192,6 +197,7 @@ describe('Navigation reducer (NAVIGATION)GET_CONTENT', () => {
error: null,
items: [
{
'@id': 'http://localhost:8080/Plone/front-page',
title: 'Welcome to Plone!',
description:
'Congratulations! You have successfully installed Plone.',
Expand Down

0 comments on commit 0630a6e

Please sign in to comment.