-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Editor: Remove constants for notices #68361
Changes from all commits
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 |
---|---|---|
|
@@ -11,8 +11,6 @@ export const EDIT_MERGE_PROPERTIES = new Set( [ 'meta' ] ); | |
*/ | ||
export const STORE_NAME = 'core/editor'; | ||
|
||
export const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID'; | ||
export const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID'; | ||
Comment on lines
-14
to
-15
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. Thanks for working to clean those up 👏 |
||
export const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/; | ||
export const ONE_MINUTE_IN_MS = 60 * 1000; | ||
export const AUTOSAVE_PROPERTIES = [ 'title', 'excerpt', 'content' ]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,6 @@ | |
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../constants'; | ||
|
||
/** | ||
* Builds the arguments for a success notification dispatch. | ||
* | ||
|
@@ -68,7 +63,7 @@ export function getNotificationArgumentsForSaveSuccess( data ) { | |
return [ | ||
noticeMessage, | ||
{ | ||
id: SAVE_POST_NOTICE_ID, | ||
id: 'editor-save', | ||
type: 'snackbar', | ||
actions, | ||
}, | ||
|
@@ -113,7 +108,7 @@ export function getNotificationArgumentsForSaveFail( data ) { | |
return [ | ||
noticeMessage, | ||
{ | ||
id: SAVE_POST_NOTICE_ID, | ||
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. I think there was a reason that the save success and save error notices were using the same notice, though. Right now if you do the following:
You'll see the success notice remains together with the failure one: Haven't tested, but I believe that if you keep the same ID for both error and success, the new (failure) notice should remove the old (success) one properly. 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. That's a good point. I'll update to use the same string value again. |
||
id: 'editor-save', | ||
}, | ||
]; | ||
} | ||
|
@@ -131,7 +126,7 @@ export function getNotificationArgumentsForTrashFail( data ) { | |
? data.error.message | ||
: __( 'Trashing failed' ), | ||
{ | ||
id: TRASH_POST_NOTICE_ID, | ||
id: 'editor-trash-fail', | ||
}, | ||
]; | ||
} |
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.
There is no need to remove the failed trash notice. If actions fail again, the same notice will be reused because the notice has the same static ID. Users will be redirected if they succeed, and WP will display a different notice.
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.
Makes sense to me 👍