-
Notifications
You must be signed in to change notification settings - Fork 301
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 Gutenberg block to allow users to add Sign in with Google button to their site's layout #10046
Comments
Please assign this issue to me once it's moved to EB, as I'll get started on it early in this sprint and aim to have it ready for early testing 👍🏻 |
@tofumatt could you please expand IB to have more details because right now it is just a set of requirements that we want to achieve in this task? I want to know how we are going to use the new script, how we are going to register the block, how the new script will be loaded in gutenberg (using block.json?), how we are going to use the buttons render function to render them as block content, etc. |
@eugene-manuilov Understood. I added a proof-of-concept PR, as writing it out in the IB for this issue seemed quite awkward and I think the proof-of-concept PR does a better job expressing the general approach we'd take for this. I did amend the IB slightly but I think the proof-of-concept PR shows how we would approach this, please let me know if that's okay or if anything's unclear. |
This is true only when we are 100% sure that the taken approach is correct, but if something is off then this approach turns into a time waste approach. This is why we strongly discourage PR-as-IB approach and breaking this rule is not good because it encourages other engineers with less experience follow the same logic to start coding instead of thinking through how it should be implemented and writing it down as IB. 😄 I don't say that your PR is wrong, but this is the 30 points ticket and we need to think out everything well. Plus, I already see some things there that might be done differently or require additional work after you changed the approach how buttons were rendered. This is something that we should discuss here instead of PR comments. So, could you please write detailed IB with all what you think we need to do to achieve the goal of this ticket? Here are some points that we need to think through or pay attention to when writing IB:
|
I don't understand—we use the existing WooCommerce class to attach a div to render the button in: site-kit-wp/includes/Modules/Sign_In_With_Google.php Lines 414 to 418 in 297909f
Good point, I've added it to the IB. I had planned to do this but mentioned it explicitly.
I figured keeping them close to their related modules made sense, but your approach makes sense too. But blocks are not just JS/CSS; this block is dynamic but all blocks need some PHP. Still, I've updated the IB to put the block code (including the PHP) in its own folder, elsewhere in the repo 👍🏻
I've noted this in the IB 👍🏻
Block files include JSX that needs to be compiled, plus we might want to use modules in them eventually. Even if we didn't want to use code from a node module outside of what WordPress offers in the |
Ok, knowing this is a time sensitive issue, i am going to approve IB and we will continue discussing it in PR if something is missing 👍. IB ✔. Moving it to Execution and assigning to you, @tofumatt. |
Now we have the workspaces setup we could use workspaces here as the block does not need to share any plugin packages and might even be easier to develop with more up to date packages. This could be a follow up issue if needed because of the time sensitive nature of this issue. |
|
1 similar comment
|
I attached the video under details, but it is a bit long. Here is a shorter version—In this video, when I add the SIWG block to the header or footer, the editor does not show its preview. However, if I add it under the page content, the preview is displayed correctly. Steps-
Recording.1822.mp4 |
QA Update ⚠Tested on main environment. @tofumatt Recording.1823.mp4 |
@mohitwp This is now ready to test on |
QA Update ✅
cc @wpdarren Note: I tested this across different WordPress versions and noticed that the SIWG module throws a fatal error on WordPress 6.0.3 and earlier versions. Additionally, the SIWG option and block do not appear on the front end even after connecting SIWG. I created a separate issue #10266 for this. |
Feature Description
In order to allow users to add Sign in with Google buttons anywhere on their website, we should add a Gutenberg block that allows users to output a Sign in with Google button using Full Site Editing.
This feature will only be available to users using modern, block themes. As a fallback we can also provide documentation that will allow users of older/incompatible themes some HTML they can output on their site that will also be transformed by our own Sign in with Google JS loader.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
<div />
with the right class name. Something uncommon likeclass="googlesitekit-sign-in-with-google__frontend-output-button"
.Implementation Brief
See: #10191 for a draft/proof-of-concept PR.
blocks
where we'll put Gutenberg blocks. Rather than place them inassets/
orincludes
, let's keep all block code in its own foldersign-in-with-google
and add anindex.js
file for the block, along with ablock.json
,Edit.js
, andindex.php
index.js
should useregisterBlockType
from@wordpress/blocks
to register a block with anedit
that outputs a simple Sign in with Google button. See the Memorable Quotes branch for an example/reference.SignInWithGoogleBlock
to theblockEditor.config.js
webpack config.index.php
:register_block_type
, register a dynamic Gutenberg block with a JS edit mode and arender_callback()
PHP function that outputs a<div class="googlesitekit-sign-in-with-google__frontend-output-button"></div>
. See: https://github.com/google/site-kit-wp/pull/10191/files#diff-ff708944a78c09c2bd101a1447961236c9875183fa1618ce89277cb48670067e for the proof-of-concept.$render_buttons
should be removed, see: https://github.com/google/site-kit-wp/pull/10191/files#diff-5d9448f7515540d9d39cb7f666fd5dc594af902a96aef39a181a6de355263e3aL412register_block
inside the Sign in with Google module'sregister
function when it is active, using theinit
WordPress hook.render_signinwithgoogle
function so it doesn't render any login buttons when the user is already signed in to WordPress, unless they're on the WordPress login page (eg.$is_wp_login
istrue
)Test Coverage
QA Brief
signInWithGoogleModule
feature flag<div class="googlesitekit-sign-in-with-google__frontend-output-button"></div>
.A note from Darren for @mohitwp or @kelvinballoo when picking up this ticket let's add some additional testing here to ensure we're covering a few different setups.
Changelog entry
The text was updated successfully, but these errors were encountered: