Skip to content
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

Revert "Compat: Upgrade admin notices to use Notices module at runtime" #12440

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ Yields action objects used in signalling that a notice is to be created.
* options.isDismissible: Whether the notice can
be dismissed by user.
Defaults to `true`.
* options.speak: Whether the notice
content should be
announced to screen
readers. Defaults to
`true`.
* options.actions: User actions to be
presented with notice.

Expand Down
1 change: 0 additions & 1 deletion lib/packages-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
'wp-embed',
'wp-i18n',
'wp-keycodes',
'wp-notices',
'wp-nux',
'wp-plugins',
'wp-url',
Expand Down
6 changes: 0 additions & 6 deletions packages/components/src/notice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { RawHTML } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -22,16 +21,11 @@ function Notice( {
onRemove = noop,
isDismissible = true,
actions = [],
__unstableHTML,
} ) {
const classes = classnames( className, 'components-notice', 'is-' + status, {
'is-dismissible': isDismissible,
} );

if ( __unstableHTML ) {
children = <RawHTML>{ children }</RawHTML>;
}

return (
<div className={ classes }>
<div className="components-notice__content">
Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/notice/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ function NoticeList( { notices, onRemove = noop, className = 'components-notice-
<div className={ className }>
{ children }
{ [ ...notices ].reverse().map( ( notice ) => (
<Notice
{ ...omit( notice, [ 'content' ] ) }
key={ notice.id }
onRemove={ removeNotice( notice.id ) }
>
<Notice { ...omit( notice, 'content' ) } key={ notice.id } onRemove={ removeNotice( notice.id ) }>
{ notice.content }
</Notice>
) ) }
Expand Down
6 changes: 6 additions & 0 deletions packages/edit-post/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 4.0.0 (Unreleased)

### Breaking Change

- Revert: The `AdminNotices` component added in 3.1.0 has been removed.

## 3.1.2 (2018-11-22)

## 3.1.1 (2018-11-21)
Expand Down
105 changes: 0 additions & 105 deletions packages/edit-post/src/components/admin-notices/index.js

This file was deleted.

61 changes: 0 additions & 61 deletions packages/edit-post/src/components/admin-notices/test/index.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import Sidebar from '../sidebar';
import PluginPostPublishPanel from '../sidebar/plugin-post-publish-panel';
import PluginPrePublishPanel from '../sidebar/plugin-pre-publish-panel';
import FullscreenMode from '../fullscreen-mode';
import AdminNotices from '../admin-notices';

function Layout( {
mode,
Expand Down Expand Up @@ -71,7 +70,6 @@ function Layout( {
<BrowserURL />
<UnsavedChangesWarning />
<AutosaveMonitor />
<AdminNotices />
<Header />
<div
className="edit-post-layout__content"
Expand Down
1 change: 0 additions & 1 deletion packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import '@wordpress/core-data';
import '@wordpress/editor';
import '@wordpress/nux';
import '@wordpress/viewport';
import '@wordpress/notices';
import { registerCoreBlocks } from '@wordpress/block-library';
import { render, unmountComponentAtNode } from '@wordpress/element';
import { dispatch } from '@wordpress/data';
Expand Down
7 changes: 6 additions & 1 deletion packages/notices/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
## 2.0.0 (Unreleased)

### Breaking Change

- Revert: The `speak` option added in v1.1.0 has been removed.

## 1.1.0 (2018-11-20)

### New Feature

- The `createNotice` can now optionally accept a WPNotice object as the sole argument.
Copy link
Member Author

Choose a reason for hiding this comment

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

This never actually went through in #11604. See #11604 (comment) .

- New option `speak` enables control as to whether the notice content is announced to screen readers (defaults to `true`)

### Bug Fixes
Expand Down
16 changes: 3 additions & 13 deletions packages/notices/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { uniqueId } from 'lodash';
/**
* Internal dependencies
*/
import { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';
import { DEFAULT_CONTEXT } from './constants';

/**
* Yields action objects used in signalling that a notice is to be created.
Expand All @@ -23,32 +23,23 @@ import { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';
* @param {?boolean} options.isDismissible Whether the notice can
* be dismissed by user.
* Defaults to `true`.
* @param {?boolean} options.speak Whether the notice
* content should be
* announced to screen
* readers. Defaults to
* `true`.
* @param {?Array<WPNoticeAction>} options.actions User actions to be
* presented with notice.
*/
export function* createNotice( status = DEFAULT_STATUS, content, options = {} ) {
export function* createNotice( status = 'info', content, options = {} ) {
const {
speak = true,
isDismissible = true,
context = DEFAULT_CONTEXT,
id = uniqueId( context ),
actions = [],
__unstableHTML,
} = options;

// The supported value shape of content is currently limited to plain text
// strings. To avoid setting expectation that e.g. a WPElement could be
// supported, cast to a string.
content = String( content );

if ( speak ) {
yield { type: 'SPEAK', message: content };
}
yield { type: 'SPEAK', message: content };

yield {
type: 'CREATE_NOTICE',
Expand All @@ -57,7 +48,6 @@ export function* createNotice( status = DEFAULT_STATUS, content, options = {} )
id,
status,
content,
__unstableHTML,
isDismissible,
actions,
},
Expand Down
7 changes: 0 additions & 7 deletions packages/notices/src/store/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,3 @@
* @type {string}
*/
export const DEFAULT_CONTEXT = 'global';

/**
* Default notice status.
*
* @type {string}
*/
export const DEFAULT_STATUS = 'info';
9 changes: 2 additions & 7 deletions packages/notices/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,11 @@ const DEFAULT_NOTICES = [];
* `info`, `error`, or `warning`. Defaults
* to `info`.
* @property {string} content Notice message.
* @property {string} __unstableHTML Notice message as raw HTML. Intended to
* serve primarily for compatibility of
* server-rendered notices, and SHOULD NOT
* be used for notices. It is subject to
* removal without notice.
* @property {boolean} isDismissible Whether the notice can be dismissed by
* user. Defaults to `true`.
* @property {WPNoticeAction[]} actions User actions to present with notice.
*
* @typedef {WPNotice}
* @typedef {Notice}
*/

/**
Expand All @@ -53,7 +48,7 @@ const DEFAULT_NOTICES = [];
* @param {Object} state Notices state.
* @param {?string} context Optional grouping context.
*
* @return {WPNotice[]} Array of notices.
* @return {Notice[]} Array of notices.
*/
export function getNotices( state, context = DEFAULT_CONTEXT ) {
return state[ context ] || DEFAULT_NOTICES;
Expand Down
Loading