Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: "View Stats" couldn't be enabled in onboarding wizard, on new installs. #211

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/.github
/.storybook

/bin
/tests
/node_modules
/assets/src
Expand All @@ -18,11 +19,14 @@
.travis.yml
.editorconfig
.babelrc
.gitpod.yml
.jscrsrc
.jshintrc
.eslintignore
.eslintrc
.eslintrc.json
.nvmrc
.phpcs.xml.dist
.prettierrc.json
.prettierignore
.stylelintrc.json
Expand All @@ -34,12 +38,16 @@
sample-data/wordpress.sql
sample-data/sample-data.numbers
bower.json
codecov.yml
composer.json
composer.lock
npm-shrinkwrap.json
openapitools.json
package.json
package-lock.json
phpunit.xml
phpunit.xml.dist
phpunit-with-integration.xml
plausible-analytics.zip
CHANGELOG.md
README.md
Expand All @@ -52,4 +60,5 @@ contributing.md
postcss.config.js
webpack.config.js
docker-compose.yml
tailwind.config.js
wp-textdomain.js
44 changes: 30 additions & 14 deletions assets/src/js/admin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,34 @@ document.addEventListener('DOMContentLoaded', () => {
saveOptionOnNext: function (e) {
let hash = document.location.hash.replace('#', '');

if (hash === 'api_token_slide' || hash === 'domain_name_slide') {
let form = e.target.closest('.plausible-analytics-wizard-step-section');
let inputs = form.getElementsByTagName('INPUT');
let options = [];

for (let input of inputs) {
options.push({name: input.name, value: input.value});
}
if (hash !== 'api_token_slide' && hash !== 'domain_name_slide') {
return;
}

let data = new FormData();
data.append('action', 'plausible_analytics_save_options');
data.append('options', JSON.stringify(options));
data.append('_nonce', plausible.nonce);
let form = e.target.closest('.plausible-analytics-wizard-step-section');
let inputs = form.getElementsByTagName('INPUT');
let options = [];

plausible.ajax(data);
for (let input of inputs) {
options.push({name: input.name, value: input.value});
}

let data = new FormData();

data.append('action', 'plausible_analytics_save_options');
data.append('options', JSON.stringify(options));
data.append('_nonce', plausible.nonce);

plausible.ajax(data).then(response => {
/**
* Disable View Stats button, if API token is entered and valid.
*/
if (hash === 'api_token_slide' && response.success === true) {
let stats_button = document.getElementById('enable_analytics_dashboard_view_stats_in_wordpress');

stats_button.removeAttribute('disabled');
}
});
},

/**
Expand Down Expand Up @@ -358,7 +370,11 @@ document.addEventListener('DOMContentLoaded', () => {

document.dispatchEvent(event);

return response.data;
if (response.data !== undefined) {
return response.data;
} else {
return response;
}
});
},

Expand Down
Loading