| 1 |
/** |
| 2 |
* WordPress dependencies. |
| 3 |
*/ |
| 4 |
import { WPElement } from '@wordpress/element'; |
| 5 |
import { __ } from '@wordpress/i18n'; |
| 6 |
|
| 7 |
/** |
| 8 |
* Internal dependencies. |
| 9 |
*/ |
| 10 |
import { useFeatureSettings } from '../provider'; |
| 11 |
|
| 12 |
/** |
| 13 |
* Styles. |
| 14 |
*/ |
| 15 |
import '../style.css'; |
| 16 |
|
| 17 |
/** |
| 18 |
* Feature tab component. |
| 19 |
* |
| 20 |
* @param {object} props Component props. |
| 21 |
* @param {WPElement} props.feature Feature slug. |
| 22 |
* @returns {WPElement} Feature tab component. |
| 23 |
*/ |
| 24 |
export default ({ feature }) => { |
| 25 |
const { getFeature, featuresRequiringSync } = useFeatureSettings(); |
| 26 |
|
| 27 |
const { shortTitle, isAvailable } = getFeature(feature); |
| 28 |
|
| 29 |
const availabilityStatus = isAvailable ? '' : __('Unavailable', 'elasticpress'); |
| 30 |
|
| 31 |
const status = featuresRequiringSync.includes(feature) |
| 32 |
? __('Sync required', 'elasticpress') |
| 33 |
: availabilityStatus; |
| 34 |
|
| 35 |
return ( |
| 36 |
<div className="ep-feature-tab"> |
| 37 |
{shortTitle} |
| 38 |
{status ? <small className="ep-feature-tab__status">{status}</small> : null} |
| 39 |
</div> |
| 40 |
); |
| 41 |
}; |
| 42 |
|