/**
* External dependencies
*/
import React from 'react';
import classNames from 'classnames';
/**
* WordPress dependencies
*/
const { __, sprintf } = wp.i18n;
/**
* Internal dependencies
*/
import './wizard.scss';
import Box from '../../components/sui-box';
import { getLink } from '../../../js/utils/helpers';
import Icon from '../../components/sui-icon';
import ProgressBar from '../../components/sui-progress';
import Tag from '../../components/sui-tag';
import MinifySetupWizard from '../../../js/scanners/MinifySetupWizard';
import Toggle from '../../components/sui-toggle';
import SettingsRow from '../../components/sui-box-settings/row';
import Button from '../../components/sui-button';
import Tabs from '../../components/sui-tabs';
import Tooltip from '../../components/sui-tooltip';
import {createInterpolateElement} from "@wordpress/element";
/**
* Wizard module, extends React.Component.
*
* @since 3.3.1
*/
export default class Wizard extends React.Component {
/**
* Component constructor.
*
* @param {Object} props
*/
constructor( props ) {
super( props );
this.state = {
steps: {
1: __( 'Getting Started', 'wphb' ),
2: __( 'Asset Optimization', 'wphb' ),
3: __( 'Uptime', 'wphb' ),
4: __( 'Page Caching', 'wphb' ),
5: __( 'Advanced Tools', 'wphb' ),
6: __( 'Finish', 'wphb' )
},
scanning: false,
skip: {
advCacheFile: false,
fastCGI: false
}
};
this.continueToNextStep = this.continueToNextStep.bind( this );
}
/**
* Run actions on component update.
*
* @param {Object} prevProps
* @param {Object} prevState
*/
componentDidUpdate( prevProps, prevState ) {
if ( 1 === this.props.step && this.props.showConflicts ) {
if ( this.props.step === prevProps.step && this.props.showConflicts === prevProps.showConflicts ) {
return; // Nothing changed after re-checking status.
}
// We need to save our state, so we don't show extra stuff on next step.
this.setState( {
skip: {
advCacheFile: ! this.props.issues.advCacheFile,
fastCGI: ! this.props.issues.fastCGI
}
} );
jQuery( '.sui-box-header' ).on( 'click', this.toggleContent );
}
if ( 2 === this.props.step && this.props.settings.aoEnable ) {
if ( true === this.state.scanning && this.state.scanning !== prevState.scanning ) {
const scanner = new MinifySetupWizard( this.props.minifySteps, 0 );
scanner.start();
}
}
if ( 3 <= this.props.step && this.props.step !== prevProps.step ) {
this.setState( { scanning: false } );
}
}
/**
* Show/hide content block with issues.
*
* @param {Object} e
*/
toggleContent( e ) {
e.currentTarget.parentNode.classList.toggle( 'open' );
}
/**
* Get navigation.
*
* @return {JSX.Element} Side navigation
*/
getNavigation() {
const mobileSteps = Object.entries( this.state.steps ).map( ( step, key ) => {
if ( 6 === key ) {
return null;
}
const x1 = key * 20;
const x2 = step[ 0 ] * 20;
const stroke = this.props.step <= step[ 0 ] ? '#D8D8D8' : '#1ABC9C';
return
{ __( 'No other caching plugin is detected. You can proceed with the setup.', 'wphb' ) }
); if ( this.props.issues.advCacheFile ) { title = __( 'Another caching plugin is detected', 'wphb' ); icon = 'warning-alert sui-error'; const message = createInterpolateElement( __('Hummingbird has detected an advanced-cache.php file in your site’s wp-content directory. Manage your plugins and disable any other active caching plugins to ensure Hummingbird’s page caching works properly.', 'wphb'), { a: } ); description = ({message}
{ __( 'If no other caching plugins are active, the advanced-cache.php may have been left by a previously used caching plugin. You can remove the file from the wp-content directory, or remove it via your file manager or FTP.', 'wphb' ) }
{ description }
} footerActions={
{ __( 'Please wait, this won’t take more than a minute...', 'wphb' ) }
{ __( 'Modules', 'wphb' ) } | { __( 'Settings applied', 'wphb' ) } | { __( 'Status', 'wphb' ) } |
---|---|---|
{ __( 'Asset Optimization', 'wphb' ) } |
{ ! this.props.isNetworkAdmin && this.props.settings.aoSpeedy && __( 'Speedy Optimization', 'wphb' ) }
{ ! this.props.isNetworkAdmin && ! this.props.settings.aoSpeedy && __( 'Basic Optimization', 'wphb' ) }
{ this.props.isNetworkAdmin && __( 'Active on subsites', 'wphb' ) }
{ this.props.isMember && } { this.props.isMember && |
|
{ __( 'Uptime', 'wphb' ) } | { __( 'Default settings', 'wphb' ) } | |
{ __( 'Page Caching', 'wphb' ) } | { __( 'Static Server Cache', 'wphb' ) } |
|
{ __( 'Page Caching', 'wphb' ) } |
{ __( 'Cache on mobile devices', 'wphb' ) } { __( 'Clear cache on comment post', 'wphb' ) } { __( 'Cache HTTP headers', 'wphb' ) } { __( 'Show clear cache button in admin bar', 'wphb' ) } |
{ this.props.settings.cacheOnMobile &&
|
{ __( 'Advanced Tools', 'wphb' ) } |
{ __( 'Remove query strings from my assets', 'wphb' ) } { this.props.hasWoo && |
{ this.props.settings.queryStrings &&
|
{ description }
{ 1 === this.props.step && ! this.props.showConflicts && } { 1 === this.props.step && this.props.showConflicts &&