Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): keep the data backup reachable when the config read fails

Yudhi Armyndharisda56b2808d65
diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.json
index d57bebb7f..6e73ebef7 100644
--- a/dashboard/src/i18n/locales/ar.json
+++ b/dashboard/src/i18n/locales/ar.json
@@ -938,7 +938,8 @@
"invalidFile": "هذا الملفّ ليس نسخة احتياطية صالحة لبيانات OpenWA.",
"importTooLarge": "النسخة الاحتياطية أكبر من حدّ الطلب. زِد قيمة BODY_SIZE_LIMIT على الخادم ثم أعد المحاولة."
},
- "statusLoadError": "تعذّر تحميل حالة البنية التحتية الحالية. حدّث الصفحة لإعادة المحاولة."
+ "statusLoadError": "تعذّر تحميل حالة البنية التحتية الحالية. حدّث الصفحة لإعادة المحاولة.",
+ "configLoadError": "تعذّر تحميل الإعدادات المحفوظة، لذا لا يمكن تعديلها هنا. حدّث الصفحة لإعادة المحاولة."
},
"plugins": {
"title": "الإضافات",
diff --git a/dashboard/src/i18n/locales/de.json b/dashboard/src/i18n/locales/de.json
index cc3d9d224..660a0c955 100644
--- a/dashboard/src/i18n/locales/de.json
+++ b/dashboard/src/i18n/locales/de.json
@@ -921,7 +921,8 @@
"toasts": {
"saveFailed": "Speichern fehlgeschlagen"
},
- "statusLoadError": "Der aktuelle Infrastrukturstatus konnte nicht geladen werden. Aktualisiere die Seite und versuche es erneut."
+ "statusLoadError": "Der aktuelle Infrastrukturstatus konnte nicht geladen werden. Aktualisiere die Seite und versuche es erneut.",
+ "configLoadError": "Die gespeicherte Konfiguration konnte nicht geladen werden und lässt sich hier daher nicht bearbeiten. Aktualisiere die Seite und versuche es erneut."
},
"plugins": {
"title": "Plugins",
diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.json
index 14127fb55..bb192e779 100644
--- a/dashboard/src/i18n/locales/en.json
+++ b/dashboard/src/i18n/locales/en.json
@@ -921,7 +921,8 @@
"toasts": {
"saveFailed": "Save Failed"
},
- "statusLoadError": "Couldn't load the current infrastructure status. Refresh to try again."
+ "statusLoadError": "Couldn't load the current infrastructure status. Refresh to try again.",
+ "configLoadError": "Couldn't load the saved configuration, so it can't be edited here. Refresh to try again."
},
"plugins": {
"title": "Plugins",
diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.json
index 36dcf57b6..ebb91d3a7 100644
--- a/dashboard/src/i18n/locales/es.json
+++ b/dashboard/src/i18n/locales/es.json
@@ -925,7 +925,8 @@
"invalidFile": "Ese archivo no es una copia de seguridad de datos válida de OpenWA.",
"importTooLarge": "La copia de seguridad supera el límite de la solicitud. Aumenta BODY_SIZE_LIMIT en el servidor e inténtalo de nuevo."
},
- "statusLoadError": "No se pudo cargar el estado actual de la infraestructura. Actualiza para reintentar."
+ "statusLoadError": "No se pudo cargar el estado actual de la infraestructura. Actualiza para reintentar.",
+ "configLoadError": "No se pudo cargar la configuración guardada, así que no se puede editar aquí. Actualiza para reintentar."
},
"plugins": {
"title": "Plugins",
diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.json
index 9e712c5af..97d45631c 100644
--- a/dashboard/src/i18n/locales/fr.json
+++ b/dashboard/src/i18n/locales/fr.json
@@ -925,7 +925,8 @@
"invalidFile": "Ce fichier n'est pas une sauvegarde de données OpenWA valide.",
"importTooLarge": "La sauvegarde dépasse la limite de la requête. Augmentez BODY_SIZE_LIMIT sur le serveur, puis réessayez."
},
- "statusLoadError": "Impossible de charger l'état actuel de l'infrastructure. Actualisez pour réessayer."
+ "statusLoadError": "Impossible de charger l'état actuel de l'infrastructure. Actualisez pour réessayer.",
+ "configLoadError": "Impossible de charger la configuration enregistrée, elle ne peut donc pas être modifiée ici. Actualisez pour réessayer."
},
"plugins": {
"title": "Plugins",
diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.json
index c279905d6..8c5078c22 100644
--- a/dashboard/src/i18n/locales/he.json
+++ b/dashboard/src/i18n/locales/he.json
@@ -930,7 +930,8 @@
"invalidFile": "הקובץ הזה אינו גיבוי נתונים תקין של OpenWA.",
"importTooLarge": "הגיבוי גדול מדי עבור מגבלת הבקשה. הגדילו את BODY_SIZE_LIMIT בשרת ונסו שוב."
},
- "statusLoadError": "לא ניתן לטעון את מצב התשתית הנוכחי. רעננו כדי לנסות שוב."
+ "statusLoadError": "לא ניתן לטעון את מצב התשתית הנוכחי. רעננו כדי לנסות שוב.",
+ "configLoadError": "לא ניתן לטעון את התצורה השמורה, ולכן אי אפשר לערוך אותה כאן. רעננו כדי לנסות שוב."
},
"plugins": {
"title": "תוספים",
diff --git a/dashboard/src/i18n/locales/hi.json b/dashboard/src/i18n/locales/hi.json
index c88e49f6b..448381312 100644
--- a/dashboard/src/i18n/locales/hi.json
+++ b/dashboard/src/i18n/locales/hi.json
@@ -921,7 +921,8 @@
"toasts": {
"saveFailed": "सहेजना विफल"
},
- "statusLoadError": "वर्तमान बुनियादी ढांचा स्थिति लोड नहीं की जा सकी। पुनः प्रयास करने के लिए रीफ़्रेश करें।"
+ "statusLoadError": "वर्तमान बुनियादी ढांचा स्थिति लोड नहीं की जा सकी। पुनः प्रयास करने के लिए रीफ़्रेश करें।",
+ "configLoadError": "सहेजा गया कॉन्फ़िगरेशन लोड नहीं किया जा सका, इसलिए इसे यहाँ संपादित नहीं किया जा सकता। पुनः प्रयास करने के लिए रीफ़्रेश करें।"
},
"plugins": {
"title": "प्लगइन्स",
diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.json
index 022e6e1aa..611c6c459 100644
--- a/dashboard/src/i18n/locales/it.json
+++ b/dashboard/src/i18n/locales/it.json
@@ -925,7 +925,8 @@
"invalidFile": "Questo file non è un backup dati valido di OpenWA.",
"importTooLarge": "Il backup supera il limite della richiesta. Aumenta BODY_SIZE_LIMIT sul server e riprova."
},
- "statusLoadError": "Impossibile caricare lo stato attuale dell'infrastruttura. Aggiorna per riprovare."
+ "statusLoadError": "Impossibile caricare lo stato attuale dell'infrastruttura. Aggiorna per riprovare.",
+ "configLoadError": "Impossibile caricare la configurazione salvata, quindi non è modificabile qui. Aggiorna per riprovare."
},
"plugins": {
"title": "Plugin",
diff --git a/dashboard/src/i18n/locales/ko.json b/dashboard/src/i18n/locales/ko.json
index b3f9ba6b0..3f5fffd8f 100644
--- a/dashboard/src/i18n/locales/ko.json
+++ b/dashboard/src/i18n/locales/ko.json
@@ -921,7 +921,8 @@
"toasts": {
"saveFailed": "저장 실패"
},
- "statusLoadError": "현재 인프라 상태를 불러올 수 없습니다. 새로고침 후 다시 시도하세요."
+ "statusLoadError": "현재 인프라 상태를 불러올 수 없습니다. 새로고침 후 다시 시도하세요.",
+ "configLoadError": "저장된 설정을 불러올 수 없어 여기에서 편집할 수 없습니다. 새로고침 후 다시 시도하세요."
},
"plugins": {
"title": "플러그인",
diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.json
index 13c99593e..03db2093e 100644
--- a/dashboard/src/i18n/locales/pt-BR.json
+++ b/dashboard/src/i18n/locales/pt-BR.json
@@ -925,7 +925,8 @@
"invalidFile": "Esse arquivo não é um backup de dados válido do OpenWA.",
"importTooLarge": "O backup excede o limite da requisição. Aumente BODY_SIZE_LIMIT no servidor e tente novamente."
},
- "statusLoadError": "Não foi possível carregar o status atual da infraestrutura. Atualize para tentar novamente."
+ "statusLoadError": "Não foi possível carregar o status atual da infraestrutura. Atualize para tentar novamente.",
+ "configLoadError": "Não foi possível carregar a configuração salva, então ela não pode ser editada aqui. Atualize para tentar novamente."
},
"plugins": {
"title": "Plugins",
diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.json
index 8fade1333..13f2734f0 100644
--- a/dashboard/src/i18n/locales/te.json
+++ b/dashboard/src/i18n/locales/te.json
@@ -921,7 +921,8 @@
"invalidFile": "ఆ ఫైల్ చెల్లుబాటు అయ్యే OpenWA డేటా బ్యాకప్ కాదు.",
"importTooLarge": "బ్యాకప్ అభ్యర్థన పరిమితి కంటే పెద్దది. సర్వర్‌లో BODY_SIZE_LIMIT పెంచి మళ్లీ ప్రయత్నించండి."
},
- "statusLoadError": "ప్రస్తుత ఇన్‌ఫ్రాస్ట్రక్చర్ స్థితిని లోడ్ చేయడం సాధ్యం కాలేదు. మళ్లీ ప్రయత్నించడానికి రిఫ్రెష్ చేయండి."
+ "statusLoadError": "ప్రస్తుత ఇన్‌ఫ్రాస్ట్రక్చర్ స్థితిని లోడ్ చేయడం సాధ్యం కాలేదు. మళ్లీ ప్రయత్నించడానికి రిఫ్రెష్ చేయండి.",
+ "configLoadError": "సేవ్ చేసిన కాన్ఫిగరేషన్‌ను లోడ్ చేయడం సాధ్యం కాలేదు, కాబట్టి దాన్ని ఇక్కడ సవరించలేరు. మళ్లీ ప్రయత్నించడానికి రిఫ్రెష్ చేయండి."
},
"plugins": {
"title": "ప్లగిన్స్",
diff --git a/dashboard/src/i18n/locales/tr.json b/dashboard/src/i18n/locales/tr.json
index ce928c5ee..ad4997788 100644
--- a/dashboard/src/i18n/locales/tr.json
+++ b/dashboard/src/i18n/locales/tr.json
@@ -921,7 +921,8 @@
"toasts": {
"saveFailed": "Kaydetme Başarısız"
},
- "statusLoadError": "Mevcut altyapı durumu yüklenemedi. Yeniden denemek için sayfayı yenileyin."
+ "statusLoadError": "Mevcut altyapı durumu yüklenemedi. Yeniden denemek için sayfayı yenileyin.",
+ "configLoadError": "Kayıtlı yapılandırma yüklenemedi, bu yüzden burada düzenlenemiyor. Yeniden denemek için sayfayı yenileyin."
},
"plugins": {
"title": "Eklentiler",
diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.json
index 6d3680828..fc756e15b 100644
--- a/dashboard/src/i18n/locales/zh-CN.json
+++ b/dashboard/src/i18n/locales/zh-CN.json
@@ -921,7 +921,8 @@
"invalidFile": "该文件不是有效的 OpenWA 数据备份。",
"importTooLarge": "备份超出请求大小限制。请在服务器上调高 BODY_SIZE_LIMIT 后重试。"
},
- "statusLoadError": "无法加载当前基础设施状态。请刷新重试。"
+ "statusLoadError": "无法加载当前基础设施状态。请刷新重试。",
+ "configLoadError": "无法加载已保存的配置,因此无法在此编辑。请刷新重试。"
},
"plugins": {
"title": "插件",
diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.json
index 6d227b03d..33c1894c2 100644
--- a/dashboard/src/i18n/locales/zh-HK.json
+++ b/dashboard/src/i18n/locales/zh-HK.json
@@ -921,7 +921,8 @@
"invalidFile": "該檔案並非有效的 OpenWA 資料備份。",
"importTooLarge": "備份超出請求大小限制。請在伺服器上調高 BODY_SIZE_LIMIT 後重試。"
},
- "statusLoadError": "無法載入目前的基礎設施狀態。請重新整理以重試。"
+ "statusLoadError": "無法載入目前的基礎設施狀態。請重新整理以重試。",
+ "configLoadError": "無法載入已儲存的設定,因此無法在此編輯。請重新整理以重試。"
},
"plugins": {
"title": "外掛",
diff --git a/dashboard/src/pages/Infrastructure.test.ts b/dashboard/src/pages/Infrastructure.test.ts
index 0d7b55f68..d42925941 100644
--- a/dashboard/src/pages/Infrastructure.test.ts
+++ b/dashboard/src/pages/Infrastructure.test.ts
@@ -98,6 +98,8 @@ const SAVED_BAILEYS: SavedConfig = { ...SAVED_CONFIG, engine: { ...SAVED_CONFIG.
// Saved storage differs from the running one — the "saved, awaiting restart" state, with no pin.
const SAVED_STORAGE_DRIFT: SavedConfig = { ...SAVED_CONFIG, storage: { ...SAVED_CONFIG.storage, type: 's3' } };
+const CONFIG_LOAD_ERROR = "Couldn't load the saved configuration, so it can't be edited here. Refresh to try again.";
+
const PENDING_RESTART_NOTE = 'Saved, but not applied yet — restart the server for this change to take effect.';
function jsonResponse(data: unknown, status = 200): Response {
@@ -285,10 +287,27 @@ test('a failed /config read offers no Save, so defaults cannot overwrite the sto
overrides = { savedFails: true };
renderInfrastructure();
- await screen.findByText("Couldn't load the current infrastructure status. Refresh to try again.");
+ await screen.findByText(CONFIG_LOAD_ERROR);
assert.ok(!screen.queryByRole('button', { name: 'Save Configuration' }), 'Save offered without the saved config');
});
+// The backup only reads the running database, so a missing saved config must not take it away.
+test('a failed /config read names the config, and still offers the data backup export and import', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ resetFetchCalls();
+ overrides = { savedFails: true };
+ const { container } = renderInfrastructure();
+
+ await screen.findByText(CONFIG_LOAD_ERROR);
+ assert.ok(
+ !screen.queryByText("Couldn't load the current infrastructure status. Refresh to try again."),
+ 'the status that did load is reported as failed',
+ );
+ assert.ok(container.querySelector('.data-migration-row input[type="file"]'), 'no backup import offered');
+ fireEvent.click(screen.getByRole('button', { name: 'Export data' }));
+ await waitFor(() => assert.ok(findFetchCall('GET', '/api/infra/export-data'), 'the backup export was not requested'));
+});
+
test('the storage badge names local storage in the active language', async () => {
const { screen } = rtl;
resetFetchCalls();
diff --git a/dashboard/src/pages/Infrastructure.tsx b/dashboard/src/pages/Infrastructure.tsx
index b860aabce..cbdfe162c 100644
--- a/dashboard/src/pages/Infrastructure.tsx
+++ b/dashboard/src/pages/Infrastructure.tsx
@@ -98,6 +98,38 @@ export function Infrastructure() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [infraStatus]);
+ // Data backup / restore, used to carry data across a database switch (#488). It reads and writes the
+ // running database only, so it is offered even when the saved config could not be read.
+ const dataBackupRow = (
+ <div className="data-migration-row">
+ <div>
+ <strong>{t('infrastructure.migration.backupTitle')}</strong>
+ <small>{t('infrastructure.migration.backupHint')}</small>
+ </div>
+ <div className="data-migration-actions">
+ <button className="btn-secondary btn-sm" onClick={dataBackup.exportBackup} disabled={dataBackup.migrating}>
+ {dataBackup.migrating ? <Loader2 size={14} className="animate-spin" /> : <Download size={14} />}
+ {t('infrastructure.migration.export')}
+ </button>
+ <label className="btn-secondary btn-sm" style={{ cursor: dataBackup.migrating ? 'default' : 'pointer' }}>
+ <Upload size={14} />
+ {t('infrastructure.migration.import')}
+ <input
+ type="file"
+ accept="application/json,.json"
+ className="hidden-file-input"
+ disabled={dataBackup.migrating}
+ onChange={e => {
+ const file = e.target.files?.[0];
+ if (file) void dataBackup.importBackup(file);
+ e.target.value = '';
+ }}
+ />
+ </label>
+ </div>
+ </div>
+ );
+
if (loading || configLoading) {
return (
<div className="infrastructure-page infra-loading">
@@ -112,16 +144,20 @@ export function Infrastructure() {
// Likewise without the saved config: the database, storage and engine detail fields hydrate only
// from it, and a Save sends every one of them.
if (statusError || !infraStatus || !savedConfig) {
+ const configOnly = !statusError && !!infraStatus;
return (
<div className="infrastructure-page">
<PageHeader title={t('infrastructure.title')} subtitle={t('infrastructure.subtitle')} />
<div className="infra-card status-error-card">
<AlertTriangle size={32} className="status-error-icon" />
- <p className="status-error-text">{t('infrastructure.statusLoadError')}</p>
+ <p className="status-error-text">
+ {t(configOnly ? 'infrastructure.configLoadError' : 'infrastructure.statusLoadError')}
+ </p>
<button className="btn-secondary status-error-retry" onClick={() => window.location.reload()}>
{t('common.retry')}
</button>
</div>
+ {configOnly && <section className="infra-card">{dataBackupRow}</section>}
</div>
);
}
@@ -337,38 +373,7 @@ export function Infrastructure() {
<p className="muted-hint">{t('infrastructure.database.migrationsHint')}</p>
</div>
- {/* Data backup / restore — used to carry data across a database switch (#488). */}
- <div className="data-migration-row">
- <div>
- <strong>{t('infrastructure.migration.backupTitle')}</strong>
- <small>{t('infrastructure.migration.backupHint')}</small>
- </div>
- <div className="data-migration-actions">
- <button
- className="btn-secondary btn-sm"
- onClick={dataBackup.exportBackup}
- disabled={dataBackup.migrating}
- >
- {dataBackup.migrating ? <Loader2 size={14} className="animate-spin" /> : <Download size={14} />}
- {t('infrastructure.migration.export')}
- </button>
- <label className="btn-secondary btn-sm" style={{ cursor: dataBackup.migrating ? 'default' : 'pointer' }}>
- <Upload size={14} />
- {t('infrastructure.migration.import')}
- <input
- type="file"
- accept="application/json,.json"
- className="hidden-file-input"
- disabled={dataBackup.migrating}
- onChange={e => {
- const file = e.target.files?.[0];
- if (file) void dataBackup.importBackup(file);
- e.target.value = '';
- }}
- />
- </label>
- </div>
- </div>
+ {dataBackupRow}
</section>
{/* Engine */}