Skip to content

Commit 83d73b2

Browse files
authored
release: features and fixes
- Feat Map for Restrict Content plugin - Feat Allow SVG during import - Feat Added performance features step - Fix plugin removal reliability - Fix the Import template button language in Elementor
2 parents f762764 + 3dbf31c commit 83d73b2

File tree

10 files changed

+184
-59
lines changed

10 files changed

+184
-59
lines changed

assets/src/Components/CustomTooltip.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
import { Button, Icon } from '@wordpress/components';
2-
import { useState } from '@wordpress/element';
3-
import { info } from '@wordpress/icons';
1+
import { Icon, info } from '@wordpress/icons';
42

53
import classnames from 'classnames';
64

7-
const CustomTooltip = ( { children, className } ) => {
5+
const CustomTooltip = ( { children, className, toLeft = false } ) => {
86
const tooltipClassNames = classnames( [ className, 'tiob-tooltip-wrap' ] );
97

8+
const ttStyle = toLeft ? { right: 0, left: 'unset' } : {};
9+
1010
return (
1111
<div className={ tooltipClassNames }>
12-
<Button
13-
onClick={ ( e ) => {
14-
e.preventDefault();
15-
} }
16-
className="tiob-tooltip-toggle"
17-
icon={ info }
18-
isLink
19-
isSmall
20-
/>
21-
<div className="tiob-tooltip-content">{ children }</div>
12+
<div className="tiob-tooltip-toggle">
13+
<Icon icon={ info } size={ 24 } />
14+
<div className="tiob-tooltip-content" style={ ttStyle }>
15+
{ children }
16+
</div>
17+
</div>
2218
</div>
2319
);
2420
};

assets/src/Components/ImportModal.js

Lines changed: 96 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*global tiobDash*/
22
/* eslint-disable no-console */
33
import {
4+
activateTheme,
45
cleanupImport,
56
importContent,
67
importMods,
78
importWidgets,
89
installPlugins,
910
installTheme,
10-
activateTheme,
1111
} from '../utils/site-import';
1212
import { get } from '../utils/rest';
1313
import { trailingSlashIt } from '../utils/common';
@@ -17,19 +17,24 @@ import classnames from 'classnames';
1717
import ImportModalError from './ImportModalError';
1818
import ImportModalMock from './ImportModalMock';
1919
import CustomTooltip from './CustomTooltip';
20-
import { useState, useEffect } from '@wordpress/element';
21-
import { withSelect, withDispatch } from '@wordpress/data';
20+
21+
import {
22+
createInterpolateElement,
23+
useEffect,
24+
useState,
25+
} from '@wordpress/element';
26+
import { withDispatch, withSelect } from '@wordpress/data';
2227
import { __, sprintf } from '@wordpress/i18n';
2328
import { compose } from '@wordpress/compose';
2429

2530
import {
2631
Button,
2732
Icon,
28-
ToggleControl,
2933
Modal,
3034
Panel,
3135
PanelBody,
3236
PanelRow,
37+
ToggleControl,
3338
} from '@wordpress/components';
3439

3540
const ImportModal = ( {
@@ -45,9 +50,14 @@ const ImportModal = ( {
4550
customizer: true,
4651
widgets: true,
4752
cleanup: false,
53+
performanceAddon: true,
4854
theme_install: themeData !== false,
4955
} );
56+
5057
const [ themeInstallProgress, setThemeInstallProgress ] = useState( false );
58+
const [ performanceAddonProgress, setPerformanceAddonProgress ] = useState(
59+
false
60+
);
5161
const [ cleanupProgress, setCleanupProgress ] = useState( false );
5262
const [ pluginsProgress, setPluginsProgress ] = useState( false );
5363
const [ contentProgress, setContentProgress ] = useState( false );
@@ -56,7 +66,7 @@ const ImportModal = ( {
5666
const [ frontPageID, setFrontPageID ] = useState( null );
5767
const [ currentStep, setCurrentStep ] = useState( null );
5868
const [ importing, setImporting ] = useState( false );
59-
const [ pluginOptions, setPluginOptions ] = useState( null );
69+
const [ pluginOptions, setPluginOptions ] = useState( {} );
6070
const [ error, setError ] = useState( null );
6171
const [ importData, setImportData ] = useState( null );
6272
const [ fetching, setFetching ] = useState( true );
@@ -211,6 +221,44 @@ const ImportModal = ( {
211221
'templates-patterns-collection'
212222
),
213223
},
224+
performanceAddon: {
225+
title: __(
226+
'Enable performance features for my site',
227+
'templates-patterns-collection'
228+
),
229+
icon: 'dashboard',
230+
tooltip: createInterpolateElement(
231+
__(
232+
sprintf(
233+
// translators: %s is Optimole plugin name.
234+
'Optimize and speed up your site with our trusted addon, <a><span>%s</span><icon/></a>. It’s free.',
235+
'Optimole'
236+
),
237+
'templates-patterns-collection'
238+
),
239+
{
240+
a: (
241+
<a
242+
href="https://wordpress.org/plugins/optimole-wp/"
243+
target={ '_blank' }
244+
style={ {
245+
textDecoration: 'none',
246+
display: 'inline-flex',
247+
alignItems: 'center',
248+
} }
249+
/>
250+
),
251+
icon: (
252+
<Icon
253+
size={ 10 }
254+
icon="external"
255+
style={ { marginLeft: 0 } }
256+
/>
257+
),
258+
span: <div />,
259+
}
260+
),
261+
},
214262
};
215263

216264
if ( isCleanupAllowed === 'yes' ) {
@@ -255,7 +303,11 @@ const ImportModal = ( {
255303
<Icon icon={ icon } />
256304
<span>{ title }</span>
257305
{ tooltip && (
258-
<CustomTooltip>{ tooltip }</CustomTooltip>
306+
<CustomTooltip
307+
toLeft={ id === 'performanceAddon' }
308+
>
309+
{ tooltip }
310+
</CustomTooltip>
259311
) }
260312
{ id !== 'theme_install' && (
261313
<div className="toggle-wrapper">
@@ -285,6 +337,10 @@ const ImportModal = ( {
285337
...( importData.mandatory_plugins || {} ),
286338
};
287339

340+
if ( Object.keys( allPlugins ).length < 1 ) {
341+
return null;
342+
}
343+
288344
const toggleOpen = () => {
289345
setPluginsOpened( ! pluginsOpened );
290346
};
@@ -417,7 +473,7 @@ const ImportModal = ( {
417473

418474
function runImportPlugins() {
419475
// console.clear();
420-
if ( ! pluginOptions ) {
476+
if ( ! pluginOptions && ! general.performanceAddon ) {
421477
console.log( '[S] Plugins.' );
422478
runImportContent();
423479
return false;
@@ -502,7 +558,7 @@ const ImportModal = ( {
502558
function runImportWidgets() {
503559
if ( ! general.widgets ) {
504560
console.log( '[S] Widgets.' );
505-
importDone();
561+
runPerformanceAddonInstall();
506562
return false;
507563
}
508564
setCurrentStep( 'widgets' );
@@ -515,12 +571,35 @@ const ImportModal = ( {
515571
}
516572
console.log( '[D] Widgets.' );
517573
setWidgetsProgress( 'done' );
518-
importDone();
574+
runPerformanceAddonInstall();
519575
} )
520576
.catch( ( incomingError ) =>
521577
handleError( incomingError, 'widgets' )
522578
);
523579
}
580+
function runPerformanceAddonInstall() {
581+
if ( ! general.performanceAddon ) {
582+
console.log( '[S] Performance Addon.' );
583+
importDone();
584+
return false;
585+
}
586+
setCurrentStep( 'performanceAddon' );
587+
console.log( '[P] Performance Addon.' );
588+
589+
installPlugins( { 'optimole-wp': true } )
590+
.then( ( response ) => {
591+
if ( ! response.success ) {
592+
handleError( response, 'performanceAddon' );
593+
return false;
594+
}
595+
console.log( '[D] Performance Addon.' );
596+
setPerformanceAddonProgress( 'done' );
597+
importDone();
598+
} )
599+
.catch( ( incomingError ) =>
600+
handleError( incomingError, 'performanceAddon' )
601+
);
602+
}
524603

525604
function importDone() {
526605
setCurrentStep( 'done' );
@@ -566,6 +645,10 @@ const ImportModal = ( {
566645
'Something went wrong while importing the widgets.',
567646
'templates-patterns-collection'
568647
),
648+
performanceAddon: __(
649+
'Something went wrong while installing the performance addon.',
650+
'templates-patterns-collection'
651+
),
569652
};
570653

571654
switch ( step ) {
@@ -584,6 +667,9 @@ const ImportModal = ( {
584667
case 'widgets':
585668
setWidgetsProgress( 'error' );
586669
break;
670+
case 'performanceAddon':
671+
setPerformanceAddonProgress( 'error' );
672+
break;
587673
}
588674
setError(
589675
incomingError.data
@@ -660,6 +746,7 @@ const ImportModal = ( {
660746
content: contentProgress,
661747
customizer: customizerProgress,
662748
widgets: widgetsProgress,
749+
performanceAddon: performanceAddonProgress,
663750
} }
664751
currentStep={ currentStep }
665752
willDo={ general }

assets/src/Components/ImportStepper.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import classnames from 'classnames';
22

33
import { __ } from '@wordpress/i18n';
44
import { Dashicon } from '@wordpress/components';
5+
56
const ImportStepper = ( { currentStep, progress, willDo } ) => {
67
const stepsMap = {
78
cleanup: {
@@ -43,6 +44,14 @@ const ImportStepper = ( { currentStep, progress, willDo } ) => {
4344
status: progress.widgets,
4445
willDo: willDo.widgets,
4546
},
47+
performanceAddon: {
48+
label: __(
49+
'Installing Performance Features',
50+
'templates-patterns-collection'
51+
),
52+
status: progress.performanceAddon,
53+
willDo: willDo.performanceAddon,
54+
},
4655
};
4756

4857
return (
Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
.tiob-tooltip-wrap {
2-
position: relative;
3-
display: flex;
4-
align-items: center;
5-
margin-left: 10px;
2+
margin-left: 10px;
63

7-
.tiob-tooltip-toggle {
8-
&:hover, &:focus {
9-
outline: none;
10-
box-shadow: none;
11-
+ .tiob-tooltip-content {
12-
opacity: 1;
13-
pointer-events: all;
14-
z-index: 1;
15-
}
16-
}
17-
}
4+
.tiob-tooltip-toggle {
5+
position: relative;
6+
display: flex;
7+
align-items: center;
8+
9+
> svg {
10+
fill: $blue;
11+
}
12+
13+
&:hover, &:focus {
14+
outline: none;
15+
box-shadow: none;
16+
17+
.tiob-tooltip-content {
18+
opacity: 1;
19+
pointer-events: all;
20+
}
21+
}
22+
}
1823
}
1924

2025
.tiob-tooltip-content {
21-
top: 100%;
22-
left: 0;
23-
position: absolute;
24-
min-width: 300px;
25-
background: #fff;
26-
box-shadow: rgba(99, 99, 99, 0.2) 0 2px 8px 0;
27-
padding: 10px;
28-
pointer-events: none;
29-
opacity: 0;
26+
font-size: 13px;
27+
top: 100%;
28+
left: 0;
29+
position: absolute;
30+
min-width: 300px;
31+
background: #fff;
32+
box-shadow: rgba(99, 99, 99, 0.2) 0 2px 8px 0;
33+
padding: 10px;
34+
z-index: 1;
35+
pointer-events: none;
36+
opacity: 0;
3037
}

assets/src/scss/_import-modal.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,6 @@ $base-index: 100000;
272272
font-size: 17px;
273273
font-weight: 700;
274274
line-height: 30px;
275-
276-
svg {
277-
width: 30px;
278-
height: 30px;
279-
}
280275
}
281276
}
282277

e2e-tests/cypress/integration/dashboard.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ describe('Importer Works', function () {
164164
);
165165
});
166166

167-
cy.get('.ob-import-modal').find('button').contains('Import entire site').click();
167+
cy.get('.ob-import-modal').wait(1000).find('button').contains('Import entire site').click();
168168

169169
cy.wait('@installPlugins', { timeout: 20000 }).then((req) => {
170170
expect(req.response.statusCode).to.equal(200);

elementor/src/import.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ const placeholder = document.getElementById( 'tmpl-elementor-add-section' );
6565

6666
if ( placeholder ) {
6767
const text = placeholder.textContent;
68+
const regex = /(<div class="[^"]*?elementor-add-section-drag-title[^"]*?">(.|\n)*?<\/div>)/gm;
6869
placeholder.textContent = text.replace(
70+
regex,
6971
// eslint-disable-next-line prettier/prettier
70-
'<div class=\"elementor-add-section-drag-title\">Drag widget here</div>',
71-
// eslint-disable-next-line prettier/prettier
72-
`<div class="elementor-add-section-area-button elementor-templates-cloud-button" title="${ window.tiTpc.library.libraryButton }"><svg width="100" height="100" viewBox="10 10 80 80" fill="none" xmlns="http://www.w3.org/2000/svg" class="tpc-template-cloud-icon" role="img" aria-hidden="true" focusable="false"><path d="M95.0264 100H4.97356C2.22797 100 0 97.772 0 95.0264V4.97356C0 2.22797 2.22797 0 4.97356 0H95.0264C97.772 0 100 2.22797 100 4.97356V95.0264C100 97.772 97.772 100 95.0264 100Z" fill="#0366D6"></path><path d="M82.6941 86.7448V30.8205V18.4653H70.3502H14.4146L26.7584 30.8205H70.3502V74.401L82.6941 86.7448Z" fill="white"></path><path d="M42.2416 58.9291L42.2528 71.183L53.2352 82.1653L53.1902 47.9806L18.9941 47.9355L29.9765 58.9066L42.2416 58.9291Z" fill="white" style=""></path></svg></div> <div class=\"elementor-add-section-drag-title\">Drag widget here</div>`
72+
`<div class="elementor-add-section-area-button elementor-templates-cloud-button" title="${ window.tiTpc.library.libraryButton }"><svg width="100" height="100" viewBox="10 10 80 80" fill="none" xmlns="http://www.w3.org/2000/svg" class="tpc-template-cloud-icon" role="img" aria-hidden="true" focusable="false"><path d="M95.0264 100H4.97356C2.22797 100 0 97.772 0 95.0264V4.97356C0 2.22797 2.22797 0 4.97356 0H95.0264C97.772 0 100 2.22797 100 4.97356V95.0264C100 97.772 97.772 100 95.0264 100Z" fill="#0366D6"></path><path d="M82.6941 86.7448V30.8205V18.4653H70.3502H14.4146L26.7584 30.8205H70.3502V74.401L82.6941 86.7448Z" fill="white"></path><path d="M42.2416 58.9291L42.2528 71.183L53.2352 82.1653L53.1902 47.9806L18.9941 47.9355L29.9765 58.9066L42.2416 58.9291Z" fill="white" style=""></path></svg></div> $1`
7373
);
7474
}
7575

0 commit comments

Comments
 (0)