Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(notifications-inbox): show the list toggle when nothing is selected (#9935)

teodd6407ca83ad
diff --git a/apps/web/src/features/notifications-inbox/views/notifications-none-selected.test.tsx b/apps/web/src/features/notifications-inbox/views/notifications-none-selected.test.tsx
new file mode 100644
index 0000000000..98d0d7186f
--- /dev/null
+++ b/apps/web/src/features/notifications-inbox/views/notifications-none-selected.test.tsx
@@ -0,0 +1,63 @@
+import {
+ ViewShell,
+ ViewSidebarToggle,
+} from '@app/components/view-shell/ViewShell';
+import {
+ SplitPanelContext,
+ type SplitPanelContextType,
+} from '@components/app/split-layout/context';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+import { NotificationsNoneSelected } from './notifications-none-selected';
+
+vi.mock('@core/hotkey/hotkeys', () => ({ registerHotkey: vi.fn() }));
+vi.mock('@solid-primitives/resize-observer', () => ({
+ createResizeObserver: () => {},
+ createElementSize: () => ({ width: 1200, height: 800 }),
+}));
+vi.mock('@app/components/view-shell/create-frame-width', () => ({
+ createFrameWidth: () => () => 1200,
+}));
+
+beforeEach(() => {
+ const values = new Map<string, string>();
+ vi.stubGlobal('localStorage', {
+ getItem: (key: string) => values.get(key) ?? null,
+ setItem: (key: string, value: string) => values.set(key, value),
+ removeItem: (key: string) => values.delete(key),
+ });
+});
+afterEach(() => {
+ cleanup();
+ vi.unstubAllGlobals();
+});
+
+const PANEL = {
+ handle: { isFirst: () => true },
+ isPanelActive: () => true,
+ splitHotkeyScope: 'notifications',
+} as unknown as SplitPanelContextType;
+
+it('keeps a way back to the collapsed list while nothing is selected', () => {
+ render(() => (
+ <SplitPanelContext.Provider value={PANEL}>
+ <ViewShell.Root asidePreferenceKey="notifications">
+ <ViewShell.Aside>
+ <ViewSidebarToggle action="collapse" />
+ </ViewShell.Aside>
+ <ViewShell.Main>
+ <NotificationsNoneSelected />
+ </ViewShell.Main>
+ </ViewShell.Root>
+ </SplitPanelContext.Provider>
+ ));
+ expect(screen.getByText('No notification selected')).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Show navigation' })).toBeNull();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Hide navigation' }));
+ expect(screen.getByText('Notifications')).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Show navigation' }));
+
+ expect(screen.getByRole('button', { name: 'Hide navigation' })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Show navigation' })).toBeNull();
+});
diff --git a/apps/web/src/features/notifications-inbox/views/notifications-none-selected.tsx b/apps/web/src/features/notifications-inbox/views/notifications-none-selected.tsx
new file mode 100644
index 0000000000..64a327121d
--- /dev/null
+++ b/apps/web/src/features/notifications-inbox/views/notifications-none-selected.tsx
@@ -0,0 +1,35 @@
+import {
+ useViewShell,
+ ViewShell,
+ ViewSidebar,
+} from '@app/components/view-shell';
+import { t } from '@app/lib/i18n';
+import EmptyStateInboxTrayGraphic from '@design/empty-state-inbox-tray.svg';
+import { EmptyStatePanel } from '@ui';
+import { Show } from 'solid-js';
+
+/**
+ * The preview with nothing chosen. With the list collapsed it keeps the top
+ * bar, like Home's idle pane, so the shared toggle can bring the list back.
+ */
+export function NotificationsNoneSelected() {
+ const shell = useViewShell();
+ return (
+ <>
+ <Show when={shell.aside.isCollapsed() || shell.aside.isOverlay()}>
+ <ViewShell.TopBar>
+ <ViewSidebar.Title caret={false}>
+ {t('nav.notifications')}
+ </ViewSidebar.Title>
+ </ViewShell.TopBar>
+ </Show>
+ <EmptyStatePanel
+ centered
+ class="min-h-0 flex-1"
+ graphic={EmptyStateInboxTrayGraphic}
+ title={t('notificationsInbox.noneSelectedTitle')}
+ description={t('notificationsInbox.noneSelectedDescription')}
+ />
+ </>
+ );
+}
diff --git a/apps/web/src/features/notifications-inbox/views/notifications-view.tsx b/apps/web/src/features/notifications-inbox/views/notifications-view.tsx
index 3b52ce7c64..708043c3bd 100644
--- a/apps/web/src/features/notifications-inbox/views/notifications-view.tsx
+++ b/apps/web/src/features/notifications-inbox/views/notifications-view.tsx
@@ -115,6 +115,7 @@ import {
} from '../primitives/notification-location';
import { createRowActions, rowButtons } from '../primitives/row-actions';
import { rowEntity } from '../primitives/row-entity';
+import { NotificationsNoneSelected } from './notifications-none-selected';
type ActivationMetadata = { event?: MouseEvent; newSplit?: boolean };
/** Stepping through the list and moving on from a done row replace the entry. */
@@ -1067,18 +1068,7 @@ export function NotificationsView(props: NotificationsViewProps) {
fallback={() => (
<Show
when={previewTarget()}
- fallback={
- <EmptyStatePanel
- centered
- graphic={EmptyStateInboxTrayGraphic}
- title={t(
- 'notificationsInbox.noneSelectedTitle'
- )}
- description={t(
- 'notificationsInbox.noneSelectedDescription'
- )}
- />
- }
+ fallback={<NotificationsNoneSelected />}
>
<PreviewPanel
target={previewTarget()}