Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): show that the Unknown filter's Retry is running

Yudhi Armyndharisf1bde85fe52e
diff --git a/dashboard/src/components/chats/ChatSidebar.test.ts b/dashboard/src/components/chats/ChatSidebar.test.ts
index d30086e59..66bb5702c 100644
--- a/dashboard/src/components/chats/ChatSidebar.test.ts
+++ b/dashboard/src/components/chats/ChatSidebar.test.ts
@@ -2,6 +2,7 @@
import '../../test-helpers/register-hooks.ts';
import { test, before, afterEach } from 'node:test';
import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
import { createElement } from 'react';
import type { UseQueryResult } from '@tanstack/react-query';
import type { Channel, Chat } from '../../services/api.ts';
@@ -133,3 +134,12 @@ test('a channel search with no match says so instead of showing a blank list', (
const { container } = renderSidebar('channels', [], { all: [channel], shown: [] });
assert.equal(container.querySelector('.chats-list-empty')?.textContent, t('chats.empty'));
});
+
+test('a Retry that is running is dimmed and shows the progress cursor', () => {
+ // The button stays focusable while it runs (aria-disabled, not disabled), so only a rule on that attribute
+ // tells a sighted operator it is busy.
+ const css = readFileSync(new URL('../../pages/Chats.css', import.meta.url), 'utf8');
+ const rule = css.match(/\.chats-page \.btn-secondary\[aria-disabled=['"]true['"]\]\s*\{([^}]*)\}/)?.[1] ?? '';
+ assert.match(rule, /opacity:\s*0?\.[0-9]+/);
+ assert.match(rule, /cursor:\s*progress/);
+});
diff --git a/dashboard/src/components/chats/ChatSidebar.tsx b/dashboard/src/components/chats/ChatSidebar.tsx
index 47c5620b4..ee60d9acf 100644
--- a/dashboard/src/components/chats/ChatSidebar.tsx
+++ b/dashboard/src/components/chats/ChatSidebar.tsx
@@ -277,15 +277,17 @@ function ChatSidebar({
<div className="chats-list-empty">
<AlertCircle size={24} className="text-warn" />
<span>{t('chats.newChat.contactsError')}</span>
- {/* aria-disabled, not disabled, so the keyboard stays on the button while the read runs. */}
+ {/* aria-disabled, not disabled, so the keyboard stays on the button while the read runs; Chats.css dims it. */}
<button
type="button"
className="btn-secondary"
aria-disabled={chatsTab.filterError.retrying}
+ aria-busy={chatsTab.filterError.retrying}
onClick={() => {
if (!chatsTab.filterError?.retrying) chatsTab.filterError?.onRetry();
}}
>
+ {chatsTab.filterError.retrying && <Loader2 className="animate-spin" size={16} />}
{t('common.retry')}
</button>
</div>
diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.css
index 6c20aed83..254c22c75 100644
--- a/dashboard/src/pages/Chats.css
+++ b/dashboard/src/pages/Chats.css
@@ -166,6 +166,11 @@
gap: 0.5rem;
}
+.chats-page .btn-secondary[aria-disabled='true'] {
+ opacity: 0.6;
+ cursor: progress;
+}
+
.chats-page .chat-item-card {
display: flex;
align-items: center;
diff --git a/dashboard/src/pages/Chats.features.test.ts b/dashboard/src/pages/Chats.features.test.ts
index 651d4647b..ef305c096 100644
--- a/dashboard/src/pages/Chats.features.test.ts
+++ b/dashboard/src/pages/Chats.features.test.ts
@@ -2486,6 +2486,7 @@ test('the Unknown filter says the address book could not be read, and Retry read
await screen.findByText('Could not load contacts');
assert.ok(!screen.queryByText('No chats match this filter'), 'a failed read was reported as no matching chat');
assert.equal(contactReads().length, 1);
+ assert.equal(screen.getByRole('button', { name: 'Retry' }).querySelector('.animate-spin'), null);
// The retry keeps the keyboard where it was while the read runs, and says it is busy.
failContacts = false;
@@ -2496,6 +2497,9 @@ test('the Unknown filter says the address book could not be read, and Retry read
await waitFor(() => assert.equal(contactReads().length, 2));
assert.equal(document.activeElement === retry, true, `focus is on "${focusedName()}", not on Retry`);
assert.equal(retry.getAttribute('aria-disabled'), 'true');
+ // A sighted operator sees it too: a spinner beside the label, and nothing like it before the press.
+ assert.equal(retry.getAttribute('aria-busy'), 'true');
+ assert.ok(retry.querySelector('.animate-spin'), 'the running retry shows no spinner');
release();
await screen.findByText('Bobby');