Skip to content

Commit 39fe231

Browse files
fix: reviewer feedback
1 parent 32dc1b8 commit 39fe231

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

assets/src/dashboard/parts/components/Modal.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { close } from '@wordpress/icons';
44
import { useViewportMatch } from '@wordpress/compose';
55
import { Button, Icon, Modal as CoreModal } from '@wordpress/components';
66

7-
export default function Modal({ icon, labels = {}, onRequestClose = () => {}, onConfirm = () => {}, variant = 'default', onAction2 = () => {} }) {
7+
export default function Modal({ icon, labels = {}, onRequestClose = () => {}, onConfirm = () => {}, variant = 'default', onSecondaryAction = () => {} }) {
88

99
const isMobileViewport = useViewportMatch( 'small', '<' );
1010

@@ -19,7 +19,7 @@ export default function Modal({ icon, labels = {}, onRequestClose = () => {}, on
1919
{
2020
'bg-mango-yellow': 'warning' === variant
2121
},
22-
'inline-flex optml__button flex justify-center px-5 py-3 rounded font-bold min-h-40 basis-1/5'
22+
'optml__button flex justify-center px-5 py-3 rounded font-bold min-h-40 basis-1/5'
2323
);
2424

2525
return (
@@ -57,9 +57,9 @@ export default function Modal({ icon, labels = {}, onRequestClose = () => {}, on
5757
<Button variant="primary" className={ actionButtonClasses } onClick={ onConfirm }>
5858
{ labels.action }
5959
</Button>
60-
{ labels.action2 && (
61-
<Button variant="link" className={ actionButtonClasses } onClick={ onAction2 }>
62-
{ labels.action2 }
60+
{ labels.secondaryAction && (
61+
<Button variant="link" className={ actionButtonClasses } onClick={ onSecondaryAction }>
62+
{ labels.secondaryAction }
6363
</Button>
6464
) }
6565
</div>

assets/src/dashboard/parts/connected/settings/OffloadMedia.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ const OffloadMedia = ({ settings, canSave, setSettings, setCanSave }) => {
188188
return;
189189
}
190190

191-
setModal( show_exceed_plan_quota_notice ? MODAL_STATE_EXCEED_PLAN_QUOTA_NOTICE : MODAL_STATE_ROLLBACK );
191+
setModal( MODAL_STATE_ROLLBACK );
192192
};
193193

194194
const getModalProps = ( type ) => {
@@ -255,7 +255,7 @@ const OffloadMedia = ({ settings, canSave, setSettings, setCanSave }) => {
255255
onOffloadMedia();
256256
setModal( null );
257257
},
258-
onAction2: () => {
258+
onSecondaryAction: () => {
259259
setModal( null );
260260
const options = settings;
261261
options.offload_media = 'disabled';
@@ -268,7 +268,7 @@ const OffloadMedia = ({ settings, canSave, setSettings, setCanSave }) => {
268268
title: options_strings.exceed_plan_quota_notice_title,
269269
description: options_strings.exceed_plan_quota_notice_description,
270270
action: options_strings.exceed_plan_quota_notice_start_action,
271-
action2: options_strings.exceed_plan_quota_notice_start_action2
271+
secondaryAction: options_strings.exceed_plan_quota_notice_secondary_action
272272
}
273273
}
274274
};
@@ -299,7 +299,7 @@ const OffloadMedia = ({ settings, canSave, setSettings, setCanSave }) => {
299299
}
300300

301301
if ( 'rollback' === radioBoxValue ) {
302-
setModal( show_exceed_plan_quota_notice ? MODAL_STATE_EXCEED_PLAN_QUOTA_NOTICE : MODAL_STATE_ROLLBACK );
302+
setModal( MODAL_STATE_ROLLBACK );
303303
}
304304
};
305305

inc/admin.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ private function get_dashboard_strings() {
19821982
'exceed_plan_quota_notice_title' => __( 'Your site has already reached over 50% of your monthly visits limit within just two weeks.', 'optimole-wp' ),
19831983
'exceed_plan_quota_notice_description' => __( 'Based on this trend, you are likely to exceed your free quota before the month ends. To avoid any disruption in service, we strongly recommend upgrading your plan or waiting until your traffic stabilizes before offloading your images. Do you still wish to proceed?', 'optimole-wp' ),
19841984
'exceed_plan_quota_notice_start_action' => __( 'Yes, Transfer to Optimole Cloud', 'optimole-wp' ),
1985-
'exceed_plan_quota_notice_start_action2' => __( 'No', 'optimole-wp' ),
1985+
'exceed_plan_quota_notice_secondary_action' => __( 'No', 'optimole-wp' ),
19861986
],
19871987
'help' => [
19881988
'section_one_title' => __( 'Help and Support', 'optimole-wp' ),
@@ -2186,22 +2186,13 @@ public function survey_category( $value, $scale = 1 ) {
21862186
* @return bool True if the exceed quota warning should be displayed, false otherwise.
21872187
*/
21882188
public function should_show_exceed_quota_warning() {
2189-
$current_screen = get_current_screen();
2190-
if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ||
2191-
is_network_admin() ||
2192-
! current_user_can( 'manage_options' ) ||
2193-
! $this->settings->is_connected() ||
2194-
empty( $current_screen )
2195-
) {
2189+
if ( ! $this->settings->is_connected() ) {
21962190
return false;
21972191
}
21982192
if ( get_option( 'optml_notice_hide_upg', 'no' ) === 'yes' ) {
21992193
return false;
22002194
}
22012195

2202-
if ( ! str_contains( $current_screen->base, 'page_optimole' ) ) {
2203-
return false;
2204-
}
22052196
$service_data = $this->settings->get( 'service_data' );
22062197

22072198
if ( ! isset( $service_data['plan'] ) ) {
@@ -2214,8 +2205,14 @@ public function should_show_exceed_quota_warning() {
22142205
if ( $service_data['days_since_registration'] <= 14 ) {
22152206
return false;
22162207
}
2217-
$visitors_limit = isset( $service_data['visitors_limit'] ) ? (int) $service_data['visitors_limit'] : 0;
2218-
$visitors_left = isset( $service_data['visitors_left'] ) ? (int) $service_data['visitors_left'] : 0;
2208+
2209+
$visitors_limit = isset( $service_data['visitors_limit'] ) ? (int) $service_data['visitors_limit'] : 0;
2210+
$visitors_left = isset( $service_data['visitors_left'] ) ? (int) $service_data['visitors_left'] : 0;
2211+
2212+
if ( ! $visitors_limit || ! $visitors_left ) {
2213+
return false;
2214+
}
2215+
22192216
$used_quota = $visitors_limit - $visitors_left;
22202217
$is_50_percent_used = ( $used_quota / $visitors_limit ) >= 0.5;
22212218

0 commit comments

Comments
 (0)