Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): style the session detail status for every status
Yudhi Armyndharis79fbb4088302
diff --git a/dashboard/src/pages/Sessions.css b/dashboard/src/pages/Sessions.cssindex d152aa6c6..76c511da6 100644--- a/dashboard/src/pages/Sessions.css+++ b/dashboard/src/pages/Sessions.css@@ -642,7 +642,8 @@}}-/* Status Pill for Card Headers */+/* Status Pill for Card Headers. The detail modal's .status-badge takes the same tint for each status below+ (disconnected keeps its own grey above). */.sessions-page .status-pill {display: inline-flex;padding: 0.25rem 0.75rem;@@ -653,19 +654,23 @@}.sessions-page .status-pill.created,-.sessions-page .status-pill.idle {+.sessions-page .status-pill.idle,+.sessions-page .status-badge.created {background: rgba(107, 114, 128, 0.1);color: var(--text-secondary);}.sessions-page .status-pill.initializing,.sessions-page .status-pill.connecting,-.sessions-page .status-pill.authenticating {+.sessions-page .status-pill.authenticating,+.sessions-page .status-badge.initializing,+.sessions-page .status-badge.authenticating {background: rgba(234, 179, 8, 0.1);color: var(--warning-text);}-.sessions-page .status-pill.qr_ready {+.sessions-page .status-pill.qr_ready,+.sessions-page .status-badge.qr_ready {background: rgba(59, 130, 246, 0.1);color: var(--info);}@@ -673,18 +678,21 @@/* Same amber token as the transient states above — a literal here was the only pill not on a themevariable, and it lost contrast on the dark card. The heavier tint is what separates "needs a human"from the in-progress amber, since the two must not read alike. */-.sessions-page .status-pill.action_required {+.sessions-page .status-pill.action_required,+.sessions-page .status-badge.action_required {background: rgba(245, 158, 11, 0.22);color: var(--warning-text);}-.sessions-page .status-pill.ready {+.sessions-page .status-pill.ready,+.sessions-page .status-badge.ready {background: rgba(34, 197, 94, 0.1);color: var(--success-text);}.sessions-page .status-pill.disconnected,-.sessions-page .status-pill.failed {+.sessions-page .status-pill.failed,+.sessions-page .status-badge.failed {background: rgba(239, 68, 68, 0.1);color: var(--error-text);}diff --git a/dashboard/src/pages/Sessions.css.test.ts b/dashboard/src/pages/Sessions.css.test.tsnew file mode 100644index 000000000..63e7294f7--- /dev/null+++ b/dashboard/src/pages/Sessions.css.test.ts@@ -0,0 +1,50 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { readFileSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { dirname, join } from 'node:path';+import ts from 'typescript';++// The session detail modal renders `status-badge <status>` and a session card renders `status-pill <status>`, both+// with the live status as the second class. A status without a rule renders as plain text: the badge once styled+// only the retired names connected, disconnected and connecting, so a ready session showed no green pill and a+// failed one looked the same.++const SRC = join(dirname(fileURLToPath(import.meta.url)), '..');++// The members of the `status` union of the Session interface, read from the API types.+function sessionStatuses(): string[] {+ const file = join(SRC, 'services/api.ts');+ const source = ts.createSourceFile(file, readFileSync(file, 'utf8'), ts.ScriptTarget.Latest, true);+ const found: string[] = [];+ const walk = (node: ts.Node): void => {+ if (ts.isInterfaceDeclaration(node) && node.name.text === 'Session') {+ for (const member of node.members) {+ if (ts.isPropertySignature(member) && member.name.getText() === 'status' && member.type) {+ const union = member.type;+ if (ts.isUnionTypeNode(union)) {+ for (const t of union.types)+ if (ts.isLiteralTypeNode(t) && ts.isStringLiteral(t.literal)) found.push(t.literal.text);+ }+ }+ }+ }+ ts.forEachChild(node, walk);+ };+ walk(source);+ return found;+}++const css = readFileSync(join(SRC, 'pages/Sessions.css'), 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');+const selectors = new Set(+ [...css.matchAll(/([^{}]+)\{[^{}]*\}/g)].flatMap(m => m[1].split(',').map(s => s.trim().replace(/\s+/g, ' '))),+);++test('the session detail badge and the card pill are styled for every session status', () => {+ const statuses = sessionStatuses();+ assert.ok(statuses.includes('ready') && statuses.includes('action_required'), `read only ${statuses.join(', ')}`);+ const missing = ['status-badge', 'status-pill'].flatMap(kind =>+ statuses.filter(status => !selectors.has(`.sessions-page .${kind}.${status}`)).map(status => `${kind}.${status}`),+ );+ assert.deepEqual(missing, []);+});