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

Nav sidebar: Add "view all" and "create new" buttons to sidebar #42605

Merged
merged 7 commits into from
Jun 15, 2020

Conversation

p-jackson
Copy link
Member

@p-jackson p-jackson commented May 24, 2020

Note to anyone reading this while preparing a release of the FSE plugin

This change doesn't require any release notes. We're developing a new feature which is currently hidden behind a flag.

Changes proposed in this Pull Request

May-25-2020 17-32-59

  • Re-arrange files to make room for more components
  • Add "View all posts" button
    • a8c.WpcomBlockEditorNavSidebar.allPostsLabel hook so calypso can override label
    • a8c.WpcomBlockEditorNavSidebar.allPostsUrl hook so calypso can send user back to calypso rather than wp-admin
  • Add "Create new post" button
    • a8c.WpcomBlockEditorNavSidebar.createPostLabel hook so calypso can override label
    • a8c.WpcomBlockEditorNavSidebar.createPostUrl hook so calypso will create new post using iframe'd block editor
  • a8c.WpcomBlockEditorNavSidebar.linkTarget hook so calypso can ensure links open in the outer frame rather
  • Disabled calypso css class name lint rule (names need to be more specific so they don't collide with elements in Gutenberg)

I decided to add a single general purpose getCalypsoUrlInfo message to <CalypsoifyIframe> rather than individual messages to get the "view all" and "create new" urls. In the future we'll want the ability to build even more calypso urls, like a block editor url for each post id. Seemed better to just give iframe-bridge-server.js the building blocks to do it.

I also decided to have messages to fetch the label text from <CalypsoifyIframe> rather than have it in iframe-bridge-server.js. I don't think the wpcom-block-editor app has support for translations.

Testing instructions

  • Start up dev environment for calypso, wpcom-block-editor and FSE! 3 seperate apps to make some buttons 🤦
  • Ensure WPCOM_BLOCK_EDITOR_SIDEBAR is defined†
  • Open a page or post in the calypso block editor
    • Click (W) to open sidebar
    • Button label text should match mockups pbAok1-JQ-p2#comment-1676
    • Clicking link replaces the url in the browser
  • Use wp-env or something similar to check the FSE plugin works in wp-admin without calypsoify. The button label text might not be perfect; I'm using some pre-existing text that already exists in core. I think it's close enough and we're not expecting this to be used in wp-admin editors initially. It just needs to not break.

† If running locally with wp-env then define WPCOM_BLOCK_EDITOR_SIDEBAR in apps/full-site-editing/.wp-env.override.json:

    {
      "config": {
      	"WPCOM_BLOCK_EDITOR_SIDEBAR": true
      }
    }

Or on the sandbox define it in 0-sandbox.php

@matticbot
Copy link
Contributor

@p-jackson p-jackson self-assigned this May 24, 2020
@p-jackson p-jackson added [Goal] Editor Improvements [Feature] Post/Page Editor The editor for editing posts and pages. labels May 24, 2020
@matticbot
Copy link
Contributor

matticbot commented May 24, 2020

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~121 bytes added 📈 [gzipped])

