2020-05-19 13:16:19 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2020-06-18 23:44:00 +00:00
|
|
|
import {
|
|
|
|
Card,
|
|
|
|
CardBody,
|
|
|
|
CardHeader,
|
|
|
|
__experimentalText as Text,
|
|
|
|
} from '@wordpress/components';
|
2020-05-20 13:34:49 +00:00
|
|
|
import {
|
|
|
|
Icon,
|
|
|
|
megaphone,
|
|
|
|
box,
|
|
|
|
brush,
|
|
|
|
shipping,
|
|
|
|
percent,
|
|
|
|
payment,
|
|
|
|
pencil,
|
|
|
|
lifesaver,
|
|
|
|
external,
|
|
|
|
chevronRight,
|
|
|
|
} from '@wordpress/icons';
|
2020-05-19 13:16:19 +00:00
|
|
|
import { partial } from 'lodash';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WooCommerce dependencies
|
|
|
|
*/
|
|
|
|
import { getSetting } from '@woocommerce/wc-admin-settings';
|
2020-06-18 23:44:00 +00:00
|
|
|
import { List } from '@woocommerce/components';
|
2020-05-19 13:16:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { recordEvent } from 'lib/tracks';
|
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
function getItems( props ) {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
title: __( 'Market my store', 'woocommerce-admin' ),
|
|
|
|
type: 'wc-admin',
|
|
|
|
path: 'marketing',
|
2020-05-20 13:34:49 +00:00
|
|
|
icon: megaphone,
|
2020-05-19 13:16:19 +00:00
|
|
|
listItemTag: 'marketing',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'Add products', 'woocommerce-admin' ),
|
|
|
|
type: 'wp-admin',
|
|
|
|
path: 'post-new.php?post_type=product',
|
2020-05-20 13:34:49 +00:00
|
|
|
icon: box,
|
2020-05-19 13:16:19 +00:00
|
|
|
listItemTag: 'add-products',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'Personalize my store', 'woocommerce-admin' ),
|
|
|
|
type: 'wp-admin',
|
|
|
|
path: 'customize.php',
|
2020-05-20 13:34:49 +00:00
|
|
|
icon: brush,
|
2020-05-19 13:16:19 +00:00
|
|
|
listItemTag: 'personalize-store',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'Shipping settings', 'woocommerce-admin' ),
|
|
|
|
type: 'wc-settings',
|
|
|
|
tab: 'shipping',
|
2020-05-20 13:34:49 +00:00
|
|
|
icon: shipping,
|
2020-05-19 13:16:19 +00:00
|
|
|
listItemTag: 'shipping-settings',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'Tax settings', 'woocommerce-admin' ),
|
|
|
|
type: 'wc-settings',
|
|
|
|
tab: 'tax',
|
2020-05-20 13:34:49 +00:00
|
|
|
icon: percent,
|
2020-05-19 13:16:19 +00:00
|
|
|
listItemTag: 'tax-settings',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'Payment settings', 'woocommerce-admin' ),
|
|
|
|
type: 'wc-settings',
|
|
|
|
tab: 'checkout',
|
2020-05-20 13:34:49 +00:00
|
|
|
icon: payment,
|
2020-05-19 13:16:19 +00:00
|
|
|
listItemTag: 'payment-settings',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'Edit store details', 'woocommerce-admin' ),
|
|
|
|
type: 'wc-settings',
|
|
|
|
tab: 'general',
|
2020-05-20 13:34:49 +00:00
|
|
|
icon: pencil,
|
2020-05-19 13:16:19 +00:00
|
|
|
listItemTag: 'edit-store-details',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'Get support', 'woocommerce-admin' ),
|
|
|
|
type: 'external',
|
|
|
|
href: 'https://woocommerce.com/my-account/create-a-ticket/',
|
2020-05-20 13:34:49 +00:00
|
|
|
icon: lifesaver,
|
2020-05-19 13:16:19 +00:00
|
|
|
listItemTag: 'support',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'View my store', 'woocommerce-admin' ),
|
|
|
|
type: 'external',
|
|
|
|
href: props.getSetting( 'siteUrl' ),
|
2020-05-20 13:34:49 +00:00
|
|
|
icon: external,
|
2020-05-19 13:16:19 +00:00
|
|
|
listItemTag: 'view-store',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleOnItemClick( props, event ) {
|
|
|
|
const a = event.currentTarget;
|
|
|
|
const listItemTag = a.dataset.listItemTag;
|
|
|
|
|
|
|
|
if ( ! listItemTag ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
props.recordEvent( 'home_quick_links_click', {
|
|
|
|
task_name: listItemTag,
|
|
|
|
} );
|
|
|
|
|
|
|
|
if ( typeof props.onItemClick !== 'function' ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! props.onItemClick( listItemTag ) ) {
|
|
|
|
event.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLinkTypeAndHref( item ) {
|
|
|
|
let linkType;
|
|
|
|
let href;
|
|
|
|
|
|
|
|
switch ( item.type ) {
|
|
|
|
case 'wc-admin':
|
|
|
|
linkType = 'wc-admin';
|
|
|
|
href = `admin.php?page=wc-admin&path=%2F${ item.path }`;
|
|
|
|
break;
|
|
|
|
case 'wp-admin':
|
|
|
|
linkType = 'wp-admin';
|
|
|
|
href = item.path;
|
|
|
|
break;
|
|
|
|
case 'wc-settings':
|
|
|
|
linkType = 'wp-admin';
|
|
|
|
href = `admin.php?page=wc-settings&tab=${ item.tab }`;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
linkType = 'external';
|
|
|
|
href = item.href;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
linkType,
|
|
|
|
href,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function getListItems( props ) {
|
|
|
|
return getItems( props ).map( ( item ) => {
|
|
|
|
return {
|
2020-06-19 00:13:41 +00:00
|
|
|
title: <Text as="div" variant="button">{ item.title }</Text>,
|
2020-05-20 13:34:49 +00:00
|
|
|
before: <Icon icon={ item.icon } />,
|
|
|
|
after: <Icon icon={ chevronRight } />,
|
2020-05-19 13:16:19 +00:00
|
|
|
...getLinkTypeAndHref( item ),
|
|
|
|
listItemTag: item.listItemTag,
|
|
|
|
onClick: partial( handleOnItemClick, props ),
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
const QuickLinks = ( props ) => {
|
|
|
|
const listItems = getListItems( props );
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card size="large" className="woocommerce-quick-links">
|
2020-06-18 23:44:00 +00:00
|
|
|
<CardHeader size="medium">
|
|
|
|
<Text variant="title.small">
|
|
|
|
{ __( 'Store management', 'woocommerce-admin' ) }
|
|
|
|
</Text>
|
2020-05-19 13:16:19 +00:00
|
|
|
</CardHeader>
|
|
|
|
<CardBody>
|
|
|
|
<List
|
|
|
|
items={ listItems }
|
|
|
|
className="woocommerce-quick-links__list"
|
|
|
|
/>
|
|
|
|
</CardBody>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
QuickLinks.defaultProps = {
|
|
|
|
getSetting,
|
|
|
|
recordEvent,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default QuickLinks;
|