Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): title an empty severity-filtered Logs list correctly

Yudhi Armyndhariscf36bf8bb424
diff --git a/dashboard/src/pages/Logs.test.ts b/dashboard/src/pages/Logs.test.ts
index c8ae59e97..7dfea2436 100644
--- a/dashboard/src/pages/Logs.test.ts
+++ b/dashboard/src/pages/Logs.test.ts
@@ -92,6 +92,10 @@ function installFetchStub(): void {
const shifted = [exportRow(-1), ...[...Array(300).keys()].map(exportRow)];
return Promise.resolve(jsonResponse({ data: shifted.slice(offset), total: 301 }));
}
+ // The gateway holds no error rows, so the server-side severity filter matches nothing.
+ if (new URL(url, 'http://localhost').searchParams.get('severity') === 'error') {
+ return Promise.resolve(jsonResponse({ data: [], total: 0 }));
+ }
const reply = jsonResponse({ data: LOGS, total: listTotal ?? LOGS.length });
return firstPageGate && offset === 0 ? firstPageGate.then(() => reply) : Promise.resolve(reply);
}) as typeof fetch;
@@ -300,3 +304,13 @@ test('typing a search on a later page keeps the search box mounted while page on
firstPageGate = null;
}
});
+
+test('a severity filter that matches nothing says no logs exist, not that this page has none', async () => {
+ const { screen, fireEvent } = rtl;
+ renderLogs();
+ await screen.findByText('infra.restart');
+ fireEvent.click(screen.getByRole('button', { name: 'All Severities' }));
+ fireEvent.click(screen.getByRole('option', { name: 'Error' }));
+ await screen.findByText('No logs match these filters. Adjust the severity filter to widen the search.');
+ assert.ok(screen.getByRole('heading', { name: 'No logs found' }));
+});
diff --git a/dashboard/src/pages/Logs.tsx b/dashboard/src/pages/Logs.tsx
index ea8aaedb1..5b587ada3 100644
--- a/dashboard/src/pages/Logs.tsx
+++ b/dashboard/src/pages/Logs.tsx
@@ -199,14 +199,15 @@ export function Logs() {
) : filteredLogs.length === 0 ? (
<div className="empty-table-state">
<FileText size={48} strokeWidth={1} />
- {hasSeverityFilter || hasSearch ? (
+ {hasSeverityFilter && !hasSearch ? (
+ <>
+ <h3>{t('logs.empty.title')}</h3>
+ <p>{t('logs.empty.filteredServerDescription')}</p>
+ </>
+ ) : hasSearch ? (
<>
<h3>{t('logs.empty.filteredTitle')}</h3>
- <p>
- {hasSeverityFilter && !hasSearch
- ? t('logs.empty.filteredServerDescription')
- : t('logs.empty.filteredDescription')}
- </p>
+ <p>{t('logs.empty.filteredDescription')}</p>
</>
) : (
<>