From 906b04bb01314d474c07081cabc88ccda4dad4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Grabowski?= Date: Thu, 21 Oct 2021 10:26:57 +0200 Subject: [PATCH 1/2] IBX-1267: It is possible to create content under non-container in UDW (#1966) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Grabowski --- .../content-create-button/content.create.button.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/components/content-create-button/content.create.button.js b/src/bundle/ui-dev/src/modules/universal-discovery/components/content-create-button/content.create.button.js index 0f76d7d36a..22ed9fa796 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/components/content-create-button/content.create.button.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/components/content-create-button/content.create.button.js @@ -10,6 +10,7 @@ import { ContentOnTheFlyConfigContext, SelectedLocationsContext, MultipleConfigContext, + ContentTypesMapContext, } from '../../universal.discovery.module'; const ContentCreateButton = ({ isDisabled }) => { @@ -19,6 +20,7 @@ const ContentCreateButton = ({ isDisabled }) => { const [selectedLocations, dispatchSelectedLocationsAction] = useContext(SelectedLocationsContext); const [multiple, multipleItemsLimit] = useContext(MultipleConfigContext); const { hidden, allowedLocations } = useContext(ContentOnTheFlyConfigContext); + const contentTypesMap = useContext(ContentTypesMapContext); const createLabel = Translator.trans(/*@Desc("Create")*/ 'create_content.create', {}, 'universal_discovery_widget'); const toggleContentCreateVisibility = () => { window.eZ.helpers.tooltips.hideAll(); @@ -32,12 +34,14 @@ const ContentCreateButton = ({ isDisabled }) => { ); } + const contentTypeInfo = contentTypesMap[selectedLocation?.location?.ContentInfo.Content.ContentType._href]; const isAllowedLocation = selectedLocation && (!allowedLocations || allowedLocations.includes(selectedLocation.parentLocationId)); const hasAccess = !selectedLocation || !selectedLocation.permissions || (selectedLocation.permissions && selectedLocation.permissions.create.hasAccess); const isLimitReached = multiple && multipleItemsLimit !== 0 && selectedLocations.length >= multipleItemsLimit; + const isContainer = contentTypeInfo?.isContainer ?? true; if (hidden) { return null; @@ -47,7 +51,7 @@ const ContentCreateButton = ({ isDisabled }) => {