Update: Move post actions to the editor package.#60092
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +1.13 kB (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
468e435 to
4d77010
Compare
| const { postManagementActions } = unlock( editorPrivateApis ); | ||
| const { usePostActions } = postManagementActions; |
There was a problem hiding this comment.
Do we expect future changes where consumers directly import the actions from postManagementActions? In this branch we only ever import usePostActions, so unless there are specific plans we could just export less:
lock( privateApis, {
// ...
usePostActions
} );| const actions = useMemo( | ||
| () => [ | ||
| editTemplateAction, | ||
| postActions.find( ( action ) => action.id === 'edit-post' ), |
There was a problem hiding this comment.
Should usePostActions accept an array of action IDs, so that we don't have to do this?
const [ editAction, viewRevisionsAction ] = usePostActions(
{ onActionPerformed },
[ 'edit-post', 'view-post-revisions' ]
);
const actions = useMemo(
() => [ editAction, resetTemplateAction, /* ... */ ],
[ editAction, viewRevisionsAction ]
);| }, | ||
| }; | ||
|
|
||
| export function usePostActions( { onActionPerformed } ) { |
There was a problem hiding this comment.
What was the reasoning behind passing the sole argument in an object? Since we're dealing with a new and private API, I'd be more confident and just have:
function usePostActions( onActionPerformed ) {|
I pushed three commits implementing my review suggestions. Let me know what you think, @jorgefilipecosta. |
mcsf
left a comment
There was a problem hiding this comment.
Approved as far as I'm concerned. @jorgefilipecosta, I'll leave it up to you to merge if you agree with my changes, otherwise let me know. :)
cc4a802 to
5f4c899
Compare
|
Thank you a lot for all the suggestions and for adding commits. All the suggestions made sense 👍 |
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org> Co-authored-by: mcsf <mcsf@git.wordpress.org>
Part of #59849.
This PR moves the post actions to the editor package. And introduces a new usePostActions with a global onActionPerformed function as discussed #59849 (review).
For now, the actions are not used in new places we just use them on data views as before.
After this PR and #59870 are merged we are going to unify post actions across dataviews, post details panel, and post inspector panel.
Testing