name              parsed_size           gzip_size
gutenberg-editor       +421 B  (+0.0%)     +121 B  (+0.1%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@matticbot
Copy link
Contributor

Caution: This PR affects files in the FSE Plugin on WordPress.com
Please ensure your changes work on WordPress.com before merging.

D43887-code has been created so you can easily test it on your sandbox. See this FieldGuide page about developing in the FSE Plugin for more info: PCYsg-ly5-p2

@p-jackson p-jackson changed the title Update/nav sidebar view all pages Nav sidebar: Add "view all" and "create new" buttons to sidebar May 25, 2020
@p-jackson p-jackson marked this pull request as ready for review May 25, 2020 05:34
@p-jackson p-jackson added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels May 25, 2020
@p-jackson p-jackson requested a review from a team May 25, 2020 05:35
@ramonjd ramonjd requested a review from a team May 25, 2020 21:54
'a8c.WpcomBlockEditorNavSidebar.createPostUrl',
'wpcom-block-editor/getSiteSlug',
( url, postType ) => {
if ( origin && siteSlug && ( postType === 'page' || postType === 'post' ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

In Calyspo, adding a new page or post sends me off to wp-admin

add new

Copy link
Member Author

@p-jackson p-jackson May 27, 2020

Choose a reason for hiding this comment

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

Start up dev environment for calypso, wpcom-block-editor and FSE! 3 seperate apps to make some buttons 🤦

Unfortunately this needs to be tested against calypso.localhost:3000 because this contains changes to the calypsoify iframe. Glad the sidebar is resilient to the new calypso code not being there though! It's falling back to the dotorg site behaviour as expected.

Copy link
Member

Choose a reason for hiding this comment

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

Argh, dang. Thanks for highlighting that. 🤦

Copy link
Member

Choose a reason for hiding this comment

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

I also wanted to add that the buttons work and look as expected otherwise 👍

@p-jackson p-jackson force-pushed the add/nav-sidebar-calypso-support branch from 83c8a31 to c532e62 Compare May 27, 2020 05:02
@p-jackson p-jackson force-pushed the update/nav-sidebar-view-all-pages branch from be9bfde to 48c0570 Compare May 27, 2020 05:13
@ramonjd
Copy link
Member

ramonjd commented May 27, 2020

Okay retested using calypso localhost and it works as described. There are no areas in the code that jump out at me, so it would still be good get a onceover from @Automattic/cylon when they have time.

@p-jackson p-jackson force-pushed the add/nav-sidebar-calypso-support branch from e118471 to d578668 Compare May 28, 2020 23:35
Base automatically changed from add/nav-sidebar-calypso-support to master May 29, 2020 04:15
@p-jackson p-jackson force-pushed the update/nav-sidebar-view-all-pages branch from 48c0570 to 9609834 Compare May 29, 2020 05:58
@p-jackson p-jackson force-pushed the update/nav-sidebar-view-all-pages branch from 9609834 to a21d6fa Compare June 15, 2020 07:36
Copy link
Contributor

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

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

so it would still be good get a onceover from cylon

oops

This looks fine from an FSE plugin perspective to me. I didn't test it though :)

Btw, does this handle the existing back button behavior in the top-left of the sidebar thing? i.e. if you enter the site editor from customer home, will it take you back to customer home? (and will the button label be correct?)

@p-jackson
Copy link
Member Author

Btw, does this handle the existing back button behavior in the top-left of the sidebar thing? i.e. if you enter the site editor from customer home, will it take you back to customer home? (and will the button label be correct?)

@noahtallen it goes back to wherever the calypsoify iframe tells us to go back to. So if calypsoifyGutenberg.closeUrl says customer home then that's where we go. Sometimes it says to go back to the theme gallery, in which case we go there.

The label we use for the text link is correct but unfortunately this doesn't fix the tooltip for the (W) button if that's what you meant. I'm going to work on using the official (W) button hook next, which will allow us to fix the tooltip properly.

@noahtallen
Copy link
Contributor

this doesn't fix the tooltip

Cool. I wasn't even aware that that was broken; I just meant the main label itself. Sounds good!

@p-jackson
Copy link
Member Author

IE test failures unrelated: #43298

@p-jackson p-jackson merged commit 4557694 into master Jun 15, 2020
@p-jackson p-jackson deleted the update/nav-sidebar-view-all-pages branch June 15, 2020 23:56
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 15, 2020
@a8ci18n
Copy link

a8ci18n commented Jun 16, 2020

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/3851908

Thank you @p-jackson for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Jul 16, 2020

Translation for this Pull Request has now been finished.

nsakaimbo added a commit that referenced this pull request Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Post/Page Editor The editor for editing posts and pages. [Goal] Editor Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants