2024-03-11 23:50:22 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2024-03-18 09:43:02 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2024-03-11 23:50:22 +00:00
|
|
|
import { Icon, moreVertical } from '@wordpress/icons';
|
2024-03-18 09:43:02 +00:00
|
|
|
import { Dropdown, Button, MenuGroup, MenuItem } from '@wordpress/components';
|
2024-03-20 03:26:17 +00:00
|
|
|
import { getNewPath } from '@woocommerce/navigation';
|
2024-03-18 09:43:02 +00:00
|
|
|
import { getAdminLink } from '@woocommerce/settings';
|
|
|
|
import classnames from 'classnames';
|
2024-03-11 23:50:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
|
|
|
|
2024-03-18 09:43:02 +00:00
|
|
|
export const LaunchYourStoreStatus = ( { comingSoon, storePagesOnly } ) => {
|
|
|
|
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-03-20 03:26:17 +00:00
|
|
|
const launchYourStoreLink = new URL(
|
|
|
|
getAdminLink( getNewPath( {}, '/launch-your-store', {} ) )
|
|
|
|
);
|
2024-03-11 23:50:22 +00:00
|
|
|
return (
|
|
|
|
<div className="woocommerce-lys-status">
|
|
|
|
<div className="woocommerce-lys-status-pill-wrapper">
|
2024-03-18 09:43:02 +00:00
|
|
|
<Dropdown
|
|
|
|
className="woocommerce-lys-status-dropdown"
|
|
|
|
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={ () => (
|
|
|
|
<>
|
|
|
|
<MenuGroup>
|
|
|
|
<MenuItem
|
|
|
|
href={ getAdminLink(
|
|
|
|
'admin.php?page=wc-settings'
|
|
|
|
) }
|
|
|
|
>
|
|
|
|
{ __(
|
|
|
|
'Manage site visibility',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</MenuItem>
|
|
|
|
{ isComingSoon && (
|
2024-03-20 03:26:17 +00:00
|
|
|
<MenuItem href={ launchYourStoreLink.href }>
|
2024-03-18 09:43:02 +00:00
|
|
|
{ __(
|
|
|
|
'Customize "Coming soon" page',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</MenuItem>
|
|
|
|
) }
|
|
|
|
</MenuGroup>
|
|
|
|
</>
|
|
|
|
) }
|
|
|
|
/>
|
2024-03-11 23:50:22 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|