/** * External dependencies */ import React from 'react'; /** * WordPress dependencies */ const { __, sprintf } = wp.i18n; export default ({ currentStep, serverType, rulesMethod, setRulesMethod, setServerType, rulesError, smushData, makeRequest, }) => { const stepsHeading = { 1: { title: __('Choose Server Type', 'wp-smushit'), description: __( 'Choose your server type. If you don’t know this, please contact your hosting provider.', 'wp-smushit' ), }, 2: { title: __('Add Rules', 'wp-smushit'), description: 'apache' === serverType ? __( 'Smush can automatically apply WebP conversion rules for Apache servers by writing to your .htaccess file. Alternatively, switch to Manual to apply these rules yourself.', 'wp-smushit' ) : __( 'The following configurations are for NGINX servers. If you do not have access to your NGINX config files you will need to contact your hosting provider to make these changes.', 'wp-smushit' ), }, 3: { title: __('Finish Setup', 'wp-smushit'), description: __( 'The rules have been applied successfully.', 'wp-smushit' ), }, }; const getTopNotice = () => { if (1 === currentStep && smushData.isS3Enabled) { return (

{__( 'We noticed the Amazon S3 Integration is enabled. Offloaded images will not be served in WebP format, but Smush will create local WebP copies of all images. If this is undesirable, you can quit the setup.', 'wp-smushit' )}

); } if (2 === currentStep) { const switchDirectConversionMethod = ( e ) => { e.preventDefault(); WP_Smush.WebP.switchMethod( 'direct_conversion' ); }; const suggestionMessage = sprintf( /* translators: 1: Opening ', '', '' ); return (
{rulesError && (

)}
); } if (smushData.isWpmudevHost) { const message = !smushData.isWhitelabel ? __( 'Since your site is hosted with WPMU DEV, we already have done the configurations steps for you. The only step for you would be to create WebP images below.', 'wp-smushit' ) : __( 'WebP conversion is active and working well. Your hosting has automatically pre-configured the conversion for you. The only step for you would be to create WebP images below.', 'wp-smushit' ); return (

{message}

); } }; const getStepContent = () => { if (1 === currentStep) { return (

{sprintf( /* translators: server type */ __( "We've automatically detected your server type is %s. If this is incorrect, manually select your server type to generate the relevant rules and instructions.", 'wp-smushit' ), 'nginx' === smushData.detectedServer ? 'NGINX' : 'Apache / LiteSpeed' )}

); } if (2 === currentStep) { if ('nginx' === serverType) { return (
  1. {__( 'Insert the following in the server context of your configuration file (usually found in /etc/nginx/sites-available). “The server context” refers to the part of the configuration that starts with “server {” and ends with the matching “}”.', 'wp-smushit' )}
  2. {__( 'Copy the generated code found below and paste it inside your http or server blocks.', 'wp-smushit' )}
							{smushData.nginxRules}
						
  1. {__('Reload NGINX.', 'wp-smushit')}

{__('Still having trouble?', 'wp_smushit')}{' '} {__('Get Support.', 'wp_smushit')}

); } // TODO: The non-selected button isn't focusable this way. Why arrows don't workkkkkkk? return (
); } const hideWizard = (e) => { e.preventDefault(); makeRequest('smush_toggle_webp_wizard').then(() => { location.href = smushData.urls.bulkPage; }); }; return (

{__('Convert Images to WebP', 'wp-smushit')}

{!smushData.isMultisite && (

{__('Convert now', 'wp-smushit')}

)}
); }; const stepIndicatorText = sprintf( /* translators: currentStep/totalSteps indicator */ __('Step %s', 'wp-smushit'), currentStep + '/3' ); return (
{getTopNotice()}
{stepIndicatorText}

{stepsHeading[currentStep].title}

{stepsHeading[currentStep].description}

{getStepContent()}
); };