| 1 |
/** |
| 2 |
* WordPress dependencies. |
| 3 |
*/ |
| 4 |
import { Notice } from '@wordpress/components'; |
| 5 |
import { safeHTML } from '@wordpress/dom'; |
| 6 |
import { RawHTML, WPElement } from '@wordpress/element'; |
| 7 |
import { __ } from '@wordpress/i18n'; |
| 8 |
|
| 9 |
/** |
| 10 |
* Internal dependencies. |
| 11 |
*/ |
| 12 |
import { useFeatureSettings } from '../provider'; |
| 13 |
import Settings from './settings'; |
| 14 |
|
| 15 |
/** |
| 16 |
* Reports component. |
| 17 |
* |
| 18 |
* @param {object} props Component props. |
| 19 |
* @param {WPElement} props.feature Feature slug. |
| 20 |
* @returns {WPElement} Reports component. |
| 21 |
*/ |
| 22 |
export default ({ feature }) => { |
| 23 |
const { epioLogoUrl, getFeature } = useFeatureSettings(); |
| 24 |
|
| 25 |
const { isPoweredByEpio, reqStatusCode, reqStatusMessages, settingsSchema, summary, title } = |
| 26 |
getFeature(feature); |
| 27 |
|
| 28 |
return ( |
| 29 |
<> |
| 30 |
{/* eslint-disable-next-line react/no-danger */} |
| 31 |
<h3 className="ep-dashboard-heading"> |
| 32 |
<RawHTML>{safeHTML(title)}</RawHTML> |
| 33 |
{isPoweredByEpio ? ( |
| 34 |
<img |
| 35 |
alt={__('ElasticPress.io logo')} |
| 36 |
height="20" |
| 37 |
src={epioLogoUrl} |
| 38 |
width="110" |
| 39 |
/> |
| 40 |
) : null} |
| 41 |
</h3> |
| 42 |
{/* eslint-disable-next-line react/no-danger */} |
| 43 |
<p dangerouslySetInnerHTML={{ __html: safeHTML(summary) }} /> |
| 44 |
{reqStatusMessages.map((m, i) => ( |
| 45 |
<Notice |
| 46 |
isDismissible={false} |
| 47 |
key={i} // eslint-disable-line react/no-array-index-key |
| 48 |
status={reqStatusCode === 2 ? 'error' : 'warning'} |
| 49 |
> |
| 50 |
{/* eslint-disable-next-line react/no-danger */} |
| 51 |
<span dangerouslySetInnerHTML={{ __html: safeHTML(m) }} /> |
| 52 |
</Notice> |
| 53 |
))} |
| 54 |
<Settings feature={feature} settingsSchema={settingsSchema} /> |
| 55 |
</> |
| 56 |
); |
| 57 |
}; |
| 58 |
|