-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Framework: Extract "edit-post" to its own module #4661
Conversation
b2572b6
to
1c97fe8
Compare
e59a0cd
to
a5302b0
Compare
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 agree with general direction that this helps us toward consolidating editor
and blocks
directory as also noted in #2761. There's a few open questions remaining on state responsible for editor vs. edit-post
(e.g. currentPost
remains in editor state) that we could consider refactoring further in subsequent pull requests.
The addition of storeKey
to each connected component is quite verbose. I think we should consider either a connect
custom to each top-level module which serves as a wrapper to React-Redux's connect
passing the storeKey
automatically. Alternatively, we could seek to enhance our own query
HoC to support all of the same functionality as connect
and then it would be not necessary.
Generally difficult to review some of the more granular changes, as while some files are moved verbatim, others include revisions.
onMouseDown={ this.onClick } | ||
onTouchStart={ this.onClick } | ||
ref={ this.bindContainer } | ||
{ ...omit( props, 'clearSelectedBlock' ) } |
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.
FWIW you wouldn't need to explicitly pick children
to render, since it's already a part of this.props
that would be passed.
@@ -54,7 +53,7 @@ function BlockSettingsMenu( { uids, onSelect, focus } ) { | |||
renderContent={ ( { onClose } ) => ( | |||
// Should this just use a DropdownMenu instead of a DropDown ? | |||
<NavigableMenu className="editor-block-settings-menu__content"> | |||
<BlockInspectorButton onClick={ onClose } /> | |||
{ renderBlockMenu( { onClose } ) } |
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 prop name renderBlockMenu
implies that it replaces the entirety of the menu rendering, not adding new options to the top. Would we ever need to replace all rendering? Append to the end? Is this somewhere we want to leverage hooks instead?
*/ | ||
import { getCurrentPostType } from '../../store/selectors'; | ||
|
||
export function PostScheduleCheck( { user, children } ) { |
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.
To prior comments made at #4662, I could imagine an HoC:
ifUserCan( 'publish_posts' )
lib/client-assets.php
Outdated
wp_register_script( | ||
'wp-edit-post', | ||
gutenberg_url( 'edit-post/build/index.js' ), | ||
array( 'wp-element', 'wp-components', 'wp-editor', 'wp-i18n', 'wp-date', 'wp-utils' ), |
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.
edit-post/index.js
has a reference to jQuery and heartbeat, so this should be made an explicit dependency.
Heartbeat is no longer used as a dependency in wp-editor
.
@@ -53,6 +53,7 @@ const entryPointNames = [ | |||
'i18n', | |||
'utils', | |||
'data', | |||
'edit-post', |
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.
To be able to export this as wp.editPost
we should consider mapping packages using Lodash's _.camelCase
.
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.
Might not be possible to configure webpack to do so https://webpack.js.org/configuration/output/#output-library
@@ -104,15 +104,15 @@ | |||
}, | |||
"jest": { | |||
"collectCoverageFrom": [ | |||
"(blocks|components|date|editor|element|i18n|data|utils)/**/*.js" |
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.
We also include a custom ESLint rule for each top-level directory in .eslintrc.json
:
Lines 95 to 125 in e694f6a
"selector": "ImportDeclaration[source.value=/^blocks$/]", | |
"message": "Use @wordpress/blocks as import path instead." | |
}, | |
{ | |
"selector": "ImportDeclaration[source.value=/^components$/]", | |
"message": "Use @wordpress/components as import path instead." | |
}, | |
{ | |
"selector": "ImportDeclaration[source.value=/^date$/]", | |
"message": "Use @wordpress/date as import path instead." | |
}, | |
{ | |
"selector": "ImportDeclaration[source.value=/^editor$/]", | |
"message": "Use @wordpress/editor as import path instead." | |
}, | |
{ | |
"selector": "ImportDeclaration[source.value=/^element$/]", | |
"message": "Use @wordpress/element as import path instead." | |
}, | |
{ | |
"selector": "ImportDeclaration[source.value=/^i18n$/]", | |
"message": "Use @wordpress/i18n as import path instead." | |
}, | |
{ | |
"selector": "ImportDeclaration[source.value=/^data$/]", | |
"message": "Use @wordpress/data as import path instead." | |
}, | |
{ | |
"selector": "ImportDeclaration[source.value=/^utils$/]", | |
"message": "Use @wordpress/utils as import path instead." | |
}, |
If we're fine exposing all selectors to third-party modules, we can get rid of the -- I addressed most of the feedback. Thanks @aduth |
@@ -433,7 +433,7 @@ export class BlockListBlock extends Component { | |||
> | |||
<BlockDropZone index={ order } /> | |||
{ ( showUI || isHovered ) && <BlockMover uids={ [ block.uid ] } /> } | |||
{ ( showUI || isHovered ) && <BlockSettingsMenu uids={ [ block.uid ] } /> } | |||
{ ( showUI || isHovered ) && <BlockSettingsMenu uids={ [ block.uid ] } renderBlockMenu={ renderBlockMenu } /> } |
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.
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.
Good catch, we should cherry-pick the fix from the templates branch to its own PR
Nitpick: To the naming of this module, it stands out to me as inconsistent with our general naming, not only because it's intended as a superset of functionality for the base My suggested alternative would be |
Also, we should plan to fix the assignment of the global to avoid |
cc @mtias for the name of the module. About the global, this might mean we need to find another way to assign these variables (instead of relying on the library config of webpack) |
|
||
return ( | ||
<div> | ||
<BlockSelectionClearer> |
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.
Why was this changed from a div
to BlockSelectionClearer
?
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.
Because this was handled in the parent component by using a ref to this div there. I just made this component generic and used it in both the VisualEditor
component and the inner component BlockList
I think this PR regressed the color scheme styling of the tabs in the sidebar: As you can see from the Publish button, it's supposed to be red, like other tab buttons: It should be a fairly easy fix, renaming some CSS classes in edit-post/assets/stylesheets/_admin-schemes.scss. Do you want to do it, @youknowriad, or would you like me to do it? I have time if you're busy. |
Changed in #4661, intention not clear.
These data has been moved to edit-post store as per #4661
These data has been moved to edit-post store as per #4661
This PR extracts the
edit-post
module to its own module. This step is helpful to be able to experiment with an "edit-template" later.editor
for use inedit-post
(BlockSelectionClearer
,InserterWithShortcuts
...)editor
module using a prop.Testing instructions