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

Widget Visibility: ensure we find the correct site type #22527

Merged
merged 4 commits into from
Feb 1, 2022

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Jan 27, 2022

Changes proposed in this Pull Request:

We previously relied on wpcom, which unfortunately won't work here; it does end up being defined even on Jetpack sites, because of the additional scripts from WordPress.com that are enqueued in the admin.

This was reported here: p8oabR-Nm-p2#comment-5896

Jetpack product discussion

  • N/A

Does this pull request change what data or activity we track or use?

  • No

Testing instructions:

  • You'll want to test this on wpcom simple as well as Jetpack
  • In Jetpack > settings, ensure the Widget visibility feature is active.
  • go to Appearance > Widgets
  • Add a block
  • in the right block sidebar, scroll down and open the "Advanced" panel.
  • Add a visibility rule
  • in the options, you should see the option to filter by user role, or to check whether the user is logged in or not.
    • On WordPress.com, those options should not appear.

We previously relied on wpcom, which unfortunately won't work here; it does end up being defined even on Jetpack sites, because of the additional scripts from WordPress.com that are enqueued in the admin.
@jeherve jeherve added [Feature] Widget Visibility [Pri] Low [Status] In Progress [Type] Bug When a feature is broken and / or not performing as intended labels Jan 27, 2022
@jeherve jeherve self-assigned this Jan 27, 2022
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello jeherve! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D73881-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Jan 27, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 27, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: March 1, 2022.
  • Scheduled code freeze: February 22, 2022.

@jeherve jeherve added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] In Progress labels Jan 27, 2022
@samiff samiff self-requested a review January 27, 2022 20:49
@@ -148,7 +158,7 @@ const VisibilityRule = props => {
{ label: __( 'Category', 'jetpack' ), value: 'category' },
{ label: __( 'Author', 'jetpack' ), value: 'author' },
]
.concat( isWpcom ? [] : optionsDisabledOnWpcom )
.concat( 'simple' === getSiteType() ? [] : optionsDisabledOnWpcom )
Copy link
Contributor

Choose a reason for hiding this comment

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

I could be missing something, but could the existing isSimpleSite() util be used here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately since it's not part of the same bundle (Blocks vs. Widget Visibility), we cannot fully rely on it. That's what I started from here though. In the future, and once we have a shared utility like in #22505, we could use it in both places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, I haven't delved into the webpack setup so just assumed it would be imported and bundled up. Thanks for the explanation 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that this was moved to an external js package, we can import it instead of duplicating it! 🥳 #22741

@samiff samiff added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Jan 27, 2022
@jeherve jeherve added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jan 28, 2022
@samiff samiff self-requested a review February 1, 2022 17:52
Copy link
Contributor

@samiff samiff left a comment

Choose a reason for hiding this comment

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

Tested that user/role options showed up on a WPorg site, but were hidden on simple wpcom.

@samiff samiff merged commit 523447f into master Feb 1, 2022
@samiff samiff deleted the fix/widget-visibility-roles-wpcom branch February 1, 2022 17:56
@github-actions github-actions bot removed the [Status] Needs Review To request a review from Crew. Label will be renamed soon. label Feb 1, 2022
@github-actions github-actions bot added this to the jetpack/10.7 milestone Feb 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2022

Great news! One last step: head over to your WordPress.com diff, D73881-code, and commit it.
Once you've done so, come back to this PR and add a comment with your changeset ID.

Thank you!

@samiff
Copy link
Contributor

samiff commented Feb 1, 2022

r239359-wpcom

jeherve added a commit that referenced this pull request Feb 8, 2022
In #22527, I copied over a utility function that we used in the block bundle to use in the Widget visibility bundle. However, starting in #22733, that utility function is now part of an external js package that we can use in the Widget visiblity bundle. Let's do that and save some duplication!
samiff pushed a commit that referenced this pull request Feb 8, 2022
In #22527, I copied over a utility function that we used in the block bundle to use in the Widget visibility bundle. However, starting in #22733, that utility function is now part of an external js package that we can use in the Widget visiblity bundle. Let's do that and save some duplication!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widget Visibility [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Low Touches WP.com Files [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants