-
Notifications
You must be signed in to change notification settings - Fork 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
CPT / State: Display trash notice after save request completes successfully #6306
Conversation
ddabdac
to
99672e6
Compare
Thanks for the pointer @artpi , I hadn't seen that pull request. Looks like some good effort going on there, though not sure it necessarily solves the problem I'm trying to address (notices in response to asynchronous network requests). I do see that it touches on notices behavior in Reader in response to updated props, which is a bit like option 2 I had considered in the original comment. |
}, | ||
[ NOTICE_REMOVE ]: ( state, action ) => { | ||
const { noticeId } = action; | ||
if ( ! state.hasOwnProperty( noticeId ) ) { |
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.
👍 right, omit handles this case, but it would return a new object.
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.
👍 right, omit handles this case, but it would return a new object.
Indeed, though probably very unlikely NOTICE_REMOVE
would ever be called with an invalid noticeId
.
Took the branch for a spin and wasn't able to find any obvious regressions. 👍 I'd be fine with going forward with this approach. If we do, we should update documentation on how to add a notice, and deprecate the createNotice action. |
cbd08bd
to
a72cdd9
Compare
Interesting, I hadn't thought too much on the implications these changes would have on deprecating the action creators altogether. Now that you bring it up, I suppose it would be good to have the consistency, and can't really think of a case where we'd want to explicitly call the action creator instead of hooking in via the reducer (might be a bit of a pain to create action types for e.g. DevDocs example). |
769aec4
to
64211ef
Compare
To keep the number of test actions to a minimum, I think it's fine to use the |
This pull request seeks to explore one option for displaying a notice in response to a successful network request to save a post. It also seeks to refactor notices state to better accommodate this use-case and to adhere to guidelines adopted since its original implementation (e.g. action type verb suffixing).
Implementation notes:
I considered a few options for implementing notices:
successNotice
in the promise resolution ofsavePost
componentWillReceiveProps
reveals that a success or failure has occurredTesting instructions:
Ensure Mocha tests pass:
Verify that no regressions occurred in refactorings to expected behavior for global notices.
Verify that on the custom post types listing screen, when trashing a post, a notice is shown if it completes successfully. Verify also that if trashing a second post while a notice is currently visible, the text will change to reflect "X posts" trashed.
/cc @artpi @gwwar @timmyc
Test live: https://calypso.live/?branch=add/cpt-trash-notice