2019-02-13 11:44:58 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import { Component } from '@wordpress/element';
|
|
|
|
import { compose } from '@wordpress/compose';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-09-03 21:45:40 +00:00
|
|
|
import { withDispatch, withSelect } from '@wordpress/data';
|
2019-02-13 11:44:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2020-11-09 07:17:08 +00:00
|
|
|
import SnackbarList from './snackbar/list';
|
2019-02-13 11:44:58 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
class TransientNotices extends Component {
|
|
|
|
render() {
|
2019-07-23 03:26:46 +00:00
|
|
|
const { className, notices, onRemove } = this.props;
|
|
|
|
const classes = classnames(
|
|
|
|
'woocommerce-transient-notices',
|
|
|
|
'components-notices__snackbar',
|
|
|
|
className
|
2019-07-10 16:58:51 +00:00
|
|
|
);
|
2019-07-23 03:26:46 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
return (
|
|
|
|
<SnackbarList
|
|
|
|
notices={ notices }
|
|
|
|
className={ classes }
|
|
|
|
onRemove={ onRemove }
|
|
|
|
/>
|
|
|
|
);
|
2019-02-13 11:44:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TransientNotices.propTypes = {
|
|
|
|
/**
|
|
|
|
* Additional class name to style the component.
|
|
|
|
*/
|
|
|
|
className: PropTypes.string,
|
|
|
|
/**
|
|
|
|
* Array of notices to be displayed.
|
|
|
|
*/
|
|
|
|
notices: PropTypes.array,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default compose(
|
2020-02-14 02:23:21 +00:00
|
|
|
withSelect( ( select ) => {
|
2020-11-09 07:17:08 +00:00
|
|
|
// NOTE: This uses core/notices2, if this file is copied back upstream
|
|
|
|
// to Gutenberg this needs to be changed back to core/notices.
|
|
|
|
const notices = select( 'core/notices2' ).getNotices();
|
2019-02-13 11:44:58 +00:00
|
|
|
|
|
|
|
return { notices };
|
2019-07-23 03:26:46 +00:00
|
|
|
} ),
|
2020-02-14 02:23:21 +00:00
|
|
|
withDispatch( ( dispatch ) => ( {
|
2020-11-09 07:17:08 +00:00
|
|
|
// NOTE: This uses core/notices2, if this file is copied back upstream
|
|
|
|
// to Gutenberg this needs to be changed back to core/notices.
|
|
|
|
onRemove: dispatch( 'core/notices2' ).removeNotice,
|
2019-07-23 03:26:46 +00:00
|
|
|
} ) )
|
2019-02-13 11:44:58 +00:00
|
|
|
)( TransientNotices );
|