-
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
Data Views: Add action for pages to set site homepage #65426
base: trunk
Are you sure you want to change the base?
Conversation
ab1c828
to
0f3a986
Compare
Size Change: +734 B (+0.04%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
@creativecoder is this one ready for review? :) |
@jameskoster A few things that still need doing
I'm not sure when I'll be able to get back to this, so if anyone wants to pick this up--feel free! |
Thanks @creativecoder! I'm going to have a go at picking this up. I'll start by addressing the items you listed above, and then I'll mark as ready for review. |
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.
Initial review with questions
}; | ||
|
||
return ( | ||
<form onSubmit={ onSetPageAsHomepage }> |
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.
With a slow network the UX doesn't provide a great experience.
There should be a selector/resolver which we can use to detecting that the saving of the entity is in progress. We can then use that state to render a "Loading..." type indicator for the user.
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.
Yes, nice idea! I've added the isSavingEntityRecord
selector and disabled the modal button when saving is in progress: b029794.
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's a good improvement thanks! However I don't think it's enough because in onSetPageAsHomepage
we are also doing other "work" such as updating the page status.
As a result the buttons are still enabled whilst that request is happening. I think we'll need to have the resolvers for any action that's occurring in the onSetPageAsHomepage
handler.
See screencapture.
Screen.Capture.on.2024-11-22.at.09-46-58.mp4
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 think this is not longer relevant now that we don't allow for draft Pages to be set as the homepage?
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 think this is not longer relevant now that we don't allow for draft Pages to be set as the homepage?
Yes that's right, for now, but it will likely need to be handled in the follow-up that handles draft pages.
type: 'snackbar', | ||
} ); | ||
|
||
onActionPerformed?.( items ); |
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 should stick a debugger
here and follow the code route. I suspect we don't need to call this in this scenario.
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.
@oandregal Is there any documentation about onActionPerformed
? I looked and couldn't find any.
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've removed onActionPerformed
for now: 04a7ba4.
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Thanks again for all the continued feedback and help here ❤️ I'll summarise the latest changes since @oandregal's approval:
I'm really happy with the current state, so I'm hoping this is now ready for a final review 🤞 Thank you! |
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.
Thanks for all the changes. I feel this is really close
I've got some concerns about statuses and also noticed some more UI bugs.
}; | ||
|
||
return ( | ||
<form onSubmit={ onSetPageAsHomepage }> |
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's a good improvement thanks! However I don't think it's enough because in onSetPageAsHomepage
we are also doing other "work" such as updating the page status.
As a result the buttons are still enabled whilst that request is happening. I think we'll need to have the resolvers for any action that's occurring in the onSetPageAsHomepage
handler.
See screencapture.
Screen.Capture.on.2024-11-22.at.09-46-58.mp4
# Conflicts: # packages/editor/src/components/post-actions/actions.js
@getdave Thanks for such a detailed review 🙏 I think I've addressed all your feedback, with the larger changes being:
|
👍 I'll re-review this. |
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.
Overall I think this is in good shape.
Left a few nits both nothing major.
Tested with slow network and all responding really well.
One thing I noticed is that it's not possible to "unset" the Page as the homepage. Not sure if that's planned or necessary but thought it might be worth mentioning for a followup.
Thanks for all the work to refine this 👏
<> | ||
<Text> | ||
{ sprintf( | ||
// translators: %s: title of the page to be set as the homepage. | ||
__( | ||
'Set "%s" as the site homepage? This will replace the current homepage which is set to display latest posts.' | ||
), | ||
pageTitle | ||
) } | ||
</Text> | ||
</> |
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.
Nit: Why does this need a fragment with <>
?
I keep coming to this block and thinking there must be some fundamental difference in the structure of the JSX but there isn't.
Therefore do you think we should normalise the component returned and just have a variable for modalText
passed in (you can precompute this outside of the JSX).
Example:
<Text>
{ modalText }
</Text>
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, I can't see why there was a fragment there and this string can be refactored into a variable. I've done this here: e1a7aa9.
}; | ||
|
||
return ( | ||
<form onSubmit={ onSetPageAsHomepage }> |
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 think this is not longer relevant now that we don't allow for draft Pages to be set as the homepage?
What?
Adds an action to set the home page from the site editor.
Fixes #63666
Why?
Currently there is no way to change the home setting (Settings > Reading) from the site editor. This PR adds a way to do that.
How?
Adds a dataview action for pages to set the page as the site homepage that can be triggered from the pages data view.
Testing Instructions
Screenshots or screencast