Skip to content

Commit f5dbd96

Browse files
fix: add icons and offload metric condition display based on plan
1 parent a5b49f8 commit f5dbd96

3 files changed

Lines changed: 38 additions & 10 deletions

File tree

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

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ import {
2626
bolt,
2727
update,
2828
offloadImage,
29-
settings
29+
settings,
30+
globe,
31+
arrowDownToLine,
32+
cloudDownload,
33+
chartBarDecreasing
3034
} from '../../../utils/icons';
3135

3236
import ProgressBar from '../../components/ProgressBar';
@@ -38,35 +42,44 @@ const cardClasses = 'flex p-6 bg-light-blue border border-blue-300 rounded-md';
3842

3943
const metrics = [
4044
{
45+
icon: arrowDownToLine,
4146
label: optimoleDashboardApp.strings.metrics.metricsTitle2,
4247
description: optimoleDashboardApp.strings.metrics.metricsSubtitle2,
4348
value: 'saved_size',
4449
hasButton: true,
4550
buttonText: optimoleDashboardApp.strings.metrics.adjust_compression
4651
},
4752
{
53+
icon: chartBarDecreasing,
4854
label: optimoleDashboardApp.strings.metrics.metricsTitle3,
4955
description: optimoleDashboardApp.strings.metrics.metricsSubtitle3,
5056
value: 'compression_percentage',
5157
hasButton: true,
5258
buttonText: optimoleDashboardApp.strings.metrics.adjust_compression
5359
},
5460
{
61+
icon: globe,
5562
label: optimoleDashboardApp.strings.metrics.metricsTitle4,
5663
description: optimoleDashboardApp.strings.metrics.metricsSubtitle4,
5764
value: 'traffic',
5865
hasButton: true,
5966
buttonText: optimoleDashboardApp.strings.metrics.view_analytics
60-
},
61-
{
62-
label: optimoleDashboardApp.strings.metrics.metricsTitle5,
63-
description: optimoleDashboardApp.strings.metrics.metricsSubtitle5,
64-
value: 'offloaded_images',
65-
hasButton: true,
66-
buttonText: optimoleDashboardApp.strings.metrics.manage_offloading
6767
}
6868
];
6969

70+
if ( optimoleDashboardApp.user_data?.can_use_offloading ) {
71+
metrics.push(
72+
{
73+
icon: cloudDownload,
74+
label: optimoleDashboardApp.strings.metrics.metricsTitle5,
75+
description: optimoleDashboardApp.strings.metrics.metricsSubtitle5,
76+
value: 'offloaded_images',
77+
hasButton: true,
78+
buttonText: optimoleDashboardApp.strings.metrics.manage_offloading
79+
}
80+
);
81+
}
82+
7083
const settingsTab = {
7184
offload_image: 1,
7285
advance: 2
@@ -333,8 +346,11 @@ const Dashboard = () => {
333346
) }
334347
>
335348
<div className="flex w-full flex-col">
336-
<div className="text-sm text-gray-500">
337-
{ metric.label }
349+
<div className='flex flex-row items-center gap-2 mb-2'>
350+
<Icon icon={ metric.icon } size={ 16 } className="text-info" />
351+
<div className="text-sm text-gray-500">
352+
{ metric.label }
353+
</div>
338354
</div>
339355

340356
<div className='flex items-end gap-1'>

assets/src/dashboard/utils/icons.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/src/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ export interface UserData {
577577
is_cname_assigned: string
578578
extra_visits: boolean
579579
renews_on: number
580+
can_use_offloading: boolean
580581
}
581582

582583
export interface AvailableApp2 {

0 commit comments

Comments
 (0)