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

Masterbar: Add menu structure #17629

Merged
merged 38 commits into from
Dec 3, 2020
Merged

Masterbar: Add menu structure #17629

merged 38 commits into from
Dec 3, 2020

Conversation

obenland
Copy link
Member

@obenland obenland commented Oct 27, 2020

This should be functionally ready for testing.

Changes proposed in this Pull Request:

  • Adds menu structure for unified admin menu.
  • Adds unit tests for each new menu item and some utility methods

Jetpack product discussion

pbAPfg-VL-p2#comment-1904

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

No

Testing instructions:

To test locally:

  • Add a mu-plugin that contains: add_filter( 'jetpack_load_admin_menu_class', '__return_true' );
  • Make sure your site is connected to wp.com and has the masterbar module activated.
  • Load wp-admin and check the sidebar!

To test with an Atomic site:

  • Install & activate the Jetpack Beta Plugin on your Atomic test site.
  • Go to Jetpack > Jetpack Beta
  • Under "Search for Jetpack Feature Branch" enter this branch or PR id: 17629 => Click Activate
  • Add a mu-plugin that contains: add_filter( 'jetpack_load_admin_menu_class', '__return_true' );
  • Look at the admin menu and admire the new Menu structure.
  • Click on a menu item that takes you to Calypso and marvel at this new achievement.

Proposed changelog entry for your changes:

  • Not sure yet.

@obenland obenland added [Status] In Progress [Feature] Masterbar WordPress.com Toolbar and Dashboard customizations labels Oct 27, 2020
@obenland obenland self-assigned this Oct 27, 2020
@jetpackbot
Copy link

jetpackbot commented Oct 27, 2020

Warnings
⚠️

pre-commit hook was skipped for one or more commits

This is an automated check which relies on PULL_REQUEST_TEMPLATE. We encourage you to follow that template as it helps Jetpack maintainers do their job. If you think 'Testing instructions' or 'Proposed changelog entry' are not needed for your PR - please explain why you think so. Thanks for cooperation 🤖

Generated by 🚫 dangerJS against 9f6cc03

modules/masterbar.php Outdated Show resolved Hide resolved
@cpapazoglou
Copy link
Contributor

@obenland it seems that files and modifications are unrelated to masterbar. Do you have something in mind?

@obenland obenland marked this pull request as ready for review November 6, 2020 00:11
@cpapazoglou cpapazoglou self-requested a review November 6, 2020 09:16
Copy link
Contributor

@cpapazoglou cpapazoglou left a comment

Choose a reason for hiding this comment

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

Thanks @obenland for working on this! Following your great test instructions 👏 I was able to admire 🎉 the new unified menu structure which contains the WordPress.com link for eg All new posts.

Using apply_filters( 'jetpack_load_admin_menu_class', ( defined( 'IS_WPCOM' ) && IS_WPCOM ) || jetpack_is_atomic_site() ) as condition seems enough as we can add_filter in wpcom and wpcomsh to enable / disable this feature.

I am not sure of the exact scope of this PR, so I will post below all my findings and we can decide how we can handle them:

1. We have mixed the masterbar and the menu. Has it been done intentionally? I suppose we should place the masterbar changes here only and create a separate module(?) for the menu?

2. We haven't ported the masterbar nav-unification changes which can be found by searching nav-unification in the trunk. I suppose this has been done intentionally as we will need to consolidate the changes with modules/masterbar/masterbar.php and modules/masterbar/overrides.css and coordinate with the calypsoify removal modules/calypsoify/class.jetpack-calypsoify.php so that we avoid

3. Moving to the menu structure itself:

Atomic Simple

The menu items order are identical to a simple site. Adding plugins (Contact Form and Yoast) correctly shows these plugins in the menu. I suppose that ordering doesn't matter as long as it is consistent through calypso / wp-admin.

a) We need to port the new menu styles introduced here D52281-code
b) Site Switcher "Browse Sites" is missing. We need an atomic equivalent check

if ( ! is_multisite() || ( function_exists( 'get_blog_count_for_user' ) && get_blog_count_for_user() < 2 ) ) {
			return;
		}

