Skip to content

Commit

Permalink
Revert "Compat: Upgrade admin notices to use Notices module at runtime (
Browse files Browse the repository at this point in the history
#11604)"

This reverts commit 5dbc641.
  • Loading branch information
aduth committed Nov 29, 2018
1 parent c446d06 commit d4fb9ae
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 277 deletions.
10 changes: 3 additions & 7 deletions docs/contributors/coding-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,9 @@ Exposed APIs that are still being tested, discussed and are subject to change sh
Example:

```js
export { __experimentalDoAction } from './api';
```

If an API must be exposed but is clearly not intended to be supported into the future, you may also use `__unstable` as a prefix to differentiate it from an experimental API. Unstable APIs should serve an immediate and temporary purpose. They should _never_ be used by plugin developers as they can be removed at any point without notice, and thus should be omitted from public-facing documentation. The inline code documentation should clearly caution their use.

```js
export { __unstableDoAction } from './api';
export {
internalApi as __experimentalExposedApi
} from './internalApi.js';
```

### Variable Naming
Expand Down
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
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
21 changes: 3 additions & 18 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,18 @@ 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 +43,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

0 comments on commit d4fb9ae

Please sign in to comment.