Skip to content

Commit

Permalink
Fixed: make sure 'Connect' button status is correct with valid/invali…
Browse files Browse the repository at this point in the history
…d values and/or page reloads.
  • Loading branch information
Dan0sz committed May 21, 2024
1 parent f26ab89 commit 6cb2bba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions assets/src/js/admin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ document.addEventListener('DOMContentLoaded', () => {
form.append('options', JSON.stringify(options));
form.append('_nonce', plausible.nonce);

button.children[0].classList.remove('hidden');
if (button.children.length > 0) {
button.children[0].classList.remove('hidden');
}

button.setAttribute('disabled', 'disabled');

plausible.ajax(form, button);
Expand Down Expand Up @@ -330,8 +333,15 @@ document.addEventListener('DOMContentLoaded', () => {
}
).then(response => {
if (button) {
button.children[0].classList += ' hidden';
button.removeAttribute('disabled');
if (button.children.length > 0) {
button.children[0].classList += ' hidden';
}

if (button.id === 'connect_plausible_analytics' && response.status === 200) {
button.innerText = plausible_analytics_i18n.connected;
} else {
button.removeAttribute('disabled');
}
}

if (response.status === 200) {
Expand Down
2 changes: 1 addition & 1 deletion assets/src/js/admin/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6cb2bba

Please sign in to comment.