c) Site card Default Icon needs to be updated
d) My Home "Home" submenu should link to WordPress.com
e) Stats are missing the graph image
f) Jetpack menu will need some auditing. Backup and Scan leads to wordpress.com though jetpack and it is shown as external link. Backup and Scan independent links seem not needed in this context.

g) AMP should be a single link redirecting to /wp-admin/admin.php?page=amp-options (we omit the analytics link which leads to the same page different section)

I would be happy opening separate issues for points 2 & 3 though. Let's address point 1 here!

@obenland
Copy link
Member Author

obenland commented Nov 6, 2020

Thanks for the review!

We have mixed the masterbar and the menu. Has it been done intentionally? I suppose we should place the masterbar changes here only and create a separate module(?) for the menu?

Yes, this is where we arrived in pbAPfg-VL-p2#comment-1966

We haven't ported the masterbar nav-unification changes which can be found by searching nav-unification in the trunk.

I'm not sure what you're referring to here, is there something you could link me to for context?

Site Switcher "Browse Sites" is missing. We need an atomic equivalent check

Yeah, not sure about the best way to do that one yet. Maybe wpcomsh can provide some inspiration.

AMP should be a single link redirecting to /wp-admin/admin.php?page=amp-options

Hm, I have to look into that one a bit more. Instinctively I'd probably just leave it alone since it's a separate plugin on Atomic, but I have not double-checked that yet.

Stats are missing the graph image

These seem to be only available on Simple sites.

Copy link
Contributor

@cpapazoglou cpapazoglou left a comment

Choose a reason for hiding this comment

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

Thanks for pushing the fixes @obenland !

We haven't ported the masterbar nav-unification changes which can be found by searching nav-unification in the trunk.

I'm not sure what you're referring to here, is there something you could link me to for context?

Search for nav-unification in :
/admin-bar/class.wpcom-admin-bar.php we add a .is-nav-unification in #wpadminbar
admin-bar/wpcom-admin-bar.css we use the class above to style the masterbar

eg

WithoutStyles WithStyles

Stats are missing the graph image

These seem to be only available on Simple sites.

True!

Fix site card icon

Sadly this was not enough. It seems that the following wrongly returns true and therefore styles are not applied correctly.

if ( ( function_exists( 'blavatar_exists' ) && blavatar_exists( $domain ) ) || has_site_icon() ) {
  $classes .= ' has-site-icon';
}
Wrong Correct

I can confirm that the rest of the changes are LGTM!

@obenland obenland force-pushed the add/menu-structure branch 2 times, most recently from 0ed6e2f to c3a456a Compare November 9, 2020 19:40
@obenland
Copy link
Member Author

obenland commented Nov 9, 2020

@cpapazoglou 867a910 should fix the site icon issue on WoA sites.

@cpapazoglou
Copy link
Contributor

@cpapazoglou 867a910 should fix the site icon issue on WoA sites.

Indeed, I can confirm that is fixed! Now, we just need the masterbar missing styles.

@getdave
Copy link
Contributor

getdave commented Nov 10, 2020

FYI @obenland this PR went through a number of iterations to create a structure Jetpack crew are happy with. It might be best to wait till that's merged and then put your new changes on top of that.

#17762

@obenland
Copy link
Member Author

Admin Bar mobile styles

WithoutStyles WithStyles

To make this work on WoA sites, we'll have to add the .is-nav-unification class to the body element since WP_Admin_Bar doesn't have a filter for that. It also looks like the the menu items are not 1:1 the same between simple sites and WoA. So even with the custom CSS class manually added to the admin bar element, the menu toggle doesn't show up on small screens.

@cpapazoglou
Copy link
Contributor

cpapazoglou commented Nov 11, 2020

Admin Bar mobile styles

WithoutStyles WithStyles

To make this work on WoA sites, we'll have to add the .is-nav-unification class to the body element since WP_Admin_Bar doesn't have a filter for that. It also looks like the the menu items are not 1:1 the same between simple sites and WoA. So even with the custom CSS class manually added to the admin bar element, the menu toggle doesn't show up on small screens.

Actually we don't need .is-nav-unification.. We can leverage add_filter( 'jetpack_load_admin_menu_class', '__return_true' ); or create a new filter which will load an extra .css file.

The weird thing is that jetpack already loads wpcom styles & wpcom overrides

