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-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={ () => (
|
|
|
|
<>
|
2024-04-02 02:58:45 +00:00
|
|
|
<MenuGroup className="woocommerce-lys-status-popover">
|
2024-03-18 09:43:02 +00:00
|
|
|
<MenuItem
|
|
|
|
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>
|
|
|
|
{ isComingSoon && (
|
2024-03-20 03:26:17 +00:00
|
|
|
<MenuItem href={ launchYourStoreLink.href }>
|
2024-04-02 02:58:45 +00:00
|
|
|
<Icon icon={ edit } size={ 24 } />
|
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>
|
|
|
|
);
|
|
|
|
};
|