-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
WIP: Install a block from inserter #16524
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The experiments settings bit looks good!
One question: should installing blocks also be enabled from the inserters on the Widgets screen and the Widget Blocks section in the Customizer? These inserters are still experimental (you need to enable the "Widgets" experiment for them to work) but they work exactly the same as the inserter on the main editor page, so it might make sense for them to include this functionality.
Thank you, @enriquesanchez. Good to know that there are no major a18y issues. I will have a look at these minor ones and see if I can improve them. |
I hope that it is as as simple as including the |
… into try/discover-new-blocks
onClick(); | ||
} } | ||
> | ||
{ __( 'Add' ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For screenreader users, the add button gives no context of the what the user is adding.
@@ -134,6 +139,17 @@ class EditorProvider extends Component { | |||
if ( this.props.settings !== prevProps.settings ) { | |||
this.props.updateEditorSettings( this.props.settings ); | |||
} | |||
if ( ! isEqual( this.props.downloadableBlocksToUninstall, prevProps.downloadableBlocksToUninstall ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand what this code is for—would be good to add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so the blocks get uninstalled if they're unused. I think that's how it's supposed to work.
I think this functionality would be best moved to the edit-post
package, in a component. It'd be similar to how AutosaveMonitor
is a component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross-linking a related discussion fo reference: #17576 (comment)
This functionality was removed in #17576. It should be added back once we agree on a new approach.
this.props.downloadableBlocksToUninstall.forEach( ( blockType ) => { | ||
this.props.uninstallBlock( blockType, noop, () => { | ||
this.props.createWarningNotice( | ||
__( 'Block previews can\'t uninstall.' ), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text seems like it'll need some improvement.
const createdBlock = onSelect( item ); | ||
|
||
const onInstallBlockError = () => { | ||
createErrorNotice( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline notices within the inserter popover would provide a better experience, I think. Currently the message is hidden behind the inserter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix this in a follow-up PR.
packages/block-directory/src/components/downloadable-blocks-panel/index.js
Show resolved
Hide resolved
packages/block-directory/src/components/downloadable-blocks-panel/index.js
Show resolved
Hide resolved
packages/block-directory/src/components/downloadable-block-author-info/style.scss
Show resolved
Hide resolved
); | ||
register_rest_route( | ||
$this->namespace, | ||
'/' . $this->rest_base . '/uninstall', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't feel very "restful" to use different URLs for the create and delete actions. Could "installation" be a resource? e.g. so POST /installations
creates and DELETE /installations/:id
deletes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this in a follow-up PR.
<Icon icon="chart-line"></Icon>{ sprintf( _n( '%d active installation', '%d active installations', activeInstalls ), activeInstalls ) } | ||
</div> | ||
<div className="block-directory-downloadable-block-info__column"> | ||
<Icon icon="update"></Icon><span aria-label={ sprintf( __( 'Updated %s' ), humanizedUpdated ) }>{ humanizedUpdated }</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't clear to me at first that this icon meant 'last updated'. Could we add title text? Relatedly, do these icons need alt text?
<div className="block-directory-downloadable-block-header__row"> | ||
{ | ||
icon.match( /\.(jpeg|jpg|gif|png)/ ) !== null ? | ||
<img src={ icon } alt="block icon" /> : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something more descriptive than "block icon"
that we can use? Maybe the block's title? Regardless, this string needs to be localised.
packages/block-directory/src/components/downloadable-block-header/index.js
Show resolved
Hide resolved
{ sprintf( __( 'Authored by %s' ), author ) } | ||
</span> | ||
<span className="block-directory-downloadable-block-author-info__content"> | ||
{ sprintf( _n( 'This author has %d block, with an average rating of %d.', 'This author has %d blocks, with an average rating of %d.', authorBlockCount, authorBlockRating ), authorBlockCount, authorBlockRating ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does an average rating of 0 imply that the author has no ratings? If so, should we exclude the second part of this sentence when the average rating is 0? It sounds al little awkward otherwise:
This author has 1 block, with an average rating of 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's think about this in a follow-up PR.
packages/block-directory/src/components/downloadable-block-header/style.scss
Show resolved
Hide resolved
packages/block-directory/src/components/downloadable-block-info/style.scss
Show resolved
Hide resolved
packages/block-directory/src/components/downloadable-block-info/style.scss
Show resolved
Hide resolved
packages/block-directory/src/components/downloadable-block-info/style.scss
Show resolved
Hide resolved
packages/block-directory/src/components/downloadable-block-list-item/style.scss
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very impressive work, very very solid. I can't wait for this feature to land, it's breathtaking.
I left a few tiny comments to use variables here and there, but the CSS overall is well written, well structured and superb as is.
The only thing I think probably should be fixed before shipping is this one: https://github.com/WordPress/gutenberg/pull/16524/files#r324309944 — but I did leave a couple of suggestions for how to fix that.
Closing in favour of #17431. |
Description
Extend the inserter to show available blocks for download and silently install the block when the block is inserted into the editor
This PR is still a WIP. Can you help guide me with the implementation and avoiding any pitfalls? I'm new to the block editor.
Screenshots
Types of changes
Relevant Links
[design] Main thread
https://make.wordpress.org/design/2019/04/26/block-library-installing-blocks-from-within-gutenberg/
[design] Figma
https://www.figma.com/file/QKhoOKXkBN2mHacqvrtdNuI6/Gutenberg-Block-Library%3A-Installation
[design] Mockup feedback
https://make.wordpress.org/design/2019/06/07/block-library-mockups-prototype
[dev] Block Directory Proposal
https://make.wordpress.org/meta/2019/03/08/the-block-directory-and-a-new-type-of-plugin/
[dev] Block Registration
https://github.com/WordPress/gutenberg/blob/master/docs/rfc/block-registration.md
[dev] Block Registration - assets JSON structure
#13693 (comment)
GitHub Block Directory issues
https://github.com/WordPress/block-directory/issues
GitHub Block Directory project
https://github.com/WordPress/block-directory/projects/1