@@ -53,6 +53,7 @@ const ImportModal = ( {
53
53
widgets : true ,
54
54
cleanup : false ,
55
55
performanceAddon : true ,
56
+ hyveLite : true ,
56
57
theme_install : themeData !== false ,
57
58
} ) ;
58
59
const site = tiobDash . onboarding . homeUrl || '' ;
@@ -61,6 +62,7 @@ const ImportModal = ( {
61
62
const [ performanceAddonProgress , setPerformanceAddonProgress ] = useState (
62
63
false
63
64
) ;
65
+ const [ hyveLiteProgress , setHyveLiteProgress ] = useState ( false ) ;
64
66
const [ cleanupProgress , setCleanupProgress ] = useState ( false ) ;
65
67
const [ pluginsProgress , setPluginsProgress ] = useState ( false ) ;
66
68
const [ contentProgress , setContentProgress ] = useState ( false ) ;
@@ -81,7 +83,9 @@ const ImportModal = ( {
81
83
cleanupAllowed
82
84
) ;
83
85
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
+ ) ;
85
89
const [ processingSub , setProcessingSub ] = useState ( false ) ;
86
90
87
91
useEffect ( ( ) => {
@@ -260,6 +264,44 @@ const ImportModal = ( {
260
264
}
261
265
) ,
262
266
} ,
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
+ } ,
263
305
} ;
264
306
265
307
if ( isCleanupAllowed === 'yes' ) {
@@ -305,7 +347,11 @@ const ImportModal = ( {
305
347
< span > { title } </ span >
306
348
{ tooltip && (
307
349
< CustomTooltip
308
- toLeft = { id === 'performanceAddon' || id === 'cleanup' }
350
+ toLeft = { [
351
+ 'performanceAddon' ,
352
+ 'cleanup' ,
353
+ 'hyveLite' ,
354
+ ] . includes ( id ) }
309
355
rightOffset = { id === 'cleanup' ? - 90 : 0 }
310
356
>
311
357
{ tooltip }
@@ -343,15 +389,19 @@ const ImportModal = ( {
343
389
return null ;
344
390
}
345
391
346
- const [ pluginsOpened , setPluginsOpened ] = useState ( Object . keys ( allPlugins ) . length < 3 ) ;
392
+ const [ pluginsOpened , setPluginsOpened ] = useState (
393
+ Object . keys ( allPlugins ) . length < 3
394
+ ) ;
347
395
348
396
const toggleOpen = ( ) => {
349
397
setPluginsOpened ( ! pluginsOpened ) ;
350
398
} ;
351
399
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 ( ', ' ) ;
355
405
356
406
return (
357
407
< >
@@ -392,18 +442,21 @@ const ImportModal = ( {
392
442
) ;
393
443
} ) }
394
444
</ 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
+ ) }
407
460
</ >
408
461
) ;
409
462
} ;
@@ -495,7 +548,11 @@ const ImportModal = ( {
495
548
496
549
function runImportPlugins ( ) {
497
550
// console.clear();
498
- if ( ! pluginOptions && ! general . performanceAddon ) {
551
+ if (
552
+ ! pluginOptions &&
553
+ ! general . performanceAddon &&
554
+ ! general . hyveLite
555
+ ) {
499
556
console . log ( '[S] Plugins.' ) ;
500
557
runImportContent ( ) ;
501
558
return false ;
@@ -602,7 +659,7 @@ const ImportModal = ( {
602
659
function runPerformanceAddonInstall ( ) {
603
660
if ( ! general . performanceAddon ) {
604
661
console . log ( '[S] Performance Addon.' ) ;
605
- importDone ( ) ;
662
+ runHyveLiteInstall ( ) ;
606
663
return false ;
607
664
}
608
665
setCurrentStep ( 'performanceAddon' ) ;
@@ -616,13 +673,37 @@ const ImportModal = ( {
616
673
}
617
674
console . log ( '[D] Performance Addon.' ) ;
618
675
setPerformanceAddonProgress ( 'done' ) ;
619
- importDone ( ) ;
676
+ runHyveLiteInstall ( ) ;
620
677
} )
621
678
. catch ( ( incomingError ) =>
622
679
handleError ( incomingError , 'performanceAddon' )
623
680
) ;
624
681
}
625
682
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
+
626
707
function importDone ( ) {
627
708
setCurrentStep ( 'done' ) ;
628
709
setIsCleanupAllowed ( 'yes' ) ;
@@ -671,6 +752,10 @@ const ImportModal = ( {
671
752
'Something went wrong while installing the performance addon.' ,
672
753
'templates-patterns-collection'
673
754
) ,
755
+ hyveLite : __ (
756
+ 'Something went wrong while installing the Hyve Lite plugin.' ,
757
+ 'templates-patterns-collection'
758
+ ) ,
674
759
} ;
675
760
676
761
switch ( step ) {
@@ -692,6 +777,9 @@ const ImportModal = ( {
692
777
case 'performanceAddon' :
693
778
setPerformanceAddonProgress ( 'error' ) ;
694
779
break ;
780
+ case 'hyveLite' :
781
+ setHyveLiteProgress ( 'error' ) ;
782
+ break ;
695
783
}
696
784
setError (
697
785
incomingError . data
@@ -735,24 +823,25 @@ const ImportModal = ( {
735
823
'templates-patterns-collection'
736
824
) ;
737
825
if ( skipSubscribe ) {
738
- viewWebsiteText = __ (
739
- 'View Website' ,
740
- 'templates-patterns-collection'
741
- ) ;
826
+ viewWebsiteText = __ ( 'View Website' , 'templates-patterns-collection' ) ;
742
827
skipText = __ (
743
828
'Add your own content' ,
744
829
'templates-patterns-collection'
745
830
) ;
746
831
}
747
832
748
833
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
+ } ;
756
845
757
846
const goToEditContent = ( ) => {
758
847
if ( skipSubscribe ) {
@@ -779,34 +868,36 @@ const ImportModal = ( {
779
868
fetch ( 'https://api.themeisle.com/tracking/subscribe' , {
780
869
method : 'POST' ,
781
870
headers : {
782
- 'Content-Type' : 'application/json'
871
+ 'Content-Type' : 'application/json' ,
783
872
} ,
784
- body : JSON . stringify ( {
873
+ body : JSON . stringify ( {
785
874
slug : 'templates-patterns-collection' ,
786
875
site,
787
- email
788
- } )
789
- } )
790
- . then ( r => r . json ( ) )
876
+ email,
877
+ } ) ,
878
+ } )
879
+ . then ( ( r ) => r . json ( ) )
791
880
. then ( ( response ) => {
792
881
if ( 'success' === response . code ) {
793
- markSubscribeSkip ( site )
882
+ markSubscribeSkip ( site ) ;
794
883
}
795
- } ) ?. catch ( ( error ) => {
884
+ } )
885
+ ?. catch ( ( error ) => {
796
886
console . error ( error ) ;
797
- markSubscribeSkip ( site , { isTempSkip : true } )
798
- } ) ;
799
- }
887
+ markSubscribeSkip ( site , { isTempSkip : true } ) ;
888
+ } ) ;
889
+ } ;
800
890
801
- let modalTitle = importData ?
802
- sprintf (
891
+ let modalTitle = importData
892
+ ? sprintf (
803
893
/* translators: name of starter site */
804
894
__ (
805
895
'Import %s as a complete site' ,
806
896
'templates-patterns-collection'
807
897
) ,
808
898
importData . title
809
- ) : '' ;
899
+ )
900
+ : '' ;
810
901
if ( 'done' === currentStep && ! error ) {
811
902
modalTitle = __ (
812
903
'Content was successfully imported' ,
@@ -832,12 +923,14 @@ const ImportModal = ( {
832
923
siteData . doc_url && (
833
924
< DocNotice
834
925
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
+ ) ,
836
930
url : siteData . doc_url ,
837
931
} }
838
932
/>
839
- )
840
- }
933
+ ) }
841
934
{ ! importing && 'done' !== currentStep && ! error ? (
842
935
< >
843
936
< ModalHead />
@@ -869,18 +962,26 @@ const ImportModal = ( {
869
962
customizer : customizerProgress ,
870
963
widgets : widgetsProgress ,
871
964
performanceAddon : performanceAddonProgress ,
965
+ hyveLite : hyveLiteProgress ,
872
966
} }
873
967
currentStep = { currentStep }
874
968
willDo = { general }
875
969
/>
876
970
) }
877
971
{ 'done' === currentStep && ! skipSubscribe && (
878
972
< >
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 >
880
979
881
980
< TextControl
882
- aria-label = { __ ( 'Enter your email' , 'templates-patterns-collection' ) }
883
-
981
+ aria-label = { __ (
982
+ 'Enter your email' ,
983
+ 'templates-patterns-collection'
984
+ ) }
884
985
type = "email"
885
986
value = { email }
886
987
onChange = { setEmail }
@@ -889,7 +990,12 @@ const ImportModal = ( {
889
990
</ >
890
991
) }
891
992
{ 'done' === currentStep && skipSubscribe && (
892
- < span style = { { display : 'block' , marginBottom : '60px' } } />
993
+ < span
994
+ style = { {
995
+ display : 'block' ,
996
+ marginBottom : '60px' ,
997
+ } }
998
+ />
893
999
) }
894
1000
</ >
895
1001
) }
@@ -932,7 +1038,9 @@ const ImportModal = ( {
932
1038
< div className = "import-done-actions" >
933
1039
< Button
934
1040
isLink
935
- className = { classnames ( 'close' , { 'is-grayed' : ! skipSubscribe } ) }
1041
+ className = { classnames ( 'close' , {
1042
+ 'is-grayed' : ! skipSubscribe ,
1043
+ } ) }
936
1044
disabled = { processingSub }
937
1045
onClick = { goToEditContent }
938
1046
>
0 commit comments