PluginProbe
Extendify / 0.10.2
Extendify v0.10.2
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 / Library / components / notices / InstallStandaloneNotice.js

InstallStandaloneNotice.js in Extendify 0.10.2, at src/Library/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 { Button } from '@wordpress/components'
2 import { useState } from '@wordpress/element'
3 import { __ } from '@wordpress/i18n'
4 import classNames from 'classnames'
5 import { General } from '@library/api/General'
6 import { Plugins } from '@library/api/Plugins'
7 import { useUserStore } from '@library/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="relative inline-flex items-center space-x-2">
44 <Button
45 variant="link"
46 className={classNames(
47 'h-auto p-0 text-black underline hover:no-underline',
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="absolute left-0 h-auto p-0 text-black underline opacity-100 hover:no-underline"
59 onClick={() => {}}>
60 {text}
61 </Button>
62 ) : null}
63 </div>
64 </div>
65 )
66 }
67