wp_enqueue_style( 'a8c-wpcom-masterbar', $this->wpcom_static_url( '/wp-content/mu-plugins/admin-bar/wpcom-admin-bar.css' ), array(), JETPACK__VERSION );
wp_enqueue_style( 'a8c-wpcom-masterbar-overrides', $this->wpcom_static_url( '/wp-content/mu-plugins/admin-bar/masterbar-overrides/masterbar.css' ), array(), JETPACK__VERSION );

So, I suggest:

  • temporarily include the changes in as it is conditionally loaded by the filter.
  • discard the .is-nav-unification, as filter alone is enough
  • when we launch to 100% and remove the filter, also move the styles to
    /* Remove min-height from menu elements that was causing them to render incorrectly */

    or better to wpcom /wp-content/mu-plugins/admin-bar/wpcom-admin-bar.css

Last but not least, I can confirm that without using add_filter( 'jetpack_load_admin_menu_class', '__return_true' ); the whole feature is disabled and when I used add_filter( 'jetpack_load_admin_menu_class', '__return_true' ); the feature was enabled as expected.

@obenland
Copy link
Member Author

@anomiex Thanks for your review! I fixed up the things you pointed out, this one should be good for another round of reviews.

@obenland obenland requested a review from anomiex November 24, 2020 23:49
@obenland obenland added [Status] Needs Review To request a review from fellow Jetpack developers. 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 Nov 24, 2020
@cpapazoglou
Copy link
Contributor

Fixed the menu problem here #17905

@obenland
Copy link
Member Author

@jeherve @anomiex I hope the stress of releasing 9.2 has died down a bit. Any chance you could give this a final ✅ at your convenience?

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Still need to test this some more, but I had a few questions.

modules/masterbar/admin-menu/class-admin-menu.php Outdated Show resolved Hide resolved
modules/masterbar/admin-menu/class-admin-menu.php Outdated Show resolved Hide resolved
modules/masterbar/admin-menu/class-admin-menu.php Outdated Show resolved Hide resolved
@obenland
Copy link
Member Author

Still need to test this some more, but I had a few questions.

Thank you for your feedback! Happy to make any amendments as you see fit. I also expect there to be quite a few more follow up PRs to this, particularly once we opened it to a8c-internal testing this week.

Props jeherve.
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

I have some additional remarks, but I'm approving this PR anyway, for a couple of reasons:

  • I believe we could really benefit from some additional testing in different scenarios, with popular plugins like WooCommerce, WooCommerce extensions, Yoast SEO, Elementor, et al., as well as popular themes that extend the Themes menu. By adding this to Jetpack now, it should make it easier for folks to test on Atomic. I suspect we'll find quite a few issues with such plugins and how they interact with the existing admin menu.
  • The feature is still gated by a filter, so not breaking anything by default.
  • That PR is getting big, and the more we wait, the harder it will be to review.

modules/masterbar.php Show resolved Hide resolved

remove_menu_page( 'themes.php' );
remove_submenu_page( 'themes.php', 'themes.php' );
remove_submenu_page( 'themes.php', 'theme-editor.php' );
Copy link
Member

Choose a reason for hiding this comment

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

Is it problematic that folks will lose access to this option? I know we discourage its use in general, but it remains available in wp-admin anyway, even on Atomic. I wonder if this would cause some issues for folks in support in some cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

@davemart-in Do you have thoughts on the removal/non-removal of theme & plugin editor links?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me phone a few friends. @kristenzuck, @nerdysandy thoughts on removing links to the theme & plugin editor from a happiness perspective? These pages would still be available if you knew how to get to them, but I've proposed removing them from the default menu. I'm happy to change my position on this one. Just curious if you see these pages used by many customers.

public function add_plugins_menu( $domain ) {
$calypso = $this->is_wpcom_site();

remove_submenu_page( 'plugins.php', 'plugin-editor.php' );
Copy link
Member

Choose a reason for hiding this comment

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

Just like above, is it problematic to remove the plugin editor?

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Dec 3, 2020
@obenland obenland merged commit 8d01344 into master Dec 3, 2020
@obenland obenland deleted the add/menu-structure branch December 3, 2020 22:05
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Dec 3, 2020
jeherve added a commit that referenced this pull request Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Masterbar WordPress.com Toolbar and Dashboard customizations Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.