PluginProbe
Extendify / 0.6.0
Extendify v0.6.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / middleware / hasRequiredPlugins / RequiredPluginsModal.js

RequiredPluginsModal.js in Extendify 0.6.0, at src/middleware/hasRequiredPlugins/RequiredPluginsModal.js

96 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Modal, Button, ButtonGroup } from '@wordpress/components'
2 import { render } from '@wordpress/element'
3 import { __, sprintf } from '@wordpress/i18n'
4 import ExtendifyLibrary from '@extendify/ExtendifyLibrary'
5 import { useWantedTemplateStore } from '@extendify/state/Importing'
6 import { useUserStore } from '@extendify/state/User'
7 import { getPluginDescription } from '@extendify/util/general'
8 import NeedsPermissionModal from '../NeedsPermissionModal'
9 import InstallingModal from './InstallingModal'
10
11 export default function RequiredPluginsModal({
12 forceOpen,
13 buttonLabel,
14 title,
15 message,
16 requiredPlugins,
17 }) {
18 // If there's a template in cache ready to be installed.
19 // TODO: this could probably be refactored out when overhauling required plugins
20 const wantedTemplate = useWantedTemplateStore(
21 (store) => store.wantedTemplate,
22 )
23 requiredPlugins =
24 requiredPlugins ?? wantedTemplate?.fields?.required_plugins
25
26 const closeModal = () => {
27 if (forceOpen) {
28 return
29 }
30 render(
31 <ExtendifyLibrary show={true} />,
32 document.getElementById('extendify-root'),
33 )
34 }
35 const installPlugins = () =>
36 render(
37 <InstallingModal requiredPlugins={requiredPlugins} />,
38 document.getElementById('extendify-root'),
39 )
40
41 if (!useUserStore.getState()?.canInstallPlugins) {
42 return <NeedsPermissionModal />
43 }
44
45 return (
46 <Modal
47 title={title ?? __('Install required plugins', 'extendify')}
48 isDismissible={false}>
49 <p
50 style={{
51 maxWidth: '400px',
52 }}>
53 {message ??
54 __(
55 sprintf(
56 'There is just one more step. This %s requires the following to be automatically installed and activated:',
57 wantedTemplate?.fields?.type ?? 'template',
58 ),
59 'extendify',
60 )}
61 </p>
62 {message?.length > 0 || (
63 <ul>
64 {
65 // Hardcoded temporarily to not force EP install
66 // requiredPlugins.map((plugin) =>
67 requiredPlugins
68 .filter((p) => p !== 'editorplus')
69 .map((plugin) => (
70 <li key={plugin}>
71 {getPluginDescription(plugin)}
72 </li>
73 ))
74 }
75 </ul>
76 )}
77 <ButtonGroup>
78 <Button isPrimary onClick={installPlugins}>
79 {buttonLabel ?? __('Install Plugins', 'extendify')}
80 </Button>
81 {forceOpen || (
82 <Button
83 isTertiary
84 onClick={closeModal}
85 style={{
86 boxShadow: 'none',
87 margin: '0 4px',
88 }}>
89 {__('No thanks, take me back', 'extendify')}
90 </Button>
91 )}
92 </ButtonGroup>
93 </Modal>
94 )
95 }
96