/**
* 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) {
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 (
{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 (
{__(
'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'
)}
{__(
'Copy the generated code found below and paste it inside your http or server blocks.',
'wp-smushit'
)}
);
}
// TODO: The non-selected button isn't focusable this way. Why arrows don't workkkkkkk?
return (
{__(
'Please note: Some servers have both Apache and NGINX software which may not begin serving WebP images after applying the .htaccess rules. If errors occur after applying the rules, we recommend adding NGINX rules manually.',
'wp-smushit'
)}
{__(
'If you are unable to get the automated method working, follow these steps:',
'wp-smushit'
)}
{__(
'Copy the generated code below and paste it at the top of your .htaccess file (before any existing code) in the root directory.',
'wp-smushit'
)}
{smushData.apacheRules}
{__(
"Next, click Check Status button below to see if it's working.",
'wp-smushit'
)}
{__('Troubleshooting', 'wp-smushit')}
{__(
'If .htaccess does not work, and you have access to vhosts.conf or httpd.conf, try this:',
'wp-smushit'
)}
{__(
'Look for your site in the file and find the line that starts with - add the code above that line and into that section and save the file.',
'wp-smushit'
)}
{__('Reload Apache.', 'wp-smushit')}
{__(
"If you don't know where those files are, or you aren't able to reload Apache, you would need to consult with your hosting provider or a system administrator who has access to change the configuration of your server.",
'wp-smushit'
)}