Skip to content

Commit 3bc03b1

Browse files
committed
Merge branch 'develop' into enhancement/144
2 parents 986faa0 + c59af15 commit 3bc03b1

18 files changed

+2606
-453
lines changed

.wp-env.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010
},
1111
"lifecycleScripts": {
1212
"afterStart": "bash ./tests/bin/initialize.sh"
13+
},
14+
"config": {
15+
"ALTERNATE_WP_CRON": true,
16+
"WP_AUTO_UPDATE_CORE": false
1317
}
1418
}

assets/css/admin.css

Lines changed: 145 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
table.mc-user,
2020
.mc-list-row,
2121
.mc-list-note,
22-
.mc-section {
22+
.mc-section,
23+
.mailchimp-sf-nav-tab-wrapper {
2324
max-width: 900px;
2425
width: 100%;
2526
}
@@ -38,17 +39,23 @@ table.mc-user,
3839
}
3940

4041
/* Sections */
41-
table.mc-widefat {
42+
table.mc-widefat, .mailchimp-sf-user-sync-page table.form-table {
4243
background: var(--mailchimp-color-white);
4344
border: 2px solid var(--mailchimp-color-header-bg) !important;
4445
border-radius: 6px;
4546
margin: 2.75rem 0 2.25rem;
4647
}
4748

49+
.mailchimp-sf-user-sync-page table.form-table {
50+
display: block;
51+
}
52+
53+
.mailchimp-sf-user-sync-page table.form-table tr:first-child,
4854
table.mc-widefat tr:first-child {
4955
background: var(--mailchimp-color-header-bg);
5056
}
5157

58+
.mailchimp-sf-user-sync-page table.form-table tr:first-child th,
5259
table.mc-widefat tr:first-child th {
5360
color: var(--mailchimp-color-text);
5461
font-weight: 500;
@@ -181,13 +188,17 @@ table.mc-list-select {
181188
}
182189

183190
/* Table */
191+
.mailchimp-sf-user-sync-page table.form-table td,
192+
.mailchimp-sf-user-sync-page table.form-table th,
184193
table.mc-widefat td,
185194
table.mc-widefat th {
186195
padding: 18px;
187196
text-align: left;
188197
text-shadow: none;
189198
}
190199

200+
.mailchimp-sf-user-sync-page table.form-table .last-row td,
201+
.mailchimp-sf-user-sync-page table.form-table .last-row th,
191202
table.mc-widefat .last-row td,
192203
table.mc-widefat .last-row th {
193204
border-bottom: none !important;
@@ -199,6 +210,11 @@ table.mc-widefat th {
199210
width: 130px;
200211
}
201212

213+
.mailchimp-sf-user-sync-page table.form-table th {
214+
color: var(--mailchimp-color-text-light);
215+
font-weight: 500;
216+
}
217+
202218
table.mc-widefat td label {
203219
display: block;
204220
font-size: 0.75rem;
@@ -213,6 +229,7 @@ table.mc-widefat td {
213229
line-height: 1.125 !important;
214230
}
215231

232+
.mailchimp-sf-user-sync-page table.form-table td input,
216233
table.mc-widefat td input {
217234
display: inline-block;
218235
font-style: normal;
@@ -261,6 +278,31 @@ th.mailchimp-connect {
261278
margin-top: 26px;
262279
}
263280

281+
/**
282+
* Navigation
283+
*/
284+
.mailchimp-sf-nav-tab-wrapper {
285+
margin-top: 1em;
286+
}
287+
288+
.mailchimp-sf-nav-tab-wrapper a.nav-tab {
289+
border: 0px;
290+
background: transparent;
291+
color: #000;
292+
margin-left: 0;
293+
font-weight: 500;
294+
padding: 5px 12px;
295+
}
296+
297+
.mailchimp-sf-nav-tab-wrapper a.nav-tab:hover {
298+
color: var(--mailchimp-color-link);
299+
}
300+
301+
.mailchimp-sf-nav-tab-wrapper a.nav-tab.nav-tab-active {
302+
border-bottom: 2px solid var(--mailchimp-color-link);
303+
color: var(--mailchimp-color-link);
304+
}
305+
264306
/**
265307
* Mailchimp OAuth CSS
266308
*/
@@ -390,6 +432,11 @@ body.toplevel_page_mailchimp_sf_options a {
390432
color: var(--mailchimp-color-link);
391433
}
392434

435+
body.admin_page_mailchimp_sf_create_account a:hover,
436+
body.toplevel_page_mailchimp_sf_options a:hover {
437+
color: #006570;
438+
}
439+
393440
body.admin_page_mailchimp_sf_create_account #footer-upgrade,
394441
body.toplevel_page_mailchimp_sf_options #footer-upgrade {
395442
display: none;
@@ -516,7 +563,8 @@ body.toplevel_page_mailchimp_sf_options #footer-upgrade {
516563
cursor: not-allowed;
517564
}
518565

519-
.button.mailchimp-sf-button.small {
566+
.button.mailchimp-sf-button.small,
567+
.button.mailchimp-sf-button.user-sync-settings-submit {
520568
padding: 8px 16px;
521569
line-height: 14px;
522570
float: right;
@@ -749,3 +797,97 @@ body.toplevel_page_mailchimp_sf_options #footer-upgrade {
749797
column-gap: 16px;
750798
}
751799
}
800+
801+
.mailchimp-sf-user-sync-page {
802+
max-width: 900px;
803+
}
804+
805+
.mailchimp-sf-user-sync-page .subscribe_status_label {
806+
font-weight: 500;
807+
}
808+
809+
.mailchimp-sf-user-sync-page p.description_small {
810+
font-size: 0.9em;
811+
margin-bottom: 10px;
812+
}
813+
814+
.mailchimp-sf-user-sync-status {
815+
margin: 15px 0;
816+
padding: 10px;
817+
background: #fff;
818+
border: 1px solid #ccd0d4;
819+
border-radius: 4px;
820+
}
821+
.mailchimp-sf-user-sync-status .mailchimp-sf-sync-progress {
822+
display: flex;
823+
align-items: center;
824+
flex-direction: row;
825+
}
826+
.mailchimp-sf-user-sync-status .sync-status-text {
827+
font-size: 14px;
828+
line-height: 1.4;
829+
}
830+
831+
.button.mailchimp-cancel-user-sync-button {
832+
margin-left: auto;
833+
}
834+
835+
@media screen and (max-width: 480px) {
836+
.mailchimp-sf-user-sync-status .mailchimp-sf-sync-progress {
837+
flex-direction: column;
838+
align-items: flex-start;
839+
}
840+
841+
.button.mailchimp-cancel-user-sync-button {
842+
margin-left: 0px;
843+
margin-top: 10px;
844+
}
845+
}
846+
847+
.mailchimp-sf-user-sync-errors {
848+
margin-top: 2rem;
849+
}
850+
851+
.mailchimp-sf-user-sync-errors-header {
852+
display: flex;
853+
justify-content: space-between;
854+
align-items: center;
855+
}
856+
857+
.mailchimp-sf-user-sync-error-action {
858+
min-width: 120px;
859+
text-align: right;
860+
}
861+
862+
.mailchimp-sf-start-user-sync-wrapper {
863+
width: 100%;
864+
margin-top: 2em;
865+
background-color: #ffffff;
866+
border: 1px solid #ccd0d4;
867+
border-radius: 6px;
868+
}
869+
870+
.mailchimp-sf-start-user-sync-box {
871+
display: flex;
872+
justify-content: space-between;
873+
align-items: center;
874+
padding: 1rem;
875+
}
876+
877+
.mailchimp-sf-start-user-sync-box h2 {
878+
margin: 0;
879+
}
880+
881+
.mailchimp-sf-start-user-sync-box p {
882+
margin-top: 0.5rem;
883+
}
884+
885+
.mailchimp-sf-start-user-sync-box .mailchimp-sf-button {
886+
float: none;
887+
margin-right: 8px;
888+
}
889+
890+
.mailchimp-sf-start-user-sync-box a {
891+
text-decoration: none;
892+
}
893+

assets/js/admin.js

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,143 @@
414414
});
415415
});
416416
})(jQuery); // eslint-disable-line no-undef
417+
418+
// User Sync Settings.
419+
(function ($) {
420+
const userSyncSettingsPage = $('.mailchimp-sf-user-sync-page');
421+
if (userSyncSettingsPage.length > 0) {
422+
const syncExistingContactsOnly = $(
423+
'tr.mailchimp-user-sync-existing-contacts-only input[type="checkbox"]',
424+
);
425+
if (syncExistingContactsOnly) {
426+
syncExistingContactsOnly.change(function () {
427+
if (this.checked) {
428+
$('tr.mailchimp-user-sync-subscriber-status').hide();
429+
} else {
430+
$('tr.mailchimp-user-sync-subscriber-status').show();
431+
}
432+
});
433+
434+
// Trigger change event to hide/show subscriber status.
435+
syncExistingContactsOnly.trigger('change');
436+
}
437+
}
438+
})(jQuery); // eslint-disable-line no-undef
439+
440+
// Update the user sync status.
441+
(function ($) {
442+
const statusWrapper = $('.mailchimp-sf-user-sync-status');
443+
const processRunning = statusWrapper.length;
444+
if (!processRunning) {
445+
return;
446+
}
447+
448+
const params = window.mailchimp_sf_admin_params || {};
449+
const ajaxUrl = params.ajax_url;
450+
const ajaxNonce = params.user_sync_status_nonce;
451+
452+
const intervalId = setInterval(function () {
453+
$.ajax({
454+
url: ajaxUrl,
455+
type: 'POST',
456+
data: {
457+
action: 'mailchimp_sf_get_user_sync_status',
458+
nonce: ajaxNonce,
459+
},
460+
success(response) {
461+
if (response.success && response.data) {
462+
if (response.data.is_running && response.data.status) {
463+
// Update the sync status on the page
464+
statusWrapper.html(response.data.status);
465+
} else {
466+
// Clear interval and reload the page.
467+
clearInterval(intervalId);
468+
window.location.reload();
469+
}
470+
}
471+
},
472+
error(jqXHR, textStatus, errorThrown) {
473+
// eslint-disable-next-line no-console
474+
console.error('Error: ', textStatus, ', Details: ', errorThrown);
475+
},
476+
});
477+
}, 30000); // 30000 milliseconds = 30 seconds
478+
})(jQuery); // eslint-disable-line no-undef
479+
480+
// User Sync Error logs.
481+
(function ($) {
482+
const userSyncErrors = $('.mailchimp-sf-user-sync-errors');
483+
if (!userSyncErrors) {
484+
return;
485+
}
486+
487+
const params = window.mailchimp_sf_admin_params || {};
488+
const tableSelector = 'table.mailchimp-sf-user-sync-errors-table';
489+
const noErrorsFoundRow =
490+
'<tr><td colspan="4"><em>' + params.no_errors_found + '</em></td></tr>';
491+
$('#mailchimp-sf-clear-user-sync-errors').on('click', function (e) {
492+
e.preventDefault();
493+
$(this).prop('disabled', true);
494+
$('.mailchimp-sf-user-sync-errors-header-actions .spinner').addClass('is-active');
495+
496+
$.ajax({
497+
url: params.ajax_url,
498+
type: 'POST',
499+
data: {
500+
action: 'mailchimp_sf_delete_user_sync_error',
501+
id: 'all',
502+
nonce: params.delete_user_sync_error_nonce,
503+
},
504+
success(response) {
505+
if (response && response.success) {
506+
$(tableSelector + ' tbody').html(noErrorsFoundRow);
507+
$('.mailchimp-sf-user-sync-errors-header-actions .spinner').removeClass(
508+
'is-active',
509+
);
510+
} else {
511+
window.location.reload();
512+
}
513+
},
514+
error(jqXHR, textStatus, errorThrown) {
515+
// eslint-disable-next-line no-console
516+
console.error('Error: ', textStatus, ', Details: ', errorThrown);
517+
window.location.reload();
518+
},
519+
});
520+
});
521+
522+
$(tableSelector).on('click', '.mailchimp-sf-user-sync-error-delete', function (e) {
523+
e.preventDefault();
524+
525+
const errorId = $(this).data('id');
526+
const rowId = '#row-' + errorId;
527+
$(rowId).find('.mailchimp-sf-user-sync-error-action .spinner').addClass('is-active');
528+
$(this).prop('disabled', true);
529+
$.ajax({
530+
url: params.ajax_url,
531+
type: 'POST',
532+
data: {
533+
action: 'mailchimp_sf_delete_user_sync_error',
534+
nonce: params.delete_user_sync_error_nonce,
535+
id: errorId,
536+
},
537+
success(response) {
538+
if (response && response.success) {
539+
$(rowId).remove();
540+
541+
if (!$(tableSelector + ' tbody tr').length) {
542+
$(tableSelector + ' tbody').html(noErrorsFoundRow);
543+
$('#mailchimp-sf-clear-user-sync-errors').prop('disabled', true);
544+
}
545+
} else {
546+
window.location.reload();
547+
}
548+
},
549+
error(jqXHR, textStatus, errorThrown) {
550+
// eslint-disable-next-line no-console
551+
console.error('Error: ', textStatus, ', Details: ', errorThrown);
552+
window.location.reload();
553+
},
554+
});
555+
});
556+
})(jQuery); // eslint-disable-line no-undef

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
],
1313
"prefer-stable": true,
1414
"require": {
15-
"php": ">=7.0"
15+
"php": ">=7.0",
16+
"woocommerce/action-scheduler": "3.8.2"
1617
},
1718
"require-dev": {
1819
"10up/phpcs-composer": "^3.0",
@@ -37,4 +38,4 @@
3738
"scripts": {
3839
"lint": "phpcs --standard=./phpcs.xml -p -s ."
3940
}
40-
}
41+
}

0 commit comments

Comments
 (0)