{__('General')}
+ {__('Sites')}
{__('Account')}
@@ -256,6 +319,9 @@ function SettingsPanels({ settings, loaded, onChange, wporg }) {
+
+
+
@@ -278,11 +344,12 @@ function SettingsPanels({ settings, loaded, onChange, wporg }) {
* @param {boolean} props.open Whether the dialog is open.
* @param {?Object} props.settings The settings, or null while they are read.
* @param {?Object} props.loaded The settings as the window first read them, for what takes a relaunch.
+ * @param {?Object} props.php The PHP versions the bundle has and the fallback (useSettings), null while unread, `{ error }` when it could not be.
* @param {Function} props.onChange Changes one setting; resolves to `{ ok, settings }` or `{ ok: false, error }`.
* @param {Object} props.wporg The contributor's details and how to change them.
* @param {Function} props.onClose Asked for by the close button, Escape, or a press outside.
*/
-export function SettingsDialog({ open, settings, loaded, onChange, wporg, onClose }) {
+export function SettingsDialog({ open, settings, loaded, php, onChange, wporg, onClose }) {
return (
{ if (!next) onClose(); }}>
@@ -290,7 +357,7 @@ export function SettingsDialog({ open, settings, loaded, onChange, wporg, onClos
{__('Settings')}
-
+
);
diff --git a/src/renderer/hooks/use-settings.jsx b/src/renderer/hooks/use-settings.jsx
index 60534d03..6e2e534d 100644
--- a/src/renderer/hooks/use-settings.jsx
+++ b/src/renderer/hooks/use-settings.jsx
@@ -6,9 +6,15 @@ import { useCallback, useEffect, useState } from 'react';
// dialog opened before then can say it is still reading them. `loaded` is
// what main answered first and does not change: a setting that takes a
// relaunch, the language, is one whose value now differs from it.
+// `php` is what the bundled Playground can run a site on, `{ versions,
+// fallback }`, read once with the settings: the dialog offers the versions
+// and the details say which one a server starts on, which is the fallback
+// where the one set is not among them. Null until read; `{ error }` when it
+// could not be, so the dialog can say so rather than offer nothing.
export function useSettings() {
const [settings, setSettings] = useState(null);
const [loaded, setLoaded] = useState(null);
+ const [php, setPhp] = useState(null);
useEffect(() => {
let cancelled = false;
@@ -20,6 +26,16 @@ export function useSettings() {
})
// eslint-disable-next-line no-console -- reaches the log file, see the note in useDetectedEditors.
.catch((err) => console.error('Could not read the settings:', err));
+ window.api.listPhpVersions()
+ .then((res) => {
+ if (cancelled) return;
+ setPhp(res?.ok ? { versions: res.versions, fallback: res.fallback } : { error: true });
+ })
+ .catch((err) => {
+ // eslint-disable-next-line no-console -- see the note above.
+ console.error('Could not read the PHP versions:', err);
+ if (!cancelled) setPhp({ error: true });
+ });
return () => { cancelled = true; };
}, []);
@@ -39,5 +55,5 @@ export function useSettings() {
return result;
}, []);
- return { settings, loaded, change };
+ return { settings, loaded, php, change };
}
diff --git a/src/renderer/index.jsx b/src/renderer/index.jsx
index bd06b695..6c3180c3 100644
--- a/src/renderer/index.jsx
+++ b/src/renderer/index.jsx
@@ -83,6 +83,7 @@ import { TicketListCard } from './components/ticket-list.jsx';
import { useDetectedEditors } from './hooks/use-detected-editors.jsx';
import { useContributorProvenance } from './hooks/use-contributor-provenance.jsx';
import { useSettings } from './hooks/use-settings.jsx';
+import { phpVersionChoice } from './settings-view.cjs';
import { useNextActionCue } from './hooks/use-next-action-cue.jsx';
import { useSites } from './hooks/use-sites.jsx';
import { usePullRequest } from './hooks/use-pull-request.jsx';
@@ -132,7 +133,10 @@ function App() {
const wporg = useContributorProvenance();
// The app's settings (#559), and the dialog they are changed in. The menu
// asks for the dialog too, over a subscription the whole window holds.
- const { settings, loaded: loadedSettings, change: changeSetting } = useSettings();
+ const { settings, loaded: loadedSettings, php: phpVersions, change: changeSetting } = useSettings();
+ // The PHP a server starts on: the one set where the bundle has it, and
+ // the fallback where it does not, decided where the dialog decides it.
+ const startingPhp = settings ? phpVersionChoice({ versions: phpVersions?.versions, fallback: phpVersions?.fallback, stored: settings.phpVersion }).value : null;
const [settingsOpen, setSettingsOpen] = useState(false);
const openSettings = useCallback(() => setSettingsOpen(true), []);
const closeSettings = useCallback(() => setSettingsOpen(false), []);
@@ -684,6 +688,8 @@ function App() {
createdAt={siteMeta?.[s]?.createdAt}
label={siteMeta?.[s]?.label}
projectType={siteMeta?.[s]?.projectType}
+ settings={settings}
+ startingPhp={startingPhp}
onInitialized={onInitialized}
onSiteMetaPatch={onSiteMetaPatch}
onDelete={onDelete}
@@ -720,7 +726,7 @@ function App() {
)}