/** * External dependencies */ import { __, _n, sprintf } from '@wordpress/i18n'; import { Notice, ExternalLink } from '@wordpress/components'; import { createInterpolateElement } from '@wordpress/element'; import { Alert } from '@woocommerce/icons'; import { Icon, chevronDown } from '@wordpress/icons'; /** * Internal dependencies */ import { useCombinedIncompatibilityNotice } from './use-combined-incompatibility-notice'; import { SwitchToClassicShortcodeButton } from '../switch-to-classic-shortcode-button'; import './editor.scss'; interface ExtensionNoticeProps { block: 'woocommerce/cart' | 'woocommerce/checkout'; clientId: string; } /** * Shows a notice when there are incompatible extensions. * * Tracks events: * - switch_to_classic_shortcode_click * - switch_to_classic_shortcode_confirm * - switch_to_classic_shortcode_cancel * - switch_to_classic_shortcode_undo */ export function IncompatibleExtensionsNotice( { block, clientId, }: ExtensionNoticeProps ) { const [ isVisible, dismissNotice, incompatibleExtensions, incompatibleExtensionsCount, ] = useCombinedIncompatibilityNotice( block ); if ( ! isVisible ) { return null; } const noticeContent = ( <> { incompatibleExtensionsCount > 1 ? createInterpolateElement( __( 'Some active extensions do not yet support this block. This may impact the shopper experience. Learn more', 'woocommerce' ), { a: ( ), } ) : createInterpolateElement( sprintf( // translators: %s is the name of the extension. __( '%s does not yet support this block. This may impact the shopper experience. Learn more', 'woocommerce' ), Object.values( incompatibleExtensions )[ 0 ] ), { strong: , a: ( ), } ) } ); const entries = Object.entries( incompatibleExtensions ); const remainingEntries = entries.length - 2; return (
} />

{ noticeContent }

{ incompatibleExtensionsCount > 1 && (
    { entries.slice( 0, 2 ).map( ( [ id, title ] ) => (
  • { title }
  • ) ) }
) } { entries.length > 2 && (
{ sprintf( // translators: %s is the number of incompatible extensions. _n( '%s more incompatibility', '%s more incompatibilities', remainingEntries, 'woocommerce' ), remainingEntries ) }
    { entries.slice( 2 ).map( ( [ id, title ] ) => (
  • { title }
  • ) ) }
) }
); }