Skip to content

Commit

Permalink
Editor: Remove constants for notices (#68361)
Browse files Browse the repository at this point in the history
Unlinked contributors: aduth.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: paaljoachim <paaljoachim@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
  • Loading branch information
5 people authored Dec 30, 2024
1 parent 8e2d050 commit bc28417
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',
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',
},
];
}
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',
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' };
[
[
'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

1 comment on commit bc28417

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in bc28417.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12551042803
📝 Reported issues:

Please sign in to comment.