From aee4bd78db8d36e59e20a59d69537875e9f190b7 Mon Sep 17 00:00:00 2001
From: Stefan Hildebrandt <695494+hildebrandttk@users.noreply.github.com>
Date: Mon, 15 Jun 2026 12:01:17 +0200
Subject: [PATCH] feat: add Edit contact button to email viewer contact sidebar
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Clicking an email address in the viewer already shows a contact detail
sidebar. An "Edit" button now appears there (for known contacts) that
navigates directly to the contact edit form via the existing URL-param
intent system (?contactId=…&view=edit), removing the need to open the
Contacts page manually and search for the contact.
---
app/(main)/[locale]/contacts/page.tsx | 3 +-
.../__tests__/contact-sidebar-edit.test.tsx | 106 ++++++++++++++++++
components/email/email-viewer.tsx | 50 ++++++---
locales/cs/common.json | 20 +++-
locales/da/common.json | 20 +++-
locales/de/common.json | 20 +++-
locales/en/common.json | 20 +++-
locales/es/common.json | 20 +++-
locales/fr/common.json | 20 +++-
locales/hu/common.json | 20 +++-
locales/it/common.json | 20 +++-
locales/ja/common.json | 20 +++-
locales/ko/common.json | 20 +++-
locales/lv/common.json | 20 +++-
locales/nl/common.json | 20 +++-
locales/pl/common.json | 20 +++-
locales/pt/common.json | 20 +++-
locales/ru/common.json | 20 +++-
locales/tr/common.json | 20 +++-
locales/uk/common.json | 20 +++-
locales/zh/common.json | 20 +++-
21 files changed, 484 insertions(+), 35 deletions(-)
create mode 100644 components/email/__tests__/contact-sidebar-edit.test.tsx
diff --git a/app/(main)/[locale]/contacts/page.tsx b/app/(main)/[locale]/contacts/page.tsx
index aac399b4..6deb6a47 100644
--- a/app/(main)/[locale]/contacts/page.tsx
+++ b/app/(main)/[locale]/contacts/page.tsx
@@ -173,12 +173,13 @@ export default function ContactsPage() {
const addEmail = searchParams.get('addEmail');
const addName = searchParams.get('addName');
const from = searchParams.get('from');
+ const viewParam = searchParams.get('view');
if (!contactId && !addEmail && !from) return;
intentAppliedRef.current = true;
if (from === 'email') setReturnToEmail(true);
if (contactId) {
setSelectedContact(contactId);
- setView('detail');
+ setView(viewParam === 'edit' ? 'edit' : 'detail');
} else if (addEmail) {
setCreatePrefill({ email: addEmail, name: addName ?? undefined });
setSelectedContact(null);
diff --git a/components/email/__tests__/contact-sidebar-edit.test.tsx b/components/email/__tests__/contact-sidebar-edit.test.tsx
new file mode 100644
index 00000000..d8433779
--- /dev/null
+++ b/components/email/__tests__/contact-sidebar-edit.test.tsx
@@ -0,0 +1,106 @@
+import { render, screen, fireEvent } from '@testing-library/react';
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { ContactSidebarPanel } from '../email-viewer';
+import type { ContactCard } from '@/lib/jmap/types';
+
+const contact: ContactCard = {
+ id: 'c1',
+ addressBookIds: {},
+ name: {
+ components: [
+ { kind: 'given', value: 'Alice' },
+ { kind: 'surname', value: 'Smith' },
+ ],
+ isOrdered: true,
+ },
+ emails: { e0: { address: 'alice@example.com' } },
+};
+
+const unknownEmail = 'unknown@example.com';
+
+describe('ContactSidebarPanel', () => {
+ beforeEach(() => {
+ Object.assign(navigator, {
+ clipboard: { writeText: vi.fn().mockResolvedValue(undefined) },
+ });
+ });
+
+ it('shows Edit button when contact is known and onEditContact is provided', () => {
+ render(
+