-
Notifications
You must be signed in to change notification settings - Fork 293
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
Add enhanced Thank with Google setting validation #5461
Comments
Thanks @kuasha420 – a few comments for you here:
This is the default output of the function. It calls them "names" which is consistent with the corresponding property on the This issue is specific to changes to the settings validation though, so we may need another issue for this if we don't have one already. We shouldn't need this yet (see below)
I'm not sure we need to inline this, why not simply add Regarding valid post types, consider this situation:
In this scenario, the saved value would include invalid post types meaning that if this validation were done before saving, the user would be blocked from making changes. In this case, I think the client side validation related to submit changes should remain more basic, essentially ensuring the shape is correct or enforcing required values. Then on the server side, we can filter out any invalid post types in the |
@aaemnnosttv Your comment makes sense. So, should we just check that the values inside the Regarding the Public Post Types, if answer to the earlier question is yes, then we will not need it here. But it will be needed for #5456, should I add that point in the IB for #5456 or we need a separate issue? Cheers! |
Yes, you got it 👍
This would be infrastructure needed for implementing the UI so while we could include it there, I think it makes for more clearly defined scope to keep them separate. Please open a new issue for this and then we can update #5456 to depend on it. The server side settings sanitization and filtering can be done as part of this issue then, I'll update the ACs to include this. |
@felixarntz, @aaemnnosttv, @kuasha420, should we rename the |
Good shout @hussain-t – I'm going to make #5533 dependent on this issue as well so that the changes here will be updated in that one as it already depends on another dependency of this one. No changes should be needed here. |
IB ✅ |
As per the QA brief here, there's nothing directly to QA yet. Given this already has unit tests covering the logic implemented, moving directly to Approval. |
The Thank with Google settings should be more appropriately validated in JS.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
colorTheme
must be a string and one of the following values (use an array already since this will later become more than 1 value):blue
buttonPlacement
must be a string and one of the following values:dynamic_low
dynamic_high
static_auto
static_above-content
static_below-content
static_below-first-paragraph
buttonPostTypes
must be a list/array with one or more non-empty string valuesSettings
class should be updated to implement itssanitize_callback
similar to other modules, essentially stripping out invalid values and sanitizing new valuesget
method should be enhanced to ensure thebuttonPostTypes
key only includes valid public post type slugs (a.k.a.name
s)sanitize_callback
as wellImplementation Brief
In
assets/js/modules/thank-with-google/util/validation.js
:validColorThemes
array which will contain the valid color theme values from the AC.validButtonPlacements
array which will contain the valid button placement values from the AC.isValidColorTheme
function to make sure thecolorTheme
is avalidColorThemes
.isValidButtonPlacement
function to make sure thebuttonPlacement
is avalidButtonPlacements
.In
Google\Site_Kit\Modules\Thank_With_Google\Settings
class:get_sanitize_callback
.get_post_types
function witharray( 'public' => true )
args.buttonPostTypes
only contains valid public post types and filter out the rest.buttonPlacement
andcolorTheme
values are also valid as par AC.get
method that also makes sure no invalid settings are returned.get_sanitize_callback
. We can extract out the filtering/validation logic and use those in both places.Test Coverage
Thank_With_Google\Settings
.QA Brief
This is hard to QA without actual Settings Edit UI being completed. For now, is would be adequate for an engineer to make sure the related tests are correct and try to set the settings via browser console.
Changelog entry
The text was updated successfully, but these errors were encountered: