| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
import { compose } from '@wordpress/compose'; |
| 5 |
import { withSelect } from '@wordpress/data'; |
| 6 |
|
| 7 |
export function ErrorNoticeCheck( { hasErrorNoticeAction, children } ) { |
| 8 |
if ( ! hasErrorNoticeAction ) { |
| 9 |
return null; |
| 10 |
} |
| 11 |
|
| 12 |
return children; |
| 13 |
} |
| 14 |
|
| 15 |
export default compose( [ |
| 16 |
withSelect( ( select ) => { |
| 17 |
const { getEditedPostAttribute } = select( 'core/editor' ); |
| 18 |
|
| 19 |
const beyondwordsErrorMessage = |
| 20 |
getEditedPostAttribute( 'meta' ).beyondwords_error_message; |
| 21 |
const speechkitErrorMessage = |
| 22 |
getEditedPostAttribute( 'meta' ).speechkit_error_message; |
| 23 |
|
| 24 |
return { |
| 25 |
hasErrorNoticeAction: |
| 26 |
!! beyondwordsErrorMessage || !! speechkitErrorMessage, |
| 27 |
}; |
| 28 |
} ), |
| 29 |
] )( ErrorNoticeCheck ); |
| 30 |
|