import { isBusinessPlan, isEcommercePlan } from '@automattic/calypso-products'; import { localizeUrl } from '@automattic/i18n-utils'; import { localize, LocalizeProps } from 'i18n-calypso'; import PlanStorage from 'calypso/blocks/plan-storage'; import { useSelector } from 'calypso/state'; import { canCurrentUser } from 'calypso/state/selectors/can-current-user'; import { getSiteSlug, getSitePlanSlug } from 'calypso/state/sites/selectors'; import { getSelectedSiteId } from 'calypso/state/ui/selectors'; const ExcessiveDiskSpace = ( { translate }: { translate: LocalizeProps[ 'translate' ] } ) => { const selectedSiteId = useSelector( getSelectedSiteId ); const siteSlug = useSelector( ( state ) => getSiteSlug( state, selectedSiteId ) ); const canUserUpgrade = useSelector( ( state ) => canCurrentUser( state, selectedSiteId ?? 0, 'manage_options' ) ); const sitePlanSlug = useSelector( ( state ) => getSitePlanSlug( state, selectedSiteId ) ?? '' ); const planHasTopStorageSpace = isBusinessPlan( sitePlanSlug ) || isEcommercePlan( sitePlanSlug ); const displayUpgradeLink = canUserUpgrade && ! planHasTopStorageSpace; return (
{ translate( 'Your site does not have enough available storage space.' ) }
{ displayUpgradeLink && translate( 'Please {{a}}purchase a plan with additional storage{{/a}} or contact our support team for help.', { components: { a: , }, } ) } { ! displayUpgradeLink && ( { translate( 'You can either {{a}}buy additional storage{{/a}} or {{b}}delete media files{{/b}} until you have less than 95% space usage.', { components: { a: , b: ( ), }, } ) } ) }
); }; export default localize( ExcessiveDiskSpace );