From d3fecae85fe534c883bbc925ceaaf137902b6921 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 31 Oct 2026 16:22:03 +0100 Subject: [PATCH] feat: hide the contacts directory when the server refuses it, and let users or admins turn it off #1457 --- .../contacts-directory-entry.test.tsx | 90 +++++++++++++++++++ components/contacts/contacts-app.tsx | 18 +++- .../settings-search-anchors.test.tsx | 2 +- components/settings/contacts-settings.tsx | 17 ++++ lib/admin/restriction-keys.ts | 9 ++ lib/settings-search.ts | 1 + locales/ar/common.json | 2 + locales/ca/common.json | 2 + locales/cs/common.json | 2 + locales/da/common.json | 2 + locales/de/common.json | 4 +- locales/en/common.json | 2 + locales/es/common.json | 4 +- locales/et/common.json | 2 + locales/fa/common.json | 2 + locales/fr/common.json | 4 +- locales/he/common.json | 2 + locales/hu/common.json | 2 + locales/it/common.json | 4 +- locales/ja/common.json | 4 +- locales/ko/common.json | 4 +- locales/lv/common.json | 4 +- locales/mn/common.json | 2 + locales/nb/common.json | 2 + locales/nl/common.json | 4 +- locales/pl/common.json | 4 +- locales/pt/common.json | 4 +- locales/ro/common.json | 2 + locales/ru/common.json | 4 +- locales/sk/common.json | 2 + locales/th/common.json | 2 + locales/tr/common.json | 2 + locales/uk/common.json | 4 +- locales/zh-TW/common.json | 2 + locales/zh/common.json | 4 +- stores/settings-store.ts | 5 ++ 36 files changed, 211 insertions(+), 15 deletions(-) create mode 100644 components/contacts/__tests__/contacts-directory-entry.test.tsx diff --git a/components/contacts/__tests__/contacts-directory-entry.test.tsx b/components/contacts/__tests__/contacts-directory-entry.test.tsx new file mode 100644 index 000000000..9e8a07326 --- /dev/null +++ b/components/contacts/__tests__/contacts-directory-entry.test.tsx @@ -0,0 +1,90 @@ +import { act, fireEvent, render, screen } from '@testing-library/react'; +import { afterEach, describe, expect, it, vi } from 'vitest'; +import type { IJMAPClient } from '@/lib/jmap/client-interface'; +import type { DirectoryStatus } from '@/stores/contact-store'; + +// The Directory entry in the Contacts sidebar (#1457): it follows the user's +// setting, and goes away when the server refuses to list its directory. + +vi.mock('next/navigation', () => ({ + useRouter: () => ({ push: vi.fn(), back: vi.fn() }), + useParams: () => ({ locale: 'en' }), + usePathname: () => '/en/contacts', + useSearchParams: () => new URLSearchParams(), +})); +vi.mock('@/components/contacts/contact-activity', () => ({ ContactActivity: () => null })); +vi.mock('@/components/layout/navigation-rail', () => ({ NavigationRail: () =>