From 747b5fd0346db5d31de08fa063ee85a33e40761d Mon Sep 17 00:00:00 2001 From: alihamza1221 Date: Mon, 18 Nov 2024 23:34:14 +0500 Subject: [PATCH 1/4] fix:Order blocks in sidebar doesn't respect layout restrictions: required and fixed position --- .../manage/Blocks/Block/EditBlockWrapper.jsx | 9 +-------- .../components/manage/Blocks/Block/Order/Item.jsx | 12 +++++++++++- packages/volto/src/helpers/Blocks/Blocks.js | 13 +++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/volto/src/components/manage/Blocks/Block/EditBlockWrapper.jsx b/packages/volto/src/components/manage/Blocks/Block/EditBlockWrapper.jsx index 3c94084860..249e5dbd56 100644 --- a/packages/volto/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +++ b/packages/volto/src/components/manage/Blocks/Block/EditBlockWrapper.jsx @@ -9,6 +9,7 @@ import { buildStyleObjectFromData, buildStyleClassNamesExtenders, } from '@plone/volto/helpers'; +import { hideHandler } from '@plone/volto/helpers/Blocks/Blocks'; import dragSVG from '@plone/volto/icons/drag.svg'; import { Button } from 'semantic-ui-react'; import includes from 'lodash/includes'; @@ -28,14 +29,6 @@ const messages = defineMessages({ }); const EditBlockWrapper = (props) => { - const hideHandler = (data) => { - return ( - !!data.fixed || - (!config.experimental.addBlockButton.enabled && - !(blockHasValue(data) && props.blockProps.editable)) - ); - }; - const { intl, blockProps, draginfo, children } = props; const { allowedBlocks, diff --git a/packages/volto/src/components/manage/Blocks/Block/Order/Item.jsx b/packages/volto/src/components/manage/Blocks/Block/Order/Item.jsx index 5580fc416f..5b4cc766b4 100644 --- a/packages/volto/src/components/manage/Blocks/Block/Order/Item.jsx +++ b/packages/volto/src/components/manage/Blocks/Block/Order/Item.jsx @@ -2,10 +2,12 @@ import React, { forwardRef } from 'react'; import classNames from 'classnames'; import { useDispatch, useSelector } from 'react-redux'; import { includes } from 'lodash'; +import isBoolean from 'lodash/isBoolean'; import cx from 'classnames'; import { Icon } from '@plone/volto/components'; import { setUIState } from '@plone/volto/actions'; import config from '@plone/volto/registry'; +import { hideHandler } from '@plone/volto/helpers/Blocks/Blocks'; import deleteSVG from '@plone/volto/icons/delete.svg'; import dragSVG from '@plone/volto/icons/drag.svg'; @@ -39,6 +41,11 @@ export const Item = forwardRef( const gridSelected = useSelector((state) => state.form.ui.gridSelected); const dispatch = useDispatch(); + const visible = !hideHandler(data); + const required = isBoolean(data.required) + ? data.required + : includes(config.blocks.requiredBlocks, data.type); + return (
  • - {!clone && onRemove && ( + {!clone && onRemove && !required && (