2021-09-21 19:33:44 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
|
|
|
import { Button } from '@wordpress/components';
|
2022-01-06 12:53:30 +00:00
|
|
|
import { getAdminLink } from '@woocommerce/settings';
|
2021-09-21 19:33:44 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
|
|
|
import { Text } from '@woocommerce/experimental';
|
2021-12-10 13:01:13 +00:00
|
|
|
import { Pill } from '@woocommerce/components';
|
2021-09-21 19:33:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './Plugin.scss';
|
|
|
|
|
|
|
|
export type PluginProps = {
|
|
|
|
isActive: boolean;
|
|
|
|
isBusy?: boolean;
|
2021-12-10 13:01:13 +00:00
|
|
|
isBuiltByWC: boolean;
|
2021-09-21 19:33:44 +00:00
|
|
|
isDisabled?: boolean;
|
|
|
|
isInstalled: boolean;
|
|
|
|
description?: string;
|
|
|
|
installAndActivate?: ( slug: string ) => void;
|
|
|
|
imageUrl?: string;
|
|
|
|
manageUrl?: string;
|
|
|
|
name: string;
|
|
|
|
slug: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Plugin: React.FC< PluginProps > = ( {
|
|
|
|
description,
|
|
|
|
imageUrl,
|
|
|
|
installAndActivate = () => {},
|
|
|
|
isActive,
|
|
|
|
isBusy,
|
2021-12-10 13:01:13 +00:00
|
|
|
isBuiltByWC,
|
2021-09-21 19:33:44 +00:00
|
|
|
isDisabled,
|
|
|
|
isInstalled,
|
|
|
|
manageUrl,
|
|
|
|
name,
|
|
|
|
slug,
|
|
|
|
} ) => {
|
|
|
|
return (
|
|
|
|
<div className="woocommerce-plugin-list__plugin">
|
|
|
|
{ imageUrl && (
|
|
|
|
<div className="woocommerce-plugin-list__plugin-logo">
|
|
|
|
<img
|
|
|
|
src={ imageUrl }
|
|
|
|
alt={ sprintf(
|
|
|
|
/* translators: %s = name of the plugin */
|
2022-03-30 09:00:04 +00:00
|
|
|
__( '%s logo', 'woocommerce' ),
|
2021-09-21 19:33:44 +00:00
|
|
|
name
|
|
|
|
) }
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
) }
|
|
|
|
<div className="woocommerce-plugin-list__plugin-text">
|
|
|
|
<Text variant="subtitle.small" as="h4">
|
|
|
|
{ name }
|
2021-12-10 13:01:13 +00:00
|
|
|
{ isBuiltByWC && (
|
|
|
|
<Pill>
|
2022-03-30 09:00:04 +00:00
|
|
|
{ __( 'Built by WooCommerce', 'woocommerce' ) }
|
2021-12-10 13:01:13 +00:00
|
|
|
</Pill>
|
|
|
|
) }
|
2021-09-21 19:33:44 +00:00
|
|
|
</Text>
|
|
|
|
<Text variant="subtitle.small">{ description }</Text>
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-plugin-list__plugin-action">
|
|
|
|
{ isActive && manageUrl && (
|
|
|
|
<Button
|
|
|
|
disabled={ isDisabled }
|
|
|
|
isBusy={ isBusy }
|
|
|
|
isSecondary
|
|
|
|
href={ getAdminLink( manageUrl ) }
|
|
|
|
onClick={ () =>
|
|
|
|
recordEvent( 'marketing_manage', {
|
|
|
|
extension_name: slug,
|
|
|
|
} )
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{ __( 'Manage', 'woocommmerce-admin' ) }
|
|
|
|
</Button>
|
|
|
|
) }
|
|
|
|
{ isInstalled && ! isActive && (
|
|
|
|
<Button
|
|
|
|
disabled={ isDisabled }
|
|
|
|
isBusy={ isBusy }
|
|
|
|
isSecondary
|
|
|
|
onClick={ () => installAndActivate( slug ) }
|
|
|
|
>
|
|
|
|
{ __( 'Activate', 'woocommmerce-admin' ) }
|
|
|
|
</Button>
|
|
|
|
) }
|
|
|
|
{ ! isInstalled && (
|
|
|
|
<Button
|
|
|
|
disabled={ isDisabled }
|
|
|
|
isBusy={ isBusy }
|
|
|
|
isSecondary
|
|
|
|
onClick={ () => installAndActivate( slug ) }
|
|
|
|
>
|
|
|
|
{ __( 'Get started', 'woocommmerce-admin' ) }
|
|
|
|
</Button>
|
|
|
|
) }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|