PluginProbe
Extendify / 0.3.0
Extendify v0.3.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 / components / notices / InstallStandaloneNotice.js

InstallStandaloneNotice.js in Extendify 0.3.0, at src/components/notices/InstallStandaloneNotice.js

67 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n'
2 import { Button } from '@wordpress/components'
3 import { useState } from '@wordpress/element'
4 import { Plugins } from '../../api/Plugins'
5 import classNames from 'classnames'
6 import { General } from '../../api/General'
7 import { useUserStore } from '../../state/User'
8
9 export const InstallStandaloneNotice = () => {
10 const [text, setText] = useState('')
11 const giveFreebieImports = useUserStore((state) => state.giveFreebieImports)
12 const installAndActivate = () => {
13 setText(__('Installing...', 'extendify'))
14 Promise.all([
15 General.ping('stln-footer-install'),
16 Plugins.installAndActivate(['extendify']),
17 new Promise((resolve) => setTimeout(resolve, 1000)),
18 ])
19 .then(async () => {
20 giveFreebieImports(10)
21 setText(__('Success! Reloading...', 'extendify'))
22 await General.ping('stln-footer-success')
23 window.location.reload()
24 })
25 .catch(async (error) => {
26 console.error(error)
27 setText(__('Error. See console.', 'extendify'))
28 await General.ping('stln-footer-fail')
29 })
30 }
31
32 return (
33 <div>
34 <span className="text-black">
35 {__(
36 'Install the new Extendify Library plugin to get the latest we have to offer',
37 'extendify',
38 )}
39 </span>
40 <span className="px-2 opacity-50" aria-hidden="true">
41 &#124;
42 </span>
43 <div className="inline-flex space-x-2 items-center relative">
44 <Button
45 variant="link"
46 className={classNames(
47 'text-black underline hover:no-underline p-0 h-auto',
48 { 'opacity-0': text },
49 )}
50 onClick={installAndActivate}>
51 {__('Install Extendify standalone plugin', 'extendify')}
52 </Button>
53 {/* Little hacky to keep the text in place. Might need to tweak this */}
54 {text ? (
55 <Button
56 variant="link"
57 disabled={true}
58 className="text-black underline hover:no-underline p-0 h-auto absolute left-0 opacity-100"
59 onClick={() => {}}>
60 {text}
61 </Button>
62 ) : null}
63 </div>
64 </div>
65 )
66 }
67