-
Notifications
You must be signed in to change notification settings - Fork 798
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
Update block scaffolding to use the withNotices HOC #14895
Conversation
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: April 7, 2020. |
const setErrorNotice = () => { | ||
noticeOperations.removeAllNotices(); | ||
noticeOperations.createErrorNotice( __( 'Put error message here.', 'jetpack' ) ); | ||
}; |
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.
Part of me wonders if we shouldn't extract this into a shared function available to all blocks? Ideally, that function could also handle all kinds of notices, not just erors. Something like this:
export function displayNotice( message, noticeOperations, type = 'error' ) {
noticeOperations.removeAllNotices();
noticeOperations.createNotice( { status: type, content: message } );
}
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.
That might be worth trying in some blocks, but I'd rather we only move stuff into the scaffolding when we've already had success with it in other blocks.
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.
You're right. I suggested we give that a try in #14884 (comment)
Until then, we should be able to merge your PR and revisit once we have some blocks using it.
Co-Authored-By: Jeremy Herve <jeremy@jeremy.hu>
In of #14884 we realised we were doing notices wrongly. We should update the block scaffolding to do it the right way.
Changes proposed in this Pull Request:
withNotices
HOCIs this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
Proposed changelog entry for your changes: