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

Gutenberg: Add WP.com shortlinks extension #29475

Merged
merged 2 commits into from
Dec 18, 2018

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Dec 15, 2018

Fixes Automattic/jetpack#10925
Fixes #29221

In the WP.com old editor, we used to have the shortlinks handy in the sidebar. We don't have them in Gutenberg, and they can sometimes be a very handy feature. This PR creates the UI for the WP.com shortlinks, adds it to the Jetpack sidebar and registers it as a beta extension.

For inspiration of how it looks and works, we're borrowing from the legacy Calypso editor sidebar:

Also, see the corresponding Jetpack PR that's necessary for this to work: Automattic/jetpack#10981

Changes proposed in this Pull Request

  • Create a new panel in the Jetpack sidebar for displaying WP.com shortlinks
  • Add WP.com shortlinks in the list of Jetpack beta extensions

Preview

Positioning in the Jetpack sidebar:

How it looks:

Focusing the field autoselects the shortlink:

Testing instructions

Notes

I'm marking this as low priority, as it isn't super important to have. In the same time, I think it's handy to have it, and it's straightforward enough so we could have it ready for the next Jetpack version.

@tyxla tyxla added Jetpack [Pri] Low Address when resources are available. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR [Goal] Gutenberg Working towards full integration with Gutenberg [Type] New feature labels Dec 15, 2018
@tyxla tyxla self-assigned this Dec 15, 2018
@matticbot
Copy link
Contributor

@simison
Copy link
Member

simison commented Dec 15, 2018

Seems like a perfect case for clipboard component from Calypso, but at the same time I wouldn't complicate something that already works.

https://wpcalypso.wordpress.com/devdocs/client/components/forms/clipboard-button/README.md

@tyxla
Copy link
Member Author

tyxla commented Dec 17, 2018

Seems like a perfect case for clipboard component from Calypso, but at the same time I wouldn't complicate something that already works.

Yeah, I thought that for the first iteration we could keep it simple and do what we already were doing in Calypso. Will wait for some design feedback to confirm that decision though.

@@ -0,0 +1,39 @@
/** @format */
Copy link
Member

Choose a reason for hiding this comment

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

We can drop Prettier pragmas since #29403

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Good point, removed in 1e3979b

@lezama
Copy link
Contributor

lezama commented Dec 17, 2018

great initiative Marin!

Copy link
Member

@roccotripaldi roccotripaldi left a comment

Choose a reason for hiding this comment

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

tested locally, and after a rebase, it worked lovely!

jeherve pushed a commit to Automattic/jetpack that referenced this pull request Dec 17, 2018
)

In the WP.com old editor, we used to have the shortlinks handy in the sidebar. We don't have them in Gutenberg, and they can sometimes be a very handy feature. This PR registers the post shortlink as a REST API field, and as a Gutenberg plugin, which are necessary to be able to build the UI for shortlinks in Gutenberg.

#### Changes proposed in this Pull Request:

* Add shortlinks to the REST API post response.
* Register shortlinks as a Gutenberg plugin, so they're available in our block availability endpoint.

#### Testing instructions:

* Start a JN site with this branch.
* Connect the site, and activate all recommended features.
* Write a post and save it.
* Type `wp.data.select( 'core/editor' ).getCurrentPost().jetpack_shortlink` in your browser console.
* Verify it returns a correct shortlink that leads to the post you just created.
* Type `window.Jetpack_Editor_Initial_State.available_blocks.shortlinks` in your browser console.
* Verify it returns `{available: true}`.
* Want to test the actual Gutenberg extension that uses this? Go to Automattic/wp-calypso#29475 and follow the test instructions there

#### Proposed changelog entry for your changes:

* Shortlinks: Register as REST API post field and Gutenberg plugin

#### Notes

I'm marking this as low priority, as it isn't super important to have. In the same time, I think it's handy to have it, and it's straightforward enough so we could have it ready for the next Jetpack version.
@MichaelArestad
Copy link
Contributor

Nice!

My initial instinct would be to enhance the Gutenberg interface like this:
image

However, I suspect that not only will the permalink location be changing, but we also face the problem of folks not knowing where shortlinks come from. I think what you came up with is a great start. My suggestions would be to indeed add the clipboard component next to what you're already displaying. I can't tell from the docs, but if it adds a button with an icon next to the link, it'll look great. I would appreciate you taking a stab at adding the clipboard functionality.

@tyxla tyxla force-pushed the add/jetpack-gutenberg-shortlinks branch from 1e3979b to c22c84d Compare December 18, 2018 11:05
@tyxla
Copy link
Member Author

tyxla commented Dec 18, 2018

Thank you, folks!

My suggestions would be to indeed add the clipboard component next to what you're already displaying. I can't tell from the docs, but if it adds a button with an icon next to the link, it'll look great. I would appreciate you taking a stab at adding the clipboard functionality.

Sounds like something that would make sense to be explored in another PR. Will merge this one, and will explore using a clipboard button next to the link. Stay tuned!

@tyxla tyxla added [Status] Ready to Merge and removed [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Dec 18, 2018
@tyxla tyxla merged commit 9df0718 into master Dec 18, 2018
@tyxla tyxla deleted the add/jetpack-gutenberg-shortlinks branch December 18, 2018 12:08
blowery added a commit that referenced this pull request Dec 18, 2018
…sh-2019

* origin/master:
  Signup: Fix logo SVG on mobile devices (#29508)
  Update dependency react-modal to v3.7.1
  Gutenberg: Add WP.com shortlinks extension (#29475)
  Gutenlypso: launch to production (#29326)
  Gutenlypso: Keep changes when opting-out (#29431)
  Eslint: Use Gutenberg svg wrappers for extensions (#29531)
  Tiled gallery block: add mosaic layout (#29338)
  Tiled gallery: Remove redundant Fragment (#28994)
@tyxla
Copy link
Member Author

tyxla commented Dec 18, 2018

@MichaelArestad @simison: I've fiddled with adding the copy button, here's a PR: #29556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg Jetpack [Pri] Low Address when resources are available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants