From d06f7ab641fafad0cfdf1c69381dc1e44696e008 Mon Sep 17 00:00:00 2001 From: David Ichim Date: Wed, 11 Dec 2024 15:44:54 +0200 Subject: [PATCH 1/7] fix(context-navigation): error on layout page when types was an object - contentTypes was returning ( "@id": "htito://Aocolhost:3000/@types" } in certain situations where the cookie expired you tried to load the layout page. Now we check to ensure that the value is an array before attempting to map over it. --- .../Blocks/ContextNavigation/ContextNavigationEdit.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.jsx b/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.jsx index 06b90648..657ed26e 100644 --- a/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.jsx +++ b/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.jsx @@ -20,8 +20,12 @@ const ContextNavigationFillEdit = (props) => { (state) => state.types?.types || [], shallowEqual, ); + const availableTypes = React.useMemo( - () => contentTypes?.map((type) => [type.id, type.title || type.name]), + () => + Array.isArray(contentTypes) + ? contentTypes.map((type) => [type.id, type.title || type.name]) + : [], [contentTypes], ); From 35aabb31ef1619ff60695228373a9b1e08c248d6 Mon Sep 17 00:00:00 2001 From: David Ichim Date: Sun, 15 Dec 2024 16:13:35 +0200 Subject: [PATCH 2/7] fix(report-navigation): check if page has children before rendering it as a detail - This way if there is no extra children you can actually click to navigate to the page --- .../Blocks/ContextNavigation/variations/ReportNavigation.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.jsx b/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.jsx index 6476f4a4..49587b53 100644 --- a/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.jsx +++ b/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.jsx @@ -37,7 +37,7 @@ function renderNode(node, parentLevel) { const hasChildItems = node.items?.length; const nodeType = node.type; const isDocument = nodeType === 'document'; - let wrapWithDetails = isDocument && level > 2; + let wrapWithDetails = isDocument && level > 2 && hasChildItems; return (
  • Date: Mon, 16 Dec 2024 12:48:43 +0200 Subject: [PATCH 3/7] fix(UniversaLink): added option to open in new tab when isDisplayFile is true refs#281635 --- .../volto/components/manage/UniversalLink/UniversalLink.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx b/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx index 036b11a1..975c159c 100644 --- a/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx +++ b/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx @@ -127,6 +127,12 @@ const UniversalLink = ({ Date: Mon, 16 Dec 2024 11:52:29 +0100 Subject: [PATCH 4/7] style: Automated code fix --- .../components/manage/UniversalLink/UniversalLink.jsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx b/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx index 975c159c..927e8896 100644 --- a/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx +++ b/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx @@ -127,12 +127,7 @@ const UniversalLink = ({ Date: Mon, 16 Dec 2024 17:59:07 +0200 Subject: [PATCH 5/7] feat(report-navigation): add download icon and ensure file is downloaded directly - Replaced `RouterLink` with `UniversalLink` for file links that download - Added `Icon` component to display download icon for file links --- .../variations/ReportNavigation.jsx | 54 +++++++++---------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.jsx b/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.jsx index 49587b53..7b56bec7 100644 --- a/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.jsx +++ b/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.jsx @@ -1,14 +1,15 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { Link as RouterLink } from 'react-router-dom'; import cx from 'classnames'; import { compose } from 'redux'; import { withRouter } from 'react-router'; import { flattenToAppURL } from '@plone/volto/helpers'; -import { UniversalLink, MaybeWrap } from '@plone/volto/components'; +import { UniversalLink, MaybeWrap, Icon } from '@plone/volto/components'; import { withContentNavigation } from '@plone/volto/components/theme/Navigation/withContentNavigation'; +import downloadSVG from '@plone/volto/icons/download.svg'; + /** * Handles click on summary links and closes parent details elements * @param {Event} e - Click event @@ -37,6 +38,7 @@ function renderNode(node, parentLevel) { const hasChildItems = node.items?.length; const nodeType = node.type; const isDocument = nodeType === 'document'; + const isFile = nodeType === 'file'; let wrapWithDetails = isDocument && level > 2 && hasChildItems; return (
  • - {nodeType !== 'link' ? ( - + + wrapWithDetails && handleSummaryClick(e, wrapWithDetails) + } > - - wrapWithDetails && handleSummaryClick(e, wrapWithDetails) - } - > - {node.title} - {nodeType === 'file' && node.getObjSize - ? ' [' + node.getObjSize + ']' - : ''} - - - ) : ( - + {isFile && } {node.title} + {isFile && node.getObjSize ? ' [' + node.getObjSize + ']' : ''} - )} + {(hasChildItems && (
      {node.items.map((node) => renderNode(node, level))} @@ -99,9 +95,9 @@ export function ReportNavigation(props) {