Skip to content

Commit ac1a54d

Browse files
release: version 1.2.11
- Onboarding wizard changes.
2 parents 76923be + 7f1ad97 commit ac1a54d

File tree

9 files changed

+277
-88
lines changed

9 files changed

+277
-88
lines changed

assets/src/Components/ImportModal.js

Lines changed: 162 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const ImportModal = ( {
5353
widgets: true,
5454
cleanup: false,
5555
performanceAddon: true,
56+
hyveLite: true,
5657
theme_install: themeData !== false,
5758
} );
5859
const site = tiobDash.onboarding.homeUrl || '';
@@ -61,6 +62,7 @@ const ImportModal = ( {
6162
const [ performanceAddonProgress, setPerformanceAddonProgress ] = useState(
6263
false
6364
);
65+
const [ hyveLiteProgress, setHyveLiteProgress ] = useState( false );
6466
const [ cleanupProgress, setCleanupProgress ] = useState( false );
6567
const [ pluginsProgress, setPluginsProgress ] = useState( false );
6668
const [ contentProgress, setContentProgress ] = useState( false );
@@ -81,7 +83,9 @@ const ImportModal = ( {
8183
cleanupAllowed
8284
);
8385
const [ email, setEmail ] = useState( tiobDash.emailSubscribe.email || '' );
84-
const [ skipSubscribe, setSkipSubscribe ] = useState( 'yes' === tiobDash?.emailSubscribe?.skipStatus );
86+
const [ skipSubscribe, setSkipSubscribe ] = useState(
87+
'yes' === tiobDash?.emailSubscribe?.skipStatus
88+
);
8589
const [ processingSub, setProcessingSub ] = useState( false );
8690

8791
useEffect( () => {
@@ -260,6 +264,44 @@ const ImportModal = ( {
260264
}
261265
),
262266
},
267+
hyveLite: {
268+
title: __( 'AI Chatbot', 'templates-patterns-collection' ),
269+
icon: 'admin-comments',
270+
tooltip: createInterpolateElement(
271+
sprintf(
272+
// translators: %s is Hyve plugin name.
273+
__(
274+
'Hyve is an AI-powered chatbot that transforms your WordPress content into engaging conversations. %sHyve%s',
275+
'templates-patterns-collection'
276+
),
277+
'<a><span>',
278+
'</span><icon/></a>'
279+
),
280+
{
281+
a: (
282+
// eslint-disable-next-line jsx-a11y/anchor-has-content
283+
<a
284+
href="https://wordpress.org/plugins/hyve-lite/"
285+
target={ '_blank' }
286+
rel="external noreferrer noopener"
287+
style={ {
288+
textDecoration: 'none',
289+
display: 'inline-flex',
290+
alignItems: 'center',
291+
} }
292+
/>
293+
),
294+
icon: (
295+
<Icon
296+
size={ 10 }
297+
icon="external"
298+
style={ { marginLeft: 0 } }
299+
/>
300+
),
301+
span: <div />,
302+
}
303+
),
304+
},
263305
};
264306

265307
if ( isCleanupAllowed === 'yes' ) {
@@ -305,7 +347,11 @@ const ImportModal = ( {
305347
<span>{ title }</span>
306348
{ tooltip && (
307349
<CustomTooltip
308-
toLeft={ id === 'performanceAddon' || id === 'cleanup' }
350+
toLeft={ [
351+
'performanceAddon',
352+
'cleanup',
353+
'hyveLite',
354+
].includes( id ) }
309355
rightOffset={ id === 'cleanup' ? -90 : 0 }
310356
>
311357
{ tooltip }
@@ -343,15 +389,19 @@ const ImportModal = ( {
343389
return null;
344390
}
345391

346-
const [ pluginsOpened, setPluginsOpened ] = useState( Object.keys( allPlugins ).length < 3 );
392+
const [ pluginsOpened, setPluginsOpened ] = useState(
393+
Object.keys( allPlugins ).length < 3
394+
);
347395

348396
const toggleOpen = () => {
349397
setPluginsOpened( ! pluginsOpened );
350398
};
351399

352-
const pluginsList = Object.keys( allPlugins ).map( ( slug, index ) => {
353-
return allPlugins[ slug ];
354-
} ).join( ', ' );
400+
const pluginsList = Object.keys( allPlugins )
401+
.map( ( slug, index ) => {
402+
return allPlugins[ slug ];
403+
} )
404+
.join( ', ' );
355405

356406
return (
357407
<>
@@ -392,18 +442,21 @@ const ImportModal = ( {
392442
);
393443
} ) }
394444
</PanelBody>
395-
{ ! pluginsOpened && (<i className="plugin-summary">
396-
<CustomTooltip
397-
toLeft={false}
398-
>
399-
<span
400-
dangerouslySetInnerHTML={ {
401-
__html: pluginsList,
402-
} }
403-
/>
404-
</CustomTooltip>
405-
{ __( 'Additional plugins are required for this Starter Site in order to work properly. ', 'templates-patterns-collection' ) }
406-
</i>) }
445+
{ ! pluginsOpened && (
446+
<i className="plugin-summary">
447+
<CustomTooltip toLeft={ false }>
448+
<span
449+
dangerouslySetInnerHTML={ {
450+
__html: pluginsList,
451+
} }
452+
/>
453+
</CustomTooltip>
454+
{ __(
455+
'Additional plugins are required for this Starter Site in order to work properly. ',
456+
'templates-patterns-collection'
457+
) }
458+
</i>
459+
) }
407460
</>
408461
);
409462
};
@@ -495,7 +548,11 @@ const ImportModal = ( {
495548

496549
function runImportPlugins() {
497550
// console.clear();
498-
if ( ! pluginOptions && ! general.performanceAddon ) {
551+
if (
552+
! pluginOptions &&
553+
! general.performanceAddon &&
554+
! general.hyveLite
555+
) {
499556
console.log( '[S] Plugins.' );
500557
runImportContent();
501558
return false;
@@ -602,7 +659,7 @@ const ImportModal = ( {
602659
function runPerformanceAddonInstall() {
603660
if ( ! general.performanceAddon ) {
604661
console.log( '[S] Performance Addon.' );
605-
importDone();
662+
runHyveLiteInstall();
606663
return false;
607664
}
608665
setCurrentStep( 'performanceAddon' );
@@ -616,13 +673,37 @@ const ImportModal = ( {
616673
}
617674
console.log( '[D] Performance Addon.' );
618675
setPerformanceAddonProgress( 'done' );
619-
importDone();
676+
runHyveLiteInstall();
620677
} )
621678
.catch( ( incomingError ) =>
622679
handleError( incomingError, 'performanceAddon' )
623680
);
624681
}
625682

683+
function runHyveLiteInstall() {
684+
if ( ! general.hyveLite ) {
685+
console.log( '[S] Hyve Lite.' );
686+
importDone();
687+
return false;
688+
}
689+
setCurrentStep( 'hyveLite' );
690+
console.log( '[P] Hyve Lite.' );
691+
692+
installPlugins( { 'hyve-lite': true } )
693+
.then( ( response ) => {
694+
if ( ! response.success ) {
695+
handleError( response, 'hyveLite' );
696+
return false;
697+
}
698+
console.log( '[D] Hyve Lite.' );
699+
setHyveLiteProgress( 'done' );
700+
importDone();
701+
} )
702+
.catch( ( incomingError ) =>
703+
handleError( incomingError, 'hyveLite' )
704+
);
705+
}
706+
626707
function importDone() {
627708
setCurrentStep( 'done' );
628709
setIsCleanupAllowed( 'yes' );
@@ -671,6 +752,10 @@ const ImportModal = ( {
671752
'Something went wrong while installing the performance addon.',
672753
'templates-patterns-collection'
673754
),
755+
hyveLite: __(
756+
'Something went wrong while installing the Hyve Lite plugin.',
757+
'templates-patterns-collection'
758+
),
674759
};
675760

676761
switch ( step ) {
@@ -692,6 +777,9 @@ const ImportModal = ( {
692777
case 'performanceAddon':
693778
setPerformanceAddonProgress( 'error' );
694779
break;
780+
case 'hyveLite':
781+
setHyveLiteProgress( 'error' );
782+
break;
695783
}
696784
setError(
697785
incomingError.data
@@ -735,24 +823,25 @@ const ImportModal = ( {
735823
'templates-patterns-collection'
736824
);
737825
if ( skipSubscribe ) {
738-
viewWebsiteText = __(
739-
'View Website',
740-
'templates-patterns-collection'
741-
);
826+
viewWebsiteText = __( 'View Website', 'templates-patterns-collection' );
742827
skipText = __(
743828
'Add your own content',
744829
'templates-patterns-collection'
745830
);
746831
}
747832

748833
const markSubscribeSkip = ( redirect, data = {} ) => {
749-
ajaxAction( tiobDash.emailSubscribe.ajaxURL, 'skip_subscribe', tiobDash.emailSubscribe.nonce, data )
750-
.then(() => {
751-
setSkipSubscribe(true);
752-
setProcessingSub( false );
753-
window.location.href = redirect;
754-
});
755-
}
834+
ajaxAction(
835+
tiobDash.emailSubscribe.ajaxURL,
836+
'skip_subscribe',
837+
tiobDash.emailSubscribe.nonce,
838+
data
839+
).then( () => {
840+
setSkipSubscribe( true );
841+
setProcessingSub( false );
842+
window.location.href = redirect;
843+
} );
844+
};
756845

757846
const goToEditContent = () => {
758847
if ( skipSubscribe ) {
@@ -779,34 +868,36 @@ const ImportModal = ( {
779868
fetch( 'https://api.themeisle.com/tracking/subscribe', {
780869
method: 'POST',
781870
headers: {
782-
'Content-Type': 'application/json'
871+
'Content-Type': 'application/json',
783872
},
784-
body: JSON.stringify({
873+
body: JSON.stringify( {
785874
slug: 'templates-patterns-collection',
786875
site,
787-
email
788-
})
789-
})
790-
.then( r => r.json() )
876+
email,
877+
} ),
878+
} )
879+
.then( ( r ) => r.json() )
791880
.then( ( response ) => {
792881
if ( 'success' === response.code ) {
793-
markSubscribeSkip( site )
882+
markSubscribeSkip( site );
794883
}
795-
})?.catch( ( error ) => {
884+
} )
885+
?.catch( ( error ) => {
796886
console.error( error );
797-
markSubscribeSkip( site, { isTempSkip: true } )
798-
});
799-
}
887+
markSubscribeSkip( site, { isTempSkip: true } );
888+
} );
889+
};
800890

801-
let modalTitle = importData ?
802-
sprintf(
891+
let modalTitle = importData
892+
? sprintf(
803893
/* translators: name of starter site */
804894
__(
805895
'Import %s as a complete site',
806896
'templates-patterns-collection'
807897
),
808898
importData.title
809-
) : '';
899+
)
900+
: '';
810901
if ( 'done' === currentStep && ! error ) {
811902
modalTitle = __(
812903
'Content was successfully imported',
@@ -832,12 +923,14 @@ const ImportModal = ( {
832923
siteData.doc_url && (
833924
<DocNotice
834925
data={ {
835-
text: __( 'Learn more about this starter site', 'templates-patterns-collection' ),
926+
text: __(
927+
'Learn more about this starter site',
928+
'templates-patterns-collection'
929+
),
836930
url: siteData.doc_url,
837931
} }
838932
/>
839-
)
840-
}
933+
) }
841934
{ ! importing && 'done' !== currentStep && ! error ? (
842935
<>
843936
<ModalHead />
@@ -869,18 +962,26 @@ const ImportModal = ( {
869962
customizer: customizerProgress,
870963
widgets: widgetsProgress,
871964
performanceAddon: performanceAddonProgress,
965+
hyveLite: hyveLiteProgress,
872966
} }
873967
currentStep={ currentStep }
874968
willDo={ general }
875969
/>
876970
) }
877971
{ 'done' === currentStep && ! skipSubscribe && (
878972
<>
879-
<p className="tpc-subscribe-email-text">{ __( 'Stay up-to-date on news, tips and product updates', 'templates-patterns-collection' ) }</p>
973+
<p className="tpc-subscribe-email-text">
974+
{ __(
975+
'Stay up-to-date on news, tips and product updates',
976+
'templates-patterns-collection'
977+
) }
978+
</p>
880979

881980
<TextControl
882-
aria-label={ __( 'Enter your email', 'templates-patterns-collection' ) }
883-
981+
aria-label={ __(
982+
'Enter your email',
983+
'templates-patterns-collection'
984+
) }
884985
type="email"
885986
value={ email }
886987
onChange={ setEmail }
@@ -889,7 +990,12 @@ const ImportModal = ( {
889990
</>
890991
) }
891992
{ 'done' === currentStep && skipSubscribe && (
892-
<span style={{display: 'block', marginBottom: '60px'}}/>
993+
<span
994+
style={ {
995+
display: 'block',
996+
marginBottom: '60px',
997+
} }
998+
/>
893999
) }
8941000
</>
8951001
) }
@@ -932,7 +1038,9 @@ const ImportModal = ( {
9321038
<div className="import-done-actions">
9331039
<Button
9341040
isLink
935-
className={ classnames( 'close', { 'is-grayed': ! skipSubscribe } ) }
1041+
className={ classnames( 'close', {
1042+
'is-grayed': ! skipSubscribe,
1043+
} ) }
9361044
disabled={ processingSub }
9371045
onClick={ goToEditContent }
9381046
>

0 commit comments

Comments
 (0)