Skip to content

Commit 8af5483

Browse files
feat: display active optimization status
1 parent 2c2f829 commit 8af5483

File tree

2 files changed

+58
-40
lines changed

2 files changed

+58
-40
lines changed

assets/src/dashboard/parts/connected/Sidebar.js

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,35 @@ const reasons = [
1919
optimoleDashboardApp.strings.upgrade.reason_4
2020
];
2121

22-
const statuses = [
23-
{
24-
label: optimoleDashboardApp.strings.optimization_status.statusTitle1,
25-
description: optimoleDashboardApp.strings.optimization_status.statusSubTitle1
26-
},
27-
{
28-
label: optimoleDashboardApp.strings.optimization_status.statusTitle2,
29-
description: optimoleDashboardApp.strings.optimization_status.statusSubTitle2
30-
},
31-
{
32-
label: optimoleDashboardApp.strings.optimization_status.statusTitle3,
33-
description: optimoleDashboardApp.strings.optimization_status.statusSubTitle3
34-
}
35-
];
36-
3722
const Sidebar = () => {
3823
const {
3924
name,
4025
domain,
41-
plan
26+
plan,
27+
statuses
4228
} = useSelect( select => {
43-
const { getUserData } = select( 'optimole' );
29+
const { getUserData, getSiteSettings } = select( 'optimole' );
4430

4531
const user = getUserData();
32+
const siteSettings = getSiteSettings();
33+
34+
const statuses = [
35+
{
36+
active: 'enabled' === siteSettings?.image_replacer,
37+
label: optimoleDashboardApp.strings.optimization_status.statusTitle1,
38+
description: optimoleDashboardApp.strings.optimization_status.statusSubTitle1
39+
},
40+
{
41+
active: 'enabled' === siteSettings?.lazyload,
42+
label: optimoleDashboardApp.strings.optimization_status.statusTitle2,
43+
description: optimoleDashboardApp.strings.optimization_status.statusSubTitle2
44+
},
45+
{
46+
active: 'enabled' === siteSettings?.scale,
47+
label: optimoleDashboardApp.strings.optimization_status.statusTitle3,
48+
description: optimoleDashboardApp.strings.optimization_status.statusSubTitle3
49+
}
50+
];
4651

4752
let domain = user?.cdn_key + '.i.optimole.com';
4853
if ( user?.domain !== undefined && '' !== user?.domain ) {
@@ -52,7 +57,8 @@ const Sidebar = () => {
5257
return {
5358
name: user?.display_name,
5459
domain,
55-
plan: user?.plan
60+
plan: user?.plan,
61+
statuses: statuses.filter( status => status.active )
5662
};
5763
});
5864

@@ -138,28 +144,35 @@ const Sidebar = () => {
138144
</Button>
139145
) }
140146

141-
<div className="bg-white flex flex-col text-gray-700 border-0 rounded-lg shadow-md p-8">
142-
<h3 className="text-base m-0">{ optimoleDashboardApp.strings.optimization_status.title }</h3>
143-
<ul>
144-
{ statuses.map( ( status, index ) => (
145-
<li
146-
key={ index }
147-
className="flex items-start gap-2"
148-
>
149-
<Icon icon="yes-alt" className="text-light-black mt-1" />
150-
<div className="text-light-black font-normal text-base">
151-
<div className='font-semibold'>
152-
{ status.label }
153-
</div>
154-
<div>
155-
{ status.description }
147+
{ 0 < statuses.length && (
148+
<div className="bg-white flex flex-col text-gray-700 border-0 rounded-lg shadow-md p-8">
149+
<h3 className="text-base m-0">{ optimoleDashboardApp.strings.optimization_status.title }</h3>
150+
<ul>
151+
{ statuses.map( ( status, index ) => (
152+
<li
153+
key={ index }
154+
className="flex items-start gap-2"
155+
>
156+
<Icon icon="yes-alt" className="text-light-black mt-1" />
157+
<div className="text-light-black font-normal text-base">
158+
<div className='font-semibold'>
159+
{ status.label }
160+
</div>
161+
<div>
162+
{ status.description }
163+
</div>
156164
</div>
157-
</div>
158-
</li>
159-
) ) }
160-
</ul>
161-
<ExternalLink className='font-semibold text-sm' href='https://docs.optimole.com/article/2238-optimization-tips'>{ optimoleDashboardApp.strings.optimization_tips }</ExternalLink>
162-
</div>
165+
</li>
166+
) ) }
167+
</ul>
168+
<p
169+
className="m-0 -mt-3"
170+
dangerouslySetInnerHTML={ {
171+
__html: optimoleDashboardApp.strings.optimization_tips
172+
} }
173+
/>
174+
</div>
175+
) }
163176
</div>
164177
);
165178
};

inc/admin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,12 @@ private function get_dashboard_strings() {
19941994
'statusTitle3' => __( 'Image Scalling Active', 'optimole-wp' ),
19951995
'statusSubTitle3' => __( 'All images are perfectly sized for devices', 'optimole-wp' ),
19961996
],
1997-
'optimization_tips' => __( 'View all optimization tips', 'optimole-wp' ),
1997+
'optimization_tips' => sprintf(
1998+
/* translators: 1 is the opening anchor tag, 2 is the closing anchor tag */
1999+
__( '%1$sView all optimization tips%2$s', 'optimole-wp' ),
2000+
'<a style="white-space:nowrap; text-decoration: underline !important;" href="https://docs.optimole.com/article/2238-optimization-tips" target="_blank"> ',
2001+
'<span style="text-decoration:none; font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>'
2002+
),
19982003
];
19992004
}
20002005

0 commit comments

Comments
 (0)