Skip to content

Commit 7c3664a

Browse files
committed
Trigger oauth process from suggest to login page.
1 parent f7411a8 commit 7c3664a

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

assets/js/admin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
// Finish OAuth connection and save token.
9999
$.post(params.ajax_url, finishData, function (finishResponse) {
100100
if (finishResponse.success) {
101-
// Token is saved in the database, reload the page to reflect the changes.
102-
window.location.reload();
101+
// Token is saved in the database, redirect to the settings page to reflect the changes.
102+
window.location.href = params.admin_settings_url;
103103
} else {
104104
console.log(
105105
'Error calling OAuth finish endpoint. Data:',

includes/admin/templates/suggest-to-login.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
?>
2727
</p>
2828

29-
<a href="<?php echo esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ); ?>" class="button mailchimp-sf-button"><?php esc_html_e( 'Connect account', 'mailchimp' ); ?></a>
29+
<button id="mailchimp_sf_oauth_connect" class="button mailchimp-sf-button">
30+
<span class="mailchimp-sf-loading hidden">
31+
<svg class="animate-spin" width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
32+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
33+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
34+
</svg>
35+
</span>
36+
<?php esc_html_e( 'Connect account', 'mailchimp' ); ?>
37+
</button>
38+
<p class="mailchimp-sf-oauth-error error-field" style="display:none;"></p>
39+
<div id="mailchimp-sf-popup-blocked-modal" style="display:none;">
40+
<p><?php esc_html_e( 'Please allow your browser to show popups for this page.', 'mailchimp' ); ?></p>
41+
</div>
3042
</div>
3143
</div>

includes/class-mailchimp-admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ public function enqueue_admin_page_scripts( $hook_suffix ) {
410410
'modal_title' => esc_html__( 'Login Popup is blocked!', 'mailchimp' ),
411411
'modal_button_try_again' => esc_html__( 'Try again', 'mailchimp' ),
412412
'modal_button_cancel' => esc_html__( 'No, cancel!', 'mailchimp' ),
413+
'admin_settings_url' => esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ),
413414
);
414415

415416
// Create account page specific data.

0 commit comments

Comments
 (0)