2024-03-11 23:50:22 +00:00
/ * *
* External dependencies
* /
2024-03-18 09:43:02 +00:00
import { __ } from '@wordpress/i18n' ;
2024-04-02 02:58:45 +00:00
import { Icon , moreVertical , edit , cog } from '@wordpress/icons' ;
2024-03-18 09:43:02 +00:00
import { Dropdown , Button , MenuGroup , MenuItem } from '@wordpress/components' ;
2024-04-16 02:36:43 +00:00
import { getAdminLink , getSetting } from '@woocommerce/settings' ;
2024-03-18 09:43:02 +00:00
import classnames from 'classnames' ;
2024-03-11 23:50:22 +00:00
/ * *
* Internal dependencies
* /
import './style.scss' ;
2024-04-08 08:29:49 +00:00
import { SiteVisibilityTour } from '../tour' ;
import { useSiteVisibilityTour } from '../tour/use-site-visibility-tour' ;
2024-04-16 02:36:43 +00:00
import { COMING_SOON_PAGE_EDITOR_LINK } from '../constants' ;
2024-03-11 23:50:22 +00:00
2024-04-25 23:07:56 +00:00
export const LaunchYourStoreStatus = ( {
comingSoon ,
storePagesOnly ,
} : {
comingSoon : string ;
storePagesOnly : string ;
} ) = > {
2024-03-18 09:43:02 +00:00
const isComingSoon = comingSoon && comingSoon === 'yes' ;
const isStorePagesOnly =
isComingSoon && storePagesOnly && storePagesOnly === 'yes' ;
const comingSoonText = isStorePagesOnly
2024-04-02 02:58:33 +00:00
? __ ( 'Store coming soon' , 'woocommerce' )
: __ ( 'Site coming soon' , 'woocommerce' ) ;
2024-03-18 09:43:02 +00:00
const liveText = __ ( 'Live' , 'woocommerce' ) ;
const dropdownText = isComingSoon ? comingSoonText : liveText ;
2024-04-08 08:29:49 +00:00
const { showTour , setShowTour , onClose , shouldTourBeShown } =
useSiteVisibilityTour ( ) ;
2024-04-05 01:26:30 +00:00
2024-03-11 23:50:22 +00:00
return (
< div className = "woocommerce-lys-status" >
2024-04-08 08:29:49 +00:00
{ shouldTourBeShown && showTour && (
< SiteVisibilityTour
onClose = { ( ) = > {
onClose ( ) ;
setShowTour ( false ) ;
} }
/ >
) }
2024-03-11 23:50:22 +00:00
< div className = "woocommerce-lys-status-pill-wrapper" >
2024-03-18 09:43:02 +00:00
< Dropdown
className = "woocommerce-lys-status-dropdown"
2024-04-25 23:07:56 +00:00
// @ts-expect-error Property does exists
2024-03-18 09:43:02 +00:00
focusOnMount = { true }
popoverProps = { { placement : 'bottom-start' } }
renderToggle = { ( { isOpen , onToggle } ) = > (
< Button onClick = { onToggle } aria - expanded = { isOpen } >
< div
className = { classnames (
'woocommerce-lys-status-pill' ,
{ 'is-live' : ! isComingSoon }
) }
>
< span > { dropdownText } < / span >
< Icon icon = { moreVertical } size = { 18 } / >
< / div >
< / Button >
) }
renderContent = { ( ) = > (
< >
2024-04-02 02:58:45 +00:00
< MenuGroup className = "woocommerce-lys-status-popover" >
2024-03-18 09:43:02 +00:00
< MenuItem
2024-04-25 23:07:56 +00:00
// @ts-expect-error Prop gets passed down to underlying button https://developer.wordpress.org/block-editor/reference-guides/components/menu-item/#props
2024-03-18 09:43:02 +00:00
href = { getAdminLink (
2024-04-04 21:28:58 +00:00
'admin.php?page=wc-settings&tab=site-visibility'
2024-03-18 09:43:02 +00:00
) }
>
2024-04-02 02:58:45 +00:00
< Icon icon = { cog } size = { 24 } / >
2024-03-18 09:43:02 +00:00
{ __ (
'Manage site visibility' ,
'woocommerce'
) }
< / MenuItem >
2024-04-16 02:36:43 +00:00
{ isComingSoon &&
getSetting ( 'currentThemeIsFSETheme' ) && (
< MenuItem
2024-04-25 23:07:56 +00:00
// @ts-expect-error Prop gets passed down to underlying button https://developer.wordpress.org/block-editor/reference-guides/components/menu-item/#props
2024-04-16 02:36:43 +00:00
href = {
COMING_SOON_PAGE_EDITOR_LINK
}
>
< Icon icon = { edit } size = { 24 } / >
{ __ (
'Customize "Coming soon" page' ,
'woocommerce'
) }
< / MenuItem >
) }
2024-03-18 09:43:02 +00:00
< / MenuGroup >
< / >
) }
/ >
2024-03-11 23:50:22 +00:00
< / div >
< / div >
) ;
} ;