From 60c7efad107d6bff635ef84df4cb72340ed6e71f Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Wed, 4 Nov 2026 12:51:03 +0100 Subject: [PATCH] fix: call the default calendar and address book "Calendar" and "Contacts" everywhere, as Settings does Stalwart names them "Stalwart Calendar (
)" and "Stalwart Address Book ()". Settings already showed plain names; the sidebars, pickers, the event and task editors, invitations, print and confirm texts now use the same helper. A colleague's shared default keeps whose it is. Two test fixtures used Stalwart's default name for a long or own book name and now use a name the user chose, since a default name is no longer shown as is. --- .../calendar/__tests__/calendar-app.test.tsx | 2 +- .../collection-default-names.test.tsx | 78 +++++++++++++++++++ components/calendar/calendar-app.tsx | 8 +- components/calendar/calendar-print.tsx | 10 ++- .../calendar/calendar-sidebar-panel.tsx | 8 +- components/calendar/calendar-toolbar.tsx | 10 ++- components/calendar/event-detail-popover.tsx | 4 +- components/calendar/event-modal.tsx | 4 +- components/calendar/ical-import-modal.tsx | 4 +- components/calendar/quick-create-popover.tsx | 4 +- components/calendar/task-list-view.tsx | 4 +- components/calendar/task-modal.tsx | 4 +- .../contacts/__tests__/contact-form.test.tsx | 4 +- .../contacts/address-book-picker-dialog.tsx | 4 +- components/contacts/contact-form.tsx | 4 +- components/contacts/contacts-app.tsx | 17 ++-- components/contacts/contacts-sidebar.tsx | 7 +- .../email/calendar-invitation-banner.tsx | 4 +- .../booking-calendar-actions.tsx | 4 +- hooks/use-collection-names.ts | 30 +++++++ lib/default-collection-name.ts | 17 ++++ 21 files changed, 196 insertions(+), 35 deletions(-) create mode 100644 components/calendar/__tests__/collection-default-names.test.tsx create mode 100644 hooks/use-collection-names.ts diff --git a/components/calendar/__tests__/calendar-app.test.tsx b/components/calendar/__tests__/calendar-app.test.tsx index 91526ea73..f02537e85 100644 --- a/components/calendar/__tests__/calendar-app.test.tsx +++ b/components/calendar/__tests__/calendar-app.test.tsx @@ -779,7 +779,7 @@ describe('CalendarApp view menu', () => { describe('CalendarApp long names', () => { it('shows the full name of a cut-off calendar on hover', () => { - const long = { ...calendars[0], name: 'Stalwart Calendar (usera@internal.bulwarkmail.org)' }; + const long = { ...calendars[0], name: 'Quarterly planning with the regional sales team (usera@internal.bulwarkmail.org)' }; useCalendarStore.setState({ calendars: [long] } as never); renderApp(); expect(screen.getByTestId('calendar-item').querySelector('[title]')).toHaveAttribute('title', long.name); diff --git a/components/calendar/__tests__/collection-default-names.test.tsx b/components/calendar/__tests__/collection-default-names.test.tsx new file mode 100644 index 000000000..5d6e4c1f8 --- /dev/null +++ b/components/calendar/__tests__/collection-default-names.test.tsx @@ -0,0 +1,78 @@ +import { render, screen } from '@testing-library/react'; +import { describe, it, expect, vi } from 'vitest'; +import { CalendarSidebarPanel } from '../calendar-sidebar-panel'; +import { ContactsSidebar } from '@/components/contacts/contacts-sidebar'; +import { collectionLabel } from '@/lib/default-collection-name'; +import type { AddressBook, Calendar } from '@/lib/jmap/types'; + +// next-intl is mocked globally in vitest.setup: t returns the key. +vi.mock('@/stores/account-store', () => { + const state = { accounts: [], activeAccountId: null }; + const hook = (sel?: (s: typeof state) => unknown) => (typeof sel === 'function' ? sel(state) : state); + hook.getState = () => state; + return { useAccountStore: hook }; +}); + +function cal(overrides: Partial{props.shownCalendars.length > 0 && ( - {t("print.calendars", { names: props.shownCalendars.map((c) => c.name).join(", ") })} + {t("print.calendars", { names: props.shownCalendars.map((c) => shownName.calendar(c)).join(", ") })} )} {props.shownCalendars.length > 0 && ·} {t("print.time_zone", { zone: formatPrintTimeZone(props.timeZone, locale, props.periodDate) })} @@ -632,6 +634,7 @@ function priorityKey(priority: number): string | null { } function TaskListPrint({ tasks, calendars, timeFormat }: { tasks: CalendarTask[]; calendars: Calendar[]; timeFormat: TimeFormat }) { + const shownName = useCollectionNames(); const t = useTranslations("calendar"); const intlFormatter = useDisplayDateFormatter(); if (tasks.length === 0) return
{t("tasks.no_tasks")}
; @@ -659,7 +662,7 @@ function TaskListPrint({ tasks, calendars, timeFormat }: { tasks: CalendarTask[] {done ? "✓" : ""}