Skip to content

Commit

Permalink
Editor: Remove constants for notices
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Dec 27, 2024
1 parent 9ae31d3 commit 7e2de0d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
2 changes: 0 additions & 2 deletions packages/editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { TRASH_POST_NOTICE_ID } from './constants';
import { localAutosaveSet } from './local-autosave';
import {
getNotificationArgumentsForSaveSuccess,
Expand Down Expand Up @@ -347,7 +346,6 @@ export const trashPost =
const postType = await registry
.resolveSelect( coreStore )
.getPostType( postTypeSlug );
registry.dispatch( noticesStore ).removeNotice( TRASH_POST_NOTICE_ID );
const { rest_base: restBase, rest_namespace: restNamespace = 'wp/v2' } =
postType;
dispatch( { type: 'REQUEST_POST_DELETE_START' } );
Expand Down
2 changes: 0 additions & 2 deletions packages/editor/src/store/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
export const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
export const ONE_MINUTE_IN_MS = 60 * 1000;
export const AUTOSAVE_PROPERTIES = [ 'title', 'excerpt', 'content' ];
Expand Down
11 changes: 3 additions & 8 deletions packages/editor/src/store/utils/notice-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -68,7 +63,7 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
return [
noticeMessage,
{
id: SAVE_POST_NOTICE_ID,
id: 'editor-save-success',
type: 'snackbar',
actions,
},
Expand Down Expand Up @@ -113,7 +108,7 @@ export function getNotificationArgumentsForSaveFail( data ) {
return [
noticeMessage,
{
id: SAVE_POST_NOTICE_ID,
id: 'editor-save-fail',
},
];
}
Expand All @@ -131,7 +126,7 @@ export function getNotificationArgumentsForTrashFail( data ) {
? data.error.message
: __( 'Trashing failed' ),
{
id: TRASH_POST_NOTICE_ID,
id: 'editor-trash-fail',
},
];
}
7 changes: 3 additions & 4 deletions packages/editor/src/store/utils/test/notice-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
getNotificationArgumentsForSaveFail,
getNotificationArgumentsForTrashFail,
} from '../notice-builder';
import { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../../constants';

describe( 'getNotificationArgumentsForSaveSuccess()', () => {
const postType = {
Expand All @@ -27,7 +26,7 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => {
};
const post = { ...previousPost };
const defaultExpectedAction = {
id: SAVE_POST_NOTICE_ID,
id: 'editor-save-success',
actions: [],
type: 'snackbar',
};
Expand Down Expand Up @@ -106,7 +105,7 @@ describe( 'getNotificationArgumentsForSaveFail()', () => {
const error = { code: '42', message: 'Something went wrong.' };
const post = { status: 'publish' };
const edits = { status: 'publish' };
const defaultExpectedAction = { id: SAVE_POST_NOTICE_ID };
const defaultExpectedAction = { id: 'editor-save-fail' };
[
[
'when error code is `rest_autosave_no_changes`',
Expand Down Expand Up @@ -190,7 +189,7 @@ describe( 'getNotificationArgumentsForTrashFail()', () => {
].forEach( ( [ description, error, message ] ) => {
// eslint-disable-next-line jest/valid-title
it( description, () => {
const expectedValue = [ message, { id: TRASH_POST_NOTICE_ID } ];
const expectedValue = [ message, { id: 'editor-trash-fail' } ];
expect( getNotificationArgumentsForTrashFail( { error } ) ).toEqual(
expectedValue
);
Expand Down

0 comments on commit 7e2de0d

Please sign in to comment.