PluginProbe
Extendify / 3.1.5
Extendify v3.1.5
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 0.7.0 All 126 releases
extendify / src / AutoLaunch / components / LaunchUpdate.jsx

LaunchUpdate.jsx in Extendify 3.1.5, at src/AutoLaunch/components/LaunchUpdate.jsx

67 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { forceReinstallPlugin, runUpdates } from '@auto-launch/functions/setup';
2 import { digest } from '@shared/api/digest';
3 import { Spinner } from '@wordpress/components';
4 import { useCallback, useEffect } from '@wordpress/element';
5 import { __ } from '@wordpress/i18n';
6
7 // The reload is also the retry; the server bounds how many, so it can't loop.
8 export const LaunchUpdate = ({
9 pluginUpdateNeeded,
10 themeUpdateNeeded,
11 pluginUpdateViaRest,
12 pluginSlug,
13 attempt,
14 }) => {
15 const cardClass = 'flex w-full flex-col items-center p-6 text-center lg:p-10';
16
17 const applyUpdates = useCallback(async () => {
18 // Run serially, not concurrently: two WP upgraders fight over the shared
19 // maintenance flag and filesystem.
20 const phpUpdateNeeded =
21 themeUpdateNeeded || (pluginUpdateNeeded && !pluginUpdateViaRest);
22 try {
23 if (phpUpdateNeeded) {
24 const result = await runUpdates();
25 if (result?.errors?.length) {
26 throw new Error(result.errors.join('; '));
27 }
28 }
29 if (pluginUpdateNeeded && pluginUpdateViaRest) {
30 await forceReinstallPlugin(pluginSlug);
31 }
32 } catch (error) {
33 digest({
34 error,
35 details: { source: 'auto-launch', caller: 'launch-update', attempt },
36 });
37 } finally {
38 window.location.reload();
39 }
40 }, [
41 pluginUpdateNeeded,
42 themeUpdateNeeded,
43 pluginUpdateViaRest,
44 pluginSlug,
45 attempt,
46 ]);
47
48 useEffect(() => {
49 applyUpdates();
50 }, [applyUpdates]);
51
52 return (
53 <div className={cardClass}>
54 <Spinner className="h-10 w-10 text-design-main" />
55 <h2 className="mt-6 mb-0 p-0 text-lg font-semibold text-gray-900">
56 {__('Updating your site', 'extendify-local')}
57 </h2>
58 <p className="mx-auto mt-3 mb-0 max-w-md p-0 text-base text-gray-900">
59 {__(
60 "We're installing the latest updates. Please don't close this window — it will only take a moment.",
61 'extendify-local',
62 )}
63 </p>
64 </div>
65 );
66 };
67