Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): name webhook filter enum values in words
Yudhi Armyndharisb9d9dee3a5a8
diff --git a/dashboard/src/components/FilterBuilder.test.ts b/dashboard/src/components/FilterBuilder.test.tsnew file mode 100644index 000000000..ce9906130--- /dev/null+++ b/dashboard/src/components/FilterBuilder.test.ts@@ -0,0 +1,42 @@+// The enum filters offer message types and chat kinds as tags. The values sent are the API's keys;+// the tags must read as words.+import '../test-helpers/register-hooks.ts';+import { test, before, after } from 'node:test';+import assert from 'node:assert/strict';+import { createElement } from 'react';++let rtl: typeof import('@testing-library/react');+let FilterBuilder: (typeof import('./FilterBuilder.tsx'))['FilterBuilder'];++before(async () => {+ const { installJsdomGlobals } = await import('../test-helpers/jsdom.ts');+ await installJsdomGlobals();+ const { i18nReady } = await import('../i18n/index.ts');+ await i18nReady;+ rtl = await import('@testing-library/react');+ ({ FilterBuilder } = await import('./FilterBuilder.tsx'));+});++after(() => rtl.cleanup());++test('enum tags name message types and chat kinds in words', () => {+ const { container } = rtl.render(+ createElement(FilterBuilder, {+ filters: {+ conditions: [+ { field: 'type', operator: 'is', value: [] },+ { field: 'kind', operator: 'is', value: [] },+ ],+ },+ onChange: () => {},+ chats: [],+ }),+ );++ const [types, kinds] = Array.from(container.querySelectorAll('.filter-enum')).map(row =>+ Array.from(row.querySelectorAll('.enum-tag')).map(tag => tag.textContent),+ );+ assert.ok(types.includes('Voice message'), `message type tags: ${types.join(', ')}`);+ assert.ok(types.includes('Hidden 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.tsxindex 4ac40f5bc..7a068b75f 100644--- a/dashboard/src/components/FilterBuilder.tsx+++ b/dashboard/src/components/FilterBuilder.tsx@@ -18,6 +18,8 @@ interface FieldDescriptor {kind: FieldKind;operators: WebhookFilterOperator[];enumValues?: readonly string[];+ /** i18n namespace that names each enum value; the value itself is what the filter sends. */+ enumLabels?: string;}// Mirrors the backend message-family field registry (src/modules/webhook/filters/filter-types.ts).@@ -26,9 +28,15 @@ const MESSAGE_FIELDS: FieldDescriptor[] = [{ field: 'recipient', kind: 'id', operators: ['is', 'isNot'] },{ field: 'chatId', kind: 'id', operators: ['is', 'isNot'] },{ field: 'body', kind: 'text', operators: ['contains', 'equals'] },- { field: 'type', kind: 'enum', operators: ['is', 'isNot'], enumValues: MESSAGE_TYPES },+ {+ field: 'type',+ kind: 'enum',+ operators: ['is', 'isNot'],+ enumValues: MESSAGE_TYPES,+ enumLabels: 'chats.messageType',+ },{ field: 'isGroup', kind: 'boolean', operators: ['is'] },- { field: 'kind', kind: 'enum', operators: ['is', 'isNot'], enumValues: CHAT_KINDS },+ { field: 'kind', kind: 'enum', operators: ['is', 'isNot'], enumValues: CHAT_KINDS, enumLabels: 'chats.kind' },{ field: 'fromMe', kind: 'boolean', operators: ['is'] },{ field: 'hasMedia', kind: 'boolean', operators: ['is'] },{ field: 'mentions', kind: 'idArray', operators: ['is', 'isNot'] },@@ -231,7 +239,7 @@ export function FilterBuilder({ filters, onChange, chats }: FilterBuilderProps)});}}>- {option}+ {t(`${def.enumLabels}.${option}`, { defaultValue: option })}</button>);})}diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.jsonindex 733300a0a..10b2fe926 100644--- a/dashboard/src/i18n/locales/ar.json+++ b/dashboard/src/i18n/locales/ar.json@@ -143,7 +143,9 @@"group": "مجموعة","channel": "قناة","status": "الحالة",- "broadcast": "بث"+ "broadcast": "بث",+ "individual": "فردي",+ "unknown": "غير معروف"},"tab": {"chats": "المحادثات",diff --git a/dashboard/src/i18n/locales/de.json b/dashboard/src/i18n/locales/de.jsonindex 904612c06..beaa8c396 100644--- a/dashboard/src/i18n/locales/de.json+++ b/dashboard/src/i18n/locales/de.json@@ -139,7 +139,9 @@"group": "Gruppe","channel": "Kanal","status": "Status",- "broadcast": "Broadcast"+ "broadcast": "Broadcast",+ "individual": "Einzelchat",+ "unknown": "Unbekannt"},"tab": {"chats": "Chats",diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.jsonindex d96270e87..7a3936215 100644--- a/dashboard/src/i18n/locales/en.json+++ b/dashboard/src/i18n/locales/en.json@@ -139,7 +139,9 @@"group": "Group","channel": "Channel","status": "Status",- "broadcast": "Broadcast"+ "broadcast": "Broadcast",+ "individual": "Individual",+ "unknown": "Unknown"},"tab": {"chats": "Chats",diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.jsonindex 484d7102a..a8fc20218 100644--- a/dashboard/src/i18n/locales/es.json+++ b/dashboard/src/i18n/locales/es.json@@ -140,7 +140,9 @@"group": "Grupo","channel": "Canal","status": "Estado",- "broadcast": "Difusión"+ "broadcast": "Difusión",+ "individual": "Individual",+ "unknown": "Desconocido"},"tab": {"chats": "Chats",diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.jsonindex 9092d9771..2488c6c86 100644--- a/dashboard/src/i18n/locales/fr.json+++ b/dashboard/src/i18n/locales/fr.json@@ -140,7 +140,9 @@"group": "Groupe","channel": "Chaîne","status": "Statut",- "broadcast": "Diffusion"+ "broadcast": "Diffusion",+ "individual": "Individuel",+ "unknown": "Inconnu"},"tab": {"chats": "Discussions",diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.jsonindex 2c1c1ed8a..56890a05a 100644--- a/dashboard/src/i18n/locales/he.json+++ b/dashboard/src/i18n/locales/he.json@@ -141,7 +141,9 @@"group": "קבוצה","channel": "ערוץ","status": "סטטוס",- "broadcast": "שידור"+ "broadcast": "שידור",+ "individual": "פרטי",+ "unknown": "לא ידוע"},"tab": {"chats": "שיחות",diff --git a/dashboard/src/i18n/locales/hi.json b/dashboard/src/i18n/locales/hi.jsonindex ece82b0e7..763a5fca1 100644--- a/dashboard/src/i18n/locales/hi.json+++ b/dashboard/src/i18n/locales/hi.json@@ -139,7 +139,9 @@"group": "समूह","channel": "चैनल","status": "स्टेटस",- "broadcast": "प्रसारण"+ "broadcast": "प्रसारण",+ "individual": "व्यक्तिगत",+ "unknown": "अज्ञात"},"tab": {"chats": "चैट्स",diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.jsonindex 51cf7529d..74ea57e6d 100644--- a/dashboard/src/i18n/locales/it.json+++ b/dashboard/src/i18n/locales/it.json@@ -140,7 +140,9 @@"group": "Gruppo","channel": "Canale","status": "Stato",- "broadcast": "Trasmissione"+ "broadcast": "Trasmissione",+ "individual": "Individuale",+ "unknown": "Sconosciuto"},"tab": {"chats": "Chat",diff --git a/dashboard/src/i18n/locales/ko.json b/dashboard/src/i18n/locales/ko.jsonindex 5fa04dd5a..9e42ae5a4 100644--- a/dashboard/src/i18n/locales/ko.json+++ b/dashboard/src/i18n/locales/ko.json@@ -139,7 +139,9 @@"group": "그룹","channel": "채널","status": "상태",- "broadcast": "브로드캐스트"+ "broadcast": "브로드캐스트",+ "individual": "개인",+ "unknown": "알 수 없음"},"tab": {"chats": "채팅",diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.jsonindex 9c901feab..190444e4f 100644--- a/dashboard/src/i18n/locales/pt-BR.json+++ b/dashboard/src/i18n/locales/pt-BR.json@@ -140,7 +140,9 @@"group": "Grupo","channel": "Canal","status": "Status",- "broadcast": "Transmissão"+ "broadcast": "Transmissão",+ "individual": "Individual",+ "unknown": "Desconhecido"},"tab": {"chats": "Chats",diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.jsonindex 84316774e..653919a09 100644--- a/dashboard/src/i18n/locales/te.json+++ b/dashboard/src/i18n/locales/te.json@@ -139,7 +139,9 @@"group": "సమూహం","channel": "ఛానెల్","status": "స్థితి",- "broadcast": "ప్రసారం"+ "broadcast": "ప్రసారం",+ "individual": "వ్యక్తిగత",+ "unknown": "తెలియనిది"},"tab": {"chats": "చాట్లు",diff --git a/dashboard/src/i18n/locales/tr.json b/dashboard/src/i18n/locales/tr.jsonindex 9f9277d15..f1ebb6b74 100644--- a/dashboard/src/i18n/locales/tr.json+++ b/dashboard/src/i18n/locales/tr.json@@ -139,7 +139,9 @@"group": "Grup","channel": "Kanal","status": "Durum",- "broadcast": "Toplu Mesaj Listesi"+ "broadcast": "Toplu Mesaj Listesi",+ "individual": "Bireysel",+ "unknown": "Bilinmiyor"},"tab": {"chats": "Sohbetler",diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.jsonindex a2819f105..86a430c90 100644--- a/dashboard/src/i18n/locales/zh-CN.json+++ b/dashboard/src/i18n/locales/zh-CN.json@@ -139,7 +139,9 @@"group": "群组","channel": "频道","status": "状态",- "broadcast": "广播"+ "broadcast": "广播",+ "individual": "个人",+ "unknown": "未知"},"tab": {"chats": "聊天",diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.jsonindex 647d83113..00aa941dd 100644--- a/dashboard/src/i18n/locales/zh-HK.json+++ b/dashboard/src/i18n/locales/zh-HK.json@@ -139,7 +139,9 @@"group": "群組","channel": "頻道","status": "狀態",- "broadcast": "廣播"+ "broadcast": "廣播",+ "individual": "個人",+ "unknown": "未知"},"tab": {"chats": "聊天",