mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-17 16:19:13 +00:00
Merge branch 'feat/desktop-offline' into feat/do-files-sync
This commit is contained in:
+26
-2
@@ -313,6 +313,18 @@ optgroup {
|
||||
background-color: var(--color-muted-foreground);
|
||||
}
|
||||
|
||||
/* The folded folder column (components/layout/sidebar.tsx) leaves its 48px
|
||||
to the icons: a 4px scrollbar, in a gutter kept on both sides. */
|
||||
:root:not([data-native-scrollbars="on"]) [data-folder-rail]::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
@supports not selector(::-webkit-scrollbar) {
|
||||
:root:not([data-native-scrollbars="on"]) [data-folder-rail] {
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
}
|
||||
|
||||
/* Enhanced Email Content Styling */
|
||||
|
||||
.email-content-wrapper {
|
||||
@@ -617,8 +629,9 @@ optgroup {
|
||||
--titlebar-right-inset: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw));
|
||||
--titlebar-left-inset: env(titlebar-area-x, 0px);
|
||||
--titlebar-row-height: env(titlebar-area-height, 0px);
|
||||
/* Where a drawer from the window's edge starts (the folder drawer): under
|
||||
the top bar, and under the window's controls when they are over the page. */
|
||||
/* Where a drawer from the window's edge starts (Mail's folders, the
|
||||
Calendar, Contacts and Files sidebars): under the top bar, and under the
|
||||
window's controls when they are over the page. */
|
||||
--drawer-top: max(var(--app-top-inset), var(--titlebar-row-height));
|
||||
}
|
||||
|
||||
@@ -627,6 +640,17 @@ html[data-window-controls] [data-window-row-right] {
|
||||
padding-right: calc(var(--titlebar-right-inset) + 0.5rem) !important;
|
||||
}
|
||||
|
||||
/*
|
||||
* The composer's header runs over its plugin panels. The head above the panel at the
|
||||
* window's right takes that room inside itself, so it stays as wide as the panel and
|
||||
* its Hide button stays at the panel's edge, with its window buttons left of the controls.
|
||||
*/
|
||||
html[data-window-controls]:not([dir="rtl"]) [data-window-row-right] > [data-composer-panel-head="right"],
|
||||
html[data-window-controls][dir="rtl"] [data-window-row-right] > [data-composer-panel-head="left"] {
|
||||
margin-right: calc(-1 * (var(--titlebar-right-inset) + 0.5rem));
|
||||
padding-right: calc(var(--titlebar-right-inset) + 0.5rem);
|
||||
}
|
||||
|
||||
/* Something floating at the top end of a page with no row: next to the controls, lined up. */
|
||||
html[data-window-controls]:not([dir="rtl"]) [data-window-beside-controls] {
|
||||
right: calc(var(--titlebar-right-inset) + 0.5rem);
|
||||
|
||||
@@ -866,3 +866,56 @@ describe('CalendarApp company calendars on a phone', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Below the full desktop the sidebar is the same drawer as Mail's folders
|
||||
// (usability test 2026-11-04): from the window's edge, the page dimmed,
|
||||
// Escape closes it, and the focus goes in and back to the menu button.
|
||||
describe('CalendarApp sidebar drawer', () => {
|
||||
beforeEach(() => {
|
||||
media.desktop = false;
|
||||
});
|
||||
|
||||
const drawer = () => screen.getByTestId('calendar-sidebar-drawer');
|
||||
const menu = () => screen.getByRole('button', { name: 'nav_open_menu' });
|
||||
|
||||
it("opens from the window's edge, over the app rail and under the top bar", () => {
|
||||
renderApp();
|
||||
const classes = drawer().className.split(/\s+/);
|
||||
expect(classes).toEqual(expect.arrayContaining(['fixed', 'start-0', 'top-[var(--drawer-top)]', 'bottom-0']));
|
||||
expect(classes).not.toContain('absolute');
|
||||
});
|
||||
|
||||
it("is out of reach while closed, so Tab doesn't walk into the hidden calendars", () => {
|
||||
renderApp();
|
||||
expect(drawer()).toHaveAttribute('inert');
|
||||
fireEvent.click(menu());
|
||||
expect(drawer()).not.toHaveAttribute('inert');
|
||||
});
|
||||
|
||||
it('takes the focus in, keeps Tab there and gives it back to the menu button on Escape', () => {
|
||||
renderApp();
|
||||
menu().focus();
|
||||
fireEvent.click(menu());
|
||||
expect(drawer().contains(document.activeElement)).toBe(true);
|
||||
const stops = Array.from(drawer().querySelectorAll<HTMLElement>('button:not(:disabled)'));
|
||||
stops.at(-1)!.focus();
|
||||
fireEvent.keyDown(stops.at(-1)!, { key: 'Tab' });
|
||||
expect(document.activeElement).toBe(stops[0]);
|
||||
|
||||
fireEvent.keyDown(document.activeElement!, { key: 'Escape' });
|
||||
expect(drawer()).toHaveAttribute('inert');
|
||||
expect(document.activeElement).toBe(menu());
|
||||
});
|
||||
|
||||
it('closes on a click on the dimmed window and gives the focus back to the menu button', () => {
|
||||
renderApp();
|
||||
menu().focus();
|
||||
fireEvent.click(menu());
|
||||
const scrim = screen.getByTestId('drawer-scrim');
|
||||
expect(scrim.className.split(/\s+/)).toEqual(expect.arrayContaining(['fixed', 'inset-0']));
|
||||
(document.activeElement as HTMLElement).blur();
|
||||
fireEvent.click(scrim);
|
||||
expect(drawer()).toHaveAttribute('inert');
|
||||
expect(document.activeElement).toBe(menu());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -60,6 +60,7 @@ import { useIsFocusedProTab, useIsPaneScoped } from "@/hooks/use-pane-context";
|
||||
import { useProMultiAccountCalendars } from "@/hooks/use-pro-multi-account-calendars";
|
||||
import { useEventUserEmails } from "@/hooks/use-event-user-emails";
|
||||
import { ResizeHandle } from "@/components/layout/resize-handle";
|
||||
import { EdgeDrawer } from "@/components/layout/edge-drawer";
|
||||
import { descriptionWithNote } from "@/lib/calendar-description";
|
||||
import { filterTasksByCalendars } from "@/lib/calendar-tasks";
|
||||
import { baseEventStoreId, isServerRecurrenceInstance } from "@/lib/recurrence-instances";
|
||||
@@ -183,6 +184,7 @@ export function CalendarApp({ linkSegments: routeSegments }: CalendarAppProps =
|
||||
// collapses into a burger-toggled overlay instead of taking inline space.
|
||||
const isNarrow = !isFullDesktop;
|
||||
const [narrowSidebarOpen, setNarrowSidebarOpen] = useState(false);
|
||||
const closeNarrowSidebar = useCallback(() => setNarrowSidebarOpen(false), []);
|
||||
useEffect(() => { if (!isNarrow) setNarrowSidebarOpen(false); }, [isNarrow]);
|
||||
const { showAppsModal, inlineApp, loadedApps, handleManageApps, handleInlineApp, closeInlineApp, closeAppsModal } = useSidebarApps();
|
||||
const { client, isAuthenticated, logout, checkAuth, switchAccount, activeAccountId, isLoading: authLoading } = useAuthStore();
|
||||
@@ -2218,6 +2220,97 @@ export function CalendarApp({ linkSegments: routeSegments }: CalendarAppProps =
|
||||
/>
|
||||
);
|
||||
|
||||
// The sidebar's content: beside the views on the full desktop, a drawer below it.
|
||||
const calendarSidebar = (
|
||||
<>
|
||||
<CalendarSidebarHeader
|
||||
onCreateEvent={() => { setNarrowSidebarOpen(false); openCreateForView(); }}
|
||||
createLabel={createLabel}
|
||||
tourTarget={!isNarrow}
|
||||
/>
|
||||
<div className="flex-1 overflow-y-auto overflow-x-hidden py-3">
|
||||
<div className="px-3">
|
||||
<MiniCalendar
|
||||
selectedDate={selectedDate}
|
||||
displayMonth={miniMonth}
|
||||
onSelectDate={handleMiniCalendarSelect}
|
||||
onChangeMonth={handleMiniMonthChange}
|
||||
events={events}
|
||||
firstDayOfWeek={firstDayOfWeek}
|
||||
showWeekNumbers={showWeekNumbers}
|
||||
/>
|
||||
</div>
|
||||
<CalendarSidebarPanel
|
||||
calendars={allCalendars}
|
||||
selectedCalendarIds={shownCalendarIds}
|
||||
onToggleVisibility={toggleShownCalendar}
|
||||
onColorChange={client ? (calendarId, color) => {
|
||||
if (calendarId === BIRTHDAY_CALENDAR_ID) {
|
||||
updateSetting('birthdayCalendarColor', color);
|
||||
return;
|
||||
}
|
||||
// Shared calendars: recolor locally only (the viewer usually
|
||||
// can't write the owner's calendar, and it'd recolor it for
|
||||
// everyone). Personal calendars write through to the server.
|
||||
const cal = allCalendars.find((c) => c.id === calendarId);
|
||||
if (cal?.isShared) {
|
||||
setSharedCalendarColor(sharedCalendarColorKey(cal), color);
|
||||
return;
|
||||
}
|
||||
updateCalendar(client, calendarId, { color });
|
||||
} : undefined}
|
||||
onResetColor={(cal) => {
|
||||
// Drop the local override. A calendar with a server color goes
|
||||
// back to it; one without gets a fresh unused color from the
|
||||
// auto-assign effect (so it never reverts to a collision).
|
||||
removeSharedCalendarColor(sharedCalendarColorKey(cal));
|
||||
}}
|
||||
onShareCalendar={client ? (cal) => setSharingCalendarId(cal.id) : undefined}
|
||||
onCreateEvent={(cal: Calendar) => {
|
||||
setDefaultCalendarIdForCreate(cal.id);
|
||||
openCreateModal();
|
||||
}}
|
||||
onClearCalendar={client ? async (cal: Calendar) => {
|
||||
const ok = await confirmAction({
|
||||
title: tMgmt("clear_events"),
|
||||
message: tMgmt("confirm_clear", { name: shownName.calendar(cal) }),
|
||||
variant: "destructive",
|
||||
confirmText: tMgmt("clear_events"),
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
const count = await clearCalendarEvents(client, cal.id);
|
||||
toast.success(tMgmt("events_cleared", { count }));
|
||||
} catch (err) {
|
||||
// The store rethrows the server's reason (#434).
|
||||
toast.error(err instanceof Error && err.message ? err.message : tMgmt("error_clear"));
|
||||
}
|
||||
} : undefined}
|
||||
onDeleteCalendar={client ? async (cal: Calendar) => {
|
||||
const ok = await confirmAction({
|
||||
title: tMgmt("delete"),
|
||||
message: tMgmt("confirm_delete", { name: shownName.calendar(cal) }),
|
||||
variant: "destructive",
|
||||
confirmText: tMgmt("delete"),
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
await removeCalendar(client, cal.id);
|
||||
toast.success(tMgmt("calendar_deleted"));
|
||||
} catch {
|
||||
toast.error(tMgmt("error_delete"));
|
||||
}
|
||||
} : undefined}
|
||||
onCreateCalendar={client ? () => setShowCreateCalendar(true) : undefined}
|
||||
onSubscribe={canSubscribe ? () => setShowSubscriptionModal(true) : undefined}
|
||||
onEditSubscription={(subId) => setEditingSubscription(subId)}
|
||||
client={client}
|
||||
multiAccountMode={multiAccountEnabled && accountClients.length > 1}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={cn("flex flex-col overflow-hidden pt-[var(--app-top-inset)]", mvShell ? "bg-[var(--mv-canvas)]" : "bg-background", isEmbedded ? "h-full" : "h-dvh")}>
|
||||
{!isEmbedded && <SkipLink>{tShell("skip_to_content")}</SkipLink>}
|
||||
@@ -2253,138 +2346,49 @@ export function CalendarApp({ linkSegments: routeSegments }: CalendarAppProps =
|
||||
<InlineAppView apps={loadedApps} activeAppId={inlineApp!.id} onClose={closeInlineApp} className="flex-1" />
|
||||
)}
|
||||
|
||||
{/* Narrow-pane backdrop: dim and close overlay sidebar */}
|
||||
{isNarrow && narrowSidebarOpen && !inlineApp && (
|
||||
<div
|
||||
className={cn(
|
||||
"inset-0 bg-black/50 z-40",
|
||||
isEmbedded ? "absolute" : "fixed"
|
||||
)}
|
||||
onClick={() => setNarrowSidebarOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!inlineApp && (
|
||||
<div className="flex flex-col flex-1 min-w-0 min-h-0">
|
||||
<div className="flex flex-1 min-w-0 min-h-0">
|
||||
{/* Sidebar - in-flow when desktop pane, overlay when narrow */}
|
||||
{(isNarrow || !sidebarCollapsed) && (
|
||||
{/* The sidebar: in flow on the full desktop; below it a drawer from
|
||||
the window's edge, over the app rail, as Mail's folders. */}
|
||||
{isNarrow && (
|
||||
<EdgeDrawer
|
||||
open={narrowSidebarOpen}
|
||||
onClose={closeNarrowSidebar}
|
||||
contained={isEmbedded || mvShell}
|
||||
// A closed drawer is off-screen: not a pane for F6.
|
||||
data-pane={narrowSidebarOpen ? "sidebar" : undefined}
|
||||
data-testid="calendar-sidebar-drawer"
|
||||
className="border-e border-border bg-secondary overflow-hidden"
|
||||
>
|
||||
{calendarSidebar}
|
||||
</EdgeDrawer>
|
||||
)}
|
||||
{!isNarrow && !sidebarCollapsed && (
|
||||
<>
|
||||
<div
|
||||
// A closed drawer is off-screen: not a pane for F6.
|
||||
data-pane={!isNarrow || narrowSidebarOpen ? "sidebar" : undefined}
|
||||
data-pane="sidebar"
|
||||
className={cn(
|
||||
"border-e border-border bg-secondary flex flex-col overflow-hidden flex-shrink-0",
|
||||
!isResizing && "transition-[width] duration-300",
|
||||
isNarrow && cn(
|
||||
"absolute inset-y-0 start-0 z-50 w-72 pt-[var(--app-top-inset)]",
|
||||
"transform transition-transform duration-300 ease-in-out",
|
||||
!narrowSidebarOpen && "-translate-x-full rtl:translate-x-full"
|
||||
)
|
||||
)}
|
||||
style={isNarrow ? undefined : { width: `${calSidebarWidth}px` }}
|
||||
style={{ width: `${calSidebarWidth}px` }}
|
||||
>
|
||||
<CalendarSidebarHeader
|
||||
onCreateEvent={() => { setNarrowSidebarOpen(false); openCreateForView(); }}
|
||||
createLabel={createLabel}
|
||||
tourTarget={!isNarrow}
|
||||
/>
|
||||
<div className="flex-1 overflow-y-auto overflow-x-hidden py-3">
|
||||
<div className="px-3">
|
||||
<MiniCalendar
|
||||
selectedDate={selectedDate}
|
||||
displayMonth={miniMonth}
|
||||
onSelectDate={handleMiniCalendarSelect}
|
||||
onChangeMonth={handleMiniMonthChange}
|
||||
events={events}
|
||||
firstDayOfWeek={firstDayOfWeek}
|
||||
showWeekNumbers={showWeekNumbers}
|
||||
/>
|
||||
</div>
|
||||
<CalendarSidebarPanel
|
||||
calendars={allCalendars}
|
||||
selectedCalendarIds={shownCalendarIds}
|
||||
onToggleVisibility={toggleShownCalendar}
|
||||
onColorChange={client ? (calendarId, color) => {
|
||||
if (calendarId === BIRTHDAY_CALENDAR_ID) {
|
||||
updateSetting('birthdayCalendarColor', color);
|
||||
return;
|
||||
}
|
||||
// Shared calendars: recolor locally only (the viewer usually
|
||||
// can't write the owner's calendar, and it'd recolor it for
|
||||
// everyone). Personal calendars write through to the server.
|
||||
const cal = allCalendars.find((c) => c.id === calendarId);
|
||||
if (cal?.isShared) {
|
||||
setSharedCalendarColor(sharedCalendarColorKey(cal), color);
|
||||
return;
|
||||
}
|
||||
updateCalendar(client, calendarId, { color });
|
||||
} : undefined}
|
||||
onResetColor={(cal) => {
|
||||
// Drop the local override. A calendar with a server color goes
|
||||
// back to it; one without gets a fresh unused color from the
|
||||
// auto-assign effect (so it never reverts to a collision).
|
||||
removeSharedCalendarColor(sharedCalendarColorKey(cal));
|
||||
}}
|
||||
onShareCalendar={client ? (cal) => setSharingCalendarId(cal.id) : undefined}
|
||||
onCreateEvent={(cal: Calendar) => {
|
||||
setDefaultCalendarIdForCreate(cal.id);
|
||||
openCreateModal();
|
||||
}}
|
||||
onClearCalendar={client ? async (cal: Calendar) => {
|
||||
const ok = await confirmAction({
|
||||
title: tMgmt("clear_events"),
|
||||
message: tMgmt("confirm_clear", { name: shownName.calendar(cal) }),
|
||||
variant: "destructive",
|
||||
confirmText: tMgmt("clear_events"),
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
const count = await clearCalendarEvents(client, cal.id);
|
||||
toast.success(tMgmt("events_cleared", { count }));
|
||||
} catch (err) {
|
||||
// The store rethrows the server's reason (#434).
|
||||
toast.error(err instanceof Error && err.message ? err.message : tMgmt("error_clear"));
|
||||
}
|
||||
} : undefined}
|
||||
onDeleteCalendar={client ? async (cal: Calendar) => {
|
||||
const ok = await confirmAction({
|
||||
title: tMgmt("delete"),
|
||||
message: tMgmt("confirm_delete", { name: shownName.calendar(cal) }),
|
||||
variant: "destructive",
|
||||
confirmText: tMgmt("delete"),
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
await removeCalendar(client, cal.id);
|
||||
toast.success(tMgmt("calendar_deleted"));
|
||||
} catch {
|
||||
toast.error(tMgmt("error_delete"));
|
||||
}
|
||||
} : undefined}
|
||||
onCreateCalendar={client ? () => setShowCreateCalendar(true) : undefined}
|
||||
onSubscribe={canSubscribe ? () => setShowSubscriptionModal(true) : undefined}
|
||||
onEditSubscription={(subId) => setEditingSubscription(subId)}
|
||||
client={client}
|
||||
multiAccountMode={multiAccountEnabled && accountClients.length > 1}
|
||||
/>
|
||||
</div>
|
||||
{calendarSidebar}
|
||||
</div>
|
||||
{!isNarrow && (
|
||||
<ResizeHandle
|
||||
pane="sidebar"
|
||||
value={calSidebarWidth}
|
||||
min={180}
|
||||
max={400}
|
||||
onResizeStart={() => { dragStartWidth.current = calSidebarWidth; setIsResizing(true); }}
|
||||
onResize={(delta) => setCalSidebarWidth(Math.max(180, Math.min(400, dragStartWidth.current + delta)))}
|
||||
onResizeEnd={() => {
|
||||
setIsResizing(false);
|
||||
localStorage.setItem("calendar-sidebar-width", String(calSidebarWidth));
|
||||
}}
|
||||
onDoubleClick={() => { setCalSidebarWidth(256); localStorage.setItem("calendar-sidebar-width", "256"); }}
|
||||
/>
|
||||
)}
|
||||
<ResizeHandle
|
||||
pane="sidebar"
|
||||
value={calSidebarWidth}
|
||||
min={180}
|
||||
max={400}
|
||||
onResizeStart={() => { dragStartWidth.current = calSidebarWidth; setIsResizing(true); }}
|
||||
onResize={(delta) => setCalSidebarWidth(Math.max(180, Math.min(400, dragStartWidth.current + delta)))}
|
||||
onResizeEnd={() => {
|
||||
setIsResizing(false);
|
||||
localStorage.setItem("calendar-sidebar-width", String(calSidebarWidth));
|
||||
}}
|
||||
onDoubleClick={() => { setCalSidebarWidth(256); localStorage.setItem("calendar-sidebar-width", "256"); }}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
@@ -102,6 +102,48 @@ describe('ContactsApp', () => {
|
||||
expect(within(drawer()).getByText('tabs.all')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// The same drawer as Mail's folders (usability test 2026-11-04): it opened
|
||||
// beside the app rail, ignored Escape and left the focus on the page.
|
||||
it("opens the drawer from the window's edge, over the app rail and under the top bar", () => {
|
||||
renderContacts();
|
||||
const classes = drawer().className.split(/\s+/);
|
||||
expect(classes).toEqual(expect.arrayContaining(['fixed', 'start-0', 'top-[var(--drawer-top)]', 'bottom-0']));
|
||||
expect(classes).not.toContain('absolute');
|
||||
});
|
||||
|
||||
it('takes the focus into the drawer, keeps Tab there and gives it back to the menu button on Escape', () => {
|
||||
renderContacts();
|
||||
const menu = screen.getAllByRole('button', { name: 'open_categories' })[0];
|
||||
menu.focus();
|
||||
fireEvent.click(menu);
|
||||
// The category on screen.
|
||||
const current = within(drawer()).getByRole('button', { name: /tabs\.all/ });
|
||||
expect(document.activeElement).toBe(current);
|
||||
const stops = Array.from(drawer().querySelectorAll<HTMLElement>('button:not(:disabled)'));
|
||||
stops.at(-1)!.focus();
|
||||
fireEvent.keyDown(stops.at(-1)!, { key: 'Tab' });
|
||||
expect(document.activeElement).toBe(stops[0]);
|
||||
|
||||
fireEvent.keyDown(document.activeElement!, { key: 'Escape' });
|
||||
expect(drawer()).toHaveAttribute('inert');
|
||||
expect(document.activeElement).toBe(menu);
|
||||
});
|
||||
|
||||
it('dims the whole window behind the drawer and closes it on a click there, back to the menu button', () => {
|
||||
renderContacts();
|
||||
const menu = screen.getAllByRole('button', { name: 'open_categories' })[0];
|
||||
menu.focus();
|
||||
fireEvent.click(menu);
|
||||
const scrim = screen.getByTestId('drawer-scrim');
|
||||
expect(scrim.className.split(/\s+/)).toEqual(expect.arrayContaining(['fixed', 'inset-0']));
|
||||
// A press on the scrim drops the focus to the page.
|
||||
(document.activeElement as HTMLElement).blur();
|
||||
fireEvent.click(scrim);
|
||||
expect(drawer()).toHaveAttribute('inert');
|
||||
expect(screen.queryByTestId('drawer-scrim')).toBeNull();
|
||||
expect(document.activeElement).toBe(menu);
|
||||
});
|
||||
|
||||
it("closes the drawer when something in it is picked, so it doesn't stay over the form", () => {
|
||||
renderContacts();
|
||||
fireEvent.click(screen.getAllByRole('button', { name: 'open_categories' })[0]);
|
||||
|
||||
@@ -49,6 +49,7 @@ import { useIsEmbedded } from "@/hooks/use-is-embedded";
|
||||
import { useIsFocusedProTab } from "@/hooks/use-pane-context";
|
||||
import { useProMultiAccountContacts } from "@/hooks/use-pro-multi-account-contacts";
|
||||
import { ResizeHandle } from "@/components/layout/resize-handle";
|
||||
import { EdgeDrawer } from "@/components/layout/edge-drawer";
|
||||
import { useIsFullDesktop, useIsMobile } from "@/hooks/use-media-query";
|
||||
import { useRefreshGesture } from "@/hooks/use-refresh-gesture";
|
||||
import type { ContactCard, AddressBook, AddressBookRights } from "@/lib/jmap/types";
|
||||
@@ -210,6 +211,7 @@ function ContactsAppContent({ linkSegments: routeSegments }: ContactsAppProps =
|
||||
// into a burger-toggled overlay.
|
||||
const isNarrow = !isFullDesktop;
|
||||
const [narrowSidebarOpen, setNarrowSidebarOpen] = useState(false);
|
||||
const closeNarrowSidebar = useCallback(() => setNarrowSidebarOpen(false), []);
|
||||
useEffect(() => { if (!isNarrow) setNarrowSidebarOpen(false); }, [isNarrow]);
|
||||
// A new view (a form, a group, a contact) replaces whatever the drawer was for.
|
||||
useEffect(() => { setNarrowSidebarOpen(false); }, [view]);
|
||||
@@ -1285,6 +1287,60 @@ function ContactsAppContent({ linkSegments: routeSegments }: ContactsAppProps =
|
||||
}
|
||||
})();
|
||||
|
||||
// The categories: beside the list on the full desktop, a drawer below it.
|
||||
const contactsSidebar = (
|
||||
<ContactsSidebar
|
||||
groups={groups}
|
||||
individuals={individuals}
|
||||
addressBooks={addressBooks}
|
||||
activeCategory={activeCategory}
|
||||
onSelectCategory={guard(handleSelectCategory)}
|
||||
onCreateGroup={fromDrawer(guard(handleCreateGroup))}
|
||||
onCreateContact={fromDrawer(guard(handleCreateNew))}
|
||||
onCreateAddressBook={client ? fromDrawer(() => setCreatingAddressBook(true)) : undefined}
|
||||
onImport={fromDrawer(() => setShowImportDialog(true))}
|
||||
onEditGroup={fromDrawer(guard(handleEditGroupFromSidebar))}
|
||||
onDeleteGroup={fromDrawer(handleDeleteGroupFromSidebar)}
|
||||
onComposeGroup={fromDrawer(handleComposeGroupFromSidebar)}
|
||||
onDropContacts={handleDropContacts}
|
||||
onDropContactsToCategory={handleDropContactsToCategory}
|
||||
onRenameAddressBook={client ? fromDrawer((book: AddressBook) => setRenamingAddressBook(book)) : undefined}
|
||||
onShareAddressBook={client ? fromDrawer((book: AddressBook) => setSharingAddressBookId(book.id)) : undefined}
|
||||
onSetDefaultAddressBook={client ? fromDrawer(async (book: AddressBook) => {
|
||||
try {
|
||||
await setDefaultAddressBook(client, book);
|
||||
toast.success(t("address_books.default_updated"));
|
||||
} catch {
|
||||
toast.error(t("address_books.set_default_failed"));
|
||||
}
|
||||
}) : undefined}
|
||||
onCreateContactInBook={fromDrawer(guard((book: AddressBook) => {
|
||||
setDefaultBookIdForCreate(book.id);
|
||||
setSelectedContact(null);
|
||||
setView("create");
|
||||
}))}
|
||||
onDeleteAddressBook={client ? fromDrawer(async (book: AddressBook) => {
|
||||
const ok = await confirmDialog({
|
||||
title: t("address_books.delete_title"),
|
||||
message: t("address_books.confirm_delete", { name: shownName.addressBook(book) }),
|
||||
variant: "destructive",
|
||||
confirmText: t("address_books.delete"),
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
await removeAddressBook(client, book);
|
||||
toast.success(t("address_books.deleted"));
|
||||
} catch {
|
||||
toast.error(t("address_books.delete_failed"));
|
||||
}
|
||||
}) : undefined}
|
||||
onRenameKeyword={fromDrawer((kw: string) => setRenamingKeyword(kw))}
|
||||
onDeleteKeyword={fromDrawer((kw: string) => void handleDeleteKeyword(kw))}
|
||||
directoryCount={showDirectory ? directoryPrincipals.length : undefined}
|
||||
multiAccountMode={multiAccountEnabled && accountClients.length > 1}
|
||||
/>
|
||||
);
|
||||
|
||||
const mobileBackToList = () => {
|
||||
if (returnToEmail) {
|
||||
setReturnToEmail(false);
|
||||
@@ -1331,105 +1387,49 @@ function ContactsAppContent({ linkSegments: routeSegments }: ContactsAppProps =
|
||||
{inlineApp && (
|
||||
<InlineAppView apps={loadedApps} activeAppId={inlineApp!.id} onClose={closeInlineApp} />
|
||||
)}
|
||||
{/* Clips the closed drawer, so it never sits over the nav rail. */}
|
||||
{/* Holds the drawer in a Pro pane and clips it there when closed. */}
|
||||
<div className={cn("relative flex flex-1 min-h-0 overflow-hidden", inlineApp && "hidden")}>
|
||||
{/* Narrow-pane backdrop for the overlay categories sidebar */}
|
||||
{isNarrow && narrowSidebarOpen && (
|
||||
<div
|
||||
className={cn(
|
||||
"inset-0 bg-black/50 z-40",
|
||||
isEmbedded ? "absolute" : "fixed"
|
||||
)}
|
||||
onClick={() => setNarrowSidebarOpen(false)}
|
||||
/>
|
||||
{/* Panel 1: the categories. Below the full desktop a drawer from the
|
||||
window's edge, over the app rail, as Mail's folders. */}
|
||||
{showListPanel && isNarrow && (
|
||||
<EdgeDrawer
|
||||
open={narrowSidebarOpen}
|
||||
onClose={closeNarrowSidebar}
|
||||
contained={isEmbedded || mvShell}
|
||||
data-testid="contacts-sidebar-drawer"
|
||||
data-pane="sidebar"
|
||||
className="border-e border-border bg-background"
|
||||
>
|
||||
{contactsSidebar}
|
||||
</EdgeDrawer>
|
||||
)}
|
||||
{showListPanel && !isNarrow && !isMobile && (
|
||||
<>
|
||||
<div
|
||||
data-pane="sidebar"
|
||||
className={cn(
|
||||
"border-e border-border flex flex-col flex-shrink-0 bg-background",
|
||||
!isSidebarResizing && "transition-[width] duration-300",
|
||||
)}
|
||||
style={{ width: `${sidebarWidth}px` }}
|
||||
>
|
||||
{contactsSidebar}
|
||||
</div>
|
||||
<ResizeHandle
|
||||
pane="sidebar"
|
||||
value={sidebarWidth}
|
||||
min={180}
|
||||
max={400}
|
||||
onResizeStart={() => { sidebarDragStartWidth.current = sidebarWidth; setIsSidebarResizing(true); }}
|
||||
onResize={(delta) => setSidebarWidth(Math.max(180, Math.min(400, sidebarDragStartWidth.current + delta)))}
|
||||
onResizeEnd={() => {
|
||||
setIsSidebarResizing(false);
|
||||
localStorage.setItem("contacts-sidebar-width", String(sidebarWidth));
|
||||
}}
|
||||
onDoubleClick={() => { setSidebarWidth(256); localStorage.setItem("contacts-sidebar-width", "256"); }}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{/* Panel 1: Categories sidebar (in-flow on desktop, overlay on narrow) */}
|
||||
{showListPanel && (!isMobile || isNarrow) && (
|
||||
<>
|
||||
<div
|
||||
data-testid={isNarrow ? "contacts-sidebar-drawer" : undefined}
|
||||
data-pane="sidebar"
|
||||
className={cn(
|
||||
"border-e border-border flex flex-col flex-shrink-0 bg-background",
|
||||
!isSidebarResizing && "transition-[width] duration-300",
|
||||
isNarrow && cn(
|
||||
"absolute inset-y-0 start-0 z-50 w-72 pt-[var(--app-top-inset)]",
|
||||
"transform transition-[transform,visibility] duration-300 ease-in-out",
|
||||
!narrowSidebarOpen && "invisible -translate-x-full rtl:translate-x-full"
|
||||
)
|
||||
)}
|
||||
// Closed, the drawer is out of reach: no clicks, no Tab stops.
|
||||
inert={isNarrow && !narrowSidebarOpen}
|
||||
style={isNarrow ? undefined : { width: `${sidebarWidth}px` }}
|
||||
>
|
||||
<ContactsSidebar
|
||||
groups={groups}
|
||||
individuals={individuals}
|
||||
addressBooks={addressBooks}
|
||||
activeCategory={activeCategory}
|
||||
onSelectCategory={guard(handleSelectCategory)}
|
||||
onCreateGroup={fromDrawer(guard(handleCreateGroup))}
|
||||
onCreateContact={fromDrawer(guard(handleCreateNew))}
|
||||
onCreateAddressBook={client ? fromDrawer(() => setCreatingAddressBook(true)) : undefined}
|
||||
onImport={fromDrawer(() => setShowImportDialog(true))}
|
||||
onEditGroup={fromDrawer(guard(handleEditGroupFromSidebar))}
|
||||
onDeleteGroup={fromDrawer(handleDeleteGroupFromSidebar)}
|
||||
onComposeGroup={fromDrawer(handleComposeGroupFromSidebar)}
|
||||
onDropContacts={handleDropContacts}
|
||||
onDropContactsToCategory={handleDropContactsToCategory}
|
||||
onRenameAddressBook={client ? fromDrawer((book: AddressBook) => setRenamingAddressBook(book)) : undefined}
|
||||
onShareAddressBook={client ? fromDrawer((book: AddressBook) => setSharingAddressBookId(book.id)) : undefined}
|
||||
onSetDefaultAddressBook={client ? fromDrawer(async (book: AddressBook) => {
|
||||
try {
|
||||
await setDefaultAddressBook(client, book);
|
||||
toast.success(t("address_books.default_updated"));
|
||||
} catch {
|
||||
toast.error(t("address_books.set_default_failed"));
|
||||
}
|
||||
}) : undefined}
|
||||
onCreateContactInBook={fromDrawer(guard((book: AddressBook) => {
|
||||
setDefaultBookIdForCreate(book.id);
|
||||
setSelectedContact(null);
|
||||
setView("create");
|
||||
}))}
|
||||
onDeleteAddressBook={client ? fromDrawer(async (book: AddressBook) => {
|
||||
const ok = await confirmDialog({
|
||||
title: t("address_books.delete_title"),
|
||||
message: t("address_books.confirm_delete", { name: shownName.addressBook(book) }),
|
||||
variant: "destructive",
|
||||
confirmText: t("address_books.delete"),
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
await removeAddressBook(client, book);
|
||||
toast.success(t("address_books.deleted"));
|
||||
} catch {
|
||||
toast.error(t("address_books.delete_failed"));
|
||||
}
|
||||
}) : undefined}
|
||||
onRenameKeyword={fromDrawer((kw: string) => setRenamingKeyword(kw))}
|
||||
onDeleteKeyword={fromDrawer((kw: string) => void handleDeleteKeyword(kw))}
|
||||
directoryCount={showDirectory ? directoryPrincipals.length : undefined}
|
||||
multiAccountMode={multiAccountEnabled && accountClients.length > 1}
|
||||
/>
|
||||
</div>
|
||||
{!isNarrow && (
|
||||
<ResizeHandle
|
||||
pane="sidebar"
|
||||
value={sidebarWidth}
|
||||
min={180}
|
||||
max={400}
|
||||
onResizeStart={() => { sidebarDragStartWidth.current = sidebarWidth; setIsSidebarResizing(true); }}
|
||||
onResize={(delta) => setSidebarWidth(Math.max(180, Math.min(400, sidebarDragStartWidth.current + delta)))}
|
||||
onResizeEnd={() => {
|
||||
setIsSidebarResizing(false);
|
||||
localStorage.setItem("contacts-sidebar-width", String(sidebarWidth));
|
||||
}}
|
||||
onDoubleClick={() => { setSidebarWidth(256); localStorage.setItem("contacts-sidebar-width", "256"); }}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* The list and the contact: the main content, after the sidebar. */}
|
||||
<AppMain
|
||||
|
||||
@@ -323,6 +323,8 @@ export function ContactsSidebar({
|
||||
{/* All contacts */}
|
||||
<button
|
||||
onClick={() => onSelectCategory("all")}
|
||||
// Marked as the other categories are: the drawer opens on it.
|
||||
aria-current={isAllActive ? "true" : undefined}
|
||||
className={cn(
|
||||
"w-full flex items-center gap-2 px-3 text-sm transition-colors min-h-8 pointer-coarse:min-h-11",
|
||||
isAllActive
|
||||
@@ -342,6 +344,7 @@ export function ContactsSidebar({
|
||||
{directoryCount !== undefined && (
|
||||
<button
|
||||
onClick={() => onSelectCategory("directory")}
|
||||
aria-current={activeCategory === "directory" ? "true" : undefined}
|
||||
className={cn(
|
||||
"w-full flex items-center gap-2 px-3 text-sm transition-colors min-h-8 pointer-coarse:min-h-11",
|
||||
activeCategory === "directory"
|
||||
|
||||
@@ -0,0 +1,401 @@
|
||||
import { render, screen, fireEvent, act, waitFor, within } from '@testing-library/react';
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest';
|
||||
import React from 'react';
|
||||
import { EmailComposer } from '../email-composer';
|
||||
import { useAuthStore } from '@/stores/auth-store';
|
||||
import { DEFAULT_POLICY_SNAPSHOT, type PolicySnapshot } from '@/lib/desktop/policy-schema';
|
||||
import type { BulwarkDesktopBridge, DesktopRecentFile } from '@/lib/desktop/types';
|
||||
|
||||
// Recent files in the Attach menu, in the desktop app: the shell's side is
|
||||
// repos/desktop's test/recent-files.spec.ts; here the bridge is a stub.
|
||||
|
||||
const hoisted = vi.hoisted(() => ({
|
||||
picked: [] as unknown[],
|
||||
beforeAttachmentUpload: vi.fn(async (_info: { name: string }) => true),
|
||||
toastError: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/components/files/file-picker-dialog', () => ({
|
||||
FilePickerDialog: ({ onPick }: { onPick: (nodes: unknown[]) => void }) =>
|
||||
React.createElement(
|
||||
'button',
|
||||
{ type: 'button', 'data-testid': 'fake-file-picker', onClick: () => onPick(hoisted.picked) },
|
||||
'pick',
|
||||
),
|
||||
}));
|
||||
|
||||
// ─── Heavy component mocks (mirrors composer-plugin-attachment-source.test.tsx) ─
|
||||
|
||||
vi.mock('@/components/email/rich-text-editor', () => ({
|
||||
RichTextEditor: () => React.createElement('div', { 'data-testid': 'rich-text-editor' }),
|
||||
}));
|
||||
vi.mock('@/components/plugins/plugin-slot', () => ({ PluginSlot: () => null }));
|
||||
|
||||
vi.mock('@/components/identity/sub-address-helper', () => ({ SubAddressHelper: () => null }));
|
||||
vi.mock('@/components/templates/template-picker', () => ({ TemplatePicker: () => null }));
|
||||
vi.mock('@/components/templates/template-form', () => ({ TemplateForm: () => null }));
|
||||
vi.mock('@/components/files/file-preview-modal', () => ({ FilePreviewModal: () => null }));
|
||||
vi.mock('@/hooks/use-focus-trap', () => ({
|
||||
useFocusTrap: () => ({ current: null }),
|
||||
}));
|
||||
vi.mock('@/hooks/use-pro-multi-account-identities', () => ({
|
||||
useProMultiAccountIdentities: () => ({ enabled: false, groups: [], allIdentities: [] }),
|
||||
stripCrossAccountIdentityPrefix: (id: string) => ({ localAccountId: null, rawId: id }),
|
||||
}));
|
||||
|
||||
// ─── Store mocks ──────────────────────────────────────────────────────────────
|
||||
|
||||
vi.mock('@/stores/auth-store', () => {
|
||||
const state = {
|
||||
client: null,
|
||||
identities: [],
|
||||
primaryIdentity: null,
|
||||
isAuthenticated: false,
|
||||
isDemoMode: false,
|
||||
activeAccountId: null,
|
||||
connectionLost: false,
|
||||
getClientForAccount: () => undefined,
|
||||
getAllConnectedClients: () => new Map(),
|
||||
syncIdentities: () => {},
|
||||
refreshIdentities: async () => {},
|
||||
};
|
||||
const hook = (sel?: (s: typeof state) => unknown) =>
|
||||
typeof sel === 'function' ? sel(state) : state;
|
||||
hook.getState = () => state;
|
||||
hook.setState = (p: Partial<typeof state>) => Object.assign(state, p);
|
||||
return { useAuthStore: hook };
|
||||
});
|
||||
|
||||
vi.mock('@/stores/identity-store', () => {
|
||||
const state = {
|
||||
identities: [{ id: 'id-me', email: 'me@example.com', name: 'Me' }],
|
||||
defaultIdentityId: 'id-me',
|
||||
};
|
||||
const hook = (sel?: (s: typeof state) => unknown) =>
|
||||
typeof sel === 'function' ? sel(state) : state;
|
||||
hook.getState = () => state;
|
||||
hook.setState = (p: Partial<typeof state>) => Object.assign(state, p);
|
||||
return { useIdentityStore: hook };
|
||||
});
|
||||
|
||||
vi.mock('@/stores/account-store', () => {
|
||||
const state = { accounts: [], getAccountById: () => undefined };
|
||||
const hook = (sel?: (s: typeof state) => unknown) =>
|
||||
typeof sel === 'function' ? sel(state) : state;
|
||||
hook.getState = () => state;
|
||||
hook.setState = (p: Partial<typeof state>) => Object.assign(state, p);
|
||||
return { useAccountStore: hook };
|
||||
});
|
||||
|
||||
vi.mock('@/stores/email-store', () => {
|
||||
const state = {
|
||||
draftSaveEnabled: false,
|
||||
sendRawEmail: async () => ({ sent: true }),
|
||||
};
|
||||
const hook = (sel?: (s: typeof state) => unknown) =>
|
||||
typeof sel === 'function' ? sel(state) : state;
|
||||
hook.getState = () => state;
|
||||
hook.setState = (p: Partial<typeof state>) => Object.assign(state, p);
|
||||
return { useEmailStore: hook };
|
||||
});
|
||||
|
||||
vi.mock('@/stores/settings-store', () => {
|
||||
const state = {
|
||||
timeFormat: '24h',
|
||||
plainTextMode: false,
|
||||
subAddressDelimiter: '+',
|
||||
autoSelectReplyIdentity: true,
|
||||
attachmentReminderEnabled: false,
|
||||
attachmentReminderKeywords: [],
|
||||
emptySubjectWarningEnabled: true,
|
||||
sendDelaySeconds: 0,
|
||||
signaturePosition: 'above_quote',
|
||||
signatureSeparatorEnabled: false,
|
||||
requestReadReceiptDefault: false,
|
||||
addTrustedSender: () => {},
|
||||
trustedSendersAddressBook: null,
|
||||
updateSetting: () => {},
|
||||
};
|
||||
const hook = (sel?: (s: typeof state) => unknown) =>
|
||||
typeof sel === 'function' ? sel(state) : state;
|
||||
hook.getState = () => state;
|
||||
hook.setState = (p: Partial<typeof state>) => Object.assign(state, p);
|
||||
return { useSettingsStore: hook };
|
||||
});
|
||||
|
||||
vi.mock('@/stores/contact-store', () => {
|
||||
const state = {
|
||||
contacts: [],
|
||||
getAutocomplete: async () => [],
|
||||
addToTrustedSendersBook: async () => {},
|
||||
};
|
||||
const hook = (sel?: (s: typeof state) => unknown) =>
|
||||
typeof sel === 'function' ? sel(state) : state;
|
||||
hook.getState = () => state;
|
||||
hook.setState = (p: Partial<typeof state>) => Object.assign(state, p);
|
||||
return { useContactStore: hook };
|
||||
});
|
||||
|
||||
vi.mock('@/stores/template-store', () => {
|
||||
const state = { templates: [], addTemplate: async () => {} };
|
||||
const hook = (sel?: (s: typeof state) => unknown) =>
|
||||
typeof sel === 'function' ? sel(state) : state;
|
||||
hook.getState = () => state;
|
||||
hook.setState = (p: Partial<typeof state>) => Object.assign(state, p);
|
||||
return { useTemplateStore: hook };
|
||||
});
|
||||
|
||||
// ─── Misc dependency mocks ────────────────────────────────────────────────────
|
||||
|
||||
vi.mock('@/stores/toast-store', () => ({
|
||||
toast: { info: () => {}, error: hoisted.toastError, success: () => {} },
|
||||
}));
|
||||
|
||||
vi.mock('@/lib/plugin-hooks', () => ({
|
||||
identityHooks: {
|
||||
onSignatureRender: { size: 0, transform: async (value: unknown) => value },
|
||||
onIdentitySelect: { size: 0, emit: async () => {} },
|
||||
},
|
||||
templateHooks: {
|
||||
onTemplateRender: { size: 0, transform: async (value: unknown) => value },
|
||||
onTemplateApply: { size: 0, emit: async () => {} },
|
||||
},
|
||||
emailHooks: {
|
||||
onComposerOpen: { call: async () => [] },
|
||||
onRecipientChange: { call: async () => [] },
|
||||
getRecipientSuggestions: { call: async () => [] },
|
||||
onRecipientChipsChange: { transform: async (chips: unknown) => chips },
|
||||
onDraftChange: { emit: () => {} },
|
||||
onBeforeDraftAutoSave: { transform: async (draft: unknown) => draft },
|
||||
onBeforeEmailSend: { intercept: async () => true, interceptOutcome: async () => 'allowed' },
|
||||
onBeforeAttachmentUpload: { intercept: hoisted.beforeAttachmentUpload },
|
||||
onComposeSend: { takeOver: async () => 'default' },
|
||||
onTransformOutgoingEmail: { transform: async (email: unknown) => email },
|
||||
},
|
||||
contactHooks: {
|
||||
search: { call: async () => [] },
|
||||
onProvideRecipientSuggestions: { transform: async (initial: unknown) => initial },
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('@/lib/email-sanitization', () => ({
|
||||
sanitizeSignatureHtml: (v: string) => v,
|
||||
sanitizeEmailHtml: (v: string) => v,
|
||||
parseHtmlSafely: (html: string) => new DOMParser().parseFromString(html, 'text/html'),
|
||||
}));
|
||||
|
||||
vi.mock('@/lib/email-threading', () => ({
|
||||
computeReplyThreadingHeaders: () => ({ inReplyTo: [], references: [] }),
|
||||
}));
|
||||
vi.mock('@/lib/signature-utils', () => ({
|
||||
appendPlainTextSignature: (body: string) => body,
|
||||
getPlainTextSignature: () => '',
|
||||
plainTextBodyHasSignature: () => false,
|
||||
plainTextBodyWithoutSignature: (body: string) => body,
|
||||
}));
|
||||
vi.mock('@/lib/sub-addressing', () => ({ generateSubAddress: () => '' }));
|
||||
vi.mock('@/lib/debug', () => ({ debug: { log: () => {}, warn: () => {}, error: () => {} } }));
|
||||
vi.mock('@/components/email/quoted-html', () => ({
|
||||
buildQuotedHtmlBlock: () => '',
|
||||
serializeEditorContent: () => '',
|
||||
}));
|
||||
vi.mock('@/lib/template-utils', () => ({ substitutePlaceholders: (s: string) => s }));
|
||||
|
||||
// ─── Tests ────────────────────────────────────────────────────────────────────
|
||||
|
||||
const NOW = Date.now();
|
||||
const RECENT: DesktopRecentFile[] = [
|
||||
{ id: 'id-report', name: 'Quarterly report.docx', folder: '\\\\files\\team\\Reports', path: '\\\\files\\team\\Reports\\Quarterly report.docx', usedAt: NOW - 5 * 60_000, icon: 'data:image/png;base64,iVBORw0KGgo=' },
|
||||
{ id: 'id-budget', name: 'Budget 2027.xlsx', folder: 'C:\\Users\\me\\Documents', path: 'C:\\Users\\me\\Documents\\Budget 2027.xlsx', usedAt: NOW - 3 * 60 * 60_000 },
|
||||
];
|
||||
|
||||
interface DesktopOptions {
|
||||
files?: DesktopRecentFile[];
|
||||
policyOff?: boolean;
|
||||
/** The shell's native menus: the Attach menu must stay HTML all the same. */
|
||||
popup?: ReturnType<typeof vi.fn>;
|
||||
}
|
||||
|
||||
function desktop({ files = RECENT, policyOff = false, popup }: DesktopOptions = {}) {
|
||||
const snapshot: PolicySnapshot = {
|
||||
...DEFAULT_POLICY_SNAPSHOT,
|
||||
...(policyOff ? { RecentFilesInAttach: { value: false, source: 'forced-machine', locked: true } } : {}),
|
||||
} as PolicySnapshot;
|
||||
const list = vi.fn(async () => ({ ok: true as const, files }));
|
||||
const attach = vi.fn(async (id: string) => {
|
||||
const file = files.find((f) => f.id === id);
|
||||
return file
|
||||
? { ok: true as const, file: { name: file.name, data: new TextEncoder().encode(`bytes of ${file.name}`) } }
|
||||
: { ok: false as const, reason: 'unknown' as const };
|
||||
});
|
||||
window.bulwarkDesktop = {
|
||||
version: 1,
|
||||
platform: 'win32',
|
||||
policy: { get: () => snapshot, onChange: () => () => {} },
|
||||
recentFiles: { list, attach },
|
||||
...(popup ? { menu: { popup, setState: () => {}, onCommand: () => () => {} } } : {}),
|
||||
} as unknown as BulwarkDesktopBridge;
|
||||
return { list, attach };
|
||||
}
|
||||
|
||||
function client(overrides: Record<string, unknown> = {}) {
|
||||
return {
|
||||
createDraft: vi.fn().mockResolvedValue('draft-1'),
|
||||
getEmail: vi.fn(),
|
||||
hasDelayedSend: () => false,
|
||||
getMaxDelayedSend: () => 0,
|
||||
// No Files, no plugins: in a browser, Attach is a plain button.
|
||||
supportsFiles: () => false,
|
||||
getMaxSizeAttachmentsPerEmail: () => 0,
|
||||
getMaxSizeUpload: () => 0,
|
||||
uploadBlob: vi.fn(() => new Promise(() => {})),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
const rows = () => screen.queryAllByTestId('composer-recent-file');
|
||||
|
||||
async function openMenu() {
|
||||
fireEvent.click(screen.getByTestId('composer-attach-menu'));
|
||||
await act(async () => {});
|
||||
}
|
||||
|
||||
describe('recent files in the Attach menu', () => {
|
||||
afterEach(() => {
|
||||
window.bulwarkDesktop = undefined;
|
||||
useAuthStore.setState({ client: null });
|
||||
vi.clearAllMocks();
|
||||
hoisted.beforeAttachmentUpload.mockImplementation(async () => true);
|
||||
});
|
||||
|
||||
it('in a browser the paperclip is the plain button it was', () => {
|
||||
useAuthStore.setState({ client: client() as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
expect(screen.queryByTestId('composer-attach-menu')).toBeNull();
|
||||
expect(screen.getByRole('button', { name: 'attach' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('in the desktop app the paperclip opens a menu: recent files first, then the file dialog', async () => {
|
||||
const { list } = desktop();
|
||||
useAuthStore.setState({ client: client() as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
expect(list).not.toHaveBeenCalled();
|
||||
await openMenu();
|
||||
expect(list).toHaveBeenCalledTimes(1);
|
||||
|
||||
const menu = screen.getByRole('menu');
|
||||
const items = within(menu).getAllByRole('menuitem');
|
||||
expect(items.map((item) => item.getAttribute('data-testid'))).toEqual(['composer-recent-file', 'composer-recent-file', 'composer-attach-from-device']);
|
||||
expect(within(menu).getByText('heading')).toBeInTheDocument();
|
||||
expect(items[2]).toHaveTextContent('browse');
|
||||
|
||||
const [report, budget] = rows();
|
||||
expect(report).toHaveTextContent('Quarterly report.docx');
|
||||
expect(report).toHaveTextContent('\\\\files\\team\\Reports');
|
||||
expect(report).toHaveTextContent('5 minutes ago');
|
||||
expect(report).toHaveAttribute('title', '\\\\files\\team\\Reports\\Quarterly report.docx');
|
||||
expect(report.querySelector('img')).toHaveAttribute('src', RECENT[0].icon);
|
||||
// No icon from the shell: the app's own for the type.
|
||||
expect(budget.querySelector('img')).toBeNull();
|
||||
expect(budget.querySelector('svg')).not.toBeNull();
|
||||
expect(budget).toHaveTextContent('3 hours ago');
|
||||
});
|
||||
|
||||
it('one click attaches that file through the composer\'s own checks and closes the menu', async () => {
|
||||
const { attach } = desktop();
|
||||
useAuthStore.setState({ client: client() as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
await openMenu();
|
||||
fireEvent.click(rows()[1]);
|
||||
expect(screen.queryByRole('menu')).toBeNull();
|
||||
expect(attach).toHaveBeenCalledWith('id-budget');
|
||||
expect(await screen.findByText('Budget 2027.xlsx')).toBeInTheDocument();
|
||||
expect(hoisted.beforeAttachmentUpload).toHaveBeenCalledWith(expect.objectContaining({ name: 'Budget 2027.xlsx', size: 'bytes of Budget 2027.xlsx'.length }));
|
||||
});
|
||||
|
||||
it('a plugin can refuse it, as it can a file from the dialog', async () => {
|
||||
hoisted.beforeAttachmentUpload.mockImplementation(async (info) => info.name !== 'Budget 2027.xlsx');
|
||||
desktop();
|
||||
useAuthStore.setState({ client: client() as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
await openMenu();
|
||||
fireEvent.click(rows()[1]);
|
||||
await act(async () => {});
|
||||
expect(hoisted.beforeAttachmentUpload).toHaveBeenCalled();
|
||||
expect(screen.queryByText('Budget 2027.xlsx')).toBeNull();
|
||||
});
|
||||
|
||||
it('the server\'s size limit applies too', async () => {
|
||||
desktop();
|
||||
useAuthStore.setState({ client: client({ getMaxSizeUpload: () => 5 }) as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
await openMenu();
|
||||
fireEvent.click(rows()[0]);
|
||||
await act(async () => {});
|
||||
expect(hoisted.toastError).toHaveBeenCalledWith('attachment_too_large');
|
||||
expect(screen.queryByText('Quarterly report.docx')).toBeNull();
|
||||
});
|
||||
|
||||
it('says so when the file is gone or too large for the app', async () => {
|
||||
const { attach } = desktop();
|
||||
useAuthStore.setState({ client: client() as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
attach.mockResolvedValueOnce({ ok: false, reason: 'missing' } as never);
|
||||
await openMenu();
|
||||
fireEvent.click(rows()[0]);
|
||||
await act(async () => {});
|
||||
expect(hoisted.toastError).toHaveBeenLastCalledWith('missing');
|
||||
|
||||
attach.mockResolvedValueOnce({ ok: false, reason: 'too-large' } as never);
|
||||
await openMenu();
|
||||
fireEvent.click(rows()[0]);
|
||||
await act(async () => {});
|
||||
expect(hoisted.toastError).toHaveBeenLastCalledWith('too_large');
|
||||
});
|
||||
|
||||
it('with nothing recent the menu has only its other entries', async () => {
|
||||
desktop({ files: [] });
|
||||
useAuthStore.setState({ client: client() as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
await openMenu();
|
||||
const menu = screen.getByRole('menu');
|
||||
expect(within(menu).queryByText('heading')).toBeNull();
|
||||
expect(within(menu).queryByRole('separator')).toBeNull();
|
||||
expect(within(menu).getAllByRole('menuitem').map((item) => item.getAttribute('data-testid'))).toEqual(['composer-attach-from-device']);
|
||||
});
|
||||
|
||||
it('with the policy off there\'s no list, and Attach is what it was', async () => {
|
||||
const { list } = desktop({ policyOff: true });
|
||||
useAuthStore.setState({ client: client() as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
expect(screen.queryByTestId('composer-attach-menu')).toBeNull();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'attach' }));
|
||||
await act(async () => {});
|
||||
expect(list).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('keys: the first file has the focus, arrows move, Escape closes', async () => {
|
||||
desktop();
|
||||
useAuthStore.setState({ client: client() as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
await openMenu();
|
||||
await waitFor(() => expect(document.activeElement).toBe(rows()[0]), { timeout: 5000 });
|
||||
fireEvent.keyDown(document.activeElement!, { key: 'ArrowDown' });
|
||||
expect(document.activeElement).toBe(rows()[1]);
|
||||
fireEvent.keyDown(document.activeElement!, { key: 'ArrowDown' });
|
||||
expect(document.activeElement).toHaveAttribute('data-testid', 'composer-attach-from-device');
|
||||
fireEvent.keyDown(document.activeElement!, { key: 'Escape' });
|
||||
expect(screen.queryByRole('menu')).toBeNull();
|
||||
});
|
||||
|
||||
it('stays an HTML menu where the shell would draw it natively', async () => {
|
||||
const popup = vi.fn(async () => null);
|
||||
desktop({ popup });
|
||||
useAuthStore.setState({ client: client() as never });
|
||||
render(<EmailComposer onClose={vi.fn()} />);
|
||||
await openMenu();
|
||||
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 300)); });
|
||||
expect(popup).not.toHaveBeenCalled();
|
||||
expect(rows()).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
@@ -585,6 +585,7 @@ describe('composer-sidebar and composer-sidebar-right', () => {
|
||||
Element.prototype.getBoundingClientRect = function (this: Element) {
|
||||
if (this.matches('[data-testid="email-composer"]')) return rect(100, 800);
|
||||
if (this.matches('[data-composer-header]')) return rect(100, 156);
|
||||
if (this.matches('[data-composer-panels]')) return rect(156, 800);
|
||||
if (this.matches('[data-composer-footer]')) return rect(740, 800);
|
||||
return original.call(this);
|
||||
};
|
||||
@@ -593,7 +594,9 @@ describe('composer-sidebar and composer-sidebar-right', () => {
|
||||
render(<EmailComposer initialData={DRAFT} onClose={vi.fn()} />);
|
||||
fireEvent.click(document.querySelector('[data-composer-panel-toggle="right"]')!);
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('overlay');
|
||||
expect(panel('right').style.top).toBe('56px');
|
||||
// The header is above the row the panel is laid over: the panel starts at that row's top.
|
||||
expect(document.querySelector('[data-composer-panels]')!.contains(document.querySelector('[data-composer-header]'))).toBe(false);
|
||||
expect(panel('right').style.top).toBe('0px');
|
||||
expect(panel('right').style.bottom).toBe('60px');
|
||||
} finally {
|
||||
Element.prototype.getBoundingClientRect = original;
|
||||
@@ -718,7 +721,7 @@ describe('composer-sidebar and composer-sidebar-right', () => {
|
||||
// Opened once: it stays open for the next composer.
|
||||
render(<EmailComposer initialData={DRAFT} onClose={vi.fn()} />);
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('docked');
|
||||
fireEvent.click(screen.getByRole('button', { name: 'plugin_panel_hide' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'hide_panel' }));
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('folded');
|
||||
});
|
||||
|
||||
@@ -742,11 +745,134 @@ describe('composer-sidebar and composer-sidebar-right', () => {
|
||||
offerSlots('p1', ['composer-sidebar-right']);
|
||||
render(<EmailComposer initialData={DRAFT} onClose={vi.fn()} />);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'plugin_panel_show' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'show_panel' }));
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('overlay');
|
||||
expect(panel('right').className).toContain('absolute');
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'plugin_panel_hide' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'hide_panel' }));
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('folded');
|
||||
});
|
||||
});
|
||||
|
||||
// With a panel open, the composer's header runs over it: Full screen, Pop out
|
||||
// and Close end the whole composer, not the message column in the middle of
|
||||
// it. The panel's head (the header above it) has its own Hide button.
|
||||
describe('the composer header with a plugin panel open', () => {
|
||||
function stubWidth(width: number) {
|
||||
class FixedWidthObserver {
|
||||
constructor(private cb: ResizeObserverCallback) {}
|
||||
observe(el: Element) {
|
||||
if ((el as HTMLElement).dataset.testid !== 'email-composer') return;
|
||||
this.cb([{ target: el, contentRect: { width, height: 700 } } as unknown as ResizeObserverEntry], this as unknown as ResizeObserver);
|
||||
}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
}
|
||||
vi.stubGlobal('ResizeObserver', FixedWidthObserver);
|
||||
}
|
||||
const panel = (side: 'left' | 'right') => document.querySelector<HTMLElement>(`[data-composer-sidebar="${side}"]`)!;
|
||||
const header = () => document.querySelector<HTMLElement>('[data-composer-header]')!;
|
||||
const head = (side: 'left' | 'right') => document.querySelector<HTMLElement>(`[data-composer-panel-head="${side}"]`);
|
||||
const buttons = (el: HTMLElement) => Array.from(el.querySelectorAll<HTMLElement>('button'));
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
for (const side of ['left', 'right']) {
|
||||
localStorage.removeItem(`composerPluginSidebarCollapsed:${side}`);
|
||||
localStorage.removeItem(`composerPluginSidebarWidth:${side}`);
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps Close the last control, at the end of the row over the open panel', () => {
|
||||
stubWidth(1400);
|
||||
offerSlots('p1', ['composer-sidebar-right']);
|
||||
render(<EmailComposer initialData={DRAFT} onClose={vi.fn()} />);
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('docked');
|
||||
|
||||
// One row over the message and the panel: the panel is not beside the header.
|
||||
expect(header().parentElement).toBe(screen.getByTestId('email-composer'));
|
||||
expect(header().compareDocumentPosition(panel('right')) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
// The part of it above the panel is as wide as the panel...
|
||||
const right = head('right')!;
|
||||
expect(header()).toContainElement(right);
|
||||
expect(right.style.minWidth).toBe('260px');
|
||||
// ...and ends with Full screen, Pop out and Close, Close last.
|
||||
const all = buttons(header());
|
||||
expect(all[all.length - 1]).toBe(screen.getByTestId('composer-close'));
|
||||
expect(right).toContainElement(screen.getByTestId('composer-close'));
|
||||
expect(right).toContainElement(screen.getByTestId('composer-maximize'));
|
||||
});
|
||||
|
||||
it('gives the open panel a Hide button in its head, and the header a Show button while it is folded', () => {
|
||||
stubWidth(1400);
|
||||
offerSlots('p1', ['composer-sidebar', 'composer-sidebar-right']);
|
||||
render(<EmailComposer initialData={DRAFT} onClose={vi.fn()} />);
|
||||
|
||||
for (const side of ['left', 'right'] as const) {
|
||||
const hide = head(side)!.querySelector<HTMLElement>(`[data-composer-panel-hide="${side}"]`)!;
|
||||
expect(hide).toBeTruthy();
|
||||
expect(hide).toHaveAccessibleName('hide_panel');
|
||||
expect(hide.getAttribute('title')).toBe('hide_panel');
|
||||
expect(hide.getAttribute('aria-expanded')).toBe('true');
|
||||
}
|
||||
// At the panel's inner edge, where it meets the message: last in the left head, first in the right one.
|
||||
expect(buttons(head('left')!).at(-1)!.dataset.composerPanelHide).toBe('left');
|
||||
expect(buttons(head('right')!)[0].dataset.composerPanelHide).toBe('right');
|
||||
|
||||
fireEvent.click(head('right')!.querySelector('[data-composer-panel-hide]')!);
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('folded');
|
||||
expect(head('right')).toBeNull();
|
||||
// Folded: one Show button in the header, before the window buttons; Close still last.
|
||||
const show = screen.getByRole('button', { name: 'show_panel' });
|
||||
expect(header()).toContainElement(show);
|
||||
expect(show.getAttribute('aria-expanded')).toBe('false');
|
||||
const all = buttons(header());
|
||||
expect(all[all.length - 1]).toBe(screen.getByTestId('composer-close'));
|
||||
expect(all.indexOf(show)).toBeLessThan(all.indexOf(screen.getByTestId('composer-maximize')));
|
||||
|
||||
fireEvent.click(show);
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('docked');
|
||||
expect(head('right')).toContainElement(screen.getByTestId('composer-close'));
|
||||
});
|
||||
|
||||
it('hides the panel with Hide and closes the composer only with Close', () => {
|
||||
stubWidth(1400);
|
||||
offerSlots('p1', ['composer-sidebar-right']);
|
||||
const onClose = vi.fn();
|
||||
render(<EmailComposer initialData={DRAFT} onClose={onClose} />);
|
||||
|
||||
const hide = head('right')!.querySelector<HTMLElement>('[data-composer-panel-hide]')!;
|
||||
const close = screen.getByTestId('composer-close');
|
||||
expect(hide).not.toBe(close);
|
||||
expect(hide).not.toHaveAccessibleName(close.getAttribute('aria-label')!);
|
||||
|
||||
fireEvent.click(hide);
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('folded');
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
expect(screen.queryByRole('alertdialog')).toBeNull();
|
||||
expect(screen.getByTestId('email-composer')).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByTestId('composer-close'));
|
||||
expect(onClose.mock.calls.length > 0 || screen.queryByRole('alertdialog') !== null).toBe(true);
|
||||
});
|
||||
|
||||
it('gives a panel laid over a narrow composer the same head', () => {
|
||||
stubWidth(700);
|
||||
offerSlots('p1', ['composer-sidebar-right']);
|
||||
render(<EmailComposer initialData={DRAFT} onClose={vi.fn()} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'show_panel' }));
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('overlay');
|
||||
expect(head('right')).toContainElement(screen.getByTestId('composer-close'));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'hide_panel' }));
|
||||
expect(panel('right').dataset.composerSidebarMode).toBe('folded');
|
||||
});
|
||||
|
||||
it('keeps Close last in a composer that is its own window', () => {
|
||||
stubWidth(1400);
|
||||
offerSlots('p1', ['composer-sidebar-right']);
|
||||
render(<EmailComposer initialData={DRAFT} onClose={vi.fn()} ownWindow={{}} />);
|
||||
const all = buttons(header());
|
||||
expect(all[all.length - 1]).toBe(screen.getByTestId('composer-close'));
|
||||
expect(head('right')).toContainElement(screen.getByTestId('composer-close'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
"use client";
|
||||
|
||||
// The composer-sidebar and composer-sidebar-right plugin panels. Each has a
|
||||
// width the user can drag (kept across composers) and a button in the
|
||||
// composer's header that shows and hides it (the left panel's at the start,
|
||||
// the right one's at the end, like the reader's). Folded, a panel takes no
|
||||
// room at all. When the composer is too narrow for an open panel next to
|
||||
// it, the panel folds by itself (right first); opening it anyway lays it
|
||||
// over the composer instead of squeezing the message into a column nobody
|
||||
// can write in. Laid over, it stays between the composer's header and its
|
||||
// bottom bar: the panel's own button, Close and Send stay in reach.
|
||||
// width the user can drag (kept across composers). The composer's header
|
||||
// runs across the whole composer, panels included, so its window buttons
|
||||
// (Full screen, Pop out, Close) stay at the far end of it, as Outlook and
|
||||
// Gmail have them. The part of that row above an open panel is the
|
||||
// panel's head: it holds "Hide <panel>", at the panel's inner edge. A
|
||||
// folded panel takes no room at all, and a "Show <panel>" button in the
|
||||
// header brings it back (the left panel's at the start, the right one's
|
||||
// before the window buttons). When the composer is too narrow for an open
|
||||
// panel next to it, the panel folds by itself (right first); opening it
|
||||
// anyway lays it over the composer instead of squeezing the message into a
|
||||
// column nobody can write in. Laid over, it stays between the header and
|
||||
// the bottom bar: Hide, Close and Send stay in reach.
|
||||
|
||||
import { useEffect, useLayoutEffect, useRef, useState, type RefObject } from "react";
|
||||
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode, type RefObject } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen } from "@/components/icons";
|
||||
import { PluginSlot } from "@/components/plugins/plugin-slot";
|
||||
import { usePluginSlotOffers } from "@/hooks/use-plugin-slot-offers";
|
||||
import { get as getActivePlugin } from "@/lib/plugin-sandbox/registry";
|
||||
import { onPanelRequest, type PanelRequest } from "@/lib/plugin-sandbox/panel-requests";
|
||||
import { ResizeHandle } from "@/components/layout/resize-handle";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -196,40 +201,123 @@ export function useComposerSidebars(root: HTMLElement | null, composerId: string
|
||||
}
|
||||
};
|
||||
|
||||
return { modes, open, close, toggle, focusRequests, widths, setSideWidth };
|
||||
// What the panels are called in their Show and Hide buttons: their plugins' names.
|
||||
const nameOf = (offers: readonly { pluginId: string }[]) =>
|
||||
offers.map((o) => getActivePlugin(o.pluginId)?.plugin.name).filter((n): n is string => !!n).join(", ") || null;
|
||||
const names: Record<ComposerSidebarSide, string | null> = { left: nameOf(leftOffers), right: nameOf(rightOffers) };
|
||||
|
||||
return { modes, open, close, toggle, focusRequests, widths, setSideWidth, names };
|
||||
}
|
||||
|
||||
/** The button in the composer's header that shows and hides one panel (none on phones). */
|
||||
export function ComposerPanelToggle({
|
||||
side,
|
||||
mode,
|
||||
onToggle,
|
||||
className,
|
||||
}: {
|
||||
/** Open beside the composer or over it: on screen, with a head in the header row. */
|
||||
export function isPanelOpen(mode: ComposerSidebarMode | null): boolean {
|
||||
return mode === "docked" || mode === "overlay";
|
||||
}
|
||||
|
||||
/** The Show or Hide button of one panel. */
|
||||
function PanelButton({ side, open, name, onToggle, className }: {
|
||||
side: ComposerSidebarSide;
|
||||
mode: ComposerSidebarMode | null;
|
||||
open: boolean;
|
||||
name: string | null;
|
||||
onToggle: () => void;
|
||||
className?: string;
|
||||
}) {
|
||||
const t = useTranslations("email_viewer");
|
||||
if (!mode) return null;
|
||||
const isOpen = mode !== "folded";
|
||||
const Icon = side === "left" ? (isOpen ? PanelLeftClose : PanelLeftOpen) : (isOpen ? PanelRightClose : PanelRightOpen);
|
||||
const t = useTranslations("composer_panel");
|
||||
const tViewer = useTranslations("email_viewer");
|
||||
const label = name
|
||||
? t(open ? "hide_panel" : "show_panel", { name })
|
||||
: tViewer(open ? "plugin_panel_hide" : "plugin_panel_show");
|
||||
const Icon = side === "left" ? (open ? PanelLeftClose : PanelLeftOpen) : (open ? PanelRightClose : PanelRightOpen);
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); onToggle(); }}
|
||||
className={cn("hidden md:grid h-8 w-8 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground", className)}
|
||||
title={t(isOpen ? "plugin_panel_hide" : "plugin_panel_show")}
|
||||
aria-label={t(isOpen ? "plugin_panel_hide" : "plugin_panel_show")}
|
||||
aria-pressed={isOpen}
|
||||
title={label}
|
||||
aria-label={label}
|
||||
aria-expanded={open}
|
||||
data-composer-panel-toggle={side}
|
||||
data-composer-panel-hide={open ? side : undefined}
|
||||
>
|
||||
<Icon className="h-4 w-4 rtl:-scale-x-100" />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The button in the composer's header that brings a folded panel back (none
|
||||
* on phones). An open panel's Hide button is in its head instead
|
||||
* (ComposerPanelHead).
|
||||
*/
|
||||
export function ComposerPanelToggle({
|
||||
side,
|
||||
mode,
|
||||
name = null,
|
||||
onToggle,
|
||||
className,
|
||||
}: {
|
||||
side: ComposerSidebarSide;
|
||||
mode: ComposerSidebarMode | null;
|
||||
name?: string | null;
|
||||
onToggle: () => void;
|
||||
className?: string;
|
||||
}) {
|
||||
if (mode !== "folded") return null;
|
||||
return <PanelButton side={side} open={false} name={name} onToggle={onToggle} className={className} />;
|
||||
}
|
||||
|
||||
/**
|
||||
* The part of the composer's header row above an open panel, as wide as the
|
||||
* panel: its Hide button at the panel's inner edge, and for the right panel
|
||||
* whatever else ends the row (the window buttons, Close last), so they stay
|
||||
* at the far end of the composer. On phones there are no panels, and no head.
|
||||
*/
|
||||
export function ComposerPanelHead({
|
||||
side,
|
||||
mode,
|
||||
width = COMPOSER_SIDEBAR_WIDTH,
|
||||
name = null,
|
||||
onToggle,
|
||||
className,
|
||||
childrenClassName,
|
||||
children,
|
||||
}: {
|
||||
side: ComposerSidebarSide;
|
||||
mode: ComposerSidebarMode | null;
|
||||
width?: number;
|
||||
name?: string | null;
|
||||
onToggle: () => void;
|
||||
/** Padding of the row it is part of. */
|
||||
className?: string;
|
||||
/** The gap between what it holds besides Hide, as in the row it is part of. */
|
||||
childrenClassName?: string;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
if (!isPanelOpen(mode)) return null;
|
||||
const hide = <PanelButton side={side} open name={name} onToggle={onToggle} />;
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
// Below md, where panels aren't shown, only what it holds besides Hide
|
||||
// shows, at the end of the row (one laid over a composer that got narrower).
|
||||
"contents md:flex shrink-0 items-center self-stretch border-border",
|
||||
side === "left" ? "border-e" : "border-s",
|
||||
className,
|
||||
)}
|
||||
// At least the panel's width, so Hide sits at the panel's edge; more when
|
||||
// the buttons need it (a narrow panel in the desktop app, beside its controls).
|
||||
style={{ minWidth: width }}
|
||||
data-composer-panel-head={side}
|
||||
>
|
||||
{side === "right" && hide}
|
||||
<div className="hidden md:block flex-1" />
|
||||
{/* No gap of the head's own around Hide and the space: a 260 px panel in the desktop app has just enough room for the buttons. */}
|
||||
{children && <div className={cn("contents md:flex items-center", childrenClassName)}>{children}</div>}
|
||||
{side === "left" && hide}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const COMPOSER_HEADER = "[data-composer-header], [data-mv-compose-titlebar], [data-mv-compose-inline-bar]";
|
||||
const COMPOSER_FOOTER = "[data-composer-footer]";
|
||||
|
||||
|
||||
+191
-116
@@ -92,7 +92,7 @@ import { useIdentityStore } from "@/stores/identity-store";
|
||||
import { useProMultiAccountIdentities, stripCrossAccountIdentityPrefix } from "@/hooks/use-pro-multi-account-identities";
|
||||
import { useAccountStore } from "@/stores/account-store";
|
||||
import { useSettingsStore } from "@/stores/settings-store";
|
||||
import { ComposerPanelToggle, ComposerPluginSidebar, useComposerSidebars } from "./composer-plugin-sidebars";
|
||||
import { ComposerPanelHead, ComposerPanelToggle, ComposerPluginSidebar, isPanelOpen, useComposerSidebars } from "./composer-plugin-sidebars";
|
||||
import { dragKindFromTypes } from "@/components/pro/pro-shell-drop";
|
||||
import { useIsPaneScoped } from "@/hooks/use-pane-context";
|
||||
import { ComposerSelectionMenu, useComposerSelectionMenu } from "./composer-selection-menu";
|
||||
@@ -188,7 +188,10 @@ import { fileStorage } from "@/lib/plugin-storage";
|
||||
import { usePolicyStore } from "@/stores/policy-store";
|
||||
import { isAppLockedNow } from "@/lib/app-lock/state";
|
||||
import { registerComposeFlush, registerComposeSnapshot } from "@/lib/compose-flush-registry";
|
||||
import { getDesktopBridge } from "@/lib/desktop/bridge";
|
||||
import { getDesktopBridge, isDesktopApp } from "@/lib/desktop/bridge";
|
||||
import { readRecentFile, RECENT_FILE_MAX_BYTES, useRecentFilesOffered } from "@/lib/desktop/recent-files";
|
||||
import type { DesktopRecentFile } from "@/lib/desktop/types";
|
||||
import { RecentFilesMenuSection } from "@/components/email/recent-files-menu-section";
|
||||
import { useDesktopCommands } from "@/lib/desktop/commands";
|
||||
import { noteComposerLanguage } from "@/lib/desktop/languages";
|
||||
import { noteOpenDraft } from "@/lib/desktop/window-restore";
|
||||
@@ -650,6 +653,7 @@ export function EmailComposer({
|
||||
const tEdit = useTranslations('desktopEdit');
|
||||
const tOfflineDrafts = useTranslations('offlineDrafts');
|
||||
const tOffline = useTranslations('offline');
|
||||
const tRecent = useTranslations('desktopAttachRecent');
|
||||
const tOfflineNotes = useTranslations('offlineConflicts');
|
||||
const tSendGuards = useTranslations('send_guards');
|
||||
const tWords = useTranslations('compose_words');
|
||||
@@ -2778,6 +2782,20 @@ export function EmailComposer({
|
||||
void addFiles(initialFiles, { handedIn: true });
|
||||
}, [client, initialFiles, addFiles]);
|
||||
|
||||
// The Attach menu's recent files, in the desktop app (lib/desktop/recent-files.ts). The
|
||||
// shell reads the file; from there it's a file like one from the file dialog.
|
||||
const recentOffered = useRecentFilesOffered();
|
||||
const attachRecentFile = useCallback(async (file: DesktopRecentFile) => {
|
||||
const result = await readRecentFile(file.id);
|
||||
if (result.ok) {
|
||||
await addFiles([result.file]);
|
||||
return;
|
||||
}
|
||||
if (result.reason === 'missing') toast.error(tRecent('missing', { name: file.name }));
|
||||
else if (result.reason === 'too-large') toast.error(tRecent('too_large', { name: file.name, max: formatFileSize(RECENT_FILE_MAX_BYTES) }));
|
||||
else if (result.reason === 'failed') toast.error(tRecent('failed', { name: file.name }));
|
||||
}, [addFiles, tRecent]);
|
||||
|
||||
const handleFileSelect = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (!event.target.files) return;
|
||||
await addFiles(Array.from(event.target.files));
|
||||
@@ -3621,13 +3639,28 @@ export function EmailComposer({
|
||||
[pluginDraft, pluginSelection, pluginComposerId, pluginSidebars.focusRequests.right],
|
||||
);
|
||||
|
||||
// The buttons that show and hide the plugin panels, in the header.
|
||||
const leftPanelToggle = pluginSidebars.modes.left
|
||||
? <ComposerPanelToggle side="left" mode={pluginSidebars.modes.left} onToggle={() => pluginSidebars.toggle('left')} />
|
||||
// The plugin panels in the header row: a folded one's Show button, and an
|
||||
// open one's head with its Hide button (see composer-plugin-sidebars.tsx).
|
||||
const leftPanelToggle = pluginSidebars.modes.left === 'folded'
|
||||
? <ComposerPanelToggle side="left" mode="folded" name={pluginSidebars.names.left} onToggle={() => pluginSidebars.toggle('left')} />
|
||||
: null;
|
||||
const rightPanelToggle = pluginSidebars.modes.right
|
||||
? <ComposerPanelToggle side="right" mode={pluginSidebars.modes.right} onToggle={() => pluginSidebars.toggle('right')} />
|
||||
const rightPanelToggle = pluginSidebars.modes.right === 'folded'
|
||||
? <ComposerPanelToggle side="right" mode="folded" name={pluginSidebars.names.right} onToggle={() => pluginSidebars.toggle('right')} />
|
||||
: null;
|
||||
const rightPanelOpen = isPanelOpen(pluginSidebars.modes.right);
|
||||
const panelHead = (side: 'left' | 'right', className: string, children?: React.ReactNode, childrenClassName?: string) => (
|
||||
<ComposerPanelHead
|
||||
side={side}
|
||||
mode={pluginSidebars.modes[side]}
|
||||
width={pluginSidebars.widths[side]}
|
||||
name={pluginSidebars.names[side]}
|
||||
onToggle={() => pluginSidebars.toggle(side)}
|
||||
className={className}
|
||||
childrenClassName={childrenClassName}
|
||||
>
|
||||
{children}
|
||||
</ComposerPanelHead>
|
||||
);
|
||||
|
||||
// The right-click menu on selected text, when a plugin put entries in it.
|
||||
const selectionMenu = useComposerSelectionMenu();
|
||||
@@ -4737,6 +4770,86 @@ export function EmailComposer({
|
||||
</button>
|
||||
);
|
||||
|
||||
// What ends the header row: the window buttons, Close last. With the right
|
||||
// panel open they end its head instead, at the far end of the composer.
|
||||
const windowButtons = (
|
||||
<>
|
||||
{canMaximize && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setMaximized((v) => !v)}
|
||||
className="hidden md:grid h-8 w-8 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
aria-label={maximized ? t('restore') : t('maximize')}
|
||||
title={maximized ? t('restore') : t('maximize')}
|
||||
data-testid="composer-maximize"
|
||||
>
|
||||
{maximized ? <Minimize2 className="w-4 h-4" /> : <Maximize2 className="w-4 h-4" />}
|
||||
</button>
|
||||
)}
|
||||
{popOutButton(cn(phoneLayout ? "hidden md:grid" : "grid", "h-8 w-8 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground"), "w-4 h-4")}
|
||||
{!closeBesideControls && composerCloseButton}
|
||||
</>
|
||||
);
|
||||
const mvInlineButtons = mvWindow && (
|
||||
<>
|
||||
{mvWindow.popOut && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={mvWindow.popOut}
|
||||
className="grid h-8 w-8 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
aria-label={t('pop_out')}
|
||||
title={t('pop_out')}
|
||||
>
|
||||
<ExternalLink className="h-4 w-4" />
|
||||
</button>
|
||||
)}
|
||||
{popOutButton("grid h-8 w-8 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground", "h-4 w-4")}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleClose()}
|
||||
className="grid h-8 w-8 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
aria-label={tCommon('close')}
|
||||
title={tCommon('close')}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
const mvWindowButtons = mvWindow && (
|
||||
<>
|
||||
{mvWindow.state !== "minimized" && popOutButton("grid h-7 w-7 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-foreground/10 hover:text-foreground", "h-4 w-4")}
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); mvWindow.setState(mvWindow.state === "minimized" ? "normal" : "minimized"); }}
|
||||
className="grid h-7 w-7 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-foreground/10 hover:text-foreground"
|
||||
aria-label={mvWindow.state === "minimized" ? t("restore") : t("minimize")}
|
||||
title={mvWindow.state === "minimized" ? t("restore") : t("minimize")}
|
||||
>
|
||||
<Minus className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); mvWindow.setState(mvWindow.state === "maximized" ? "normal" : "maximized"); }}
|
||||
className="grid h-7 w-7 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-foreground/10 hover:text-foreground"
|
||||
aria-label={mvWindow.state === "maximized" ? t("restore") : t("maximize")}
|
||||
title={mvWindow.state === "maximized" ? t("restore") : t("maximize")}
|
||||
>
|
||||
{mvWindow.state === "maximized" ? <Minimize2 className="h-4 w-4" /> : <Maximize2 className="h-4 w-4" />}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); handleClose(); }}
|
||||
className="grid h-7 w-7 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-foreground/10 hover:text-foreground"
|
||||
aria-label={tCommon('close')}
|
||||
title={tCommon('close')}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
// Files dropped on the header attach, as on the rest of the message.
|
||||
const headerDropProps = { onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop };
|
||||
|
||||
// `keepDraft`: the bin's discard, which deletes the draft once its Undo is
|
||||
// over, not here.
|
||||
const handleDiscardAndClose = ({ keepDraft = false }: { keepDraft?: boolean } = {}) => {
|
||||
@@ -5019,8 +5132,11 @@ export function EmailComposer({
|
||||
data-testid="email-composer"
|
||||
// Edits made while the draft moves wouldn't move with it.
|
||||
inert={isPoppingOut || undefined}
|
||||
// The header row on top, across the plugin panels too, so the window
|
||||
// buttons and Close end the whole composer; panels and message below.
|
||||
data-tour="composer"
|
||||
className={cn(
|
||||
"flex h-full bg-background relative",
|
||||
"flex flex-col h-full bg-background relative",
|
||||
className,
|
||||
// Over everything but dialogs (z-60) and toasts; below the desktop app's window controls.
|
||||
// At the folder sidebar's z-50 and after it in the page, so over it (compose-p2-5).
|
||||
@@ -5039,112 +5155,57 @@ export function EmailComposer({
|
||||
<div role="status" aria-live="polite" aria-atomic="true" className="sr-only" data-testid="composer-live-region">
|
||||
{liveMessage && <span key={liveMessage.n}>{liveMessage.text}</span>}
|
||||
</div>
|
||||
<ComposerPluginSidebar side="left" mode={pluginSidebars.modes.left} extraProps={pluginSidebarLeftProps} width={pluginSidebars.widths.left} onWidthChange={(w) => pluginSidebars.setSideWidth('left', w)} />
|
||||
{/* Right-side composer sidebar slot is rendered after the main content div below. */}
|
||||
<div
|
||||
className="flex flex-col h-full bg-background relative flex-1 min-w-0"
|
||||
data-tour="composer"
|
||||
onDragEnter={handleDragEnter}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDragOver={handleDragOver}
|
||||
onDrop={handleDrop}
|
||||
>
|
||||
{/* Drag overlay */}
|
||||
{isDraggingOver && (
|
||||
<div className="absolute inset-0 z-50 flex items-center justify-center bg-background/80 border-2 border-dashed border-primary rounded-lg pointer-events-none">
|
||||
<div className="flex flex-col items-center gap-2 text-primary">
|
||||
<Paperclip className="w-8 h-8" />
|
||||
<span className="text-sm font-medium">{t('drop_files')}</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{/* Header - mobile: clean bar with close/send, desktop: title bar.
|
||||
In Mountain View's window it is the window's title bar instead. */}
|
||||
{mvWindow?.variant === "inline" ? (
|
||||
<div className="flex items-center gap-2 h-10 ps-4 pe-1.5 shrink-0 border-b border-border/50" data-mv-compose-inline-bar="">
|
||||
{mode === 'replyAll'
|
||||
? <ReplyAll className="w-4 h-4 text-muted-foreground flex-shrink-0" />
|
||||
: mode === 'forward'
|
||||
? <Forward className="w-4 h-4 text-muted-foreground flex-shrink-0" />
|
||||
: <Reply className="w-4 h-4 text-muted-foreground flex-shrink-0" />}
|
||||
<h3 className="flex-1 min-w-0 truncate text-sm" data-testid="composer-save-status" data-status={saveStatus}>
|
||||
{mode === 'reply' ? t('reply') : mode === 'replyAll' ? t('reply_all') : mode === 'forward' ? t('forward') : t('new_message')}
|
||||
</h3>
|
||||
{saveStatus === 'saving' && <Save className="w-3.5 h-3.5 animate-pulse text-muted-foreground flex-shrink-0" aria-label={t('saving')} />}
|
||||
{leftPanelToggle}
|
||||
{rightPanelToggle}
|
||||
{mvWindow.popOut && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={mvWindow.popOut}
|
||||
className="grid h-8 w-8 place-items-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
aria-label={t('pop_out')}
|
||||
title={t('pop_out')}
|
||||
>
|
||||
<ExternalLink className="h-4 w-4" />
|
||||
</button>
|
||||
)}
|
||||
{popOutButton("grid h-8 w-8 place-items-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground", "h-4 w-4")}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleClose()}
|
||||
className="grid h-8 w-8 place-items-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
aria-label={tCommon('close')}
|
||||
title={tCommon('close')}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
<div className="flex items-stretch h-10 shrink-0 border-b border-border/50" data-mv-compose-inline-bar="" {...headerDropProps}>
|
||||
{panelHead('left', 'px-1.5')}
|
||||
<div className="flex-1 min-w-0 flex items-center gap-2 ps-4 pe-1.5">
|
||||
{mode === 'replyAll'
|
||||
? <ReplyAll className="w-4 h-4 text-muted-foreground flex-shrink-0" />
|
||||
: mode === 'forward'
|
||||
? <Forward className="w-4 h-4 text-muted-foreground flex-shrink-0" />
|
||||
: <Reply className="w-4 h-4 text-muted-foreground flex-shrink-0" />}
|
||||
<h3 className="flex-1 min-w-0 truncate text-sm" data-testid="composer-save-status" data-status={saveStatus}>
|
||||
{mode === 'reply' ? t('reply') : mode === 'replyAll' ? t('reply_all') : mode === 'forward' ? t('forward') : t('new_message')}
|
||||
</h3>
|
||||
{saveStatus === 'saving' && <Save className="w-3.5 h-3.5 animate-pulse text-muted-foreground flex-shrink-0" aria-label={t('saving')} />}
|
||||
{leftPanelToggle}
|
||||
{rightPanelToggle}
|
||||
{!rightPanelOpen && mvInlineButtons}
|
||||
</div>
|
||||
{panelHead('right', 'ps-1.5 pe-1.5', mvInlineButtons, 'gap-2')}
|
||||
</div>
|
||||
) : mvWindow ? (
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center gap-1 h-10 ps-4 pe-1.5 shrink-0 bg-[var(--mv-search-bg)]",
|
||||
"flex items-stretch h-10 shrink-0 bg-[var(--mv-search-bg)]",
|
||||
mvWindow.state === "minimized" && "cursor-pointer",
|
||||
)}
|
||||
data-mv-compose-titlebar=""
|
||||
onClick={mvWindow.state === "minimized" ? () => mvWindow.setState("normal") : undefined}
|
||||
{...headerDropProps}
|
||||
>
|
||||
<h3 className="flex-1 min-w-0 truncate text-sm font-medium" data-testid="composer-save-status" data-status={saveStatus}>
|
||||
{mode === 'reply' || mode === 'replyAll' || mode === 'forward'
|
||||
? (subject || t('new_message'))
|
||||
: t('new_message')}
|
||||
</h3>
|
||||
{saveStatus === 'saving' && <Save className="w-3.5 h-3.5 animate-pulse text-muted-foreground flex-shrink-0" aria-label={t('saving')} />}
|
||||
{mvWindow.state !== "minimized" && leftPanelToggle}
|
||||
{mvWindow.state !== "minimized" && rightPanelToggle}
|
||||
{mvWindow.state !== "minimized" && popOutButton("grid h-7 w-7 place-items-center rounded-full text-muted-foreground hover:bg-foreground/10 hover:text-foreground", "h-4 w-4")}
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); mvWindow.setState(mvWindow.state === "minimized" ? "normal" : "minimized"); }}
|
||||
className="grid h-7 w-7 place-items-center rounded-full text-muted-foreground hover:bg-foreground/10 hover:text-foreground"
|
||||
aria-label={mvWindow.state === "minimized" ? t("restore") : t("minimize")}
|
||||
title={mvWindow.state === "minimized" ? t("restore") : t("minimize")}
|
||||
>
|
||||
<Minus className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); mvWindow.setState(mvWindow.state === "maximized" ? "normal" : "maximized"); }}
|
||||
className="grid h-7 w-7 place-items-center rounded-full text-muted-foreground hover:bg-foreground/10 hover:text-foreground"
|
||||
aria-label={mvWindow.state === "maximized" ? t("restore") : t("maximize")}
|
||||
title={mvWindow.state === "maximized" ? t("restore") : t("maximize")}
|
||||
>
|
||||
{mvWindow.state === "maximized" ? <Minimize2 className="h-4 w-4" /> : <Maximize2 className="h-4 w-4" />}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => { e.stopPropagation(); handleClose(); }}
|
||||
className="grid h-7 w-7 place-items-center rounded-full text-muted-foreground hover:bg-foreground/10 hover:text-foreground"
|
||||
aria-label={tCommon('close')}
|
||||
title={tCommon('close')}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
{mvWindow.state !== "minimized" && panelHead('left', 'px-1.5')}
|
||||
<div className="flex-1 min-w-0 flex items-center gap-1 ps-4 pe-1.5">
|
||||
<h3 className="flex-1 min-w-0 truncate text-sm font-medium" data-testid="composer-save-status" data-status={saveStatus}>
|
||||
{mode === 'reply' || mode === 'replyAll' || mode === 'forward'
|
||||
? (subject || t('new_message'))
|
||||
: t('new_message')}
|
||||
</h3>
|
||||
{saveStatus === 'saving' && <Save className="w-3.5 h-3.5 animate-pulse text-muted-foreground flex-shrink-0" aria-label={t('saving')} />}
|
||||
{mvWindow.state !== "minimized" && leftPanelToggle}
|
||||
{mvWindow.state !== "minimized" && rightPanelToggle}
|
||||
{(mvWindow.state === "minimized" || !rightPanelOpen) && mvWindowButtons}
|
||||
</div>
|
||||
{mvWindow.state !== "minimized" && panelHead('right', 'ps-1.5 pe-1.5', mvWindowButtons, 'gap-1')}
|
||||
</div>
|
||||
) : (
|
||||
<div ref={setComposerHeader} className="flex items-center gap-3 px-4 py-2 md:py-0 md:h-14 border-b bg-background shrink-0" data-composer-header="">
|
||||
<div ref={setComposerHeader} className="flex items-stretch md:h-14 border-b bg-background shrink-0" data-composer-header="" {...headerDropProps}>
|
||||
{panelHead('left', 'px-2')}
|
||||
<div className="flex-1 min-w-0 flex items-center gap-3 px-4 py-2 md:py-0">
|
||||
{closeBesideControls && composerCloseButton}
|
||||
{/* The left panel's button at the start, the right one's at the end: where each panel is. */}
|
||||
{/* A folded panel's Show button where the panel goes: the left one's at the start, the right one's before the window buttons. */}
|
||||
{leftPanelToggle && <div className="hidden md:flex -ms-2">{leftPanelToggle}</div>}
|
||||
<div className="flex-1 min-w-0 flex items-center gap-3">
|
||||
<div className="flex items-center gap-2" data-testid="composer-save-status" data-status={saveStatus}>
|
||||
@@ -5214,23 +5275,31 @@ export function EmailComposer({
|
||||
</Button>
|
||||
))}
|
||||
{rightPanelToggle}
|
||||
{canMaximize && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setMaximized((v) => !v)}
|
||||
className="hidden md:grid h-8 w-8 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
aria-label={maximized ? t('restore') : t('maximize')}
|
||||
title={maximized ? t('restore') : t('maximize')}
|
||||
data-testid="composer-maximize"
|
||||
>
|
||||
{maximized ? <Minimize2 className="w-4 h-4" /> : <Maximize2 className="w-4 h-4" />}
|
||||
</button>
|
||||
)}
|
||||
{popOutButton(cn(phoneLayout ? "hidden md:grid" : "grid", "h-8 w-8 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground"), "w-4 h-4")}
|
||||
{!closeBesideControls && composerCloseButton}
|
||||
{!rightPanelOpen && windowButtons}
|
||||
</div>
|
||||
{panelHead('right', 'ps-1.5 pe-4', windowButtons, 'gap-3')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* The left panel, the message and the right panel, under the header. */}
|
||||
<div className="flex flex-1 min-h-0 relative" data-composer-panels="">
|
||||
<ComposerPluginSidebar side="left" mode={pluginSidebars.modes.left} extraProps={pluginSidebarLeftProps} width={pluginSidebars.widths.left} onWidthChange={(w) => pluginSidebars.setSideWidth('left', w)} />
|
||||
<div
|
||||
className="flex flex-col h-full bg-background relative flex-1 min-w-0"
|
||||
onDragEnter={handleDragEnter}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDragOver={handleDragOver}
|
||||
onDrop={handleDrop}
|
||||
>
|
||||
{/* Drag overlay */}
|
||||
{isDraggingOver && (
|
||||
<div className="absolute inset-0 z-50 flex items-center justify-center bg-background/80 border-2 border-dashed border-primary rounded-lg pointer-events-none">
|
||||
<div className="flex flex-col items-center gap-2 text-primary">
|
||||
<Paperclip className="w-8 h-8" />
|
||||
<span className="text-sm font-medium">{t('drop_files')}</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{/* Fields + body. While pinFields holds, the fields sit outside the
|
||||
body's scroll container so From/To/Cc/Bcc/Subject stay reachable
|
||||
while scrolling long bodies, matching the pinned formatting toolbar
|
||||
@@ -5890,14 +5959,19 @@ export function EmailComposer({
|
||||
className="hidden"
|
||||
accept="*/*"
|
||||
/>
|
||||
{(filesEnabled && composerClient?.supportsFiles?.()) || hasAttachMenuActions ? (
|
||||
{recentOffered || (filesEnabled && composerClient?.supportsFiles?.()) || hasAttachMenuActions ? (
|
||||
<ComposerToolbarMenu icon={Paperclip} label={t('attach')} testId="composer-attach-menu">
|
||||
{(close) => <>
|
||||
{/* As Outlook's: the recent files first, one click attaches one and closes. */}
|
||||
{recentOffered && (
|
||||
<RecentFilesMenuSection onPick={(file) => { close(); void attachRecentFile(file); }} />
|
||||
)}
|
||||
<ComposerToolbarMenuItem
|
||||
icon={Upload}
|
||||
onSelect={() => { close(); fileInputRef.current?.click(); }}
|
||||
testId="composer-attach-from-device"
|
||||
>
|
||||
{t('attach_from_device')}
|
||||
{isDesktopApp() ? tRecent('browse') : t('attach_from_device')}
|
||||
</ComposerToolbarMenuItem>
|
||||
{filesEnabled && composerClient?.supportsFiles?.() && (
|
||||
<ComposerToolbarMenuItem
|
||||
@@ -5905,7 +5979,7 @@ export function EmailComposer({
|
||||
onSelect={() => { close(); setFilesPicker({ client: composerClient, accountId: composerAccountId }); }}
|
||||
testId="composer-attach-from-files"
|
||||
>
|
||||
{t('attach_from_files')}
|
||||
{isDesktopApp() ? tRecent('from_files') : t('attach_from_files')}
|
||||
</ComposerToolbarMenuItem>
|
||||
)}
|
||||
<ComposerPluginMenuItems surface="composer-attach-menu" context={composerActionContext} onSelect={close} separator />
|
||||
@@ -6305,6 +6379,7 @@ export function EmailComposer({
|
||||
)}
|
||||
</div>
|
||||
<ComposerPluginSidebar side="right" mode={pluginSidebars.modes.right} extraProps={pluginSidebarRightProps} width={pluginSidebars.widths.right} onWidthChange={(w) => pluginSidebars.setSideWidth('right', w)} />
|
||||
</div>
|
||||
<ComposerSelectionMenu menu={selectionMenu} composerId={pluginComposerId} onClipboard={clipboardFromMenu} />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||
import { useLocale, useTranslations } from "next-intl";
|
||||
import { CONTEXT_MENU_ITEM_CLASS, menuLevelItems } from "@/components/ui/context-menu";
|
||||
import { attachmentIcon } from "@/components/email/attachment-chips";
|
||||
import { listRecentFiles, recentWhen, shortFolder } from "@/lib/desktop/recent-files";
|
||||
import type { DesktopRecentFile } from "@/lib/desktop/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/** Only an icon the shell made: a PNG as a data: URL. */
|
||||
const ICON_URL = /^data:image\/png;base64,[A-Za-z0-9+/=]+$/;
|
||||
|
||||
/**
|
||||
* The top of the composer's Attach menu in the desktop app: the files the OS says were
|
||||
* used last, as Outlook lists them. Mounted when the menu opens, from that click, which is
|
||||
* what the shell asks for. Until the list is there, and when it's empty, it takes no room.
|
||||
* It stays an HTML menu (data-native-menu): a native one can't show the icons and folders.
|
||||
*/
|
||||
export function RecentFilesMenuSection({ onPick }: { onPick: (file: DesktopRecentFile) => void }) {
|
||||
const t = useTranslations("desktopAttachRecent");
|
||||
const locale = useLocale();
|
||||
const [files, setFiles] = useState<DesktopRecentFile[] | null>(null);
|
||||
// One request per opening, also when a strict-mode remount runs the effect twice.
|
||||
const request = useRef<Promise<DesktopRecentFile[]> | null>(null);
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
request.current ??= listRecentFiles();
|
||||
void request.current.then((list) => {
|
||||
if (!cancelled) setFiles(list);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
// The menu put the focus on its first entry before the list came. If it's still
|
||||
// there, the first file takes it: the list is what comes first.
|
||||
useLayoutEffect(() => {
|
||||
const root = rootRef.current;
|
||||
const menu = root?.closest<HTMLElement>('[role="menu"]');
|
||||
if (!root || !menu || !files?.length) return;
|
||||
const active = document.activeElement;
|
||||
const others = menuLevelItems(menu).filter((item) => !root.contains(item));
|
||||
if (active && active === others[0]) root.querySelector<HTMLElement>('[role="menuitem"]')?.focus({ preventScroll: true });
|
||||
}, [files]);
|
||||
|
||||
const now = Date.now();
|
||||
return (
|
||||
<div ref={rootRef} data-native-menu="html" data-testid="composer-recent-files" hidden={!files?.length}>
|
||||
{files && files.length > 0 && (
|
||||
<>
|
||||
<div role="presentation" className="px-3 pb-1 pt-1.5 text-xs font-medium text-muted-foreground">
|
||||
{t("heading")}
|
||||
</div>
|
||||
{files.map((file) => {
|
||||
const Fallback = attachmentIcon(null, file.name).icon;
|
||||
return (
|
||||
<button
|
||||
key={file.id}
|
||||
type="button"
|
||||
role="menuitem"
|
||||
title={file.path}
|
||||
onClick={() => onPick(file)}
|
||||
data-testid="composer-recent-file"
|
||||
className={cn(CONTEXT_MENU_ITEM_CLASS, "w-[min(24rem,calc(100vw-3rem))] gap-2.5")}
|
||||
>
|
||||
{file.icon && ICON_URL.test(file.icon) ? (
|
||||
<img src={file.icon} alt="" aria-hidden="true" draggable={false} className="h-4 w-4 shrink-0" />
|
||||
) : (
|
||||
<Fallback className="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden="true" />
|
||||
)}
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate">{file.name}</span>
|
||||
<span className="block truncate text-xs text-muted-foreground">{shortFolder(file.folder)}</span>
|
||||
</span>
|
||||
<span className="shrink-0 self-start pt-0.5 text-xs text-muted-foreground">{recentWhen(file.usedAt, now, locale)}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
<div role="separator" className="my-1 h-px bg-border" />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -366,6 +366,53 @@ describe('FileBrowser', () => {
|
||||
expect(drawer).not.toHaveAttribute('inert');
|
||||
});
|
||||
|
||||
// The same drawer as Mail's folders (usability test 2026-11-04): it opened
|
||||
// beside the app rail with only the file list dimmed, ignored Escape and
|
||||
// left the focus on the page.
|
||||
it("opens the folder drawer from the window's edge, with the whole window dimmed", () => {
|
||||
renderBrowser();
|
||||
const drawer = screen.getByTestId('files-sidebar-drawer');
|
||||
const classes = drawer.className.split(/\s+/);
|
||||
expect(classes).toEqual(expect.arrayContaining(['fixed', 'start-0', 'top-[var(--drawer-top)]', 'bottom-0']));
|
||||
expect(classes).not.toContain('absolute');
|
||||
tree();
|
||||
expect(screen.getByTestId('drawer-scrim').className.split(/\s+/)).toEqual(expect.arrayContaining(['fixed', 'inset-0']));
|
||||
});
|
||||
|
||||
it('takes the focus into the folder drawer, keeps Tab there and gives it back on Escape without clearing the search', () => {
|
||||
renderBrowser();
|
||||
const drawer = screen.getByTestId('files-sidebar-drawer');
|
||||
const menu = screen.getByRole('button', { name: 'open_folder_tree' });
|
||||
fireEvent.change(screen.getAllByRole('searchbox')[0], { target: { value: 'notes' } });
|
||||
menu.focus();
|
||||
fireEvent.click(menu);
|
||||
// The folder on screen.
|
||||
expect(drawer.contains(document.activeElement)).toBe(true);
|
||||
expect(document.activeElement).toHaveAttribute('aria-current', 'page');
|
||||
const stops = Array.from(drawer.querySelectorAll<HTMLElement>('button:not(:disabled)'));
|
||||
stops.at(-1)!.focus();
|
||||
fireEvent.keyDown(stops.at(-1)!, { key: 'Tab' });
|
||||
expect(document.activeElement).toBe(stops[0]);
|
||||
|
||||
fireEvent.keyDown(document.activeElement!, { key: 'Escape' });
|
||||
expect(drawer).toHaveAttribute('inert');
|
||||
expect(document.activeElement).toBe(menu);
|
||||
expect(screen.getAllByRole('searchbox')[0]).toHaveValue('notes');
|
||||
});
|
||||
|
||||
it('closes the folder drawer on a click on the dimmed window and gives the focus back to the menu button', () => {
|
||||
renderBrowser();
|
||||
const drawer = screen.getByTestId('files-sidebar-drawer');
|
||||
const menu = screen.getByRole('button', { name: 'open_folder_tree' });
|
||||
menu.focus();
|
||||
fireEvent.click(menu);
|
||||
// A press on the scrim drops the focus to the page.
|
||||
(document.activeElement as HTMLElement).blur();
|
||||
fireEvent.click(screen.getByTestId('drawer-scrim'));
|
||||
expect(drawer).toHaveAttribute('inert');
|
||||
expect(document.activeElement).toBe(menu);
|
||||
});
|
||||
|
||||
it("renames in a dialog that selects the name without its extension and closes on Escape", async () => {
|
||||
renderBrowser({ props: { selectedResources: new Set(['notes.txt']) } });
|
||||
fireEvent.keyDown(window, { key: 'F2' });
|
||||
|
||||
@@ -32,6 +32,8 @@ import { INTERNAL_DRAG_TYPE, isInternalDrag, readDraggedNames } from "@/componen
|
||||
import { ResizeHandle } from "@/components/layout/resize-handle";
|
||||
import { AppMain } from "@/components/layout/app-landmarks";
|
||||
import { useIsEmbedded } from "@/hooks/use-is-embedded";
|
||||
import { useMountainViewShell } from "@/hooks/use-mountain-view-shell";
|
||||
import { EdgeDrawer } from "@/components/layout/edge-drawer";
|
||||
import { getDroppedFilesAndFolders } from "@/lib/webdav/drop-utils";
|
||||
import { getFilePreviewKind } from "@/lib/file-preview";
|
||||
import type { FileAppAction } from "@/lib/files-app-actions";
|
||||
@@ -299,6 +301,7 @@ export function FileBrowser({
|
||||
const isMobile = useIsMobile();
|
||||
const touch = useMediaQuery("(pointer: coarse)") && isMobile;
|
||||
const [narrowSidebarOpen, setNarrowSidebarOpen] = useState(false);
|
||||
const closeNarrowSidebar = useCallback(() => setNarrowSidebarOpen(false), []);
|
||||
useEffect(() => { if (!isNarrow) setNarrowSidebarOpen(false); }, [isNarrow]);
|
||||
useEffect(() => { setNarrowSidebarOpen(false); }, [currentPath]);
|
||||
// Anything picked in the drawer closes it (R7).
|
||||
@@ -845,6 +848,8 @@ export function FileBrowser({
|
||||
return;
|
||||
}
|
||||
if (e.key === "Escape") {
|
||||
// The folder drawer is the innermost layer; it closes itself (R8).
|
||||
if (narrowSidebarOpen) return;
|
||||
// The details panel over the list closes first (innermost layer, R8).
|
||||
if (showDetails && isNarrow) toggleDetails(false);
|
||||
else if (searchQuery) setSearchQuery("");
|
||||
@@ -907,7 +912,7 @@ export function FileBrowser({
|
||||
return () => window.removeEventListener("keydown", handler);
|
||||
}, [
|
||||
showNewFolder, showNewTextFile, renameTarget, renameFolder, shareTargetId, moveTarget, accountPickerMode, selectedList, singleSelected, inTrash,
|
||||
showDetails, isNarrow, toggleDetails,
|
||||
showDetails, isNarrow, toggleDetails, narrowSidebarOpen,
|
||||
selectAllVisible, onCopy, onCut, onPaste, clipboard, searchQuery, onClearSelection, deleteNames, openResource,
|
||||
focusedName, onToggleSelect, currentPath, navigateUp, viewMode, gridColumns, moveFocus, displayResources,
|
||||
]);
|
||||
@@ -1109,6 +1114,8 @@ export function FileBrowser({
|
||||
const tSidebar = useTranslations("sidebar");
|
||||
const tShell = useTranslations("shell");
|
||||
const isEmbedded = useIsEmbedded();
|
||||
// Mountain View's card holds the drawer, under its top bar.
|
||||
const mvShell = useMountainViewShell(isEmbedded);
|
||||
useRegisterCommands(tSidebar("files"), [
|
||||
{ id: "upload-files", label: tMenu("files_upload_files"), icon: Upload, run: () => fileInputRef.current?.click(), when: () => canCreate },
|
||||
{ id: "upload-folder", label: tMenu("files_upload_folder"), icon: FolderUp, run: () => folderInputRef.current?.click(), when: () => canCreate },
|
||||
@@ -1314,26 +1321,21 @@ export function FileBrowser({
|
||||
} : null;
|
||||
|
||||
return (
|
||||
// Clips the closed drawer, so it never sits over the nav rail.
|
||||
// Holds the drawer in a Pro pane and clips it there when closed.
|
||||
<div className="relative flex flex-1 min-h-0 overflow-hidden">
|
||||
{/* Folder sidebar: in flow on desktop, a drawer on narrow panes */}
|
||||
{sidebar && isNarrow && narrowSidebarOpen && (
|
||||
<div className="absolute inset-0 bg-black/50 z-40" onClick={() => setNarrowSidebarOpen(false)} />
|
||||
)}
|
||||
{/* Folder sidebar: in flow on the full desktop; below it a drawer from
|
||||
the window's edge, over the app rail, as Mail's folders. */}
|
||||
{sidebar && (isNarrow ? (
|
||||
<div
|
||||
<EdgeDrawer
|
||||
open={narrowSidebarOpen}
|
||||
onClose={closeNarrowSidebar}
|
||||
contained={isEmbedded || mvShell}
|
||||
data-testid="files-sidebar-drawer"
|
||||
data-pane="sidebar"
|
||||
className={cn(
|
||||
"absolute inset-y-0 start-0 z-50 w-72 border-e border-border",
|
||||
"transform transition-[transform,visibility] duration-300 ease-in-out",
|
||||
!narrowSidebarOpen && "invisible -translate-x-full rtl:translate-x-full",
|
||||
)}
|
||||
// Closed, the drawer is out of reach: no clicks, no Tab stops.
|
||||
inert={!narrowSidebarOpen}
|
||||
className="border-e border-border"
|
||||
>
|
||||
{sidebar}
|
||||
</div>
|
||||
</EdgeDrawer>
|
||||
) : (
|
||||
<>
|
||||
<div
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { useState } from 'react';
|
||||
import { act, fireEvent, render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { EdgeDrawer } from '../edge-drawer';
|
||||
|
||||
// The drawer Calendar, Contacts and Files open below the full desktop, with
|
||||
// the keyboard side Mail's phone drawer uses too (useEdgeDrawer).
|
||||
|
||||
function Harness({ contained = false, onPickFocus }: { contained?: boolean; onPickFocus?: () => void }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<button type="button" onClick={() => setOpen(true)}>menu</button>
|
||||
<input aria-label="elsewhere" />
|
||||
<EdgeDrawer open={open} onClose={() => setOpen(false)} contained={contained} data-testid="drawer">
|
||||
<button type="button">first</button>
|
||||
<button type="button" aria-current="true">current</button>
|
||||
<button type="button" onClick={() => { setOpen(false); onPickFocus?.(); }}>pick</button>
|
||||
</EdgeDrawer>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
describe('EdgeDrawer', () => {
|
||||
it('opens on the current item and gives the focus back to the opener after a pick', () => {
|
||||
render(<Harness />);
|
||||
const menu = screen.getByText('menu');
|
||||
menu.focus();
|
||||
fireEvent.click(menu);
|
||||
expect(document.activeElement).toBe(screen.getByText('current'));
|
||||
fireEvent.click(screen.getByText('pick'));
|
||||
expect(screen.getByTestId('drawer')).toHaveAttribute('inert');
|
||||
expect(document.activeElement).toBe(menu);
|
||||
});
|
||||
|
||||
// Seen in the desktop app: with visibility in the opening transition the
|
||||
// panel is still hidden in its first frame and refuses the focus.
|
||||
it('is visible from its first frame when it opens, and hidden only after sliding out', () => {
|
||||
render(<Harness />);
|
||||
const classes = () => screen.getByTestId('drawer').className.split(/\s+/);
|
||||
expect(classes()).toContain('transition-[transform,visibility]');
|
||||
fireEvent.click(screen.getByText('menu'));
|
||||
expect(classes()).toContain('transition-transform');
|
||||
expect(classes()).not.toContain('transition-[transform,visibility]');
|
||||
expect(classes()).not.toContain('invisible');
|
||||
});
|
||||
|
||||
it('leaves the focus where a pick moved it, outside the drawer', () => {
|
||||
render(<Harness onPickFocus={() => screen.getByLabelText('elsewhere').focus()} />);
|
||||
const menu = screen.getByText('menu');
|
||||
menu.focus();
|
||||
fireEvent.click(menu);
|
||||
act(() => fireEvent.click(screen.getByText('pick')));
|
||||
expect(document.activeElement).toBe(screen.getByLabelText('elsewhere'));
|
||||
});
|
||||
|
||||
it('stays inside a Pro pane: at the pane\'s edge, with only the pane dimmed', () => {
|
||||
render(<Harness contained />);
|
||||
fireEvent.click(screen.getByText('menu'));
|
||||
const classes = screen.getByTestId('drawer').className.split(/\s+/);
|
||||
expect(classes).toEqual(expect.arrayContaining(['absolute', 'inset-y-0', 'start-0']));
|
||||
expect(classes).not.toContain('fixed');
|
||||
expect(screen.getByTestId('drawer-scrim').className.split(/\s+/)).toContain('absolute');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,224 @@
|
||||
import { act, render, screen, fireEvent, cleanup } from '@testing-library/react';
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import type { Mailbox } from '@/lib/jmap/types';
|
||||
|
||||
// The folded folder column (600 to 1024 px) of a mailbox with many folders,
|
||||
// scrolled: shared accounts left only their headings' rules behind, stacked
|
||||
// into a ladder of lines; the unread counter sat on the icon; one folder of
|
||||
// one's own was a letter in a box; and the drawer a hover opened kept the
|
||||
// column's scroll offset, so the hovered folder was somewhere else.
|
||||
|
||||
vi.mock('@/components/plugins/plugin-slot', () => ({ PluginSlot: () => null }));
|
||||
vi.mock('@/components/tour/tour-provider', () => ({
|
||||
useTour: () => ({ startTour: vi.fn(), resetTourCompletion: vi.fn(), activeTour: null, endTour: vi.fn(), registerStep: vi.fn() }),
|
||||
}));
|
||||
vi.mock('@/contexts/drag-drop-context', () => ({
|
||||
useDragDropContext: () => ({ isDragging: false }),
|
||||
}));
|
||||
vi.mock('@/hooks/use-mailbox-drop', () => ({
|
||||
useMailboxDrop: () => ({ dropHandlers: {}, isValidDropTarget: false, isInvalidDropTarget: false }),
|
||||
}));
|
||||
vi.mock('@/hooks/use-tag-drop', () => ({
|
||||
useTagDrop: () => ({ dropHandlers: {}, isValidDropTarget: false }),
|
||||
}));
|
||||
vi.mock('../account-switcher', () => ({ AccountSwitcher: () => null }));
|
||||
|
||||
const { Sidebar } = await import('../sidebar');
|
||||
const { useAuthStore } = await import('@/stores/auth-store');
|
||||
const { useSettingsStore } = await import('@/stores/settings-store');
|
||||
const { useUIStore } = await import('@/stores/ui-store');
|
||||
|
||||
const box = (id: string, name: string, role: string | null, extra: Partial<Mailbox> = {}) => ({
|
||||
id, name, role, parentId: null, totalEmails: 0, unreadEmails: 0, myRights: { mayAddItems: true }, ...extra,
|
||||
}) as unknown as Mailbox;
|
||||
|
||||
const shared = (id: string, name: string, role: string | null, extra: Partial<Mailbox> = {}) =>
|
||||
box(`g1:${id}`, name, role, { originalId: id, accountId: 'g1', accountName: 'Sam Ortega', isShared: true, ...extra });
|
||||
|
||||
const own = [
|
||||
box('inbox', 'Inbox', 'inbox', { totalEmails: 120, unreadEmails: 9 }),
|
||||
box('clients', 'Clients', null, { parentId: 'inbox', unreadEmails: 132 }),
|
||||
box('trash', 'Trash', 'trash', { unreadEmails: 3 }),
|
||||
box('news', 'Newsletters', null, { unreadEmails: 150 }),
|
||||
];
|
||||
// A shared account without an inbox: two folders someone shared.
|
||||
const sharedNoInbox = [shared('team', 'Team', null, { unreadEmails: 2 }), shared('board', 'Board', null, { unreadEmails: 1 })];
|
||||
|
||||
const nav = () => document.querySelector<HTMLElement>('[data-folder-nav]')!;
|
||||
const drawer = () => document.querySelector<HTMLElement>('[data-folder-drawer]');
|
||||
const row = (key: string) => document.querySelector<HTMLElement>(`[data-rail-key="${key}"]`)!;
|
||||
const railButtons = () => Array.from(nav().querySelectorAll<HTMLElement>('[data-testid="folder-row"] > button'));
|
||||
|
||||
describe('the folded folder column with many folders', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
useAuthStore.setState({ activeAccountId: 'login-a', client: { getAccountId: () => 'me', getCapabilities: () => ({}) } } as never);
|
||||
useSettingsStore.setState({
|
||||
hideAccountSwitcher: true, interfaceLayout: 'default', openOnHover: true, unreadCountStyle: 'count',
|
||||
showSharedMailAccounts: true, hiddenSharedMailAccounts: {}, compactSharedMailboxes: false,
|
||||
} as never);
|
||||
useUIStore.setState({ sidebarCollapsed: true, compactSidebarExpanded: false } as never);
|
||||
});
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
vi.useRealTimers();
|
||||
vi.restoreAllMocks();
|
||||
useUIStore.setState({ sidebarCollapsed: false } as never);
|
||||
});
|
||||
|
||||
it('draws one rule between sections, never two in a row', () => {
|
||||
render(<Sidebar mailboxes={[...own, ...sharedNoInbox]} selectedMailbox="inbox" />);
|
||||
// Folders, Your folders, Shared (with its account inside), Tags.
|
||||
const rules = nav().querySelectorAll('[data-rail-separator]');
|
||||
expect(rules).toHaveLength(2 + 1);
|
||||
// Walk the column in order: something to click between any two rules.
|
||||
const order = Array.from(nav().querySelectorAll('[data-rail-separator], [data-testid="folder-row"]'));
|
||||
order.forEach((el, i) => {
|
||||
if (i === 0) return;
|
||||
const both = el.hasAttribute('data-rail-separator') && order[i - 1].hasAttribute('data-rail-separator');
|
||||
expect(both, `two rules in a row at ${i}`).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('lists a shared account as one item, which opens the drawer with it unfolded when it has no inbox', () => {
|
||||
render(<Sidebar mailboxes={[...own, ...sharedNoInbox]} selectedMailbox="inbox" />);
|
||||
const item = row('shared-account-g1');
|
||||
expect(item.getAttribute('data-testid')).toBe('folder-row');
|
||||
const button = item.querySelector('button')!;
|
||||
expect(button.getAttribute('title')).toBe('name_unread');
|
||||
expect(item.querySelector('[data-testid="folded-unread"]')?.textContent).toBe('3');
|
||||
fireEvent.click(button);
|
||||
expect(drawer()).not.toBeNull();
|
||||
expect(screen.getByText('Team')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('opens a shared account\'s inbox from its item, and marks it while one of its folders is open', () => {
|
||||
const onMailboxSelect = vi.fn();
|
||||
const mailboxes = [...own, shared('in', 'Inbox', 'inbox', { unreadEmails: 4 }), ...sharedNoInbox];
|
||||
const { rerender } = render(<Sidebar mailboxes={mailboxes} selectedMailbox="inbox" onMailboxSelect={onMailboxSelect} />);
|
||||
fireEvent.click(row('shared-account-g1').querySelector('button')!);
|
||||
expect(onMailboxSelect).toHaveBeenCalledWith('g1:in');
|
||||
rerender(<Sidebar mailboxes={mailboxes} selectedMailbox="g1:team" onMailboxSelect={onMailboxSelect} />);
|
||||
expect(row('shared-account-g1').querySelector('[data-testid="folded-selected"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('puts the counter at the icon\'s corner, beside the glyph, and says 99+ for more', () => {
|
||||
render(<Sidebar mailboxes={own} selectedMailbox="inbox" />);
|
||||
const badge = row('trash').querySelector<HTMLElement>('[data-testid="folded-unread"]')!;
|
||||
expect(badge.textContent).toBe('3');
|
||||
// On the 36px item, above the 16px icon's box, not inside it over the glyph.
|
||||
expect(badge.parentElement!.tagName).toBe('BUTTON');
|
||||
expect(badge.parentElement!.className).toContain('h-9');
|
||||
expect(badge.className.split(/\s+/)).toEqual(expect.arrayContaining(['absolute', 'top-0', 'end-0', 'h-3']));
|
||||
expect(badge.className).not.toContain('ring-2');
|
||||
expect(row('news').querySelector('[data-testid="folded-unread"]')!.textContent).toBe('99+');
|
||||
});
|
||||
|
||||
it('gives every item a tooltip with its name and count', () => {
|
||||
render(<Sidebar mailboxes={[...own, ...sharedNoInbox]} selectedMailbox="inbox" />);
|
||||
for (const button of railButtons()) {
|
||||
const title = button.getAttribute('title');
|
||||
expect(title, button.outerHTML.slice(0, 120)).toBeTruthy();
|
||||
expect(title).toBe(button.getAttribute('aria-label'));
|
||||
}
|
||||
// With unread mail the name carries the count.
|
||||
expect(row('inbox').querySelector('button')!.getAttribute('title')).toBe('name_unread');
|
||||
});
|
||||
|
||||
it('draws one folder of one\'s own as a plain folder, several with their first letter inside the folder', () => {
|
||||
render(<Sidebar mailboxes={own} selectedMailbox="inbox" />);
|
||||
expect(row('news').querySelector('[data-testid="folder-initial"]')).toBeNull();
|
||||
expect(row('news').querySelector('svg')).not.toBeNull();
|
||||
cleanup();
|
||||
render(<Sidebar mailboxes={[...own, box('receipts', 'receipts', null)]} selectedMailbox="inbox" />);
|
||||
const letter = row('receipts').querySelector('[data-testid="folder-initial"]')!;
|
||||
expect(letter.textContent).toBe('R');
|
||||
// Inside the folder glyph, an icon like the others, not a box of its own.
|
||||
expect(letter.closest('svg')?.querySelector('path')).not.toBeNull();
|
||||
expect(letter.closest('svg')!.getAttribute('class')).toContain('w-4');
|
||||
});
|
||||
|
||||
it('marks the open folder with a bar at the edge and a filled item', () => {
|
||||
render(<Sidebar mailboxes={own} selectedMailbox="trash" />);
|
||||
// Over the filled item, not under it.
|
||||
expect(row('trash').querySelector('[data-testid="folded-selected"]')!.className).toContain('z-10');
|
||||
expect(row('trash').querySelector('button')!.className).toContain('bg-accent');
|
||||
expect(row('inbox').querySelector('[data-testid="folded-selected"]')).toBeNull();
|
||||
expect(row('inbox').querySelector('button')!.className).not.toContain('bg-accent');
|
||||
});
|
||||
|
||||
it('scrolls on its own, never sideways, with a thin scrollbar', () => {
|
||||
render(<Sidebar mailboxes={own} selectedMailbox="inbox" />);
|
||||
expect(nav().hasAttribute('data-folder-rail')).toBe(true);
|
||||
expect(nav().className.split(/\s+/)).toEqual(expect.arrayContaining(['overflow-y-auto', 'overflow-x-hidden', 'min-h-0']));
|
||||
});
|
||||
|
||||
it('moves through the items with the arrows, Home and End', () => {
|
||||
render(<Sidebar mailboxes={[...own, ...sharedNoInbox]} selectedMailbox="inbox" />);
|
||||
const buttons = railButtons().filter((b) => !(b as HTMLButtonElement).disabled);
|
||||
buttons[0].focus();
|
||||
fireEvent.keyDown(buttons[0], { key: 'ArrowDown' });
|
||||
expect(document.activeElement).toBe(buttons[1]);
|
||||
fireEvent.keyDown(buttons[1], { key: 'ArrowUp' });
|
||||
expect(document.activeElement).toBe(buttons[0]);
|
||||
fireEvent.keyDown(buttons[0], { key: 'End' });
|
||||
expect(document.activeElement).toBe(buttons[buttons.length - 1]);
|
||||
fireEvent.keyDown(buttons[buttons.length - 1], { key: 'Home' });
|
||||
expect(document.activeElement).toBe(buttons[0]);
|
||||
});
|
||||
|
||||
describe('the drawer opened from the scrolled column', () => {
|
||||
// jsdom has no layout: the list's items sit at fixed places in the
|
||||
// content, further down in the longer tree of the drawer.
|
||||
let scrollTop = 0;
|
||||
const NAV_TOP = 100;
|
||||
const place = (el: Element) => {
|
||||
const key = (el as HTMLElement).dataset?.railKey;
|
||||
if (key !== 'news') return null;
|
||||
return drawer() ? 900 : 500;
|
||||
};
|
||||
beforeEach(() => {
|
||||
scrollTop = 0;
|
||||
vi.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(function (this: Element) {
|
||||
// The list shows 600px; anything else is somewhere inside it.
|
||||
const isNav = this.hasAttribute('data-folder-nav');
|
||||
const at = place(this);
|
||||
const top = isNav ? NAV_TOP : at === null ? NAV_TOP + 10 : NAV_TOP + at - scrollTop;
|
||||
const height = isNav ? 600 : 36;
|
||||
return { top, bottom: top + height, left: 0, right: 48, width: 48, height, x: 0, y: top, toJSON: () => ({}) } as DOMRect;
|
||||
});
|
||||
});
|
||||
const trackScroll = () => Object.defineProperty(nav(), 'scrollTop', {
|
||||
configurable: true,
|
||||
get: () => scrollTop,
|
||||
set: (v: number) => { scrollTop = v; },
|
||||
});
|
||||
|
||||
it('puts the hovered item back under the pointer, and the column back where it was', () => {
|
||||
vi.useFakeTimers();
|
||||
const { container } = render(<Sidebar mailboxes={own} selectedMailbox="inbox" />);
|
||||
trackScroll();
|
||||
scrollTop = 200;
|
||||
const news = row('news');
|
||||
document.elementFromPoint = vi.fn(() => news.querySelector('button'));
|
||||
// At 400 on screen in the column: 100 + 500 - 200.
|
||||
fireEvent.mouseEnter(container.firstElementChild!, { clientX: 20, clientY: 410 });
|
||||
act(() => { vi.advanceTimersByTime(400); });
|
||||
expect(drawer()).not.toBeNull();
|
||||
// In the drawer it is 900 down the list: scrolled so it is at 400 again.
|
||||
expect(scrollTop).toBe(600);
|
||||
fireEvent.mouseLeave(container.firstElementChild!);
|
||||
expect(drawer()).toBeNull();
|
||||
expect(scrollTop).toBe(200);
|
||||
});
|
||||
|
||||
it('starts at the top when All folders opens it', () => {
|
||||
render(<Sidebar mailboxes={own} selectedMailbox="inbox" />);
|
||||
trackScroll();
|
||||
scrollTop = 200;
|
||||
fireEvent.click(screen.getByTestId('folded-all-folders'));
|
||||
expect(drawer()).not.toBeNull();
|
||||
expect(scrollTop).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -102,11 +102,15 @@ describe('the folded column\'s drawer (default layout)', () => {
|
||||
expect(inDrawer).toBe(docked);
|
||||
});
|
||||
|
||||
it('mirrors the collapse arrows in RTL, where the drawer comes from the right', () => {
|
||||
// RTL: globals.css mirrors the chevrons icons; a flip of their own as well would turn them back.
|
||||
it('leaves the collapse arrows to the global RTL mirror, where the drawer comes from the right', () => {
|
||||
const arrow = () => screen.getByTestId('sidebar-collapse').querySelector('svg')!.getAttribute('class') ?? '';
|
||||
render(<Sidebar mailboxes={mailboxes} selectedMailbox="inbox" />);
|
||||
expect(screen.getByTestId('sidebar-collapse').querySelector('svg')!.getAttribute('class')).toContain('rtl:-scale-x-100');
|
||||
expect(arrow()).toMatch(/tabler-icon-chevrons-(left|right)/);
|
||||
expect(arrow()).not.toMatch(/rtl:/);
|
||||
openFromAllFolders();
|
||||
expect(screen.getByTestId('sidebar-collapse').querySelector('svg')!.getAttribute('class')).toContain('rtl:-scale-x-100');
|
||||
expect(arrow()).toMatch(/tabler-icon-chevrons-(left|right)/);
|
||||
expect(arrow()).not.toMatch(/rtl:/);
|
||||
});
|
||||
|
||||
it('keeps Tab and Shift+Tab inside while open', () => {
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
"use client";
|
||||
|
||||
import type { HTMLAttributes, ReactNode } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useEdgeDrawer } from "@/hooks/use-edge-drawer";
|
||||
|
||||
interface DrawerScrimProps {
|
||||
onClose: () => void;
|
||||
/** In a Pro pane: dims the pane only, not the other one beside it. */
|
||||
contained?: boolean;
|
||||
className?: string;
|
||||
"data-testid"?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The dimmed page behind a drawer. A click on it closes the drawer; the
|
||||
* click, not the press, so it can't go through to what is under it.
|
||||
*/
|
||||
export function DrawerScrim({ onClose, contained, className, "data-testid": testId = "drawer-scrim" }: DrawerScrimProps) {
|
||||
return (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-testid={testId}
|
||||
data-drawer-scrim=""
|
||||
className={cn("inset-0 bg-black/50 z-40", contained ? "absolute" : "fixed", className)}
|
||||
onClick={() => onClose()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
interface EdgeDrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
/**
|
||||
* In a Pro pane or Mountain View's card: at the start edge of the nearest
|
||||
* positioned box instead of the window's.
|
||||
*/
|
||||
contained?: boolean;
|
||||
/** Where the focus goes back to when the opener is gone by then. */
|
||||
returnFocus?: () => HTMLElement | null | undefined;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* A sidebar opened over the page below the full desktop, as Mail's folders
|
||||
* do: from the window's start edge (the right in RTL), over the app rail,
|
||||
* from under the top bar and the window's controls (--drawer-top) to the
|
||||
* bottom, with the page dimmed behind it. Keyboard and focus: useEdgeDrawer.
|
||||
* Closed, it is off-screen and out of reach: no clicks, no Tab stops.
|
||||
*/
|
||||
export function EdgeDrawer({ open, onClose, contained, returnFocus, className, children, ...rest }: EdgeDrawerProps) {
|
||||
const ref = useEdgeDrawer({ open, onClose, returnFocus });
|
||||
return (
|
||||
<>
|
||||
{open && <DrawerScrim onClose={onClose} contained={contained} />}
|
||||
<div
|
||||
{...rest}
|
||||
ref={ref}
|
||||
data-edge-drawer=""
|
||||
inert={!open}
|
||||
className={cn(
|
||||
"z-50 w-72 max-w-[85%] flex flex-col",
|
||||
contained ? "absolute inset-y-0 start-0" : "fixed start-0 top-[var(--drawer-top)] bottom-0",
|
||||
"transform duration-300 ease-in-out",
|
||||
// Visible at once on opening, so the focus can go in straight away
|
||||
// (a visibility transition keeps it hidden for that first frame);
|
||||
// hidden only once it has slid out on closing.
|
||||
open ? "shadow-xl transition-transform" : "invisible -translate-x-full rtl:translate-x-full transition-[transform,visibility]",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+217
-42
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { hoverOpens } from "@/lib/open-on-hover";
|
||||
import { memo, useState, useEffect, useMemo, useCallback, useRef, useId, Fragment, ReactNode } from "react";
|
||||
import { memo, useState, useEffect, useLayoutEffect, useMemo, useCallback, useRef, useId, Fragment, ReactNode } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRouter } from "@/i18n/navigation";
|
||||
import { PluginSlot } from "@/components/plugins/plugin-slot";
|
||||
@@ -396,6 +396,9 @@ interface SidebarRowProps {
|
||||
testName?: string;
|
||||
testMailboxId?: string;
|
||||
testShared?: boolean;
|
||||
/** Names the row the same folded and unfolded, so the drawer opened by a
|
||||
* hover can put the hovered item back under the pointer. */
|
||||
railKey?: string;
|
||||
}
|
||||
|
||||
function SidebarRow({
|
||||
@@ -420,6 +423,7 @@ function SidebarRow({
|
||||
testName,
|
||||
testMailboxId,
|
||||
testShared,
|
||||
railKey,
|
||||
}: SidebarRowProps) {
|
||||
const t = useTranslations('sidebar');
|
||||
const tShell = useTranslations('shell');
|
||||
@@ -436,6 +440,8 @@ function SidebarRow({
|
||||
unread, total, role: testRole, mode: countMode, showTotalGlobally: showFolderTotalCount, mountainView,
|
||||
}).unread;
|
||||
const accessibleName = unreadForName > 0 ? tShell('name_unread', { name: label, count: unreadForName }) : undefined;
|
||||
// The default layout's folded column: one grid of square items.
|
||||
const railItem = isCollapsed && !mountainView;
|
||||
const [labelRef, shortenedLabel] = useShortenedText(labelCandidates ?? [label]);
|
||||
// Touch has no right-click: a long-press opens the same menu (R7), and a
|
||||
// ⋮ shows it too.
|
||||
@@ -473,21 +479,31 @@ function SidebarRow({
|
||||
data-shared={testShared ? 'true' : undefined}
|
||||
data-selected={isSelected ? 'true' : undefined}
|
||||
data-has-unread={(unread ?? 0) > 0 && testRole !== 'drafts' ? '' : undefined}
|
||||
style={{ paddingBlock: 'var(--density-sidebar-py)' }}
|
||||
data-rail-key={railKey ?? testMailboxId ?? undefined}
|
||||
style={railItem ? undefined : { paddingBlock: 'var(--density-sidebar-py)' }}
|
||||
className={cn(
|
||||
"group w-full flex items-center tap:min-h-[44px] text-sm transition-colors duration-150",
|
||||
isCollapsed ? "justify-center px-1" : "pe-2",
|
||||
// Folded, every item is the same square on one grid, as in Outlook's
|
||||
// folded pane: the button carries the hover and the selection, and a
|
||||
// bar at the column's edge marks the open one.
|
||||
// Mountain View's 72px rail keeps its own pill rows (globals.css).
|
||||
railItem ? "relative justify-center py-px" : isCollapsed ? "justify-center px-1" : "pe-2",
|
||||
openFromRow && "cursor-pointer select-none",
|
||||
isVirtual
|
||||
? "text-muted-foreground"
|
||||
: isSelected
|
||||
? "bg-accent text-accent-foreground font-semibold border-s-2 border-primary"
|
||||
: "hover:bg-muted/50 text-foreground border-s-2 border-transparent",
|
||||
railItem
|
||||
? (isVirtual ? "text-muted-foreground" : isSelected ? "text-accent-foreground font-semibold" : "text-foreground")
|
||||
: isVirtual
|
||||
? "text-muted-foreground"
|
||||
: isSelected
|
||||
? "bg-accent text-accent-foreground font-semibold border-s-2 border-primary"
|
||||
: "hover:bg-muted/50 text-foreground border-s-2 border-transparent",
|
||||
// Only a folder that takes the drop lights up. Elsewhere the pointer
|
||||
// says no (dropEffect none), as in a native mail client.
|
||||
isValidDropTarget && "bg-primary/20 ring-2 ring-primary ring-inset"
|
||||
)}
|
||||
>
|
||||
{railItem && isSelected && (
|
||||
<span aria-hidden="true" data-testid="folded-selected" className="absolute z-10 start-0 top-1/2 -translate-y-1/2 h-5 w-[0.1875rem] rounded-e-full bg-primary" />
|
||||
)}
|
||||
{!isCollapsed && (
|
||||
<div
|
||||
className="flex items-center flex-shrink-0"
|
||||
@@ -528,28 +544,36 @@ function SidebarRow({
|
||||
aria-describedby={muted && !isCollapsed ? mutedId : undefined}
|
||||
className={cn(
|
||||
"flex items-center gap-2 min-w-0 transition-colors",
|
||||
isCollapsed ? "justify-center" : "flex-1 text-start",
|
||||
railItem
|
||||
? cn(
|
||||
// 36px high: the icon sits 10px down, under the counter's
|
||||
// 12px, so the counter never covers the glyph.
|
||||
"relative justify-center w-full max-w-10 h-9 rounded-md focus-visible:outline-2 focus-visible:outline-ring focus-visible:-outline-offset-2",
|
||||
!isVirtual && (isSelected ? "bg-accent" : "hover:bg-muted/60"),
|
||||
)
|
||||
: isCollapsed ? "relative justify-center w-10 h-8" : "flex-1 text-start",
|
||||
isVirtual && "cursor-default select-none"
|
||||
)}
|
||||
title={isCollapsed ? label : undefined}
|
||||
// Folded, the name and count are only in the tooltip.
|
||||
title={isCollapsed ? (accessibleName ?? label) : undefined}
|
||||
>
|
||||
<span className="relative flex items-center justify-center flex-shrink-0 w-4 h-4">
|
||||
{icon}
|
||||
{/* Folded to icons, the count rides on the icon (p2-9); the name says it already. */}
|
||||
{isCollapsed && unreadForName > 0 && (
|
||||
unreadCountStyle === 'dot' ? (
|
||||
<span aria-hidden="true" data-testid="folded-unread" className="absolute -top-0.5 -end-1 w-2 h-2 rounded-full bg-primary ring-2 ring-secondary" />
|
||||
) : (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
data-testid="folded-unread"
|
||||
className="absolute -top-2 -end-3 min-w-4 h-4 px-1 rounded-full bg-primary text-primary-foreground text-[0.625rem] leading-4 font-semibold tabular-nums text-center ring-2 ring-secondary"
|
||||
>
|
||||
{unreadForName > 99 ? '99+' : unreadForName}
|
||||
</span>
|
||||
)
|
||||
)}
|
||||
</span>
|
||||
{/* Folded to icons, a small counter at the icon's top corner (p2-9); the name says it already. */}
|
||||
{isCollapsed && unreadForName > 0 && (
|
||||
unreadCountStyle === 'dot' ? (
|
||||
<span aria-hidden="true" data-testid="folded-unread" className="absolute top-1.5 end-1.5 w-1.5 h-1.5 rounded-full bg-primary" />
|
||||
) : (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
data-testid="folded-unread"
|
||||
className="absolute top-0 end-0 min-w-3 h-3 px-[0.1875rem] rounded-full bg-primary text-primary-foreground text-[0.5625rem] leading-3 font-semibold tabular-nums text-center"
|
||||
>
|
||||
{unreadForName > 99 ? '99+' : unreadForName}
|
||||
</span>
|
||||
)
|
||||
)}
|
||||
{!isCollapsed && (
|
||||
<>
|
||||
<span
|
||||
@@ -598,20 +622,52 @@ function SidebarRow({
|
||||
);
|
||||
}
|
||||
|
||||
/** A folder of one's own on the folded strip: its first letter in a small box. */
|
||||
/**
|
||||
* A folder of one's own on the folded strip, when there are several: the
|
||||
* folder glyph the other rows use, same size and stroke, with the folder's
|
||||
* first letter inside it. A letter in a box of its own looked like no other
|
||||
* icon in the column.
|
||||
*/
|
||||
function FolderInitial({ name, className }: { name: string; className?: string }) {
|
||||
const initial = Array.from(name.trim())[0]?.toLocaleUpperCase() ?? '?';
|
||||
return (
|
||||
<span
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-testid="folder-initial"
|
||||
className={cn(className, "grid place-items-center rounded-[0.25rem] border border-current text-[0.625rem] font-semibold leading-none")}
|
||||
data-testid="folder-initial-icon"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth={2}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
className={className}
|
||||
>
|
||||
{initial}
|
||||
</span>
|
||||
{/* Lucide's folder outline. */}
|
||||
<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" />
|
||||
<text
|
||||
data-testid="folder-initial"
|
||||
x="12"
|
||||
y="13"
|
||||
textAnchor="middle"
|
||||
dominantBaseline="central"
|
||||
fill="currentColor"
|
||||
stroke="none"
|
||||
fontSize="10"
|
||||
fontWeight="700"
|
||||
>
|
||||
{initial}
|
||||
</text>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/** Whether the folder `id` is this node or below it. */
|
||||
const subtreeHas = (node: MailboxNode, id: string): boolean =>
|
||||
node.id === id || node.children.some((child) => subtreeHas(child, id));
|
||||
/** Unread mail in the folders below a node (a shared account counts nothing itself). */
|
||||
const subtreeUnread = (node: MailboxNode): number =>
|
||||
node.children.reduce((sum, child) => sum + (child.unreadEmails ?? 0) + subtreeUnread(child), 0);
|
||||
|
||||
/** A folder the server gave a role (inbox, sent, trash...), as opposed to one the user made. */
|
||||
const isSystemFolder = (node: MailboxNode) => !!node.role;
|
||||
/** Key of the single-account "Your folders" section in the collapsed set. */
|
||||
@@ -634,6 +690,7 @@ function SidebarSectionHeader({
|
||||
status,
|
||||
onAdd,
|
||||
addTitle,
|
||||
railKey,
|
||||
}: {
|
||||
label: string;
|
||||
expanded: boolean;
|
||||
@@ -650,9 +707,14 @@ function SidebarSectionHeader({
|
||||
onContextMenu?: (event: React.MouseEvent) => void;
|
||||
/** A short note after the label, e.g. how many accounts have loaded. */
|
||||
status?: ReactNode;
|
||||
/** The folded column's item for the same thing (see SidebarRow). */
|
||||
railKey?: string;
|
||||
}) {
|
||||
if (isCollapsed) {
|
||||
return first ? null : <div className="h-px bg-border/50 mx-2 my-2" aria-hidden />;
|
||||
// One thin rule between sections. A sub-section (a shared account, the
|
||||
// folders inside a Pro account group) draws none: under a section's own
|
||||
// rule they stacked into a ladder of lines.
|
||||
return first || sub ? null : <div className="h-px bg-border mx-2.5 my-1.5" data-rail-separator="" aria-hidden />;
|
||||
}
|
||||
|
||||
const paddingY = sub ? "pt-2" : first ? "pt-3" : "pt-5";
|
||||
@@ -670,6 +732,7 @@ function SidebarSectionHeader({
|
||||
return (
|
||||
<div
|
||||
onContextMenu={onContextMenu}
|
||||
data-rail-key={railKey}
|
||||
className={cn(
|
||||
"group w-full flex items-center pb-1 select-none rounded-sm hover:bg-muted/40 transition-colors",
|
||||
paddingX,
|
||||
@@ -740,6 +803,7 @@ function MailboxTreeItem({
|
||||
pickOnly = false,
|
||||
sharedAccountName,
|
||||
renderAfterChild,
|
||||
initials = false,
|
||||
}: {
|
||||
node: MailboxNode;
|
||||
selectedMailbox: string;
|
||||
@@ -763,19 +827,23 @@ function MailboxTreeItem({
|
||||
/** Rendered after each direct child's subtree, e.g. the Scheduled row after
|
||||
* Drafts. Not passed further down. */
|
||||
renderAfterChild?: (child: MailboxNode) => React.ReactNode;
|
||||
/** Folded: several folders of one's own are listed, so each carries its
|
||||
* first letter. One alone is a plain folder. */
|
||||
initials?: boolean;
|
||||
}) {
|
||||
const tNotifications = useTranslations('notifications');
|
||||
const tListExtra = useTranslations('mail_list_extra');
|
||||
const tSidebar = useTranslations('sidebar');
|
||||
const hasChildren = node.children.length > 0;
|
||||
const isExpanded = expandedFolders.has(node.id);
|
||||
const Icon = sharedAccountName ? User : getIconForMailbox(node.role, hasChildren, isExpanded, node.id);
|
||||
// Folded, no subfolders show, so no folder is drawn open.
|
||||
const Icon = sharedAccountName ? User : getIconForMailbox(node.role, hasChildren, isExpanded && !isCollapsed, node.id);
|
||||
const isVirtualNode = node.id.startsWith('shared-');
|
||||
const isSelected = selectedMailbox === node.id;
|
||||
const label = sharedAccountName ?? localizeMailboxName(node.role, node.name, (k) => tSidebar(`mailboxes.${k}`));
|
||||
// Folded to icons, eight folders of one's own were eight identical folder
|
||||
// icons (p2-9): each shows its first letter instead.
|
||||
const letterIcon = isCollapsed && !node.role && !sharedAccountName && !isVirtualNode;
|
||||
// icons (p2-9): each carries its first letter inside the folder glyph.
|
||||
const letterIcon = isCollapsed && initials && !node.role && !sharedAccountName && !isVirtualNode;
|
||||
// Only for the active login's folders: its client tells a missing
|
||||
// accountId (own mailbox) apart.
|
||||
const muted = useMutedMailbox(isVirtualNode || dragAccountId || pickOnly ? null : node);
|
||||
@@ -969,6 +1037,7 @@ function TagItem({
|
||||
isCollapsed={isCollapsed}
|
||||
dropHandlers={globalDragging ? (dropHandlers as Record<string, unknown>) : undefined}
|
||||
isValidDropTarget={isValidDropTarget}
|
||||
railKey={`tag:${node.id}`}
|
||||
/>
|
||||
|
||||
{hasChildren && isExpanded && !isCollapsed && node.children.map((child) => (
|
||||
@@ -1299,9 +1368,26 @@ function SidebarImpl({
|
||||
}, [railOpen]);
|
||||
// The pointer resting on the folders floats the tree out; on the header
|
||||
// (expand, compose) it doesn't, so the expand button can still be clicked.
|
||||
const armRailHover = useCallback((target: EventTarget | null) => {
|
||||
const navRef = useRef<HTMLElement>(null);
|
||||
// The item the pointer rests on in the folded column, and where on screen.
|
||||
const hoveredRailItem = useRef<{ key: string; top: number } | null>(null);
|
||||
const lastPointer = useRef<{ x: number; y: number; target: EventTarget | null }>({ x: 0, y: 0, target: null });
|
||||
// Read when the tree floats out, not when the pointer arrived: the column
|
||||
// may have been scrolled under a resting pointer in between.
|
||||
const noteHoveredRailItem = useCallback(() => {
|
||||
const { x, y, target } = lastPointer.current;
|
||||
const under = typeof document.elementFromPoint === 'function' ? document.elementFromPoint(x, y) : null;
|
||||
const from = under ?? (target instanceof Element ? target : null);
|
||||
const item = from?.closest<HTMLElement>('[data-rail-key]');
|
||||
hoveredRailItem.current = item?.dataset.railKey && navRef.current?.contains(item)
|
||||
? { key: item.dataset.railKey, top: item.getBoundingClientRect().top }
|
||||
: null;
|
||||
}, []);
|
||||
const armRailHover = useCallback((e: React.MouseEvent) => {
|
||||
if (!hoverOpens()) return;
|
||||
if (mvShell) { setRailHovered(true); return; }
|
||||
const target = e.target;
|
||||
lastPointer.current = { x: e.clientX, y: e.clientY, target };
|
||||
if (mvShell) { noteHoveredRailItem(); setRailHovered(true); return; }
|
||||
if (target instanceof Element && target.closest('[data-sidebar-head]')) {
|
||||
if (railHoverTimer.current) clearTimeout(railHoverTimer.current);
|
||||
railHoverTimer.current = null;
|
||||
@@ -1310,9 +1396,59 @@ function SidebarImpl({
|
||||
if (railHoverTimer.current) return;
|
||||
railHoverTimer.current = setTimeout(() => {
|
||||
railHoverTimer.current = null;
|
||||
noteHoveredRailItem();
|
||||
setRailHovered(true);
|
||||
}, RAIL_HOVER_DELAY_MS);
|
||||
}, [mvShell]);
|
||||
}, [mvShell, noteHoveredRailItem]);
|
||||
// The folded column and the tree floated out of it share one scrolling
|
||||
// list. Scrolled down the column, the tree opened at that same offset, which
|
||||
// in the longer tree was somewhere else: a hover now puts the hovered item
|
||||
// back under the pointer, All folders starts at the top (and the focus
|
||||
// brings the open folder into view), and folding back returns the column
|
||||
// to where it was.
|
||||
const railScrollTop = useRef<number | null>(null);
|
||||
useLayoutEffect(() => {
|
||||
const nav = navRef.current;
|
||||
if (!nav) return;
|
||||
if (hoverExpanded) {
|
||||
if (railScrollTop.current !== null) return;
|
||||
railScrollTop.current = nav.scrollTop;
|
||||
const hovered = railOpen ? null : hoveredRailItem.current;
|
||||
const item = hovered
|
||||
? Array.from(nav.querySelectorAll<HTMLElement>('[data-rail-key]')).find((el) => el.dataset.railKey === hovered.key)
|
||||
: null;
|
||||
nav.scrollTop = item && hovered ? nav.scrollTop + item.getBoundingClientRect().top - hovered.top : 0;
|
||||
return;
|
||||
}
|
||||
if (railScrollTop.current === null) return;
|
||||
const railTop = railScrollTop.current;
|
||||
railScrollTop.current = null;
|
||||
// Unfolded meanwhile: the full list keeps its own place.
|
||||
if (!isCollapsed) return;
|
||||
nav.scrollTop = railTop;
|
||||
// A folder picked in the tree is shown in the column too.
|
||||
const current = nav.querySelector<HTMLElement>('[aria-current="page"]');
|
||||
if (!current) return;
|
||||
const view = nav.getBoundingClientRect();
|
||||
const box = current.getBoundingClientRect();
|
||||
if (box.top < view.top) nav.scrollTop += box.top - view.top;
|
||||
else if (box.bottom > view.bottom) nav.scrollTop += box.bottom - view.bottom;
|
||||
}, [hoverExpanded, railOpen, isCollapsed]);
|
||||
// Folded, the arrows, Home and End go from item to item, Enter opens.
|
||||
const moveInRail = useCallback((e: React.KeyboardEvent<HTMLElement>) => {
|
||||
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp' && e.key !== 'Home' && e.key !== 'End') return;
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
||||
const items = Array.from(e.currentTarget.querySelectorAll<HTMLElement>('[data-testid="folder-row"] > button:not(:disabled)'));
|
||||
if (items.length === 0) return;
|
||||
const at = items.indexOf(document.activeElement as HTMLElement);
|
||||
const next = e.key === 'Home' ? 0
|
||||
: e.key === 'End' ? items.length - 1
|
||||
: at < 0 ? 0
|
||||
: e.key === 'ArrowDown' ? Math.min(at + 1, items.length - 1) : Math.max(at - 1, 0);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
items[next].focus();
|
||||
}, []);
|
||||
const { primaryIdentity: _primaryIdentity, activeAccountId } = useAuthStore(useShallow((state) => ({ primaryIdentity: state.primaryIdentity, activeAccountId: state.activeAccountId })));
|
||||
const [expandedFolders, setExpandedFolders] = useState<Set<string>>(new Set());
|
||||
const [expandedTags, setExpandedTags] = useState<Set<string>>(new Set());
|
||||
@@ -1681,6 +1817,7 @@ function SidebarImpl({
|
||||
colorful={colorfulSidebarIcons}
|
||||
onContextMenu={active ? handleMailboxContextMenu : undefined}
|
||||
dragAccountId={dragAccountId}
|
||||
initials={tree.length > 1}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@@ -1770,6 +1907,31 @@ function SidebarImpl({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (isCollapsed) {
|
||||
// Folded, a shared account is one item: its inbox opens, or
|
||||
// without one the drawer with the account unfolded. It was
|
||||
// left out, and only its heading's rule stayed behind.
|
||||
const inbox = account.children.find((child) => child.role === 'inbox');
|
||||
const selectedHere = !!selected && subtreeHas(account, selected);
|
||||
return (
|
||||
<SidebarRow
|
||||
key={account.id}
|
||||
icon={<User className={getIconClass(selectedHere, false, false)} />}
|
||||
label={account.name}
|
||||
isSelected={selectedHere}
|
||||
unread={subtreeUnread(account)}
|
||||
onClick={() => {
|
||||
if (inbox) { onSelect?.(inbox.id); return; }
|
||||
if (!expanded) onToggle();
|
||||
if (!accountExpanded) toggleSharedAccount(account.id);
|
||||
setRailOpen(true);
|
||||
}}
|
||||
isCollapsed
|
||||
testShared
|
||||
railKey={account.id}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div key={account.id}>
|
||||
<SidebarSectionHeader
|
||||
@@ -1780,6 +1942,7 @@ function SidebarImpl({
|
||||
sub
|
||||
icon={<User className="w-3.5 h-3.5 text-muted-foreground" />}
|
||||
testId="section-shared-account"
|
||||
railKey={account.id}
|
||||
onContextMenu={active && menuAccountId
|
||||
? (e) => handleSharedAccountContextMenu(e, menuAccountId)
|
||||
: undefined}
|
||||
@@ -2067,8 +2230,8 @@ function SidebarImpl({
|
||||
<div
|
||||
ref={rootRef}
|
||||
// The peek of the collapsed rail; not with hover opening turned off.
|
||||
onMouseEnter={sidebarCollapsed && !isDrawer ? (e) => armRailHover(e.target) : undefined}
|
||||
onMouseMove={sidebarCollapsed && !isDrawer && !mvShell && !railHovered ? (e) => armRailHover(e.target) : undefined}
|
||||
onMouseEnter={sidebarCollapsed && !isDrawer ? armRailHover : undefined}
|
||||
onMouseMove={sidebarCollapsed && !isDrawer && !mvShell && !railHovered ? armRailHover : undefined}
|
||||
onMouseLeave={sidebarCollapsed && !isDrawer ? () => {
|
||||
if (railHoverTimer.current) clearTimeout(railHoverTimer.current);
|
||||
railHoverTimer.current = null;
|
||||
@@ -2143,8 +2306,8 @@ function SidebarImpl({
|
||||
data-testid="sidebar-collapse"
|
||||
title={isCollapsed ? t("expand_tooltip") : t("collapse_tooltip")}
|
||||
>
|
||||
{/* The arrows point the way the column goes: mirrored in RTL, where it sits at the right. */}
|
||||
{isCollapsed ? <ChevronsRight className="w-4 h-4 rtl:-scale-x-100" /> : <ChevronsLeft className="w-4 h-4 rtl:-scale-x-100" />}
|
||||
{/* The arrows point the way the column goes; the app's global RTL mirror turns them in RTL. */}
|
||||
{isCollapsed ? <ChevronsRight className="w-4 h-4" /> : <ChevronsLeft className="w-4 h-4" />}
|
||||
</Button>
|
||||
|
||||
{/* The account switcher heads the folders by default, with the
|
||||
@@ -2211,7 +2374,19 @@ function SidebarImpl({
|
||||
{!isCollapsed && <VacationBanner />}
|
||||
|
||||
{/* Mailbox List */}
|
||||
<nav aria-label={t("folders")} className="flex-1 overflow-y-auto" data-tour="sidebar" data-folder-nav="" data-pane="folders">
|
||||
<nav
|
||||
ref={navRef}
|
||||
aria-label={t("folders")}
|
||||
// Folded, the column scrolls on its own, never sideways, with a thin
|
||||
// scrollbar (globals.css) and the same gutter on both sides so the
|
||||
// icons stay centred under the buttons above and below it.
|
||||
className={cn("flex-1 min-h-0 overflow-y-auto", isCollapsed && "overflow-x-hidden py-1 [scrollbar-gutter:stable_both-edges]")}
|
||||
data-tour="sidebar"
|
||||
data-folder-nav=""
|
||||
data-folder-rail={isCollapsed && !mvShell ? "" : undefined}
|
||||
data-pane="folders"
|
||||
onKeyDown={isCollapsed ? moveInRail : undefined}
|
||||
>
|
||||
{unifiedSectionShown && (
|
||||
<div>
|
||||
<SidebarSectionHeader
|
||||
|
||||
@@ -79,7 +79,8 @@ import { useContactStore } from "@/stores/contact-store";
|
||||
import { useIdentityStore } from "@/stores/identity-store";
|
||||
import { useUIStore, sidebarFolded, listPaneCssSize, SIDEBAR_MIN, SIDEBAR_MAX, EMAIL_LIST_MIN, EMAIL_LIST_MAX, EMAIL_LIST_HEIGHT_MIN, EMAIL_LIST_HEIGHT_MAX, READING_PANE_MIN_WIDTH, READING_PANE_MIN_HEIGHT, COMPOSER_PANE_MIN_HEIGHT } from "@/stores/ui-store";
|
||||
import { atLeast, PHONE_BELOW, useDeviceDetection } from "@/hooks/use-media-query";
|
||||
import { useFocusTrap } from "@/hooks/use-focus-trap";
|
||||
import { useEdgeDrawer } from "@/hooks/use-edge-drawer";
|
||||
import { DrawerScrim } from "@/components/layout/edge-drawer";
|
||||
import { usePaneSize } from "@/hooks/use-pane-size";
|
||||
import { useIsFocusedProTab, usePaneId } from "@/hooks/use-pane-context";
|
||||
import { useKeyboardShortcuts, type GoToMailboxTarget } from "@/hooks/use-keyboard-shortcuts";
|
||||
@@ -2621,29 +2622,18 @@ export function MailApp({ linkSegments: routeSegments }: MailAppProps = {}) {
|
||||
// Pro can mount two mail panes at once, so the sidebar id must be per-instance.
|
||||
const sidebarId = useId();
|
||||
const listHeadingId = useId();
|
||||
// The phone drawer keeps Tab inside until it closes, and Escape closes it.
|
||||
// The phone drawer keeps Tab inside until it closes, Escape closes it, and
|
||||
// the focus goes back to the toggle however it closes (Escape, X, a pick,
|
||||
// the scrim), unless it has moved on to something outside the drawer. The
|
||||
// toggle lives in whichever MobileHeader the current view renders, so it is
|
||||
// looked up inside this app instance when the one that opened it is gone.
|
||||
const phoneDrawerOpen = isMobile && sidebarOpen;
|
||||
const sidebarContainerRef = useFocusTrap({
|
||||
isActive: phoneDrawerOpen,
|
||||
onEscape: () => setSidebarOpen(false),
|
||||
restoreFocus: false,
|
||||
const closeSidebarDrawer = useCallback(() => setSidebarOpen(false), [setSidebarOpen]);
|
||||
const sidebarContainerRef = useEdgeDrawer({
|
||||
open: phoneDrawerOpen,
|
||||
onClose: closeSidebarDrawer,
|
||||
returnFocus: () => appRootRef.current?.querySelector<HTMLElement>('[data-sidebar-toggle]'),
|
||||
});
|
||||
const sidebarWasOpen = useRef(false);
|
||||
useEffect(() => {
|
||||
if (phoneDrawerOpen) {
|
||||
sidebarWasOpen.current = true;
|
||||
return;
|
||||
}
|
||||
if (!sidebarWasOpen.current) return;
|
||||
sidebarWasOpen.current = false;
|
||||
// Back to the toggle however it closed (Escape, X, a pick, the scrim),
|
||||
// unless the focus has moved on to something outside the drawer. The
|
||||
// toggle lives in whichever MobileHeader the current view renders, so
|
||||
// look it up inside this app instance rather than threading a ref through.
|
||||
const active = document.activeElement;
|
||||
if (active && active !== document.body && !sidebarContainerRef.current?.contains(active)) return;
|
||||
appRootRef.current?.querySelector<HTMLElement>('[data-sidebar-toggle]')?.focus();
|
||||
}, [phoneDrawerOpen, sidebarContainerRef]);
|
||||
// The folded column's tree open over the page as a drawer (Sidebar's
|
||||
// onDrawerChange): the function that closes it, for the scrim.
|
||||
const [closeFolderDrawer, setCloseFolderDrawer] = useState<(() => void) | null>(null);
|
||||
@@ -5890,20 +5880,13 @@ export function MailApp({ linkSegments: routeSegments }: MailAppProps = {}) {
|
||||
scope to the pane via `absolute` so the backdrop stays inside
|
||||
the pane instead of covering the whole window. */}
|
||||
{((isMobile && sidebarOpen) || closeFolderDrawer) && !inlineApp && (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
<DrawerScrim
|
||||
data-testid="folder-drawer-scrim"
|
||||
data-drawer-scrim=""
|
||||
className={cn(
|
||||
"inset-0 bg-black/50 z-40",
|
||||
// The folded column's drawer opens on a desktop, so only the
|
||||
// phone's scrim goes with the phone layout.
|
||||
isEmbedded ? "absolute" : cn("fixed", !closeFolderDrawer && "desk:hidden")
|
||||
)}
|
||||
onClick={() => {
|
||||
if (closeFolderDrawer) closeFolderDrawer();
|
||||
else setSidebarOpen(false);
|
||||
}}
|
||||
contained={isEmbedded}
|
||||
// The folded column's drawer opens on a desktop, so only the
|
||||
// phone's scrim goes with the phone layout.
|
||||
className={!isEmbedded && !closeFolderDrawer ? "desk:hidden" : undefined}
|
||||
onClose={closeFolderDrawer ?? closeSidebarDrawer}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
@@ -224,6 +224,12 @@
|
||||
<decimal id="DeveloperToolsAvailability_Value" valueName="DeveloperToolsAvailability" required="true" minValue="0" maxValue="2"/>
|
||||
</elements>
|
||||
</policy>
|
||||
<policy name="RecentFilesInAttach" class="Both" displayName="$(string.RecentFilesInAttach)" explainText="$(string.RecentFilesInAttach_Explain)" key="Software\Policies\Bulwark\Desktop" valueName="RecentFilesInAttach">
|
||||
<parentCategory ref="Bulwark_Desktop_privacy"/>
|
||||
<supportedOn ref="SUPPORTED_Bulwark_Desktop"/>
|
||||
<enabledValue><decimal value="1"/></enabledValue>
|
||||
<disabledValue><decimal value="0"/></disabledValue>
|
||||
</policy>
|
||||
<policy name="FilesDriveEnabled" class="Both" displayName="$(string.FilesDriveEnabled)" explainText="$(string.FilesDriveEnabled_Explain)" key="Software\Policies\Bulwark\Desktop" valueName="FilesDriveEnabled">
|
||||
<parentCategory ref="Bulwark_Desktop_system"/>
|
||||
<supportedOn ref="SUPPORTED_Bulwark_Desktop"/>
|
||||
|
||||
@@ -67,6 +67,8 @@
|
||||
<string id="OpenWithEnabled_Explain">Wenn aktiviert oder nicht konfiguriert, trägt sich die App unter Windows in die Liste „Öffnen mit“ für gängige Dokumente und Bilder und in das Menü „Senden an“ ein, damit Benutzer eine Datei aus dem Dateimanager an eine neue Nachricht anhängen können. Sie wird nie zum Standardprogramm für diese Dateien. Wenn deaktiviert, entfernt die App diese Einträge für den Benutzer. Mail-Links und .eml-, .ics- und .vcf-Dateien sind nicht betroffen.</string>
|
||||
<string id="DeveloperToolsAvailability">Entwicklertools</string>
|
||||
<string id="DeveloperToolsAvailability_Explain">Dieselben Werte wie die gleichnamige Richtlinie von Chrome. 2: Die Entwicklertools sind aus und die Einstellung ist gesperrt. 0 oder 1 oder nicht konfiguriert: Benutzer können sie nach einer Warnung in den Einstellungen einschalten. Mit den Entwicklertools kann jeder an der Tastatur alles lesen, was die App enthält, auch E-Mails und Passwörter im Speicher.</string>
|
||||
<string id="RecentFilesInAttach">Zuletzt verwendete Dateien im Menü „Anfügen“ anzeigen</string>
|
||||
<string id="RecentFilesInAttach_Explain">Wenn aktiviert oder nicht konfiguriert, listet die Schaltfläche „Anfügen“ in einer neuen Nachricht die Dateien auf, die der Benutzer zuletzt geöffnet hat, so wie das Betriebssystem sie erfasst. Ein Klick fügt eine davon an. Die Liste wird beim Öffnen des Menüs gelesen und bleibt auf dem Gerät. Wenn deaktiviert, fehlt die Liste und die App lehnt es ab, sie zu lesen. Das Anfügen über den Dateidialog ist nicht betroffen.</string>
|
||||
<string id="FilesDriveEnabled">Dateien als Laufwerk zulassen</string>
|
||||
<string id="FilesDriveEnabled_Explain">Wenn aktiviert oder nicht konfiguriert, können Benutzer ihre Dateien im Dateimanager als Laufwerk anzeigen. Dateien werden beim Öffnen heruntergeladen. Vorerst nur unter Windows. Wenn deaktiviert, wird das Laufwerk nicht angeboten, und ein vorhandenes Laufwerk wird mit den Kopien der Dateien darin entfernt. Die Dateien auf dem Server sind davon nicht betroffen.</string>
|
||||
<string id="FilesFolderSyncEnabled">Synchronisieren von Ordnern mit Dateien zulassen</string>
|
||||
|
||||
@@ -67,6 +67,8 @@
|
||||
<string id="OpenWithEnabled_Explain">When enabled or not configured, the app adds itself to the "Open with" list for common documents and pictures and to the "Send to" menu on Windows, so people can attach a file to a new message from the file manager. It never becomes the default program for those files. When disabled, the app removes these entries for the user. Mail links and .eml, .ics and .vcf files are not affected.</string>
|
||||
<string id="DeveloperToolsAvailability">Developer tools</string>
|
||||
<string id="DeveloperToolsAvailability_Explain">The same values as Chrome's policy of this name. 2: developer tools are off and the setting is locked. 0 or 1, or not configured: people can turn them on under Settings, after a warning. Developer tools let anyone at the keyboard read everything the app holds, mail and passwords in memory included.</string>
|
||||
<string id="RecentFilesInAttach">Show recent files in the Attach menu</string>
|
||||
<string id="RecentFilesInAttach_Explain">When enabled or not configured, the Attach button in a new message lists the files the user opened recently, as the operating system records them, so one click attaches one. The list is read when the menu opens and stays on the device. When disabled, the list is gone and the app refuses to read it. Attaching through the file dialog is not affected.</string>
|
||||
<string id="FilesDriveEnabled">Allow Files as a drive</string>
|
||||
<string id="FilesDriveEnabled_Explain">When enabled or not configured, people can show their Files in the file manager as a drive, with files downloaded when opened. Windows only for now. When disabled, the drive is not offered, and a drive that is already there is removed with the copies of files in it. Files on the server are not affected.</string>
|
||||
<string id="FilesFolderSyncEnabled">Allow syncing folders with Files</string>
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
<true/>
|
||||
<key>DeveloperToolsAvailability</key>
|
||||
<integer>2</integer>
|
||||
<key>RecentFilesInAttach</key>
|
||||
<true/>
|
||||
<key>FilesDriveEnabled</key>
|
||||
<true/>
|
||||
<key>FilesFolderSyncEnabled</key>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
"BrowserSignIn": true,
|
||||
"OpenWithEnabled": true,
|
||||
"DeveloperToolsAvailability": 2,
|
||||
"RecentFilesInAttach": true,
|
||||
"FilesDriveEnabled": true,
|
||||
"FilesFolderSyncEnabled": true,
|
||||
"FilesDriveLetter": "none",
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import { useEffect, useLayoutEffect, useRef } from 'react';
|
||||
import { useFocusTrap } from '@/hooks/use-focus-trap';
|
||||
|
||||
interface UseEdgeDrawerOptions {
|
||||
/** Whether the drawer is open over the page. */
|
||||
open: boolean;
|
||||
/** Closes it: Escape, and whatever else the caller wires (scrim, X, a pick). */
|
||||
onClose: () => void;
|
||||
/**
|
||||
* Where the focus goes back to when the button that opened the drawer is
|
||||
* gone by then (a header that rendered again).
|
||||
*/
|
||||
returnFocus?: () => HTMLElement | null | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* The keyboard side of a sidebar opened over the page as a drawer (Mail's
|
||||
* folders on a phone, Calendar, Contacts and Files below the full desktop):
|
||||
* the focus goes to the current item in it, else the first, Tab stays inside
|
||||
* until it closes, Escape closes it, and however it closes (Escape, the scrim,
|
||||
* a close button, a pick) the focus goes back to the button that opened it,
|
||||
* unless the pick moved it somewhere else on purpose.
|
||||
*
|
||||
* Returns the ref for the drawer's element.
|
||||
*/
|
||||
export function useEdgeDrawer({ open, onClose, returnFocus }: UseEdgeDrawerOptions) {
|
||||
const ref = useFocusTrap({
|
||||
isActive: open,
|
||||
onEscape: onClose,
|
||||
restoreFocus: false,
|
||||
initialFocus: () => ref.current?.querySelector<HTMLElement>(
|
||||
'[aria-current]:not(:disabled):not([tabindex="-1"])'
|
||||
),
|
||||
});
|
||||
|
||||
// The opener, read before the trap moves the focus into the drawer.
|
||||
const openerRef = useRef<HTMLElement | null>(null);
|
||||
const returnFocusRef = useRef(returnFocus);
|
||||
useLayoutEffect(() => {
|
||||
returnFocusRef.current = returnFocus;
|
||||
if (!open) return;
|
||||
const active = document.activeElement;
|
||||
if (active instanceof HTMLElement && active !== document.body && !ref.current?.contains(active)) {
|
||||
openerRef.current = active;
|
||||
}
|
||||
});
|
||||
|
||||
const wasOpen = useRef(false);
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
wasOpen.current = true;
|
||||
// The current item can sit in a folded group: then the first one.
|
||||
const root = ref.current;
|
||||
if (root && !root.contains(document.activeElement)) {
|
||||
root.querySelector<HTMLElement>(
|
||||
'button:not(:disabled), [href], input:not(:disabled), [tabindex]:not([tabindex="-1"])'
|
||||
)?.focus();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!wasOpen.current) return;
|
||||
wasOpen.current = false;
|
||||
const active = document.activeElement;
|
||||
// A pick that moved the focus on (a dialog, a form) keeps it there.
|
||||
if (active && active !== document.body && !ref.current?.contains(active)) return;
|
||||
const opener = openerRef.current;
|
||||
openerRef.current = null;
|
||||
(opener?.isConnected ? opener : returnFocusRef.current?.())?.focus();
|
||||
}, [open, ref]);
|
||||
|
||||
return ref;
|
||||
}
|
||||
@@ -22,6 +22,16 @@ const source = (file: string) => readFileSync(path.join(ROOT, file), 'utf8');
|
||||
const classesOf = (el: Element) => el.getAttribute('class')!.split(/\s+/).filter((c) => c !== 'bk').sort();
|
||||
|
||||
describe('plugin UI kit components', () => {
|
||||
it('starts a long LinkButton\'s lines at its icon, as a paragraph, not centred as a button would', () => {
|
||||
// The AI assistant's examples in its panel ("Decline the invitation politely and suggest next month instead").
|
||||
render(<kit.LinkButton icon="arrow-right">Decline the invitation politely and suggest next month instead</kit.LinkButton>);
|
||||
const link = screen.getByRole('button');
|
||||
expect(link.className).toMatch(/(^|\s)text-start(\s|$)/);
|
||||
// The icon stays beside the first line rather than the middle of the text.
|
||||
expect(link.className).toMatch(/(^|\s)items-start(\s|$)/);
|
||||
expect(link.querySelector('svg')!.getAttribute('class')).toContain('mt-');
|
||||
});
|
||||
|
||||
it('renders the app\'s own Button and Input', () => {
|
||||
render(<>
|
||||
<kit.Button variant="secondary" size="sm">Cancel</kit.Button>
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
jmapServerAllowed,
|
||||
parseCertificateRule,
|
||||
parseInstanceUrl,
|
||||
pagePolicySnapshot,
|
||||
parsePolicyValue,
|
||||
parseServerPattern,
|
||||
pluginAllowedByPolicy,
|
||||
@@ -32,7 +33,7 @@ describe('the schema', () => {
|
||||
'PluginsMode', 'PluginAllowlist', 'OfflineEnabled', 'AppLockRequired', 'AppLockTimeoutMinutes', 'TelemetryAllowed',
|
||||
'CrashReportsAllowed', 'QuickComposeShortcut', 'AuthServerAllowlist', 'AuthNegotiateDelegateAllowlist',
|
||||
'AutoSelectCertificateForUrls', 'KeystoreEnabled', 'KeystoreAllowedOrigins', 'BrowserSignIn', 'WipeOfflineData',
|
||||
'OpenWithEnabled', 'DeveloperToolsAvailability', 'FilesDriveEnabled', 'FilesFolderSyncEnabled', 'FilesDriveLetter',
|
||||
'OpenWithEnabled', 'DeveloperToolsAvailability', 'RecentFilesInAttach', 'FilesDriveEnabled', 'FilesFolderSyncEnabled', 'FilesDriveLetter',
|
||||
]);
|
||||
for (const key of POLICY_KEYS) {
|
||||
const { title, description } = POLICY_SCHEMA[key];
|
||||
@@ -56,9 +57,25 @@ describe('developer tools and Open with', () => {
|
||||
expect(resolvePolicies(layers({ forcedMachine: { OpenWithEnabled: 0 } })).OpenWithEnabled).toMatchObject({ value: false, locked: true });
|
||||
expect(resolvePolicies(layers({ forcedMachine: { OpenWithEnabled: 'maybe' } })).OpenWithEnabled).toMatchObject({ value: false, locked: true });
|
||||
});
|
||||
|
||||
it('hide recent files in the Attach menu only by force, and a value nobody can read hides them', () => {
|
||||
expect(resolvePolicies(layers({})).RecentFilesInAttach).toMatchObject({ value: true, locked: false });
|
||||
expect(resolvePolicies(layers({ recommendedMachine: { RecentFilesInAttach: 0 } })).RecentFilesInAttach).toMatchObject({ value: true, locked: false });
|
||||
expect(resolvePolicies(layers({ forcedUser: { RecentFilesInAttach: 0 } })).RecentFilesInAttach).toMatchObject({ value: false, locked: true });
|
||||
expect(resolvePolicies(layers({ forcedMachine: { RecentFilesInAttach: 'yes please' } })).RecentFilesInAttach).toMatchObject({ value: false, locked: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe('Files on this computer', () => {
|
||||
it('tells the page the drive and folder sync are forced off, so it can show the lock', () => {
|
||||
const forced = resolvePolicies(layers({ forcedMachine: { FilesDriveEnabled: 0, FilesFolderSyncEnabled: 0, FilesDriveLetter: 'R' } }));
|
||||
const page = pagePolicySnapshot(forced);
|
||||
expect(page.FilesDriveEnabled).toMatchObject({ value: false, locked: true });
|
||||
expect(page.FilesFolderSyncEnabled).toMatchObject({ value: false, locked: true });
|
||||
// The letter comes from main with the drive's state.
|
||||
expect(page.FilesDriveLetter).toMatchObject({ value: null, locked: false });
|
||||
});
|
||||
|
||||
it('turn the drive and folder sync off only by force, and a value nobody can read leaves them off', () => {
|
||||
for (const key of ['FilesDriveEnabled', 'FilesFolderSyncEnabled'] as const) {
|
||||
expect(resolvePolicies(layers({}))[key]).toMatchObject({ value: true, locked: false });
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { DEFAULT_POLICY_SNAPSHOT, type PolicySnapshot } from '../policy-schema';
|
||||
import type { BulwarkDesktopBridge, DesktopRecentFilesBridge } from '../types';
|
||||
import { createElement } from 'react';
|
||||
import { renderToString } from 'react-dom/server';
|
||||
import { listRecentFiles, readRecentFile, recentFilesOffered, recentWhen, shortFolder, useRecentFilesOffered } from '../recent-files';
|
||||
|
||||
describe('shortFolder', () => {
|
||||
it('keeps the drive or share and the folders nearest the file, and drops the middle', () => {
|
||||
expect(shortFolder('C:\\Users\\me\\Documents')).toBe('C:\\Users\\me\\Documents');
|
||||
expect(shortFolder('C:\\Users\\me\\AppData\\Local\\Temp\\bw-shots-gnIFSO\\Documents\\Reports'))
|
||||
.toBe('C:\\…\\Temp\\bw-shots-gnIFSO\\Documents\\Reports');
|
||||
expect(shortFolder('\\\\fileserver\\departments\\Finance\\Controlling\\2026\\Quarterly\\Board'))
|
||||
.toBe('\\\\fileserver\\departments\\…\\Quarterly\\Board');
|
||||
expect(shortFolder('/home/me/projects/customer-a/2026/contracts/signed/final')).toBe('/…/customer-a/2026/contracts/signed/final');
|
||||
// One long name: nothing to drop, the line's ellipsis does the rest.
|
||||
const long = `C:\\${'x'.repeat(60)}`;
|
||||
expect(shortFolder(long)).toBe(long);
|
||||
});
|
||||
});
|
||||
|
||||
function setBridge(recentFiles?: Partial<DesktopRecentFilesBridge>, policy: Partial<PolicySnapshot> = {}) {
|
||||
const snapshot = { ...DEFAULT_POLICY_SNAPSHOT, ...policy };
|
||||
window.bulwarkDesktop = {
|
||||
version: 1,
|
||||
platform: 'win32',
|
||||
policy: { get: () => snapshot, onChange: () => () => {} },
|
||||
...(recentFiles ? { recentFiles: recentFiles as DesktopRecentFilesBridge } : {}),
|
||||
} as BulwarkDesktopBridge;
|
||||
}
|
||||
|
||||
const off = { RecentFilesInAttach: { value: false, source: 'forced-machine', locked: true } } as Partial<PolicySnapshot>;
|
||||
|
||||
afterEach(() => {
|
||||
window.bulwarkDesktop = undefined;
|
||||
});
|
||||
|
||||
describe('whether the Attach menu lists recent files', () => {
|
||||
it('not in a browser, not under a shell without the list, not when the policy says no', () => {
|
||||
expect(recentFilesOffered()).toBe(false);
|
||||
setBridge();
|
||||
expect(recentFilesOffered()).toBe(false);
|
||||
setBridge({ list: vi.fn(), attach: vi.fn() });
|
||||
expect(recentFilesOffered()).toBe(true);
|
||||
setBridge({ list: vi.fn(), attach: vi.fn() }, off);
|
||||
expect(recentFilesOffered()).toBe(false);
|
||||
});
|
||||
|
||||
it("says no in the server's render, so the page's first render matches it", () => {
|
||||
setBridge({ list: vi.fn(), attach: vi.fn() });
|
||||
const Probe = () => createElement('span', null, useRecentFilesOffered() ? 'menu' : 'button');
|
||||
expect(renderToString(createElement(Probe))).toBe('<span>button</span>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('listRecentFiles', () => {
|
||||
it('gives the files, and nothing when main says no or fails', async () => {
|
||||
const file = { id: 'a', name: 'a.pdf', folder: 'C:\\Docs', path: 'C:\\Docs\\a.pdf', usedAt: 1 };
|
||||
setBridge({ list: vi.fn(async () => ({ ok: true as const, files: [file] })) });
|
||||
expect(await listRecentFiles()).toEqual([file]);
|
||||
setBridge({ list: vi.fn(async () => ({ ok: false as const, reason: 'gesture' as const })) });
|
||||
expect(await listRecentFiles()).toEqual([]);
|
||||
setBridge({ list: vi.fn(async () => { throw new Error('gone'); }) });
|
||||
expect(await listRecentFiles()).toEqual([]);
|
||||
window.bulwarkDesktop = undefined;
|
||||
expect(await listRecentFiles()).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('readRecentFile', () => {
|
||||
it('turns the bytes into a File with the name main gave', async () => {
|
||||
const attach = vi.fn(async () => ({ ok: true as const, file: { name: 'Report.docx', data: new TextEncoder().encode('hello') } }));
|
||||
setBridge({ attach });
|
||||
const result = await readRecentFile('id-1');
|
||||
expect(attach).toHaveBeenCalledWith('id-1');
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
expect(result.file.name).toBe('Report.docx');
|
||||
expect(await result.file.text()).toBe('hello');
|
||||
});
|
||||
|
||||
it('says what the user can act on, and keeps quiet about a lock or a policy', async () => {
|
||||
const answer = (reason: string) => {
|
||||
setBridge({ attach: vi.fn(async () => ({ ok: false, reason }) as never) });
|
||||
return readRecentFile('x');
|
||||
};
|
||||
expect(await answer('missing')).toEqual({ ok: false, reason: 'missing' });
|
||||
expect(await answer('too-large')).toEqual({ ok: false, reason: 'too-large' });
|
||||
expect(await answer('unknown')).toEqual({ ok: false, reason: 'failed' });
|
||||
expect(await answer('gesture')).toEqual({ ok: false, reason: 'failed' });
|
||||
expect(await answer('locked')).toEqual({ ok: false, reason: 'quiet' });
|
||||
expect(await answer('policy')).toEqual({ ok: false, reason: 'quiet' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('recentWhen', () => {
|
||||
const now = new Date(2026, 10, 4, 15, 0).getTime();
|
||||
it('counts minutes and hours today, calendar days this week, then weeks and months', () => {
|
||||
expect(recentWhen(now - 20_000, now, 'en')).toBe('now');
|
||||
expect(recentWhen(now - 5 * 60_000, now, 'en')).toBe('5 minutes ago');
|
||||
expect(recentWhen(now - 3 * 60 * 60_000, now, 'en')).toBe('3 hours ago');
|
||||
// Last night at 23:00, 16 hours ago: yesterday.
|
||||
expect(recentWhen(new Date(2026, 10, 3, 23, 0).getTime(), now, 'en')).toBe('yesterday');
|
||||
expect(recentWhen(new Date(2026, 10, 1, 9, 0).getTime(), now, 'en')).toBe('3 days ago');
|
||||
expect(recentWhen(now - 15 * 24 * 60 * 60_000, now, 'en')).toBe('2 weeks ago');
|
||||
expect(recentWhen(now - 70 * 24 * 60 * 60_000, now, 'en')).toBe('2 months ago');
|
||||
expect(recentWhen(now - 3 * 60 * 60_000, now, 'de')).toBe('vor 3 Stunden');
|
||||
});
|
||||
});
|
||||
@@ -82,6 +82,7 @@ export interface PolicyValues {
|
||||
WipeOfflineData: string | null;
|
||||
OpenWithEnabled: boolean;
|
||||
DeveloperToolsAvailability: number | null;
|
||||
RecentFilesInAttach: boolean;
|
||||
FilesDriveEnabled: boolean;
|
||||
FilesFolderSyncEnabled: boolean;
|
||||
FilesDriveLetter: string | null;
|
||||
@@ -469,6 +470,19 @@ export const POLICY_SCHEMA: Record<PolicyKey, PolicyDefinition> = {
|
||||
de: 'Dieselben Werte wie die gleichnamige Richtlinie von Chrome. 2: Die Entwicklertools sind aus und die Einstellung ist gesperrt. 0 oder 1 oder nicht konfiguriert: Benutzer können sie nach einer Warnung in den Einstellungen einschalten. Mit den Entwicklertools kann jeder an der Tastatur alles lesen, was die App enthält, auch E-Mails und Passwörter im Speicher.',
|
||||
},
|
||||
},
|
||||
RecentFilesInAttach: {
|
||||
category: 'privacy',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
onInvalid: false,
|
||||
forcedOnly: true,
|
||||
sample: true,
|
||||
title: { en: 'Show recent files in the Attach menu', de: 'Zuletzt verwendete Dateien im Menü „Anfügen“ anzeigen' },
|
||||
description: {
|
||||
en: 'When enabled or not configured, the Attach button in a new message lists the files the user opened recently, as the operating system records them, so one click attaches one. The list is read when the menu opens and stays on the device. When disabled, the list is gone and the app refuses to read it. Attaching through the file dialog is not affected.',
|
||||
de: 'Wenn aktiviert oder nicht konfiguriert, listet die Schaltfläche „Anfügen“ in einer neuen Nachricht die Dateien auf, die der Benutzer zuletzt geöffnet hat, so wie das Betriebssystem sie erfasst. Ein Klick fügt eine davon an. Die Liste wird beim Öffnen des Menüs gelesen und bleibt auf dem Gerät. Wenn deaktiviert, fehlt die Liste und die App lehnt es ab, sie zu lesen. Das Anfügen über den Dateidialog ist nicht betroffen.',
|
||||
},
|
||||
},
|
||||
FilesDriveEnabled: {
|
||||
category: 'system',
|
||||
type: 'boolean',
|
||||
@@ -974,6 +988,9 @@ const PAGE_POLICY_KEYS: readonly PolicyKey[] = [
|
||||
'AppLockRequired',
|
||||
'AppLockTimeoutMinutes',
|
||||
'CrashReportsAllowed',
|
||||
'RecentFilesInAttach',
|
||||
'FilesDriveEnabled',
|
||||
'FilesFolderSyncEnabled',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -1023,6 +1040,7 @@ export const POLICY_CONSUMERS: Record<PolicyKey, PolicyConsumer> = {
|
||||
BrowserSignIn: { repo: 'shell', file: 'src/main/features/browser-sign-in.ts' },
|
||||
OpenWithEnabled: { repo: 'shell', file: 'src/main/features/os-default-app.ts' },
|
||||
DeveloperToolsAvailability: { repo: 'shell', file: 'src/main/features/dev-tools.ts' },
|
||||
RecentFilesInAttach: { repo: 'shell', file: 'src/main/features/os-recent.ts' },
|
||||
FilesDriveEnabled: { repo: 'shell', file: 'src/main/features/files-drive.ts' },
|
||||
FilesFolderSyncEnabled: { repo: 'shell', file: 'src/main/features/files-folders.ts' },
|
||||
FilesDriveLetter: { repo: 'shell', file: 'src/main/features/files-drive.ts' },
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* Recent files in the composer's Attach menu, in the desktop app only. The shell reads the
|
||||
* OS's list when the menu opens and hands over what the menu shows; attaching sends back an
|
||||
* id, and the bytes come back as a File for the composer's own checks, as a file from the
|
||||
* file dialog does. In a browser there's no bridge, and nothing here offers anything.
|
||||
*/
|
||||
|
||||
import { useSyncExternalStore } from 'react';
|
||||
import { getDesktopBridge } from './bridge';
|
||||
import { getDesktopPolicy, onDesktopPolicyChange } from './policy';
|
||||
import type { PolicySnapshot } from './policy-schema';
|
||||
import type { DesktopRecentFile } from './types';
|
||||
|
||||
/** The shell's limit for one file, the same as for a file from "Open with" (HANDOFF_MAX_BYTES). */
|
||||
export const RECENT_FILE_MAX_BYTES = 100 * 1024 * 1024;
|
||||
|
||||
/** The shell has the list and the RecentFilesInAttach policy doesn't hide it. */
|
||||
export function recentFilesOffered(policy: PolicySnapshot = getDesktopPolicy()): boolean {
|
||||
return !!getDesktopBridge()?.recentFiles && policy.RecentFilesInAttach?.value !== false;
|
||||
}
|
||||
|
||||
/** recentFilesOffered, live. False in the server's render, so the first render in the page matches it. */
|
||||
export function useRecentFilesOffered(): boolean {
|
||||
return useSyncExternalStore(onDesktopPolicyChange, () => recentFilesOffered(), () => false);
|
||||
}
|
||||
|
||||
/** Straight from the click that opened the menu: main wants one. Empty when there's nothing to show. */
|
||||
export async function listRecentFiles(): Promise<DesktopRecentFile[]> {
|
||||
const bridge = getDesktopBridge()?.recentFiles;
|
||||
if (!bridge) return [];
|
||||
try {
|
||||
const result = await bridge.list();
|
||||
return result.ok ? result.files : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export type RecentFileAttach =
|
||||
| { ok: true; file: File }
|
||||
| { ok: false; reason: 'missing' | 'too-large' | 'failed' | 'quiet' };
|
||||
|
||||
/** Straight from the click on the row. `quiet`: nothing worth telling the user (locked, or switched off). */
|
||||
export async function readRecentFile(id: string): Promise<RecentFileAttach> {
|
||||
const bridge = getDesktopBridge()?.recentFiles;
|
||||
if (!bridge) return { ok: false, reason: 'quiet' };
|
||||
try {
|
||||
const result = await bridge.attach(id);
|
||||
if (result.ok) return { ok: true, file: new File([new Uint8Array(result.file.data)], result.file.name) };
|
||||
if (result.reason === 'missing' || result.reason === 'too-large') return { ok: false, reason: result.reason };
|
||||
// Locked or switched off since the menu opened: the page shows that itself.
|
||||
if (result.reason === 'locked' || result.reason === 'policy') return { ok: false, reason: 'quiet' };
|
||||
// An id from a list a newer one replaced, or a click main didn't see: worth another try.
|
||||
return { ok: false, reason: 'failed' };
|
||||
} catch {
|
||||
return { ok: false, reason: 'failed' };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A long folder as its start and its end, which tell it apart: the drive or the share, then
|
||||
* the folders nearest the file. The middle goes, where a path's end would under an ellipsis.
|
||||
*/
|
||||
export function shortFolder(folder: string, max = 44): string {
|
||||
if (folder.length <= max) return folder;
|
||||
const sep = folder.includes('\\') ? '\\' : '/';
|
||||
const parts = folder.split(sep);
|
||||
// \\server\share, or C:, or the empty start of /home.
|
||||
const rootCount = folder.startsWith('\\\\') ? 4 : 1;
|
||||
if (parts.length <= rootCount + 1) return folder;
|
||||
const root = parts.slice(0, rootCount).join(sep);
|
||||
let tail = parts.slice(rootCount);
|
||||
while (tail.length > 1 && `${root}${sep}…${sep}${tail.join(sep)}`.length > max) tail = tail.slice(1);
|
||||
return `${root}${sep}…${sep}${tail.join(sep)}`;
|
||||
}
|
||||
|
||||
const UNITS: [Intl.RelativeTimeFormatUnit, number][] = [
|
||||
['year', 365 * 24 * 60 * 60_000],
|
||||
['month', 30 * 24 * 60 * 60_000],
|
||||
['week', 7 * 24 * 60 * 60_000],
|
||||
['day', 24 * 60 * 60_000],
|
||||
['hour', 60 * 60_000],
|
||||
['minute', 60_000],
|
||||
];
|
||||
|
||||
/** "5 minutes ago", "yesterday", "3 weeks ago", in the UI's language. Under a minute: "now". */
|
||||
export function recentWhen(usedAt: number, now: number, locale: string): string {
|
||||
const format = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });
|
||||
const ago = Math.max(0, now - usedAt);
|
||||
// Whole days by the calendar, so something from last night is "yesterday", not "10 hours ago".
|
||||
if (ago >= 12 * 60 * 60_000 && ago < 7 * 24 * 60 * 60_000) {
|
||||
const day = (time: number) => {
|
||||
const date = new Date(time);
|
||||
return Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) / (24 * 60 * 60_000);
|
||||
};
|
||||
const days = day(now) - day(usedAt);
|
||||
if (days >= 1) return format.format(-days, 'day');
|
||||
}
|
||||
for (const [unit, size] of UNITS) {
|
||||
if (ago >= size) return format.format(-Math.floor(ago / size), unit);
|
||||
}
|
||||
return format.format(0, 'second');
|
||||
}
|
||||
@@ -752,6 +752,39 @@ export interface DesktopDevToolsBridge {
|
||||
onChange: (listener: (state: DesktopDevToolsState) => void) => () => void;
|
||||
}
|
||||
|
||||
/** One of the user's recently used files, as the Attach menu shows it. Nothing more of it reaches the page. */
|
||||
export interface DesktopRecentFile {
|
||||
/** Opaque. `attach` takes it, from the window that listed it, until that window lists again. */
|
||||
id: string;
|
||||
name: string;
|
||||
/** The folder it's in, for display. */
|
||||
folder: string;
|
||||
/** The whole path, for a tooltip. */
|
||||
path: string;
|
||||
/** When it was last used, in milliseconds since 1970. */
|
||||
usedAt: number;
|
||||
/** A small icon as a data: URL, when the OS gave one in time. */
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
/** `gesture`: no click or key press just now. `policy`: RecentFilesInAttach is off. */
|
||||
export type DesktopRecentFilesResult =
|
||||
| { ok: true; files: DesktopRecentFile[] }
|
||||
| { ok: false; reason: 'policy' | 'locked' | 'gesture' };
|
||||
|
||||
export type DesktopRecentFileAttachResult =
|
||||
| { ok: true; file: DesktopOsFile }
|
||||
| { ok: false; reason: 'policy' | 'locked' | 'gesture' | 'unknown' | 'missing' | 'too-large' | 'failed' };
|
||||
|
||||
/**
|
||||
* The files the OS says were used last, for the composer's Attach menu. Main wants a click
|
||||
* or key press of its own for each call, reads only a file it just listed, and never logs.
|
||||
*/
|
||||
export interface DesktopRecentFilesBridge {
|
||||
list: () => Promise<DesktopRecentFilesResult>;
|
||||
attach: (id: string) => Promise<DesktopRecentFileAttachResult>;
|
||||
}
|
||||
|
||||
/** An attachment copied to a private folder and open in its default program. */
|
||||
export interface DesktopEditSession {
|
||||
id: string;
|
||||
@@ -1093,6 +1126,8 @@ export interface BulwarkDesktopBridge {
|
||||
devTools?: DesktopDevToolsBridge;
|
||||
/** Files on this computer. Absent on older shells. */
|
||||
files?: FilesBridge;
|
||||
/** Absent on older shells. */
|
||||
recentFiles?: DesktopRecentFilesBridge;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -103,11 +103,15 @@ export const Button = React.forwardRef<HTMLButtonElement, KitButtonProps>(functi
|
||||
);
|
||||
});
|
||||
|
||||
/** A text link styled like the app's inline links ("Add condition"). */
|
||||
/**
|
||||
* A text link styled like the app's inline links ("Add condition"). A long one
|
||||
* wraps like a paragraph: lines start at the icon's side (a button centres its
|
||||
* text otherwise), with the icon beside the first line.
|
||||
*/
|
||||
export function LinkButton({ icon, children, className, ...rest }: React.ButtonHTMLAttributes<HTMLButtonElement> & { icon?: string }) {
|
||||
return (
|
||||
<button type="button" className={cn('bk inline-flex items-center gap-1 text-sm text-primary hover:underline disabled:opacity-50 disabled:pointer-events-none', className)} {...rest}>
|
||||
{icon && <Icon name={icon} size="sm" />}
|
||||
<button type="button" className={cn('bk inline-flex items-start gap-1 text-start text-sm text-primary hover:underline disabled:opacity-50 disabled:pointer-events-none', className)} {...rest}>
|
||||
{icon && <Icon name={icon} size="sm" className="mt-[0.1875rem]" />}
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "تكتب هذه المفاتيح حرفًا على لوحة مفاتيحك، وسيتوقف عن العمل في كل التطبيقات. جرّب مفاتيح أخرى.",
|
||||
"reserved": "يستخدم النظام أو معظم التطبيقات هذه المفاتيح. جرّب مفاتيح أخرى."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "الملفات الأخيرة",
|
||||
"browse": "استعراض هذا الكمبيوتر…",
|
||||
"from_files": "من الملفات…",
|
||||
"missing": "\"{name}\" لم يعد موجودًا.",
|
||||
"too_large": "\"{name}\" أكبر من {max} ولا يمكن إرفاقه.",
|
||||
"failed": "تعذّر إرفاق \"{name}\". حاول مرة أخرى."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "مزيد من التنسيق",
|
||||
"offline": "دون اتصال",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "أنت دون اتصال. الرسالة محفوظة في المسودات.",
|
||||
"offline_send_unsaved": "أنت دون اتصال. تبقى الرسالة هنا وتُحفظ في المسودات عند عودة الاتصال."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "إظهار {name}",
|
||||
"hide_panel": "إخفاء {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "استكشاف الأخطاء وإصلاحها",
|
||||
"label": "أدوات المطورين ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Aquestes tecles escriuen un caràcter al teu teclat, i deixaria de funcionar a totes les aplicacions. Prova altres tecles.",
|
||||
"reserved": "El sistema o la majoria d'aplicacions fan servir aquestes tecles. Prova altres tecles."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Fitxers recents",
|
||||
"browse": "Explora aquest ordinador…",
|
||||
"from_files": "Des de Fitxers…",
|
||||
"missing": "«{name}» ja no hi és.",
|
||||
"too_large": "«{name}» supera {max} i no es pot adjuntar.",
|
||||
"failed": "No s'ha pogut adjuntar «{name}». Torneu-ho a provar."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Més format",
|
||||
"offline": "Sense connexió",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "No teniu connexió. El missatge està desat a Esborranys.",
|
||||
"offline_send_unsaved": "No teniu connexió. El missatge es queda aquí i es desa a Esborranys quan torneu a tenir connexió."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Mostra {name}",
|
||||
"hide_panel": "Amaga {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Resolució de problemes",
|
||||
"label": "Eines per a desenvolupadors ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Tyto klávesy na vaší klávesnici píší znak, který by pak nefungoval v žádné aplikaci. Zkuste jiné klávesy.",
|
||||
"reserved": "Tyto klávesy používá systém nebo většina aplikací. Zkuste jiné klávesy."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Poslední soubory",
|
||||
"browse": "Procházet tento počítač…",
|
||||
"from_files": "Ze Souborů…",
|
||||
"missing": "„{name}“ už neexistuje.",
|
||||
"too_large": "„{name}“ je větší než {max} a nelze ho připojit.",
|
||||
"failed": "„{name}“ se nepodařilo připojit. Zkuste to znovu."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Další formátování",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Jste offline. Zpráva je uložená v Konceptech.",
|
||||
"offline_send_unsaved": "Jste offline. Zpráva tu zůstane a uloží se do Konceptů, až budete znovu online."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Zobrazit {name}",
|
||||
"hide_panel": "Skrýt {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Řešení potíží",
|
||||
"label": "Nástroje pro vývojáře ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Disse taster skriver et tegn på dit tastatur, og det ville holde op med at virke i alle apps. Prøv andre taster.",
|
||||
"reserved": "Dit system eller de fleste apps bruger disse taster. Prøv andre taster."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Seneste filer",
|
||||
"browse": "Gennemse denne computer…",
|
||||
"from_files": "Fra Filer…",
|
||||
"missing": "\"{name}\" findes ikke længere.",
|
||||
"too_large": "\"{name}\" er større end {max} og kan ikke vedhæftes.",
|
||||
"failed": "\"{name}\" kunne ikke vedhæftes. Prøv igen."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Mere formatering",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Du er offline. Beskeden er gemt i Kladder.",
|
||||
"offline_send_unsaved": "Du er offline. Beskeden bliver her og gemmes i Kladder, når du er online igen."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Vis {name}",
|
||||
"hide_panel": "Skjul {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Fejlfinding",
|
||||
"label": "Udviklerværktøjer ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Diese Tasten erzeugen auf Ihrer Tastatur ein Zeichen, das dann in keiner App mehr funktionieren würde. Versuchen Sie andere Tasten.",
|
||||
"reserved": "Ihr System oder die meisten Apps verwenden diese Tasten. Versuchen Sie andere Tasten."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Zuletzt verwendete Dateien",
|
||||
"browse": "Diesen Computer durchsuchen…",
|
||||
"from_files": "Aus Dateien…",
|
||||
"missing": "\"{name}\" ist nicht mehr vorhanden.",
|
||||
"too_large": "\"{name}\" ist größer als {max} und kann nicht angehängt werden.",
|
||||
"failed": "\"{name}\" konnte nicht angehängt werden. Versuchen Sie es erneut."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Weitere Formatierung",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Sie sind offline. Die Nachricht ist in den Entwürfen gespeichert.",
|
||||
"offline_send_unsaved": "Sie sind offline. Die Nachricht bleibt hier und wird in den Entwürfen gespeichert, sobald Sie wieder online sind."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "{name} einblenden",
|
||||
"hide_panel": "{name} ausblenden"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Fehlerbehebung",
|
||||
"label": "Entwicklertools ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "These keys type a character on your keyboard, and it would stop working in every app. Try other keys.",
|
||||
"reserved": "Your system or most apps use these keys. Try other keys."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Recent files",
|
||||
"browse": "Browse this computer…",
|
||||
"from_files": "From Files…",
|
||||
"missing": "\"{name}\" isn't there any more.",
|
||||
"too_large": "\"{name}\" is larger than {max} and can't be attached.",
|
||||
"failed": "\"{name}\" couldn't be attached. Try again."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "More formatting",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "You're offline. The message is saved in Drafts.",
|
||||
"offline_send_unsaved": "You're offline. The message stays here and is saved in Drafts when you're back online."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Show {name}",
|
||||
"hide_panel": "Hide {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Troubleshooting",
|
||||
"label": "Developer tools ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Estas teclas escriben un carácter en tu teclado, y dejaría de funcionar en todas las aplicaciones. Prueba otras teclas.",
|
||||
"reserved": "Tu sistema o la mayoría de las aplicaciones usan estas teclas. Prueba otras teclas."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Archivos recientes",
|
||||
"browse": "Examinar este equipo…",
|
||||
"from_files": "Desde Archivos…",
|
||||
"missing": "\"{name}\" ya no existe.",
|
||||
"too_large": "\"{name}\" supera {max} y no se puede adjuntar.",
|
||||
"failed": "No se pudo adjuntar \"{name}\". Inténtalo de nuevo."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Más formato",
|
||||
"offline": "Sin conexión",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "No tienes conexión. El mensaje está guardado en Borradores.",
|
||||
"offline_send_unsaved": "No tienes conexión. El mensaje se queda aquí y se guarda en Borradores cuando vuelvas a tener conexión."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Mostrar {name}",
|
||||
"hide_panel": "Ocultar {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Solución de problemas",
|
||||
"label": "Herramientas para desarrolladores ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Need klahvid kirjutavad teie klaviatuuril märgi, mis lakkaks kõigis rakendustes töötamast. Proovige teisi klahve.",
|
||||
"reserved": "Neid klahve kasutab süsteem või enamik rakendusi. Proovige teisi klahve."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Viimati kasutatud failid",
|
||||
"browse": "Sirvi seda arvutit…",
|
||||
"from_files": "Failidest…",
|
||||
"missing": "„{name}” pole enam olemas.",
|
||||
"too_large": "„{name}” on suurem kui {max} ja seda ei saa lisada.",
|
||||
"failed": "Faili „{name}” ei saanud lisada. Proovi uuesti."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Rohkem vormindust",
|
||||
"offline": "Võrguta",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Oled võrguta. Kiri on salvestatud mustanditesse.",
|
||||
"offline_send_unsaved": "Oled võrguta. Kiri jääb siia ja salvestatakse mustanditesse, kui oled jälle võrgus."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Kuva {name}",
|
||||
"hide_panel": "Peida {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Tõrkeotsing",
|
||||
"label": "Arendaja tööriistad ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "این کلیدها روی صفحهکلید شما نویسهای مینویسند و آن نویسه دیگر در هیچ برنامهای کار نمیکند. کلیدهای دیگری را امتحان کنید.",
|
||||
"reserved": "سیستم یا بیشتر برنامهها از این کلیدها استفاده میکنند. کلیدهای دیگری را امتحان کنید."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "فایلهای اخیر",
|
||||
"browse": "مرور این رایانه…",
|
||||
"from_files": "از فایلها…",
|
||||
"missing": "«{name}» دیگر وجود ندارد.",
|
||||
"too_large": "«{name}» بزرگتر از {max} است و نمیتوان آن را پیوست کرد.",
|
||||
"failed": "پیوست «{name}» ممکن نشد. دوباره امتحان کنید."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "قالببندی بیشتر",
|
||||
"offline": "آفلاین",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "آفلاین هستید. پیام در پیشنویسها ذخیره شده است.",
|
||||
"offline_send_unsaved": "آفلاین هستید. پیام همینجا میماند و وقتی دوباره آنلاین شدید در پیشنویسها ذخیره میشود."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "نمایش {name}",
|
||||
"hide_panel": "پنهان کردن {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "عیبیابی",
|
||||
"label": "ابزارهای توسعهدهنده ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Ces touches produisent un caractère sur votre clavier, et il ne fonctionnerait plus dans aucune application. Essayez d'autres touches.",
|
||||
"reserved": "Votre système ou la plupart des applications utilisent ces touches. Essayez d'autres touches."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Fichiers récents",
|
||||
"browse": "Parcourir cet ordinateur…",
|
||||
"from_files": "Depuis Fichiers…",
|
||||
"missing": "« {name} » n'existe plus.",
|
||||
"too_large": "« {name} » dépasse {max} et ne peut pas être joint.",
|
||||
"failed": "Impossible de joindre « {name} ». Réessayez."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Plus de mise en forme",
|
||||
"offline": "Hors ligne",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Vous êtes hors ligne. Le message est enregistré dans les Brouillons.",
|
||||
"offline_send_unsaved": "Vous êtes hors ligne. Le message reste ici et sera enregistré dans les Brouillons dès que vous serez de nouveau en ligne."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Afficher {name}",
|
||||
"hide_panel": "Masquer {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Dépannage",
|
||||
"label": "Outils de développement ({shortcut})",
|
||||
|
||||
@@ -7772,6 +7772,14 @@
|
||||
"types_character": "המקשים האלה מקלידים תו במקלדת שלכם, והוא יפסיק לעבוד בכל האפליקציות. נסו מקשים אחרים.",
|
||||
"reserved": "המערכת או רוב האפליקציות משתמשות במקשים האלה. נסו מקשים אחרים."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "קבצים אחרונים",
|
||||
"browse": "עיון במחשב הזה…",
|
||||
"from_files": "מקבצים…",
|
||||
"missing": "\"{name}\" כבר לא קיים.",
|
||||
"too_large": "\"{name}\" גדול מ־{max} ולא ניתן לצרף אותו.",
|
||||
"failed": "לא ניתן היה לצרף את \"{name}\". נסו שוב."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "עוד עיצוב",
|
||||
"offline": "אין חיבור",
|
||||
@@ -7780,6 +7788,10 @@
|
||||
"offline_send_saved": "אין חיבור. ההודעה שמורה בטיוטות.",
|
||||
"offline_send_unsaved": "אין חיבור. ההודעה נשארת כאן ותישמר בטיוטות כשתחזרו לרשת."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "הצגת {name}",
|
||||
"hide_panel": "הסתרת {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "פתרון בעיות",
|
||||
"label": "כלים למפתחים ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Ezek a billentyűk karaktert írnak az Ön billentyűzetén, amely többé egyik alkalmazásban sem működne. Próbáljon más billentyűket.",
|
||||
"reserved": "Ezeket a billentyűket a rendszer vagy a legtöbb alkalmazás használja. Próbáljon más billentyűket."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Legutóbbi fájlok",
|
||||
"browse": "A számítógép tallózása…",
|
||||
"from_files": "A Fájlokból…",
|
||||
"missing": "A(z) „{name}” már nem létezik.",
|
||||
"too_large": "A(z) „{name}” nagyobb, mint {max}, ezért nem csatolható.",
|
||||
"failed": "A(z) „{name}” csatolása nem sikerült. Próbálja újra."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "További formázás",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Offline állapotban van. Az üzenet a Piszkozatok között van mentve.",
|
||||
"offline_send_unsaved": "Offline állapotban van. Az üzenet itt marad, és a Piszkozatok közé kerül, amint újra online lesz."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "{name} megjelenítése",
|
||||
"hide_panel": "{name} elrejtése"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Hibaelhárítás",
|
||||
"label": "Fejlesztői eszközök ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Questi tasti scrivono un carattere sulla tua tastiera, che smetterebbe di funzionare in tutte le app. Prova altri tasti.",
|
||||
"reserved": "Il sistema o la maggior parte delle app usano questi tasti. Prova altri tasti."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "File recenti",
|
||||
"browse": "Sfoglia questo computer…",
|
||||
"from_files": "Da File…",
|
||||
"missing": "\"{name}\" non esiste più.",
|
||||
"too_large": "\"{name}\" supera {max} e non può essere allegato.",
|
||||
"failed": "Impossibile allegare \"{name}\". Riprova."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Altre opzioni di formattazione",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Sei offline. Il messaggio è salvato nelle Bozze.",
|
||||
"offline_send_unsaved": "Sei offline. Il messaggio resta qui e viene salvato nelle Bozze quando torni online."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Mostra {name}",
|
||||
"hide_panel": "Nascondi {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Risoluzione dei problemi",
|
||||
"label": "Strumenti per sviluppatori ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "このキーはお使いのキーボードで文字を入力します。割り当てると、すべてのアプリでその文字を入力できなくなります。別のキーをお試しください。",
|
||||
"reserved": "このキーはシステムまたは多くのアプリが使用しています。別のキーをお試しください。"
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "最近使ったファイル",
|
||||
"browse": "このコンピューターを参照…",
|
||||
"from_files": "ファイルから…",
|
||||
"missing": "「{name}」はもうありません。",
|
||||
"too_large": "「{name}」は {max} を超えているため添付できません。",
|
||||
"failed": "「{name}」を添付できませんでした。もう一度お試しください。"
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "その他の書式",
|
||||
"offline": "オフライン",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "オフラインです。メッセージは下書きに保存されています。",
|
||||
"offline_send_unsaved": "オフラインです。メッセージはここに残り、オンラインに戻ると下書きに保存されます。"
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "{name}を表示",
|
||||
"hide_panel": "{name}を非表示"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "トラブルシューティング",
|
||||
"label": "デベロッパー ツール ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "이 키는 사용 중인 키보드에서 문자를 입력하며, 지정하면 모든 앱에서 그 문자를 입력할 수 없게 됩니다. 다른 키를 사용해 보세요.",
|
||||
"reserved": "시스템 또는 대부분의 앱이 이 키를 사용합니다. 다른 키를 사용해 보세요."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "최근 파일",
|
||||
"browse": "이 컴퓨터 찾아보기…",
|
||||
"from_files": "파일에서…",
|
||||
"missing": "\"{name}\"이(가) 더 이상 없어요.",
|
||||
"too_large": "\"{name}\"이(가) {max}보다 커서 첨부할 수 없어요.",
|
||||
"failed": "\"{name}\"을(를) 첨부하지 못했어요. 다시 시도해 주세요."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "추가 서식",
|
||||
"offline": "오프라인",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "오프라인 상태입니다. 메시지는 임시보관함에 저장되어 있습니다.",
|
||||
"offline_send_unsaved": "오프라인 상태입니다. 메시지는 여기에 남아 있으며 다시 온라인이 되면 임시보관함에 저장됩니다."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "{name} 표시",
|
||||
"hide_panel": "{name} 숨기기"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "문제 해결",
|
||||
"label": "개발자 도구 ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Šie taustiņi jūsu tastatūrā raksta rakstzīmi, kas pārstātu darboties visās lietotnēs. Izmēģiniet citus taustiņus.",
|
||||
"reserved": "Šos taustiņus izmanto sistēma vai lielākā daļa lietotņu. Izmēģiniet citus taustiņus."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Nesen izmantotie faili",
|
||||
"browse": "Pārlūkot šo datoru…",
|
||||
"from_files": "No Failiem…",
|
||||
"missing": "“{name}” vairs nav pieejams.",
|
||||
"too_large": "“{name}” ir lielāks par {max}, un to nevar pievienot.",
|
||||
"failed": "Neizdevās pievienot “{name}”. Mēģiniet vēlreiz."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Vairāk formatēšanas",
|
||||
"offline": "Bezsaistē",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Jūs esat bezsaistē. Ziņojums ir saglabāts melnrakstos.",
|
||||
"offline_send_unsaved": "Jūs esat bezsaistē. Ziņojums paliek šeit un tiks saglabāts melnrakstos, kad atkal būsiet tiešsaistē."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Rādīt {name}",
|
||||
"hide_panel": "Paslēpt {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Problēmu novēršana",
|
||||
"label": "Izstrādātāju rīki ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Эдгээр товч таны гар дээр тэмдэгт бичдэг тул тэр тэмдэгт бүх аппад ажиллахаа болино. Өөр товч туршина уу.",
|
||||
"reserved": "Систем эсвэл ихэнх апп эдгээр товчийг ашигладаг. Өөр товч туршина уу."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Сүүлийн файлууд",
|
||||
"browse": "Энэ компьютерээс хайх…",
|
||||
"from_files": "Файлаас…",
|
||||
"missing": "\"{name}\" байхгүй болсон байна.",
|
||||
"too_large": "\"{name}\" {max}-аас том тул хавсаргах боломжгүй.",
|
||||
"failed": "\"{name}\"-г хавсаргаж чадсангүй. Дахин оролдоно уу."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Бусад хэлбэржүүлэлт",
|
||||
"offline": "Офлайн",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Та офлайн байна. Мессеж нооргонд хадгалагдсан.",
|
||||
"offline_send_unsaved": "Та офлайн байна. Мессеж энд үлдэж, онлайн болмогц нооргонд хадгалагдана."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "{name} харуулах",
|
||||
"hide_panel": "{name} нуух"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Алдаа засах",
|
||||
"label": "Хөгжүүлэгчийн хэрэгсэл ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Disse tastene skriver et tegn på tastaturet ditt, og det ville slutte å virke i alle apper. Prøv andre taster.",
|
||||
"reserved": "Systemet ditt eller de fleste apper bruker disse tastene. Prøv andre taster."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Nylige filer",
|
||||
"browse": "Bla gjennom denne datamaskinen…",
|
||||
"from_files": "Fra Filer…",
|
||||
"missing": "«{name}» finnes ikke lenger.",
|
||||
"too_large": "«{name}» er større enn {max} og kan ikke legges ved.",
|
||||
"failed": "Kunne ikke legge ved «{name}». Prøv igjen."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Mer formatering",
|
||||
"offline": "Frakoblet",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Du er frakoblet. Meldingen er lagret i Utkast.",
|
||||
"offline_send_unsaved": "Du er frakoblet. Meldingen blir her og lagres i Utkast når du er på nett igjen."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Vis {name}",
|
||||
"hide_panel": "Skjul {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Feilsøking",
|
||||
"label": "Utviklerverktøy ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Deze toetsen typen een teken op je toetsenbord, en dat zou in geen enkele app meer werken. Probeer andere toetsen.",
|
||||
"reserved": "Je systeem of de meeste apps gebruiken deze toetsen. Probeer andere toetsen."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Recente bestanden",
|
||||
"browse": "Deze computer doorzoeken…",
|
||||
"from_files": "Uit Bestanden…",
|
||||
"missing": "\"{name}\" bestaat niet meer.",
|
||||
"too_large": "\"{name}\" is groter dan {max} en kan niet worden bijgevoegd.",
|
||||
"failed": "\"{name}\" kon niet worden bijgevoegd. Probeer het opnieuw."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Meer opmaak",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Je bent offline. Het bericht is opgeslagen in Concepten.",
|
||||
"offline_send_unsaved": "Je bent offline. Het bericht blijft hier en wordt in Concepten opgeslagen zodra je weer online bent."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "{name} tonen",
|
||||
"hide_panel": "{name} verbergen"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Probleemoplossing",
|
||||
"label": "Ontwikkelaarstools ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Te klawisze wpisują znak na Twojej klawiaturze i przestałby on działać we wszystkich aplikacjach. Wypróbuj inne klawisze.",
|
||||
"reserved": "Te klawisze są używane przez system lub większość aplikacji. Wypróbuj inne klawisze."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Ostatnie pliki",
|
||||
"browse": "Przeglądaj ten komputer…",
|
||||
"from_files": "Z Plików…",
|
||||
"missing": "„{name}” już nie istnieje.",
|
||||
"too_large": "„{name}” jest większy niż {max} i nie można go dołączyć.",
|
||||
"failed": "Nie udało się dołączyć „{name}”. Spróbuj ponownie."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Więcej formatowania",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Jesteś offline. Wiadomość jest zapisana w Szkicach.",
|
||||
"offline_send_unsaved": "Jesteś offline. Wiadomość zostaje tutaj i zostanie zapisana w Szkicach, gdy wrócisz do sieci."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Pokaż: {name}",
|
||||
"hide_panel": "Ukryj: {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Rozwiązywanie problemów",
|
||||
"label": "Narzędzia dla deweloperów ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Estas teclas escrevem um carácter no seu teclado, e ele deixaria de funcionar em todas as aplicações. Experimente outras teclas.",
|
||||
"reserved": "O seu sistema ou a maioria das aplicações usam estas teclas. Experimente outras teclas."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Arquivos recentes",
|
||||
"browse": "Procurar neste computador…",
|
||||
"from_files": "De Arquivos…",
|
||||
"missing": "\"{name}\" não existe mais.",
|
||||
"too_large": "\"{name}\" é maior que {max} e não pode ser anexado.",
|
||||
"failed": "Não foi possível anexar \"{name}\". Tente novamente."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Mais formatação",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Está offline. A mensagem está guardada em Rascunhos.",
|
||||
"offline_send_unsaved": "Está offline. A mensagem fica aqui e é guardada em Rascunhos quando voltar a estar online."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Mostrar {name}",
|
||||
"hide_panel": "Ocultar {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Resolução de problemas",
|
||||
"label": "Ferramentas de programador ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Aceste taste scriu un caracter pe tastatura ta, iar el n-ar mai funcționa în nicio aplicație. Încearcă alte taste.",
|
||||
"reserved": "Sistemul sau majoritatea aplicațiilor folosesc aceste taste. Încearcă alte taste."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Fișiere recente",
|
||||
"browse": "Răsfoiește acest computer…",
|
||||
"from_files": "Din Fișiere…",
|
||||
"missing": "„{name}” nu mai există.",
|
||||
"too_large": "„{name}” depășește {max} și nu poate fi atașat.",
|
||||
"failed": "„{name}” nu a putut fi atașat. Încearcă din nou."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Mai multe opțiuni de formatare",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Sunteți offline. Mesajul este salvat în Ciorne.",
|
||||
"offline_send_unsaved": "Sunteți offline. Mesajul rămâne aici și este salvat în Ciorne când sunteți din nou online."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Afișează {name}",
|
||||
"hide_panel": "Ascunde {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Depanare",
|
||||
"label": "Instrumente pentru dezvoltatori ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "На вашей клавиатуре эти клавиши вводят символ, и он перестал бы работать во всех приложениях. Попробуйте другие клавиши.",
|
||||
"reserved": "Эти клавиши использует система или большинство приложений. Попробуйте другие клавиши."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Недавние файлы",
|
||||
"browse": "Обзор этого компьютера…",
|
||||
"from_files": "Из Файлов…",
|
||||
"missing": "«{name}» больше не существует.",
|
||||
"too_large": "«{name}» больше {max}, его нельзя прикрепить.",
|
||||
"failed": "Не удалось прикрепить «{name}». Попробуйте ещё раз."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Дополнительное форматирование",
|
||||
"offline": "Не в сети",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Вы не в сети. Сообщение сохранено в черновиках.",
|
||||
"offline_send_unsaved": "Вы не в сети. Сообщение останется здесь и сохранится в черновиках, когда вы снова будете в сети."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Показать: {name}",
|
||||
"hide_panel": "Скрыть: {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Устранение неполадок",
|
||||
"label": "Инструменты разработчика ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Tieto klávesy na vašej klávesnici píšu znak, ktorý by potom nefungoval v žiadnej aplikácii. Skúste iné klávesy.",
|
||||
"reserved": "Tieto klávesy používa systém alebo väčšina aplikácií. Skúste iné klávesy."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Nedávne súbory",
|
||||
"browse": "Prehľadávať tento počítač…",
|
||||
"from_files": "Zo Súborov…",
|
||||
"missing": "„{name}“ už neexistuje.",
|
||||
"too_large": "„{name}“ je väčší ako {max} a nedá sa priložiť.",
|
||||
"failed": "„{name}“ sa nepodarilo priložiť. Skúste to znova."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Ďalšie formátovanie",
|
||||
"offline": "Offline",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Ste offline. Správa je uložená v Konceptoch.",
|
||||
"offline_send_unsaved": "Ste offline. Správa tu zostane a uloží sa do Konceptov, keď budete znova online."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Zobraziť {name}",
|
||||
"hide_panel": "Skryť {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Riešenie problémov",
|
||||
"label": "Nástroje pre vývojárov ({shortcut})",
|
||||
|
||||
@@ -7779,6 +7779,14 @@
|
||||
"types_character": "ปุ่มเหล่านี้พิมพ์อักขระบนแป้นพิมพ์ของคุณ และอักขระนั้นจะใช้ไม่ได้ในทุกแอป ลองใช้ปุ่มอื่น",
|
||||
"reserved": "ระบบหรือแอปส่วนใหญ่ใช้ปุ่มเหล่านี้ ลองใช้ปุ่มอื่น"
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "ไฟล์ล่าสุด",
|
||||
"browse": "เรียกดูคอมพิวเตอร์เครื่องนี้…",
|
||||
"from_files": "จากไฟล์…",
|
||||
"missing": "“{name}” ไม่มีอยู่แล้ว",
|
||||
"too_large": "“{name}” มีขนาดใหญ่กว่า {max} จึงแนบไม่ได้",
|
||||
"failed": "แนบ “{name}” ไม่สำเร็จ ลองอีกครั้ง"
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "การจัดรูปแบบเพิ่มเติม",
|
||||
"offline": "ออฟไลน์",
|
||||
@@ -7787,6 +7795,10 @@
|
||||
"offline_send_saved": "คุณออฟไลน์อยู่ ข้อความถูกบันทึกไว้ในจดหมายร่างแล้ว",
|
||||
"offline_send_unsaved": "คุณออฟไลน์อยู่ ข้อความจะอยู่ที่นี่และถูกบันทึกในจดหมายร่างเมื่อคุณกลับมาออนไลน์"
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "แสดง {name}",
|
||||
"hide_panel": "ซ่อน {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "การแก้ไขปัญหา",
|
||||
"label": "เครื่องมือสำหรับนักพัฒนาซอฟต์แวร์ ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "Bu tuşlar klavyenizde bir karakter yazar ve bu karakter hiçbir uygulamada çalışmaz olur. Başka tuşlar deneyin.",
|
||||
"reserved": "Bu tuşları sisteminiz veya çoğu uygulama kullanıyor. Başka tuşlar deneyin."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Son dosyalar",
|
||||
"browse": "Bu bilgisayara göz at…",
|
||||
"from_files": "Dosyalar'dan…",
|
||||
"missing": "\"{name}\" artık yok.",
|
||||
"too_large": "\"{name}\" {max} boyutundan büyük ve eklenemez.",
|
||||
"failed": "\"{name}\" eklenemedi. Yeniden deneyin."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Daha fazla biçimlendirme",
|
||||
"offline": "Çevrimdışı",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Çevrimdışısınız. İleti Taslaklar'a kaydedildi.",
|
||||
"offline_send_unsaved": "Çevrimdışısınız. İleti burada kalır ve yeniden çevrimiçi olduğunuzda Taslaklar'a kaydedilir."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "{name} panelini göster",
|
||||
"hide_panel": "{name} panelini gizle"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Sorun giderme",
|
||||
"label": "Geliştirici araçları ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "На вашій клавіатурі ці клавіші вводять символ, і він перестав би працювати в усіх застосунках. Спробуйте інші клавіші.",
|
||||
"reserved": "Ці клавіші використовує система або більшість застосунків. Спробуйте інші клавіші."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Нещодавні файли",
|
||||
"browse": "Огляд цього комп'ютера…",
|
||||
"from_files": "З Файлів…",
|
||||
"missing": "«{name}» більше не існує.",
|
||||
"too_large": "«{name}» більший за {max}, його не можна прикріпити.",
|
||||
"failed": "Не вдалося прикріпити «{name}». Спробуйте ще раз."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Додаткове форматування",
|
||||
"offline": "Не в мережі",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "Ви не в мережі. Повідомлення збережено в чернетках.",
|
||||
"offline_send_unsaved": "Ви не в мережі. Повідомлення залишиться тут і збережеться в чернетках, коли ви знову будете в мережі."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Показати: {name}",
|
||||
"hide_panel": "Сховати: {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Усунення несправностей",
|
||||
"label": "Інструменти розробника ({shortcut})",
|
||||
|
||||
@@ -7783,6 +7783,14 @@
|
||||
"types_character": "Các phím này gõ một ký tự trên bàn phím của bạn, và ký tự đó sẽ không dùng được trong mọi ứng dụng. Hãy thử phím khác.",
|
||||
"reserved": "Hệ thống hoặc hầu hết ứng dụng dùng các phím này. Hãy thử phím khác."
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "Tệp gần đây",
|
||||
"browse": "Duyệt máy tính này…",
|
||||
"from_files": "Từ Tệp…",
|
||||
"missing": "\"{name}\" không còn nữa.",
|
||||
"too_large": "\"{name}\" lớn hơn {max} nên không thể đính kèm.",
|
||||
"failed": "Không thể đính kèm \"{name}\". Hãy thử lại."
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "Thêm định dạng",
|
||||
"offline": "Ngoại tuyến",
|
||||
@@ -7791,6 +7799,10 @@
|
||||
"offline_send_saved": "Bạn đang ngoại tuyến. Thư đã được lưu trong Bản nháp.",
|
||||
"offline_send_unsaved": "Bạn đang ngoại tuyến. Thư vẫn ở đây và sẽ được lưu vào Bản nháp khi bạn trực tuyến trở lại."
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "Hiện {name}",
|
||||
"hide_panel": "Ẩn {name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "Khắc phục sự cố",
|
||||
"label": "Công cụ cho nhà phát triển ({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "這些鍵在您的鍵盤上會輸入一個字元,占用後該字元在所有應用程式中都無法輸入。請試試其他按鍵。",
|
||||
"reserved": "系統或大多數應用程式正在使用這些鍵。請試試其他按鍵。"
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "最近的檔案",
|
||||
"browse": "瀏覽這部電腦…",
|
||||
"from_files": "從檔案…",
|
||||
"missing": "「{name}」已不存在。",
|
||||
"too_large": "「{name}」超過 {max},無法附加。",
|
||||
"failed": "無法附加「{name}」。請再試一次。"
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "更多格式",
|
||||
"offline": "離線",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "你已離線。郵件已儲存在草稿中。",
|
||||
"offline_send_unsaved": "你已離線。郵件會留在這裡,恢復連線後儲存到草稿。"
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "顯示{name}",
|
||||
"hide_panel": "隱藏{name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "疑難排解",
|
||||
"label": "開發人員工具({shortcut})",
|
||||
|
||||
@@ -7771,6 +7771,14 @@
|
||||
"types_character": "这些键在您的键盘上会输入一个字符,占用后该字符在所有应用中都无法输入。请试试其他按键。",
|
||||
"reserved": "系统或大多数应用在使用这些键。请试试其他按键。"
|
||||
},
|
||||
"desktopAttachRecent": {
|
||||
"heading": "最近的文件",
|
||||
"browse": "浏览此电脑…",
|
||||
"from_files": "从文件…",
|
||||
"missing": "“{name}”已不存在。",
|
||||
"too_large": "“{name}”超过 {max},无法添加为附件。",
|
||||
"failed": "无法将“{name}”添加为附件。请重试。"
|
||||
},
|
||||
"compose_windows": {
|
||||
"more_formatting": "更多格式",
|
||||
"offline": "离线",
|
||||
@@ -7779,6 +7787,10 @@
|
||||
"offline_send_saved": "你已离线。邮件已保存在草稿中。",
|
||||
"offline_send_unsaved": "你已离线。邮件会留在这里,恢复联网后保存到草稿。"
|
||||
},
|
||||
"composer_panel": {
|
||||
"show_panel": "显示{name}",
|
||||
"hide_panel": "隐藏{name}"
|
||||
},
|
||||
"desktopDevTools": {
|
||||
"section_title": "故障排除",
|
||||
"label": "开发者工具({shortcut})",
|
||||
|
||||
Reference in New Issue
Block a user