-
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
Effects: Move trash post URL change to the BrowserUrl component #7228
Changes from 4 commits
3337f28
4bde03b
bcdb811
c9829bc
549e7a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ import apiRequest from '@wordpress/api-request'; | |
/** | ||
* Internal dependencies | ||
*/ | ||
import { getWPAdminURL } from '../utils/url'; | ||
import { | ||
setupEditorState, | ||
resetAutosave, | ||
|
@@ -254,6 +253,8 @@ export default { | |
dispatch( removeNotice( TRASH_POST_NOTICE_ID ) ); | ||
apiRequest( { path: `/wp/v2/${ basePath }/${ postId }`, method: 'DELETE' } ).then( | ||
() => { | ||
const post = getCurrentPost( getState() ); | ||
dispatch( resetPost( { ...post, status: 'trash' } ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make a note about updating this to |
||
dispatch( { | ||
...action, | ||
type: 'TRASH_POST_SUCCESS', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This action type is never referenced elsewhere. Should we remove it? My only hesitation might be is that it's complementing the failing type, which is in-fact referenced. The counter-point may be that the existence of this action type may be misinterpreted as a hint that it has resulting handling. I'd lean toward removal. Aside: I'd also like to refactor the notices behavior, which would include consolidating the |
||
|
@@ -271,15 +272,6 @@ export default { | |
} | ||
); | ||
}, | ||
TRASH_POST_SUCCESS( action ) { | ||
const { postId, postType } = action; | ||
|
||
window.location.href = getWPAdminURL( 'edit.php', { | ||
trashed: 1, | ||
post_type: postType, | ||
ids: postId, | ||
} ); | ||
}, | ||
TRASH_POST_FAILURE( action, store ) { | ||
const message = action.error.message && action.error.code !== 'unknown_error' ? action.error.message : __( 'Trashing failed' ); | ||
store.dispatch( createErrorNotice( message, { id: TRASH_POST_NOTICE_ID } ) ); | ||
|
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 do we export? For tests? 😉