| 1 |
import { Modal, Button } from '@wordpress/components' |
| 2 |
import { render } from '@wordpress/element' |
| 3 |
import { __, sprintf } from '@wordpress/i18n' |
| 4 |
import ExtendifyLibrary from '@library/ExtendifyLibrary' |
| 5 |
import { useWantedTemplateStore } from '@library/state/Importing' |
| 6 |
import { getPluginDescription } from '@library/util/general' |
| 7 |
|
| 8 |
export default function NeedsPermissionModal() { |
| 9 |
const wantedTemplate = useWantedTemplateStore( |
| 10 |
(store) => store.wantedTemplate, |
| 11 |
) |
| 12 |
const closeModal = () => |
| 13 |
render( |
| 14 |
<ExtendifyLibrary show={true} />, |
| 15 |
document.getElementById('extendify-root'), |
| 16 |
) |
| 17 |
const requiredPlugins = wantedTemplate?.fields?.required_plugins || [] |
| 18 |
return ( |
| 19 |
<Modal |
| 20 |
title={__('Plugins required', 'extendify')} |
| 21 |
isDismissible={false}> |
| 22 |
<p |
| 23 |
style={{ |
| 24 |
maxWidth: '400px', |
| 25 |
}}> |
| 26 |
{sprintf( |
| 27 |
__( |
| 28 |
'In order to add this %s to your site, the following plugins are required to be installed and activated.', |
| 29 |
'extendify', |
| 30 |
), |
| 31 |
wantedTemplate?.fields?.type ?? 'template', |
| 32 |
)} |
| 33 |
</p> |
| 34 |
<ul> |
| 35 |
{ |
| 36 |
// Hardcoded temporarily to not force EP install |
| 37 |
// requiredPlugins.map((plugin) => |
| 38 |
requiredPlugins |
| 39 |
.filter((p) => p !== 'editorplus') |
| 40 |
.map((plugin) => ( |
| 41 |
<li key={plugin}>{getPluginDescription(plugin)}</li> |
| 42 |
)) |
| 43 |
} |
| 44 |
</ul> |
| 45 |
<p |
| 46 |
style={{ |
| 47 |
maxWidth: '400px', |
| 48 |
fontWeight: 'bold', |
| 49 |
}}> |
| 50 |
{__( |
| 51 |
'Please contact a site admin for assistance in adding these plugins to your site.', |
| 52 |
'extendify', |
| 53 |
)} |
| 54 |
</p> |
| 55 |
<Button |
| 56 |
isPrimary |
| 57 |
onClick={closeModal} |
| 58 |
style={{ |
| 59 |
boxShadow: 'none', |
| 60 |
}}> |
| 61 |
{__('Return to library', 'extendify')} |
| 62 |
</Button> |
| 63 |
</Modal> |
| 64 |
) |
| 65 |
} |
| 66 |
|