From a4ff4a1910ee58cbbb56a0a4a00b15016adc3531 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Mon, 18 Mar 2024 12:43:35 +0100 Subject: [PATCH 1/4] feat: added volto-slim-header to configure tertiary menu from control panel --- RELEASE.md | 6 ++++ package.json | 4 ++- .../Header/HeaderSlim/TertiaryMenu.jsx | 31 ++++++++++++++++--- src/config/italiaConfig.js | 4 +++ src/helpers/config.js | 2 +- yarn.lock | 10 ++++++ 6 files changed, 51 insertions(+), 6 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 79b3c8b60..441380812 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -41,6 +41,12 @@ - ... --> +## Versione x.x.x (xx/xx/xxxx) + +### Novità + +- Ora i link in testata nell'header slim sono configurabili da pannello di controllo + ## Versione 11.7.0 (15/03/2024) ### Novità diff --git a/package.json b/package.json index 2d21bbb80..c7d6b555a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "volto-data-grid-widget", "volto-querywidget-with-browser", "@eeacms/volto-taxonomy", - "volto-feedback" + "volto-feedback", + "volto-slimheader" ], "scripts": { "prepare": "husky install", @@ -153,6 +154,7 @@ "volto-querywidget-with-browser": "0.4.1", "volto-rss-block": "3.0.0", "volto-secondarymenu": "4.0.0", + "volto-slimheader": "0.1.0", "volto-social-settings": "3.0.0", "volto-subblocks": "2.0.0", "volto-subfooter": "3.0.0", diff --git a/src/components/ItaliaTheme/Header/HeaderSlim/TertiaryMenu.jsx b/src/components/ItaliaTheme/Header/HeaderSlim/TertiaryMenu.jsx index c871d9f0f..69133bbde 100644 --- a/src/components/ItaliaTheme/Header/HeaderSlim/TertiaryMenu.jsx +++ b/src/components/ItaliaTheme/Header/HeaderSlim/TertiaryMenu.jsx @@ -3,16 +3,39 @@ * @module components/ItaliaTheme/Header/HeaderSlim/TertiaryMenu */ -import React from 'react'; +import React, { useEffect } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { useLocation } from 'react-router-dom'; import { Nav, NavItem, NavLink } from 'design-react-kit'; import { UniversalLink } from '@plone/volto/components'; +import { flattenToAppURL } from '@plone/volto/helpers'; import { useIntl } from 'react-intl'; -import config from '@plone/volto/registry'; +import { getSiteProperty } from 'design-comuni-plone-theme/helpers'; +import { getSlimHeader, getItemsByPath } from 'volto-slimheader'; const TertiaryMenu = () => { const intl = useIntl(); - let menu = config.settings.siteProperties.headerslimTertiaryMenu; - const items = menu[intl.locale]; + const pathname = useLocation().pathname; + const dispatch = useDispatch(); + + const slimHeader = useSelector((state) => state.slimHeader?.result); + const slimHeaderItems = getItemsByPath(slimHeader, pathname) + ?.filter((item) => item.visible) + .map((item) => { + return { + url: item.href || flattenToAppURL(item.linkUrl?.[0]?.['@id']) || '/', + title: item.title, + }; + }); + + const staticMenu = + getSiteProperty('headerslimTertiaryMenu', intl.locale) ?? []; + + useEffect(() => { + dispatch(getSlimHeader()); + }, [dispatch]); + + const items = slimHeaderItems?.length > 0 ? slimHeaderItems : staticMenu; return items?.length > 0 ? (