Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): label the unknown message type as Unknown

Yudhi Armyndharisb4baa336e76d
diff --git a/dashboard/src/components/DashboardCharts.test.ts b/dashboard/src/components/DashboardCharts.test.ts
index 80c716d02..159577544 100644
--- a/dashboard/src/components/DashboardCharts.test.ts
+++ b/dashboard/src/components/DashboardCharts.test.ts
@@ -51,6 +51,6 @@ test('the by-type pie legend names message types in words', async () => {
const card = (await rtl.screen.findByText('Messages by type')).closest('.chart-card') as HTMLElement;
await rtl.waitFor(() => {
const legend = Array.from(card.querySelectorAll('.recharts-legend-item-text')).map(n => n.textContent);
- assert.deepEqual(legend.sort(), ['Hidden message', 'Message', 'Voice message']);
+ assert.deepEqual(legend.sort(), ['Hidden message', 'Unknown', 'Voice message']);
});
});
diff --git a/dashboard/src/components/DashboardCharts.tsx b/dashboard/src/components/DashboardCharts.tsx
index 62e6626a6..52ba4442b 100644
--- a/dashboard/src/components/DashboardCharts.tsx
+++ b/dashboard/src/components/DashboardCharts.tsx
@@ -68,9 +68,12 @@ export function DashboardCharts() {
if (isError && forbidden) return null;
const timeSeries = (data?.timeSeries ?? []).map(p => ({ ...p, label: formatTick(p.timestamp, period) }));
- // `name` keys the slice color; `label` is what the legend and tooltip show.
+ // `name` keys the slice color; `label` is what the legend and tooltip show. The `unknown` bucket
+ // reads "Unknown", not the chat bubble's generic "Message" placeholder.
+ const typeLabel = (name: string) =>
+ t(name === 'unknown' ? 'chats.kind.unknown' : `chats.messageType.${name}`, { defaultValue: name });
const byType = Object.entries(data?.byType ?? {})
- .map(([name, value]) => ({ name, label: t(`chats.messageType.${name}`, { defaultValue: name }), value }))
+ .map(([name, value]) => ({ name, label: typeLabel(name), value }))
.sort((a, b) => b.value - a.value);
const topChats = (data?.topChats ?? [])
.slice(0, 8)
diff --git a/dashboard/src/components/FilterBuilder.test.ts b/dashboard/src/components/FilterBuilder.test.ts
index ce9906130..58575e24b 100644
--- a/dashboard/src/components/FilterBuilder.test.ts
+++ b/dashboard/src/components/FilterBuilder.test.ts
@@ -38,5 +38,8 @@ test('enum tags name message types and chat kinds in words', () => {
);
assert.ok(types.includes('Voice message'), `message type tags: ${types.join(', ')}`);
assert.ok(types.includes('Hidden message'), `message type tags: ${types.join(', ')}`);
+ // The unclassified bucket is not "any message"; it reads like the unknown chat kind.
+ assert.ok(types.includes('Unknown'), `message type tags: ${types.join(', ')}`);
+ assert.ok(!types.includes('Message'), `message type tags: ${types.join(', ')}`);
assert.deepEqual(kinds, ['Individual', 'Group', 'Channel', 'Status', 'Broadcast', 'Unknown']);
});
diff --git a/dashboard/src/components/FilterBuilder.tsx b/dashboard/src/components/FilterBuilder.tsx
index 7a068b75f..24b1886fd 100644
--- a/dashboard/src/components/FilterBuilder.tsx
+++ b/dashboard/src/components/FilterBuilder.tsx
@@ -239,7 +239,11 @@ export function FilterBuilder({ filters, onChange, chats }: FilterBuilderProps)
});
}}
>
- {t(`${def.enumLabels}.${option}`, { defaultValue: option })}
+ {/* An `unknown` type reads "Unknown" like the unknown chat kind, not the chat
+ bubble's generic "Message" placeholder. */}
+ {t(option === 'unknown' ? 'chats.kind.unknown' : `${def.enumLabels}.${option}`, {
+ defaultValue: option,
+ })}
</button>
);
})}