Describe the bug
When filling in Cloudflare credentials and enabling Optimal Settings in one step, we are receiving an error and settings are not saved.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Optimal settings should be enabled correctly
OR
Optimal settings button should be disabled until credentials are filled in
Screenshots
Error screenshot:
https://i.vgy.me/1Xinkg.jpg
Additional context
The problem was investigated by @vmanthos and @crystinutzaa here:
https://wp-media.slack.com/archives/CBJ2KQ0MU/p1583302791209100
This bug is a continuation of the following one:
https://github.com/wp-media/wp-rocket/issues/2295#issue-559886603
Backlog Grooming
Reproduce the issue ✅
Reproduced on my local test site
Identify the root cause ✅
The root cause is related to the order of the operations.
Optimal Settings are saved with AJAX call, while Cloudflare credentials are saved when submitting WP Rocket settings page.
Scope a solution ✅
1.Disable Optimal Settings (and all other CF options which run with AJAX call) until there are some valid credentials.
Estimate the effort ✅
Depending on the solution selected the effort should be [XS] if Solution 1 is selected or [S] if solution 2 is selected.
@crystinutzaa The solution 2 seems to be most appropriate in term of user experience.
Acceptance Criteria
Optimal SettingsSave ChangesWhat If
Couldn't think of edge cases. Suggestions are welcome
I think we need more considerations on this one:
Since it's an AJAX call, how do we display success/error to the user when he checks this option?
save changes, it's already too late, the option has been updated already.optimal settings. Which credentials should be used?Personal take
The development mode and optimal settings options should not be updated with AJAX. They need valid, secure credentials before being switched on/off, to make sure we perform the CF API calls as expected.
It's very likely our users don't know that those are updated via AJAX anyway, so they will be clicking on save changes after, creating a double request for the same thing.
We could simplify this and improve performance by making this change.
@Tabrisrp Does the acceptance criteria will be still the same? If so, we can go with your solution.
EDIT: Myself didn't know that development mode and optimal settings are updated with AJAX. I always click on Saves changes after updating the options 😕
@Tabrisrp I guess the effort won't be the same anymore with this solution, isn't it?
@crystinutzaa I'd like your input on what I suggested, what do you think?
Acceptance criteria would be the same, I believe the task is simpler with that solution? Credentials validation is already done when we save changes.
@Tabrisrp @crystinutzaa As the acceptance criteria will be the same, feel free to decide the solution you think it will be the best to implement.
@Tabrisrp yes, this is an even better solution. Does not need the Ajax Call in there, so on form submit these 2 options can be saved too.
@GeekPress the acceptance criteria will be exact the same.
What will happen, the credentials are validated first. If the credentials are ok, these 2 options development mode and optimal settings will be modified.
However, if the credentials fail what should happen if these 2 options are modified at the same time:
What do you think? Is this going to be ok?
@crystinutzaa I agree that the notice should only be displayed once and that one should be the invalid credentials notice.
What if: Credentials are wrong, but Optimal settings etc was enabled. When we save settings, will Optimal settings be saved as enabled?