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

Add Sign in with Google Settings View screen. #9685

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

tofumatt
Copy link
Collaborator

@tofumatt tofumatt commented Nov 14, 2024

Summary

Addresses issue:

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@tofumatt tofumatt marked this pull request as ready for review November 14, 2024 17:56
Copy link

Build files for 51ac04b are ready:

Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tofumatt – perhaps I'm missing an important detail but it seems like the infra related to the site registration setting could be simplified. Otherwise left a few other points throughout.

Comment on lines +88 to +93
const dismissedItems = select( CORE_USER ).getDismissedItems();

return dismissedItems?.some(
( item ) =>
item === 'sign-in-with-google-anyone-can-register-notice'
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the formatting, but this should be something we can simplify with the dedicated selector

Suggested change
const dismissedItems = select( CORE_USER ).getDismissedItems();
return dismissedItems?.some(
( item ) =>
item === 'sign-in-with-google-anyone-can-register-notice'
);
return select( CORE_USER ).isItemDismissed(
'sign-in-with-google-anyone-can-register-notice'
);


// If Sign in with Google does not have a client ID, do not display the
// settings view.
if ( ! clientID?.length ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the length check on a string? It works of course but I don't think there is a risk of it being misinterpreted. I think we can simply if ( ! clientID )?

Comment on lines +121 to +143
{ !! buttonTextLabel && (
<div className="googlesitekit-settings-module__meta-item">
<h5 className="googlesitekit-settings-module__meta-item-type">
{ __( 'Button text', 'google-site-kit' ) }
</h5>
<p className="googlesitekit-settings-module__meta-item-data">
<DisplaySetting value={ buttonTextLabel } />
</p>
</div>
) }

{ !! buttonThemeLabel && (
<div className="googlesitekit-settings-module__meta-item">
<h5 className="googlesitekit-settings-module__meta-item-type">
{ __( 'Button theme', 'google-site-kit' ) }
</h5>
<p className="googlesitekit-settings-module__meta-item-data">
<DisplaySetting value={ buttonThemeLabel } />
</p>
</div>
) }

{ !! buttonShapeLabel && (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible the values would ever be empty? We already have the early return at the top if there is no clientID so this seems unlikely. Given they all have defaults I don't think it is (realistically at least). Also DisplaySetting is intended to account for the case where the value is not loaded yet by holding the vertical space.

Comment on lines +192 to +193
{ anyoneCanRegisterNoticeDismissed !== undefined &&
anyoneCanRegisterNoticeDismissed !== true &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just the one condition?

Suggested change
{ anyoneCanRegisterNoticeDismissed !== undefined &&
anyoneCanRegisterNoticeDismissed !== true &&
{ anyoneCanRegisterNoticeDismissed === false &&

export const Default = Template.bind( null );
Default.storyName = 'Default';
Default.scenario = {
label: 'Modules/SignInWithGoogle/Settings/SettingsView/Default',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We almost never need to set the label manually, this was more for matching old existing scenario outputs during the migration. Its generated automatically based on the storyName and the default.title below.

.dispatch( MODULES_SIGN_IN_WITH_GOOGLE )
.receiveGetSettings( {
clientID:
'example-client-id-123123123.apps.usercontent.com',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'example-client-id-123123123.apps.usercontent.com',
'example-client-id-123123123.apps.googleusercontent.com',

*/
protected function get_datapoint_definitions() {
return array(
'GET:anyone-can-register' => array( 'service' => 'sign-in-with-google' ),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is part of the IB but it seems like overkill for surfacing a site-wide setting. Why aren't we adding this to base data and surfacing it through core/site?

Comment on lines +195 to +196
<SettingsNotice
type={ TYPE_WARNING }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what happened here, but this looks quite different from the design

image

@@ -0,0 +1,127 @@
/**
* `modules/sign-in-with-google` data store: get "Anyone can register" value from WordPress.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned before, all of the infra around this value can likely be simplified into an extension of base data exposed via core/site.

@aaemnnosttv
Copy link
Collaborator

One more detail I noticed, the badges have different padding and it's the "Beta" that doesn't match the design.

image

Beta has 6 12 where as New has 4 8 and the design shows both using the values that New has.

It seems the reduced padding was applied to the new badge specifically – which seems incorrect actually – as the sizing should be more contextual rather than badge-specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants