From dbdb5c7d1a35db83d703c2d49ca07781d3a29851 Mon Sep 17 00:00:00 2001 From: Yves Rijckaert Date: Mon, 14 Oct 2024 16:53:38 +0200 Subject: [PATCH] fix: prop control to filter out experience content types --- .../CreateEntryMenuTrigger.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/reference/src/components/CreateEntryLinkButton/CreateEntryMenuTrigger.tsx b/packages/reference/src/components/CreateEntryLinkButton/CreateEntryMenuTrigger.tsx index be20a9ca4..eebea41d4 100644 --- a/packages/reference/src/components/CreateEntryLinkButton/CreateEntryMenuTrigger.tsx +++ b/packages/reference/src/components/CreateEntryLinkButton/CreateEntryMenuTrigger.tsx @@ -73,6 +73,7 @@ interface CreateEntryMenuTrigger { customDropdownItems?: React.ReactNode; children: CreateEntryMenuTriggerChild; menuProps?: Omit; + filterExperienceTypes?: boolean; } export const CreateEntryMenuTrigger = ({ @@ -87,6 +88,7 @@ export const CreateEntryMenuTrigger = ({ customDropdownItems, children, menuProps, + filterExperienceTypes = true, }: CreateEntryMenuTrigger) => { const [isOpen, setOpen] = useState(false); const [isSelecting, setSelecting] = useState(false); @@ -107,13 +109,15 @@ export const CreateEntryMenuTrigger = ({ // Filter out content types with the Contentful:ExperienceType annotation const filteredContentTypes = useMemo( () => - contentTypes.filter((contentType) => { - const annotations = get(contentType, 'metadata.annotations.ContentType', []); - return !annotations.some( - (annotation) => get(annotation, 'sys.id') === 'Contentful:ExperienceType' - ); - }), - [contentTypes] + filterExperienceTypes + ? contentTypes.filter((contentType) => { + const annotations = get(contentType, 'metadata.annotations.ContentType', []); + return !annotations.some( + (annotation) => get(annotation, 'sys.id') === 'Contentful:ExperienceType' + ); + }) + : contentTypes, + [contentTypes, filterExperienceTypes] ); const hasDropdown = contentTypes.length > 1 || !!customDropdownItems; @@ -258,4 +262,5 @@ export const CreateEntryMenuTrigger = ({ CreateEntryMenuTrigger.defaultProps = { testId: 'create-entry-button-menu-trigger', contentTypesLabel: 'All Content Types', + filterExperienceTypes: true, };