-
+
{isEdit ? t("events.edit") : t("events.create")}
-
+
diff --git a/components/calendar/task-modal.tsx b/components/calendar/task-modal.tsx
index 75ea6439a..b6c111697 100644
--- a/components/calendar/task-modal.tsx
+++ b/components/calendar/task-modal.tsx
@@ -226,7 +226,7 @@ export function TaskModal({
{isEdit ? t("tasks.edit") : t("tasks.create")}
-
+
diff --git a/components/command-palette/__tests__/command-palette.test.tsx b/components/command-palette/__tests__/command-palette.test.tsx
index 2bd4fae1e..927e2b174 100644
--- a/components/command-palette/__tests__/command-palette.test.tsx
+++ b/components/command-palette/__tests__/command-palette.test.tsx
@@ -119,6 +119,41 @@ describe('command palette', () => {
expect(hint('search')).toBe('');
});
+ it('shows no single-key hints while single-key shortcuts are off, since those keys do nothing then', async () => {
+ const { useSettingsStore } = await import('@/stores/settings-store');
+ const hint = (label: string) => {
+ const row = screen.getAllByRole('option').find((o) => o.querySelector('.flex-1')?.textContent === label)!;
+ return [...row.querySelectorAll('kbd')].map((k) => k.textContent).join(' ');
+ };
+ useSettingsStore.setState({ singleKeyShortcuts: false });
+ try {
+ render(
);
+ pressCtrlK();
+ expect(hint('compose')).toBe('');
+ expect(hint('shortcuts')).toBe('');
+ } finally {
+ useSettingsStore.setState({ singleKeyShortcuts: true });
+ }
+ });
+
+ it('names the account Sign out leaves, as the account menu does', async () => {
+ const { useAccountStore } = await import('@/stores/account-store');
+ const before = useAccountStore.getState().accounts;
+ useAccountStore.setState({ accounts: [
+ { id: 'a1', email: 'one@example.org', username: 'one@example.org' },
+ { id: 'a2', email: 'two@example.org', username: 'two@example.org' },
+ ] } as never);
+ useAuthStore.setState({ activeAccountId: 'a2' } as never);
+ try {
+ render(
);
+ pressCtrlK();
+ expect(screen.getByText('sign_out_of(two@example.org)')).toBeInTheDocument();
+ expect(screen.queryByText('sign_out')).toBeNull();
+ } finally {
+ useAccountStore.setState({ accounts: before } as never);
+ }
+ });
+
it('shows plugin entries with the plugin name and runs them with Enter', async () => {
act(() => setPluginActions('jira', 'Jira', 'command-palette', [{ id: 'new-issue', label: 'Create issue' }]));
render(
);
diff --git a/components/command-palette/__tests__/mail-palette-commands.test.ts b/components/command-palette/__tests__/mail-palette-commands.test.ts
new file mode 100644
index 000000000..247954e94
--- /dev/null
+++ b/components/command-palette/__tests__/mail-palette-commands.test.ts
@@ -0,0 +1,28 @@
+import { readFileSync } from 'node:fs';
+import path from 'node:path';
+import { describe, expect, it } from 'vitest';
+
+// Mail registers its palette commands in mail-app.tsx, which is too big to render
+// here. Each message action with a key in the shortcuts help is in the palette too,
+// under the key the help names.
+const source = readFileSync(path.join(process.cwd(), 'components/mail/mail-app.tsx'), 'utf8');
+const block = source.slice(source.indexOf("useRegisterCommands(t('sidebar.mail')"));
+
+describe('Mail commands in the palette', () => {
+ it.each([
+ ['reply', 'r'],
+ ['reply-all', 'a'],
+ ['forward', 'f'],
+ ['star', 's'],
+ ['archive', 'e'],
+ ['delete', '#'],
+ ['mark-unread', 'u'],
+ ['mark-read', 'Shift + I'],
+ ['spam', '!'],
+ ])('has %s, shown with %s', (id, key) => {
+ const at = block.indexOf(`id: '${id}'`);
+ expect(at).toBeGreaterThan(-1);
+ const entry = block.slice(at, block.indexOf('}', at));
+ expect(entry).toContain(`shortcut: '${key}'`);
+ });
+});
diff --git a/components/command-palette/command-palette.tsx b/components/command-palette/command-palette.tsx
index 058d4a448..8169769bd 100644
--- a/components/command-palette/command-palette.tsx
+++ b/components/command-palette/command-palette.tsx
@@ -27,6 +27,7 @@ import { useGlobalSearchStore } from "@/stores/global-search-store";
import { useCalendarStore } from "@/stores/calendar-store";
import { usePolicyStore } from "@/stores/policy-store";
import { useThemeStore } from "@/stores/theme-store";
+import { useSettingsStore } from "@/stores/settings-store";
import { usePluginActions } from "@/components/plugins/plugin-actions";
import { usePluginPages, pluginPageHref } from "@/hooks/use-plugin-pages";
import { KeyboardShortcutsModal } from "@/components/keyboard-shortcuts-modal";
@@ -38,7 +39,7 @@ import { commandMatches, useRegisteredCommandGroups } from "@/lib/command-regist
import { shortcutAlternatives } from "@/lib/shortcut-keys";
import { toUnicodeEmail } from "@/lib/idn";
import { isEditableEventTarget, isKeyboardLayerOpen } from "@/lib/keyboard";
-import { isSingleKeyShortcutOff } from "@/lib/single-key-shortcuts";
+import { isSingleKeyHint, isSingleKeyShortcutOff } from "@/lib/single-key-shortcuts";
import { useFocusTrap } from "@/hooks/use-focus-trap";
import { useMediaQuery } from "@/hooks/use-media-query";
import { IconButton } from "@/components/ui/icon-button";
@@ -162,6 +163,9 @@ function CommandPalette({ onClose, onShowShortcuts }: { onClose: () => void; onS
const activeAccountId = useAuthStore((s) => s.activeAccountId);
// A touch screen has no keyboard to use the shortcuts with (R8).
const touch = useMediaQuery("(pointer: coarse)");
+ // With single-key shortcuts off, "r" or "#" does nothing: no hint for it.
+ const singleKeys = useSettingsStore((s) => s.singleKeyShortcuts !== false);
+ const hintKeys = (shortcut: string) => shortcutAlternatives(shortcut).filter((key) => singleKeys || !isSingleKeyHint(key));
const inputRef = useRef
(null);
const dialogRef = useFocusTrap({ isActive: true, onEscape: onClose, restoreFocus: true, initialFocus: () => inputRef.current });
@@ -255,7 +259,16 @@ function CommandPalette({ onClose, onShowShortcuts }: { onClose: () => void; onS
run: () => { void useAuthStore.getState().switchAccount(entry.id); },
});
}
- list.push({ id: "sign-out", group: account, icon: LogOut, label: tSidebar("sign_out"), run: () => { void useAuthStore.getState().logout(); } });
+ // It signs out of the open account only, as the account menu's entry says.
+ const current = accounts.find((entry) => entry.id === activeAccountId);
+ const currentName = current ? toUnicodeEmail(current.email || current.username) : "";
+ list.push({
+ id: "sign-out",
+ group: account,
+ icon: LogOut,
+ label: currentName ? tSidebar("sign_out_of", { account: currentName }) : tSidebar("sign_out"),
+ run: () => { void useAuthStore.getState().logout(); },
+ });
for (const action of pluginActions) {
list.push({
id: `plugin:${action.pluginId}:${action.id}`,
@@ -394,10 +407,10 @@ function CommandPalette({ onClose, onShowShortcuts }: { onClose: () => void; onS
{command.source && (
{command.source}
)}
- {command.shortcut && (
+ {command.shortcut && hintKeys(command.shortcut).length > 0 && (
// Key hints only where there is a keyboard (R8).
- {shortcutAlternatives(command.shortcut).map((key) => (
+ {hintKeys(command.shortcut).map((key) => (
{key}
))}
diff --git a/components/contacts/__tests__/contacts-app.test.tsx b/components/contacts/__tests__/contacts-app.test.tsx
index cd153f9e8..802c8f994 100644
--- a/components/contacts/__tests__/contacts-app.test.tsx
+++ b/components/contacts/__tests__/contacts-app.test.tsx
@@ -182,7 +182,7 @@ describe('ContactsApp', () => {
it('starts a new group with the contact when "Add to group" finds no group to add to', () => {
renderContacts();
fireEvent.contextMenu(screen.getByText('Alice Smith'));
- fireEvent.click(screen.getByText('context_menu.add_to_group'));
+ fireEvent.click(screen.getByText('contacts_add_to_group'));
expect(screen.getByText('groups.members_label (1)')).toBeInTheDocument();
});
@@ -190,11 +190,27 @@ describe('ContactsApp', () => {
const team: ContactCard = { id: 'g-team', kind: 'group', addressBookIds: {}, name: { full: 'Team' }, members: {} };
renderContacts([alice, bob, team]);
fireEvent.contextMenu(screen.getByText('Bob Jones'));
- fireEvent.click(screen.getByText('context_menu.add_to_group'));
+ fireEvent.click(screen.getByText('contacts_add_to_group'));
fireEvent.click(screen.getByText('bulk.new_group'));
expect(screen.getByText('groups.members_label (1)')).toBeInTheDocument();
});
+ it('offers no Edit, Move or Delete for a contact in an address book shared read-only', () => {
+ const shared = { ...alice, addressBookIds: { 'ab-shared': true } };
+ renderContacts([shared, bob]);
+ act(() => {
+ useContactStore.setState({ addressBooks: [{ id: 'ab-shared', name: 'Team', myRights: { mayRead: true, mayWrite: false } }] as never });
+ });
+ fireEvent.contextMenu(screen.getByText('Alice Smith'));
+ expect(screen.queryByRole('menuitem', { name: 'context_menu.edit' })).toBeNull();
+ expect(screen.queryByRole('menuitem', { name: /context_menu.delete/ })).toBeNull();
+ expect(screen.getByRole('menuitem', { name: 'context_menu.export_vcard' })).toBeInTheDocument();
+ fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' });
+
+ fireEvent.contextMenu(screen.getByText('Bob Jones'));
+ expect(screen.getByRole('menuitem', { name: 'context_menu.edit' })).toBeInTheDocument();
+ });
+
it('imports in a real dialog that Escape closes', () => {
renderContacts();
fireEvent.click(screen.getAllByRole('button', { name: 'open_categories' })[0]);
diff --git a/components/contacts/contact-context-menu.tsx b/components/contacts/contact-context-menu.tsx
index 9b6eea288..6281846ca 100644
--- a/components/contacts/contact-context-menu.tsx
+++ b/components/contacts/contact-context-menu.tsx
@@ -65,6 +65,8 @@ interface ContactContextMenuProps {
onBatchExport?: () => void;
onBatchAddToGroup?: () => void;
onBatchDelete?: () => void;
+ /** The contact is in an address book shared read-only: no Edit, Move or Delete. */
+ readOnly?: boolean;
}
export function ContactContextMenu({
@@ -88,8 +90,10 @@ export function ContactContextMenu({
onBatchExport,
onBatchAddToGroup,
onBatchDelete,
+ readOnly = false,
}: ContactContextMenuProps) {
const t = useTranslations("contacts");
+ const tMenu = useTranslations("menuAudit");
const printOff = useStrictestDevices().noPrint;
const email = getContactPrimaryEmail(contact);
const phone = getContactPrimaryPhone(contact);
@@ -134,7 +138,7 @@ export function ContactContextMenu({
onBatchAddToGroup?.())}
disabled={!onBatchAddToGroup}
/>
@@ -179,12 +183,12 @@ export function ContactContextMenu({
onClick={handle(handleCall)}
/>
)}
- {onEdit && }
+ {onEdit && !readOnly && }
{!inDetail && }
{onAddToGroup && (
)}
@@ -195,7 +199,7 @@ export function ContactContextMenu({
onClick={handle(onDuplicate)}
/>
)}
- {onMoveTo && (
+ {onMoveTo && !readOnly && (
)}
{email && (
@@ -225,13 +229,18 @@ export function ContactContextMenu({
onClick={handle(handlePrint)}
/>
)}
-
-
+ {!readOnly && (
+ <>
+
+
+ >
+ )}
);
}
diff --git a/components/contacts/contact-detail.tsx b/components/contacts/contact-detail.tsx
index 77edb2cdc..66a3969e2 100644
--- a/components/contacts/contact-detail.tsx
+++ b/components/contacts/contact-detail.tsx
@@ -35,6 +35,8 @@ interface ContactDetailProps {
onPrint?: () => void;
isMobile?: boolean;
className?: string;
+ /** In an address book shared read-only: no Edit, Move or Delete. */
+ readOnly?: boolean;
}
// Contexts and phone features the contact form offers, shown with the same
@@ -74,7 +76,7 @@ function getCompletedYears(dateInput: AnniversaryDate): number | null {
}
-export function ContactDetail({ contact, onEdit, onDelete, onAddToGroup, onDuplicate, onMoveTo, onCompose, onPrint, isMobile, className }: ContactDetailProps) {
+export function ContactDetail({ contact, onEdit, onDelete, onAddToGroup, onDuplicate, onMoveTo, onCompose, onPrint, isMobile, className, readOnly = false }: ContactDetailProps) {
const t = useTranslations("contacts");
const tCommon = useTranslations("common");
const locale = useLocale();
@@ -173,7 +175,7 @@ export function ContactDetail({ contact, onEdit, onDelete, onAddToGroup, onDupli
)}
{/* A phone's row has no room for this label: the ⋮ fell onto a line of its own. */}
- {isMobile ? (
+ {readOnly ? null : isMobile ? (
@@ -207,6 +209,7 @@ export function ContactDetail({ contact, onEdit, onDelete, onAddToGroup, onDupli
onClose={moreMenu.closeContextMenu}
menuRef={moreMenu.menuRef}
inDetail
+ readOnly={readOnly}
onCompose={onCompose}
onDelete={onDelete}
onAddToGroup={onAddToGroup}
diff --git a/components/contacts/contact-form.tsx b/components/contacts/contact-form.tsx
index 2191820e5..b5390e778 100644
--- a/components/contacts/contact-form.tsx
+++ b/components/contacts/contact-form.tsx
@@ -708,7 +708,7 @@ export function ContactForm({ contact, addressBooks, allKeywords, defaultAddress
{isEditing ? t("edit_title") : t("create_title")}
-
+
diff --git a/components/contacts/contact-list.tsx b/components/contacts/contact-list.tsx
index 6a11b7031..c3eef9c7a 100644
--- a/components/contacts/contact-list.tsx
+++ b/components/contacts/contact-list.tsx
@@ -105,6 +105,8 @@ function ToggleChip({ icon, label, value, onClick }: { icon: React.ReactNode; la
interface ContactListProps {
contacts: ContactCard[];
+ /** A contact in an address book shared read-only: its menu has no Edit, Move or Delete. */
+ isContactReadOnly?: (contact: ContactCard) => boolean;
selectedContactId: string | null;
searchQuery: string;
onSearchChange: (query: string) => void;
@@ -144,6 +146,7 @@ interface ContactListProps {
export function ContactList({
contacts,
+ isContactReadOnly,
selectedContactId,
searchQuery,
onSearchChange,
@@ -788,6 +791,7 @@ export function ContactList({
onBatchExport={onBulkExport}
onBatchAddToGroup={onBulkAddToGroup}
onBatchDelete={onBulkDelete}
+ readOnly={isContactReadOnly?.(contextMenu.data) ?? false}
/>
)}
diff --git a/components/contacts/contacts-app.tsx b/components/contacts/contacts-app.tsx
index a28c84ea1..83e2619d7 100644
--- a/components/contacts/contacts-app.tsx
+++ b/components/contacts/contacts-app.tsx
@@ -487,6 +487,9 @@ function ContactsAppContent({ linkSegments: routeSegments }: ContactsAppProps =
// Address books contacts can be moved to; "Move to…" needs a second one.
const writableBooks = useMemo(() => addressBooks.filter((b) => b.myRights?.mayWrite !== false), [addressBooks]);
const canMoveContacts = !!client && supportsSync && writableBooks.length > 1;
+ // A contact in an address book shared read-only can't be changed: its menus leave out Edit, Move and Delete.
+ const isContactReadOnly = useCallback((contact: ContactCard) => Object.entries(contact.addressBookIds ?? {})
+ .some(([id, inBook]) => inBook && addressBooks.find((b) => b.id === id)?.myRights?.mayWrite === false), [addressBooks]);
const handleMoveContacts = useCallback((ids: string[]) => {
if (ids.length > 0) setMovingContactIds(ids);
}, []);
@@ -1144,6 +1147,7 @@ function ContactsAppContent({ linkSegments: routeSegments }: ContactsAppProps =
onMoveTo={selectedContact && canMoveContacts ? () => handleMoveContacts([selectedContact.id]) : undefined}
onPrint={selectedContact && !printOff ? () => { void printContact(selectedContact); } : undefined}
isMobile={isMobile}
+ readOnly={selectedContact ? isContactReadOnly(selectedContact) : false}
/>
);
}
@@ -1398,6 +1402,7 @@ function ContactsAppContent({ linkSegments: routeSegments }: ContactsAppProps =
) : (