From b55feaed09778b570b4055c75fdc016cfed61250 Mon Sep 17 00:00:00 2001 From: Augustin Date: Thu, 23 Apr 2026 21:30:02 +0200 Subject: [PATCH] refactor(config): locale panel with edit/save flow like profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show current language and keyboard as read-only values, then "Modifier" button opens chip selection, "Sauvegarder" persists via API. Centered layout matching profile panel style. 💘 Generated with Crush Assisted-by: GLM-5.1 via Crush --- web/src/components/Config.jsx | 93 ++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 30 deletions(-) diff --git a/web/src/components/Config.jsx b/web/src/components/Config.jsx index 828e19d..9f4eb94 100644 --- a/web/src/components/Config.jsx +++ b/web/src/components/Config.jsx @@ -471,6 +471,10 @@ function PanelUpdates({ updates, checking, updating, needsUpdateCount, installed } function PanelLocale({ language, keyboard, layouts, api, t }) { + const { setLanguage, setKeyboard } = useI18n() + const [editLocale, setEditLocale] = useState(false) + const [draftLang, setDraftLang] = useState(language) + const [draftKbd, setDraftKbd] = useState(keyboard) const [saving, setSaving] = useState(false) const [toast, setToast] = useState(null) @@ -482,7 +486,10 @@ function PanelLocale({ language, keyboard, layouts, api, t }) { const handleSave = async () => { setSaving(true) try { - await api.savePreferences({ language, keyboard_layout: keyboard }) + await api.savePreferences({ language: draftLang, keyboard_layout: draftKbd }) + setLanguage(draftLang) + setKeyboard(draftKbd) + setEditLocale(false) showToast(t('config.saved')) } catch (err) { showToast(`${t('config.error')}: ${err.message}`) @@ -490,41 +497,67 @@ function PanelLocale({ language, keyboard, layouts, api, t }) { setSaving(false) } + const currentLang = LANGUAGES.find(l => l.id === language) + const currentKbd = layouts.find(l => l.id === keyboard) + return ( -
+
{toast &&
{toast}
} -
- {t('config.language')} -
- {LANGUAGES.map(lang => ( -
setLanguage(lang.id)} - > - {lang.name} -
- ))} +
+
+ {t('config.language')} + {currentLang?.name || language} +
+
+ {t('config.keyboardLayout')} + {currentKbd?.name || keyboard}
-
- {t('config.keyboardLayout')} -
- {layouts.map(l => ( -
setKeyboard(l.id)} - > - {l.name} + {editLocale && ( +
+
+ {t('config.language')} +
+ {LANGUAGES.map(lang => ( +
setDraftLang(lang.id)} + > + {lang.name} +
+ ))}
- ))} +
+
+ {t('config.keyboardLayout')} +
+ {layouts.map(l => ( +
setDraftKbd(l.id)} + > + {l.name} +
+ ))} +
+
+
+ )} +
+
+ {editLocale ? ( + <> + + + + ) : ( + + )}
-
-
-
)