2020-03-27 20:42:58 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
2021-05-25 15:14:14 +00:00
|
|
|
import { Icon, warning } from '@wordpress/icons';
|
2020-03-27 20:42:58 +00:00
|
|
|
|
|
|
|
export const setupErrorTypes = {
|
|
|
|
DOWNLOAD: 'download',
|
|
|
|
INSTALL: 'install',
|
|
|
|
ACTIVATE: 'activate',
|
|
|
|
SETUP: 'setup',
|
|
|
|
START: 'start',
|
|
|
|
};
|
|
|
|
|
|
|
|
const setupErrorDescriptions = {
|
2022-03-30 09:00:04 +00:00
|
|
|
[ setupErrorTypes.DOWNLOAD ]: __( 'download', 'woocommerce' ),
|
|
|
|
[ setupErrorTypes.INSTALL ]: __( 'install', 'woocommerce' ),
|
|
|
|
[ setupErrorTypes.ACTIVATE ]: __( 'activate', 'woocommerce' ),
|
|
|
|
[ setupErrorTypes.SETUP ]: __( 'set up', 'woocommerce' ),
|
|
|
|
[ setupErrorTypes.START ]: __( 'start', 'woocommerce' ),
|
2020-03-27 20:42:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function SetupNotice( { isSetupError, errorReason } ) {
|
|
|
|
const getErrorMessage = ( errorType ) => {
|
|
|
|
// Default to 'set up' description if the error type somehow doesn't exist.
|
|
|
|
const description =
|
|
|
|
errorType in setupErrorDescriptions
|
|
|
|
? setupErrorDescriptions[ errorType ]
|
|
|
|
: setupErrorDescriptions[ setupErrorTypes.SETUP ];
|
|
|
|
|
|
|
|
return sprintf(
|
2023-11-16 11:15:11 +00:00
|
|
|
/* translators: %s is the action from the setup error description above */
|
2020-03-27 20:42:58 +00:00
|
|
|
__(
|
|
|
|
'Unable to %s the plugin. Refresh the page and try again.',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2020-03-27 20:42:58 +00:00
|
|
|
),
|
|
|
|
description
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( ! isSetupError ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="wc-admin-shipping-banner-install-error">
|
2021-05-25 15:14:14 +00:00
|
|
|
<Icon icon={ warning } className="warning-icon" />
|
2020-03-27 20:42:58 +00:00
|
|
|
{ getErrorMessage( errorReason ) }
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|