From 77e6429a897030af3d7a22f5bce1383c1313e8df Mon Sep 17 00:00:00 2001 From: Victor Fernandez de Alba Date: Fri, 6 Dec 2024 13:13:46 +0100 Subject: [PATCH] Fixes ICS download in non-public event content --- .../src/components/theme/EventDetails/EventDetails.jsx | 4 ++-- .../EventDetails/__snapshots__/EventDetails.test.jsx.snap | 6 +++--- .../theme/View/__snapshots__/EventView.test.jsx.snap | 6 +++--- packages/volto/src/express-middleware/files.js | 5 ++++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/volto/src/components/theme/EventDetails/EventDetails.jsx b/packages/volto/src/components/theme/EventDetails/EventDetails.jsx index e897f4ba49..d2bcaa8f4a 100644 --- a/packages/volto/src/components/theme/EventDetails/EventDetails.jsx +++ b/packages/volto/src/components/theme/EventDetails/EventDetails.jsx @@ -6,7 +6,7 @@ import { Recurrence, } from '@plone/volto/components/theme/View/EventDatesInfo'; import { Icon } from '@plone/volto/components'; -import { expandToBackendURL } from '@plone/volto/helpers'; +import { flattenToAppURL } from '@plone/volto/helpers/Url/Url'; import calendarSVG from '@plone/volto/icons/calendar.svg'; @@ -147,7 +147,7 @@ const EventDetails = ({ content, display_as = 'aside' }) => { className="ics-download" target="_blank" rel="noreferrer" - href={`${expandToBackendURL(content['@id'])}/ics_view`} + href={`${flattenToAppURL(content['@id'])}/ics_view`} > {intl.formatMessage(messages.downloadEvent)} diff --git a/packages/volto/src/components/theme/EventDetails/__snapshots__/EventDetails.test.jsx.snap b/packages/volto/src/components/theme/EventDetails/__snapshots__/EventDetails.test.jsx.snap index 1d605e546b..a7fad6aa2f 100644 --- a/packages/volto/src/components/theme/EventDetails/__snapshots__/EventDetails.test.jsx.snap +++ b/packages/volto/src/components/theme/EventDetails/__snapshots__/EventDetails.test.jsx.snap @@ -127,7 +127,7 @@ exports[`renders event details component with all props 1`] = ` /> @@ -169,7 +169,7 @@ exports[`renders event details component with only required props 1`] = ` /> @@ -211,7 +211,7 @@ exports[`renders event details component without links to api in the text 1`] = /> diff --git a/packages/volto/src/components/theme/View/__snapshots__/EventView.test.jsx.snap b/packages/volto/src/components/theme/View/__snapshots__/EventView.test.jsx.snap index acf53acafc..269d255c4b 100644 --- a/packages/volto/src/components/theme/View/__snapshots__/EventView.test.jsx.snap +++ b/packages/volto/src/components/theme/View/__snapshots__/EventView.test.jsx.snap @@ -251,7 +251,7 @@ exports[`renders an event view component with all props 1`] = ` /> @@ -357,7 +357,7 @@ exports[`renders an event view component with only required props 1`] = ` /> @@ -458,7 +458,7 @@ exports[`renders an event view component without links to api in the text 1`] = /> diff --git a/packages/volto/src/express-middleware/files.js b/packages/volto/src/express-middleware/files.js index f13708a504..104fad2ef6 100644 --- a/packages/volto/src/express-middleware/files.js +++ b/packages/volto/src/express-middleware/files.js @@ -30,7 +30,10 @@ function filesMiddlewareFn(req, res, next) { export default function filesMiddleware() { const middleware = express.Router(); - middleware.all(['**/@@download/*', '**/@@display-file/*'], filesMiddlewareFn); + middleware.all( + ['**/@@download/*', '**/@@display-file/*', '**/ics_view'], + filesMiddlewareFn, + ); middleware.id = 'filesResourcesProcessor'; return middleware; }