Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): end a long update notice in an ellipsis
Yudhi Armyndharis240fc2e66cc5
diff --git a/dashboard/src/components/Layout.css b/dashboard/src/components/Layout.cssindex 0252b11f9..ad9ef9353 100644--- a/dashboard/src/components/Layout.css+++ b/dashboard/src/components/Layout.css@@ -57,6 +57,10 @@flex-direction: column;overflow: hidden;white-space: nowrap;+ /* The clip reaches 4px past the text, where the update link's focus ring (2px, offset 2px) is drawn; the margin+ takes the padding back, so nothing moves. */+ padding: 4px;+ margin: -4px;}.brand-name {@@ -74,8 +78,14 @@margin-top: 1px;}+/* Beside the collapse button the brand has about 123px: a longer notice (the Telugu one is about 138px) ends in an+ ellipsis instead of being cut silently, and its title and accessible name keep the whole text. */.brand-update {align-self: flex-start;+ max-width: 100%;+ box-sizing: border-box;+ overflow: hidden;+ text-overflow: ellipsis;margin-top: 2px;padding: 1px 6px;border-radius: var(--radius);diff --git a/dashboard/src/components/Layout.css.test.ts b/dashboard/src/components/Layout.css.test.tsindex bab3fdb98..469206310 100644--- a/dashboard/src/components/Layout.css.test.ts+++ b/dashboard/src/components/Layout.css.test.ts@@ -212,3 +212,19 @@ test('no stylesheet asks for the legacy touch overflow scrolling', () => {[],);});++test('a long update notice ends in an ellipsis, and its focus ring is not clipped by the brand', () => {+ const [badge] = find('.brand-update');+ assert.equal(decl(badge.body, 'text-overflow'), 'ellipsis');+ assert.equal(decl(badge.body, 'overflow'), 'hidden');+ assert.equal(decl(badge.body, 'max-width'), '100%');+ // The brand clips what leaves it; its padding has to hold the global ring, outline plus offset, all round.+ const [brand] = find('.sidebar-brand');+ assert.equal(decl(brand.body, 'overflow'), 'hidden');+ const index = readFileSync(join(DIR, '..', 'index.css'), 'utf8');+ const ring = /a:focus-visible[^{]*\{[^}]*outline:\s*(\d+)px[^}]*outline-offset:\s*(\d+)px/.exec(index);+ assert.ok(ring, 'index.css no longer draws the link focus ring');+ const reach = Number(ring[1]) + Number(ring[2]);+ assert.equal(decl(brand.body, 'padding'), `${reach}px`);+ assert.equal(decl(brand.body, 'margin'), `-${reach}px`);+});diff --git a/dashboard/src/components/Layout.test.ts b/dashboard/src/components/Layout.test.tsindex 35d6593f0..b3ad6e17e 100644--- a/dashboard/src/components/Layout.test.ts+++ b/dashboard/src/components/Layout.test.ts@@ -11,6 +11,8 @@ let MemoryRouter: (typeof import('react-router-dom'))['MemoryRouter'];let RoleContext: (typeof import('../hooks/useRole.tsx'))['RoleContext'];// Every URL the layout asked for.const requested: string[] = [];+// What the update check answers, when a test sets it; otherwise it answers 404 like every other route.+let updateCheck: object | null = null;// The window's width in CSS px. A media query sees it as it is; innerWidth is rounded to a whole pixel.let cssWidth = 1024;@@ -78,6 +80,9 @@ before(async () => {})) as unknown as typeof window.matchMedia;globalThis.fetch = ((input: RequestInfo | URL) => {requested.push(String(input));+ if (updateCheck && String(input).includes('/infra/update-check')) {+ return Promise.resolve(new Response(JSON.stringify(updateCheck), { status: 200 }));+ }return Promise.resolve(new Response(JSON.stringify({ message: 'unstubbed' }), { status: 404 }));}) as typeof fetch;const { i18nReady } = await import('../i18n/index.ts');@@ -91,6 +96,7 @@ before(async () => {afterEach(() => {rtl.cleanup();requested.length = 0;+ updateCheck = null;});after(() => rtl.cleanup());@@ -336,6 +342,14 @@ test('an unscoped admin key still checks for a newer release', async () => {await rtl.waitFor(() => assert.ok(requested.some(url => url.includes('/infra/update-check'))));});+// Beside the collapse button a long notice is cut with an ellipsis (Layout.css), so a pointer gets the whole text too.+test('the update notice keeps its whole text in its title as well as its name', async () => {+ updateCheck = { current: '0.26.0', latest: '0.27.0', updateAvailable: true, releaseUrl: 'https://example.test/r' };+ renderLayout();+ const link = await rtl.screen.findByRole('link', { name: 'v0.27.0 available' });+ assert.equal(link.getAttribute('title'), 'v0.27.0 available');+});+// The sidebar offers the Number Checker to every role; a viewer key gets the page with its Check buttons disabled.for (const userRole of ['admin', 'operator', 'viewer'] as const) {test(`the Number Checker is offered to ${userRole} keys`, () => {diff --git a/dashboard/src/components/Layout.tsx b/dashboard/src/components/Layout.tsxindex 48434a289..7b94c57f8 100644--- a/dashboard/src/components/Layout.tsx+++ b/dashboard/src/components/Layout.tsx@@ -232,7 +232,13 @@ export function Layout({ onLogout, userRole }: LayoutProps) {<span className="brand-name">{t('common.appName')}</span><span className="brand-version">v{version}</span>{update && (- <a className="brand-update" href={update.url} target="_blank" rel="noopener noreferrer">+ <a+ className="brand-update"+ href={update.url}+ target="_blank"+ rel="noopener noreferrer"+ title={t('common.updateAvailable', { version: update.latest })}+ >{t('common.updateAvailable', { version: update.latest })}</a>)}