diff --git a/packages/notices/src/store/actions.js b/packages/notices/src/store/actions.js index 4777ccfcc90f8..6d62e7fbda219 100644 --- a/packages/notices/src/store/actions.js +++ b/packages/notices/src/store/actions.js @@ -6,7 +6,7 @@ import { isPlainObject, uniqueId } from 'lodash'; /** * Internal dependencies */ -import { DEFAULT_CONTEXT } from './constants'; +import { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants'; /** * Yields action objects used in signalling that a notice is to be created. @@ -27,13 +27,13 @@ import { DEFAULT_CONTEXT } from './constants'; * @param {?Array} options.actions User actions to be * presented with notice. */ -export function* createNotice( statusOrNotice = 'info', content, options = {} ) { +export function* createNotice( statusOrNotice = DEFAULT_STATUS, content, options = {} ) { let status; if ( isPlainObject( statusOrNotice ) ) { // Support overloaded form `createNotice( notice: WPNotice )`. options = statusOrNotice; - ( { status = 'info', content } = options ); + ( { status = DEFAULT_STATUS, content } = options ); } else { // Else consider the first argument the status type string. status = statusOrNotice; diff --git a/packages/notices/src/store/constants.js b/packages/notices/src/store/constants.js index 4c6ded8a4a308..2949bde0577db 100644 --- a/packages/notices/src/store/constants.js +++ b/packages/notices/src/store/constants.js @@ -6,3 +6,10 @@ * @type {string} */ export const DEFAULT_CONTEXT = 'global'; + +/** + * Default notice status. + * + * @type {string} + */ +export const DEFAULT_STATUS = 'info'; diff --git a/packages/notices/src/store/test/actions.js b/packages/notices/src/store/test/actions.js index 416db7b30a460..40cc1d5929ede 100644 --- a/packages/notices/src/store/test/actions.js +++ b/packages/notices/src/store/test/actions.js @@ -9,7 +9,7 @@ import { createWarningNotice, removeNotice, } from '../actions'; -import { DEFAULT_CONTEXT } from '../constants'; +import { DEFAULT_CONTEXT, DEFAULT_STATUS } from '../constants'; describe( 'actions', () => { describe( 'createNotice', () => { @@ -83,7 +83,7 @@ describe( 'actions', () => { context: DEFAULT_CONTEXT, notice: { id, - status: 'info', + status: DEFAULT_STATUS, content, isDismissible: false, actions: [], @@ -131,7 +131,7 @@ describe( 'actions', () => { type: 'CREATE_NOTICE', context: DEFAULT_CONTEXT, notice: { - status: 'info', + status: DEFAULT_STATUS, content, isDismissible: true, id: expect.any( String ),