A local-first personal finance app
make sidebar menu items configurable (#9193)
Matt Fiddaman425a0a0f0e82
diff --git a/packages/component-library/src/Toggle.tsx b/packages/component-library/src/Toggle.tsxindex 8c54939081..e245a8774b 100644--- a/packages/component-library/src/Toggle.tsx+++ b/packages/component-library/src/Toggle.tsx@@ -36,7 +36,10 @@ export const Toggle = ({className={css({height: 0,width: 0,- visibility: 'hidden',+ opacity: 0,+ '&:focus-visible + label': {+ boxShadow: '0 0 0 2px ' + theme.formInputBorderSelected,+ },})}type="checkbox"/>diff --git a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-1-chromium-linux.png b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-1-chromium-linux.pngindex e4b399ab79..d88209c789 100644Binary files a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-1-chromium-linux.png and b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-2-chromium-linux.png b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-2-chromium-linux.pngindex 3eedc987cf..a30af48c3e 100644Binary files a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-2-chromium-linux.png and b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-3-chromium-linux.png b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-3-chromium-linux.pngindex 2f68c3f865..8ba4c110a0 100644Binary files a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-3-chromium-linux.png and b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-search-works-correctly-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-1-chromium-linux.pngindex 8cea0b3493..b891d9b383 100644Binary files a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-1-chromium-linux.png and b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-2-chromium-linux.png b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-2-chromium-linux.pngindex 83457c8fa5..299ac95354 100644Binary files a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-2-chromium-linux.png and b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-3-chromium-linux.png b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-3-chromium-linux.pngindex 5724fa140b..c46b12a86f 100644Binary files a/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-3-chromium-linux.png and b/packages/desktop-client/e2e/command-bar.test.ts-snapshots/Command-bar-Check-the-command-bar-visuals-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/settings.test.ts b/packages/desktop-client/e2e/settings.test.tsindex ff20d7037c..df5da19c9c 100644--- a/packages/desktop-client/e2e/settings.test.ts+++ b/packages/desktop-client/e2e/settings.test.ts@@ -40,6 +40,36 @@ test.describe('Settings', () => {expect(download.suggestedFilename()).toMatch(/^\d{4}-\d{2}-\d{2}-.*.zip$/);});+ test('moves pages between the sidebar and settings', async () => {+ await settingsPage.settings+ .locator('label[for="toggle-sidebar-item-payees"]')+ .click();+ await settingsPage.settings+ .locator('label[for="toggle-sidebar-item-schedules"]')+ .click();++ const sidebar = page.getByTestId('sidebar-primary-buttons');+ await expect(sidebar.getByRole('link', { name: 'Payees' })).toBeVisible();+ await expect(sidebar.getByRole('link', { name: 'Schedules' })).toHaveCount(+ 0,+ );+ await expect(+ settingsPage.settingsNav.getByRole('link', { name: 'Schedules' }),+ ).toBeVisible();+ await expect(+ settingsPage.settingsNav.getByRole('link', { name: 'Payees' }),+ ).toHaveCount(0);++ await settingsPage.settingsNav+ .getByRole('link', { name: 'Schedules' })+ .click();+ await expect(page).toHaveURL(/\/settings\/schedules$/);+ await expect(settingsPage.settingsNav).toBeVisible();++ await sidebar.getByRole('link', { name: 'Payees' }).click();+ await expect(page).toHaveURL(/\/payees$/);+ });+test('keeps the global CSS override readable after switching themes', async () => {await page.setViewportSize({ width: 1024, height: 900 });await page.route('**/customThemeCatalog.json', route =>diff --git a/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.pngindex 959c4e0afa..268004a011 100644Binary files a/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.png and b/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-2-chromium-linux.png b/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-2-chromium-linux.pngindex d98f6d44fd..117586563a 100644Binary files a/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-2-chromium-linux.png and b/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.png b/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.pngindex c1c53acaf2..79d849ff2b 100644Binary files a/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.png and b/packages/desktop-client/e2e/settings.test.ts-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts b/packages/desktop-client/e2e/transactions.mobile.test.tsindex 28f8d6cada..4f70cfe0c5 100644--- a/packages/desktop-client/e2e/transactions.mobile.test.ts+++ b/packages/desktop-client/e2e/transactions.mobile.test.ts@@ -60,7 +60,6 @@ test.describe('Mobile Transactions', () => {transactionEntryPage.page.url() +'?category=Food&amount=23.42&account=HSBC&date=2025-10-31&cleared=true&payee=Kroger¬es=just+a+note',);- // Note: no easy way to test cleared checkboxawait expect(page.getByTestId('transaction-form')).toMatchAriaSnapshot(`- text: Amount- textbox@@ -75,7 +74,9 @@ test.describe('Mobile Transactions', () => {- button "HSBC" [disabled]- text: Date- textbox [disabled]: 2025-10-31-- text: Cleared Notes+- text: Cleared+- checkbox [checked]+- text: Notes- textbox [disabled]: just a note`);});diff --git a/packages/desktop-client/package.json b/packages/desktop-client/package.jsonindex 5b6e9705dd..63846798fc 100644--- a/packages/desktop-client/package.json+++ b/packages/desktop-client/package.json@@ -85,6 +85,8 @@"#components/schedules": "./src/components/schedules/index.tsx","#components/schedules/schedule-edit-utils": "./src/components/schedules/schedule-edit-utils.ts","#components/select/getFirstDayOfWeek": "./src/components/select/getFirstDayOfWeek.ts",+ "#components/sidebar/sidebarMenu": "./src/components/sidebar/sidebarMenu.ts",+ "#components/sidebar/useSidebarMenuItemDetails": "./src/components/sidebar/useSidebarMenuItemDetails.ts","#components/transactions/applyRulesToTransaction": "./src/components/transactions/applyRulesToTransaction.ts","#components/transactions/table/columns": "./src/components/transactions/table/columns.ts","#components/transactions/table/utils": "./src/components/transactions/table/utils.ts",diff --git a/packages/desktop-client/src/components/CommandBar.tsx b/packages/desktop-client/src/components/CommandBar.tsxindex 074aabc111..ce3f9354e6 100644--- a/packages/desktop-client/src/components/CommandBar.tsx+++ b/packages/desktop-client/src/components/CommandBar.tsx@@ -7,28 +7,23 @@ import {SvgLibrary,SvgPiggyBank,SvgReports,- SvgStoreFront,- SvgTag,- SvgTuning,- SvgWallet,} from '@actual-app/components/icons/v1';-import {- SvgCalendar3,- SvgHelp,- SvgNotesPaperText,-} from '@actual-app/components/icons/v2';+import { SvgHelp, SvgNotesPaperText } from '@actual-app/components/icons/v2';import { styles } from '@actual-app/components/styles';import { Text } from '@actual-app/components/text';import { View } from '@actual-app/components/view';import { css } from '@emotion/css';import { Command } from 'cmdk';+import { getSidebarMenuItemPath } from '#components/sidebar/sidebarMenu';+import { useSidebarMenuItemDetails } from '#components/sidebar/useSidebarMenuItemDetails';import { useAccounts } from '#hooks/useAccounts';import { useDashboardPages } from '#hooks/useDashboardPages';import { useMetadataPref } from '#hooks/useMetadataPref';import { useModalState } from '#hooks/useModalState';import { useNavigate } from '#hooks/useNavigate';import { useReports } from '#hooks/useReports';+import { useSidebarMenu } from '#hooks/useSidebarMenu';import type { Binding, SheetFields, SheetNames } from '#spreadsheet';import {accountBalance,@@ -50,7 +45,9 @@ type SearchableItem = {* Meant for complex items that want to display more than just static text.*/content?: ReactNode;- Icon: ComponentType<SVGProps<SVGSVGElement>>;+ Icon:+ | ComponentType<SVGProps<SVGElement>>+ | ComponentType<SVGProps<SVGSVGElement>>;};type SearchSection = {@@ -101,34 +98,17 @@ export function CommandBar() {const { modalStack } = useModalState();const { startTour } = useTour();+ const { availableItems: menuItems } = useSidebarMenu();+ const menuItemDetails = useSidebarMenuItemDetails();+const navigationItems = useMemo(() => [- { id: 'budget', name: t('Budget'), path: '/budget', Icon: SvgWallet },- {- id: 'reports-nav',- name: t('Reports'),- path: '/reports',- Icon: SvgReports,- },- {- id: 'schedules',- name: t('Schedules'),- path: '/schedules',- Icon: SvgCalendar3,- },- {- id: 'payees',- name: t('Payees'),- path: '/settings/payees',- Icon: SvgStoreFront,- },- {- id: 'rules',- name: t('Rules'),- path: '/settings/rules',- Icon: SvgTuning,- },- { id: 'tags', name: t('Tags'), path: '/settings/tags', Icon: SvgTag },+ ...menuItems.map(item => ({+ id: item.id === 'reports' ? 'reports-nav' : item.id,+ name: menuItemDetails[item.id].title,+ path: getSidebarMenuItemPath(item.id, !item.hidden),+ Icon: menuItemDetails[item.id].Icon,+ })),{ id: 'settings', name: t('Settings'), path: '/settings', Icon: SvgCog },{id: 'accounts',@@ -143,7 +123,7 @@ export function CommandBar() {Icon: SvgLibrary,},],- [t],+ [t, menuItems, menuItemDetails],);useEffect(() => {diff --git a/packages/desktop-client/src/components/FinancesApp.tsx b/packages/desktop-client/src/components/FinancesApp.tsxindex 4929f71c83..befb79d5dd 100644--- a/packages/desktop-client/src/components/FinancesApp.tsx+++ b/packages/desktop-client/src/components/FinancesApp.tsx@@ -2,7 +2,7 @@ import React, { useEffect, useEffectEvent, useRef } from 'react';import type { ReactElement } from 'react';import { ErrorBoundary } from 'react-error-boundary';import { useTranslation } from 'react-i18next';-import { Navigate, Route, Routes, useHref, useLocation } from 'react-router';+import { Route, Routes, useHref, useLocation } from 'react-router';import { useResponsive } from '@actual-app/components/hooks/useResponsive';import { theme } from '@actual-app/components/theme';@@ -47,6 +47,8 @@ import {SettingsIndex,} from './settings';import { FloatableSidebar } from './sidebar';+import { SidebarMenuRoute } from './sidebar/SidebarMenuRoute';+import { StartPageRedirect } from './StartPageRedirect';import { ManageTagsPage } from './tags/ManageTagsPage';import { Titlebar } from './Titlebar';import { Tour } from './tour/Tour';@@ -260,10 +262,7 @@ export function FinancesApp() {{isNarrowWidth && <MobilePageHeaderSlot />}<Routes>- <Route- path="/"- element={<Navigate to="/budget" replace />}- />+ <Route path="/" element={<StartPageRedirect />} /><Route path="/reports/*" element={<Reports />} />@@ -282,12 +281,14 @@ export function FinancesApp() {<Routepath="/schedules"element={- <ErrorBoundary- FallbackComponent={FeatureErrorFallback}- resetKeys={[location.pathname]}- >- <NarrowAlternate name="Schedules" />- </ErrorBoundary>+ <SidebarMenuRoute id="schedules">+ <ErrorBoundary+ FallbackComponent={FeatureErrorFallback}+ resetKeys={[location.pathname]}+ >+ <NarrowAlternate name="Schedules" />+ </ErrorBoundary>+ </SidebarMenuRoute>}/><Route@@ -343,6 +344,55 @@ export function FinancesApp() {</ErrorBoundary>}/>+ <Route+ path="/payees"+ element={+ <SidebarMenuRoute id="payees">+ <ErrorBoundary+ FallbackComponent={FeatureErrorFallback}+ resetKeys={[location.pathname]}+ >+ <NarrowAlternate name="Payees" />+ </ErrorBoundary>+ </SidebarMenuRoute>+ }+ />+ <Route+ path="/tags"+ element={+ <SidebarMenuRoute id="tags">+ <ManageTagsPage />+ </SidebarMenuRoute>+ }+ />+ <Route+ path="/rules"+ element={+ <SidebarMenuRoute id="rules">+ <ErrorBoundary+ FallbackComponent={FeatureErrorFallback}+ resetKeys={[location.pathname]}+ >+ <NarrowAlternate name="Rules" />+ </ErrorBoundary>+ </SidebarMenuRoute>+ }+ />+ <Route+ path="/bank-sync"+ element={+ <SidebarMenuRoute id="bank-sync">+ <ErrorBoundary+ FallbackComponent={FeatureErrorFallback}+ resetKeys={[location.pathname]}+ >+ <View style={{ flexShrink: 0, paddingTop: 10 }}>+ <NarrowAlternate name="BankSync" />+ </View>+ </ErrorBoundary>+ </SidebarMenuRoute>+ }+ /><Routepath="/notifications"element={<NotificationsPage />}@@ -350,38 +400,64 @@ export function FinancesApp() {<Route path="/settings" element={<Settings />}><Route index element={<SettingsIndex />} /><Route path="general" element={<GeneralSettings />} />+ <Route+ path="schedules"+ element={+ <SidebarMenuRoute id="schedules" isInSettings>+ <ErrorBoundary+ FallbackComponent={FeatureErrorFallback}+ resetKeys={[location.pathname]}+ >+ <NarrowAlternate name="Schedules" />+ </ErrorBoundary>+ </SidebarMenuRoute>+ }+ /><Routepath="payees"element={- <ErrorBoundary- FallbackComponent={FeatureErrorFallback}- resetKeys={[location.pathname]}- >- <NarrowAlternate name="Payees" />- </ErrorBoundary>+ <SidebarMenuRoute id="payees" isInSettings>+ <ErrorBoundary+ FallbackComponent={FeatureErrorFallback}+ resetKeys={[location.pathname]}+ >+ <NarrowAlternate name="Payees" />+ </ErrorBoundary>+ </SidebarMenuRoute>+ }+ />+ <Route+ path="tags"+ element={+ <SidebarMenuRoute id="tags" isInSettings>+ <ManageTagsPage />+ </SidebarMenuRoute>}/>- <Route path="tags" element={<ManageTagsPage />} /><Routepath="rules"element={- <ErrorBoundary- FallbackComponent={FeatureErrorFallback}- resetKeys={[location.pathname]}- >- <NarrowAlternate name="Rules" />- </ErrorBoundary>+ <SidebarMenuRoute id="rules" isInSettings>+ <ErrorBoundary+ FallbackComponent={FeatureErrorFallback}+ resetKeys={[location.pathname]}+ >+ <NarrowAlternate name="Rules" />+ </ErrorBoundary>+ </SidebarMenuRoute>}/><Routepath="bank-sync"element={- <ErrorBoundary- FallbackComponent={FeatureErrorFallback}- resetKeys={[location.pathname]}- >- <NarrowAlternate name="BankSync" />- </ErrorBoundary>+ <SidebarMenuRoute id="bank-sync" isInSettings>+ <ErrorBoundary+ FallbackComponent={FeatureErrorFallback}+ resetKeys={[location.pathname]}+ >+ <NarrowAlternate name="BankSync" />+ </ErrorBoundary>+ </SidebarMenuRoute>}/><Route path="advanced" element={<AdvancedSettings />} />@@ -478,10 +554,7 @@ export function FinancesApp() {/>)}{/* redirect all other traffic to the budget page */}- <Route- path="/*"- element={<Navigate to="/budget" replace />}- />+ <Route path="/*" element={<StartPageRedirect />} /></Routes></View>diff --git a/packages/desktop-client/src/components/HelpMenu.tsx b/packages/desktop-client/src/components/HelpMenu.tsxindex 1737a0911c..cf169d688c 100644--- a/packages/desktop-client/src/components/HelpMenu.tsx+++ b/packages/desktop-client/src/components/HelpMenu.tsx@@ -23,13 +23,18 @@ const getPageDocs = (page: string) => {case '/reports':return 'https://actualbudget.org/docs/reports/';case '/schedules':+ case '/settings/schedules':return 'https://actualbudget.org/docs/schedules';+ case '/payees':case '/settings/payees':return 'https://actualbudget.org/docs/transactions/payees';+ case '/rules':case '/settings/rules':return 'https://actualbudget.org/docs/budgeting/rules';+ case '/tags':case '/settings/tags':return 'https://actualbudget.org/docs/transactions/tags';+ case '/bank-sync':case '/settings/bank-sync':return 'https://actualbudget.org/docs/advanced/bank-sync';case '/settings/experimental':diff --git a/packages/desktop-client/src/components/StartPageRedirect.tsx b/packages/desktop-client/src/components/StartPageRedirect.tsxnew file mode 100644index 0000000000..799d5ae0cc--- /dev/null+++ b/packages/desktop-client/src/components/StartPageRedirect.tsx@@ -0,0 +1,12 @@+import { Navigate } from 'react-router';++import { useResponsive } from '@actual-app/components/hooks/useResponsive';++import { useSidebarMenu } from '#hooks/useSidebarMenu';++export function StartPageRedirect() {+ const { isNarrowWidth } = useResponsive();+ const { startPath } = useSidebarMenu();++ return <Navigate to={isNarrowWidth ? '/budget' : startPath} replace />;+}diff --git a/packages/desktop-client/src/components/schedules/index.tsx b/packages/desktop-client/src/components/schedules/index.tsxindex 0b640bd32e..338f49ecde 100644--- a/packages/desktop-client/src/components/schedules/index.tsx+++ b/packages/desktop-client/src/components/schedules/index.tsx@@ -11,7 +11,6 @@ import type { ScheduleEntity } from '@actual-app/core/types/models';import { Search } from '#components/common/Search';import { FeatureErrorFallback } from '#components/FeatureErrorFallback';-import { Page } from '#components/Page';import { useSchedules } from '#hooks/useSchedules';import { pushModal } from '#modals/modalsSlice';import { useDispatch } from '#redux';@@ -88,7 +87,7 @@ export function Schedules() {return (<ErrorBoundary FallbackComponent={FeatureErrorFallback}>- <Page header={t('Schedules')}>+ <><Viewstyle={{flexDirection: 'row',@@ -148,7 +147,7 @@ export function Schedules() {<Trans>Add new schedule</Trans></Button></View>- </Page>+ </></ErrorBoundary>);}diff --git a/packages/desktop-client/src/components/settings/SettingsNav.test.tsx b/packages/desktop-client/src/components/settings/SettingsNav.test.tsxindex da84c4cd5c..72cf6e8d2b 100644--- a/packages/desktop-client/src/components/settings/SettingsNav.test.tsx+++ b/packages/desktop-client/src/components/settings/SettingsNav.test.tsx@@ -4,6 +4,8 @@ import { render, screen } from '@testing-library/react';import { useIsTestEnv } from '#hooks/useIsTestEnv';import { useSyncServerStatus } from '#hooks/useSyncServerStatus';+import { createTestAppStore, TestProviders } from '#mocks';+import { mergeSyncedPrefs } from '#prefs/prefsSlice';import { SettingsNav } from './SettingsNav';@@ -14,11 +16,22 @@ vi.mock('#hooks/useIsTestEnv', () => ({useIsTestEnv: vi.fn(),}));-function renderNav(initialPath: string) {+function renderNav(initialPath: string, sidebarMenuItems?: unknown[]) {+ const store = createTestAppStore();+ if (sidebarMenuItems) {+ store.dispatch(+ mergeSyncedPrefs({+ 'sidebar-menu-items': JSON.stringify(sidebarMenuItems),+ }),+ );+ }+return render(- <MemoryRouter initialEntries={[initialPath]}>- <SettingsNav />- </MemoryRouter>,+ <TestProviders store={store}>+ <MemoryRouter initialEntries={[initialPath]}>+ <SettingsNav />+ </MemoryRouter>+ </TestProviders>,);}@@ -46,6 +59,28 @@ describe('SettingsNav', () => {]);});+ it('leaves out pages that are shown in the sidebar', () => {+ renderNav('/settings', [+ { id: 'budget', hidden: false },+ { id: 'payees', hidden: false },+ { id: 'schedules', hidden: true },+ ]);++ const hrefs = screen+ .getAllByRole('link')+ .map(link => link.getAttribute('href'));++ expect(hrefs).toEqual([+ '/settings/general',+ '/settings/schedules',+ '/settings/tags',+ '/settings/rules',+ '/settings/bank-sync',+ '/settings/advanced',+ '/settings/experimental',+ ]);+ });+it('hides bank sync without a server', () => {vi.mocked(useSyncServerStatus).mockReturnValue('no-server');diff --git a/packages/desktop-client/src/components/settings/SettingsNav.tsx b/packages/desktop-client/src/components/settings/SettingsNav.tsxindex e05271d396..6fd885e008 100644--- a/packages/desktop-client/src/components/settings/SettingsNav.tsx+++ b/packages/desktop-client/src/components/settings/SettingsNav.tsx@@ -1,30 +1,37 @@import { useTranslation } from 'react-i18next';import { useResponsive } from '@actual-app/components/hooks/useResponsive';-import {- SvgCog,- SvgLibrary,- SvgPylon,- SvgTag,- SvgTuning,- SvgUserGroup,-} from '@actual-app/components/icons/v1';+import { SvgCog, SvgPylon } from '@actual-app/components/icons/v1';import { SvgSettingsSliderAlternate } from '@actual-app/components/icons/v2';import { theme } from '@actual-app/components/theme';import { spacing } from '@actual-app/components/tokens';import { View } from '@actual-app/components/view';-import { useIsTestEnv } from '#hooks/useIsTestEnv';-import { useSyncServerStatus } from '#hooks/useSyncServerStatus';+import {+ getDefaultSidebarMenuItems,+ getSidebarMenuItemPath,+ isInMobileSettingsNav,+ isSettingsSection,+} from '#components/sidebar/sidebarMenu';+import { useSidebarMenuItemDetails } from '#components/sidebar/useSidebarMenuItemDetails';+import { useSidebarMenu } from '#hooks/useSidebarMenu';import { SettingsNavLink } from './SettingsNavLink';export function SettingsNav() {const { t } = useTranslation();const { isNarrowWidth } = useResponsive();- const syncServerStatus = useSyncServerStatus();- const isTestEnv = useIsTestEnv();- const isUsingServer = syncServerStatus !== 'no-server' || isTestEnv;+ const { settingsItems, isItemAvailable } = useSidebarMenu();+ const itemDetails = useSidebarMenuItemDetails();++ const menuItems = isNarrowWidth+ ? getDefaultSidebarMenuItems().filter(+ item =>+ isSettingsSection(item.id) &&+ isInMobileSettingsNav(item.id) &&+ isItemAvailable(item.id),+ )+ : settingsItems;return (<View@@ -46,26 +53,14 @@ export function SettingsNav() {Icon={SvgCog}to="/settings/general"/>- <SettingsNavLink- title={t('Payees')}- Icon={SvgUserGroup}- to="/settings/payees"- />- {!isNarrowWidth && (- <SettingsNavLink title={t('Tags')} Icon={SvgTag} to="/settings/tags" />- )}- <SettingsNavLink- title={t('Rules')}- Icon={SvgTuning}- to="/settings/rules"- />- {isUsingServer && (+ {menuItems.map(item => (<SettingsNavLink- title={t('Bank Sync')}- Icon={SvgLibrary}- to="/settings/bank-sync"+ key={item.id}+ title={itemDetails[item.id].title}+ Icon={itemDetails[item.id].Icon}+ to={getSidebarMenuItemPath(item.id, false)}/>- )}+ ))}<SettingsNavLinktitle={t('Advanced')}Icon={SvgSettingsSliderAlternate}diff --git a/packages/desktop-client/src/components/settings/SidebarMenuListItem.tsx b/packages/desktop-client/src/components/settings/SidebarMenuListItem.tsxnew file mode 100644index 0000000000..4b614c4b34--- /dev/null+++ b/packages/desktop-client/src/components/settings/SidebarMenuListItem.tsx@@ -0,0 +1,113 @@+import type { ComponentType, SVGProps } from 'react';+import { GridListItem } from 'react-aria-components';+import { Trans, useTranslation } from 'react-i18next';++import { Button } from '@actual-app/components/button';+import { SvgMenu } from '@actual-app/components/icons/v1';+import { Text } from '@actual-app/components/text';+import { theme } from '@actual-app/components/theme';+import { Toggle } from '@actual-app/components/toggle';+import { css } from '@emotion/css';++import { isSidebarMenuItemLocked } from '#components/sidebar/sidebarMenu';+import type {+ SidebarMenuItem,+ SidebarMenuItemId,+} from '#components/sidebar/sidebarMenu';++type SidebarMenuListItemProps = {+ item: SidebarMenuItem;+ label: string;+ Icon:+ | ComponentType<SVGProps<SVGElement>>+ | ComponentType<SVGProps<SVGSVGElement>>;+ isStartPage: boolean;+ onToggle: (id: SidebarMenuItemId, isVisible: boolean) => void;+};++export function SidebarMenuListItem({+ item,+ label,+ Icon,+ isStartPage,+ onToggle,+}: SidebarMenuListItemProps) {+ const { t } = useTranslation();++ return (+ <GridListItem+ id={item.id}+ textValue={label}+ className={css({+ display: 'flex',+ flexDirection: 'row',+ alignItems: 'center',+ gap: 10,+ padding: '8px 10px',+ marginBottom: 4,+ borderRadius: 6,+ border: '1px solid ' + theme.tableBorder,+ backgroundColor: theme.tableBackground,+ outline: 'none',+ '&[data-hovered]': {+ backgroundColor: theme.tableRowBackgroundHover,+ },+ '&[data-dragging]': {+ opacity: 0.5,+ },+ '&[data-focus-visible]': {+ boxShadow: '0 0 0 2px ' + theme.formInputBorderSelected,+ },+ })}+ >+ <Button+ slot="drag"+ variant="bare"+ aria-label={t('Reorder {{ pageName }}', { pageName: label })}+ style={{+ cursor: 'grab',+ color: theme.pageTextSubdued,+ padding: 4,+ }}+ >+ <SvgMenu width={12} height={12} />+ </Button>+ <Icon+ width={14}+ height={14}+ style={{+ flexShrink: 0,+ color: item.hidden ? theme.pageTextSubdued : theme.tableText,+ }}+ />+ <Text+ style={{+ flex: 1,+ color: item.hidden ? theme.pageTextSubdued : theme.tableText,+ }}+ >+ {label}+ </Text>+ {isStartPage && (+ <Text size="small" style={{ color: theme.pageTextSubdued }}>+ <Trans>Start page</Trans>+ </Text>+ )}+ {isSidebarMenuItemLocked(item.id) ? (+ <Text+ size="small"+ style={{ color: theme.pageTextSubdued, fontStyle: 'italic' }}+ >+ <Trans>Always shown</Trans>+ </Text>+ ) : (+ <Toggle+ id={`toggle-sidebar-item-${item.id}`}+ aria-label={label}+ isOn={!item.hidden}+ onToggle={isVisible => onToggle(item.id, isVisible)}+ />+ )}+ </GridListItem>+ );+}diff --git a/packages/desktop-client/src/components/settings/SidebarSettings.tsx b/packages/desktop-client/src/components/settings/SidebarSettings.tsxnew file mode 100644index 0000000000..0322db5c8e--- /dev/null+++ b/packages/desktop-client/src/components/settings/SidebarSettings.tsx@@ -0,0 +1,122 @@+import type { DragItem } from 'react-aria';+import { DropIndicator, GridList, useDragAndDrop } from 'react-aria-components';+import { Trans, useTranslation } from 'react-i18next';++import { Button } from '@actual-app/components/button';+import { Select } from '@actual-app/components/select';+import { theme } from '@actual-app/components/theme';+import { css } from '@emotion/css';++import {+ getDefaultSidebarMenuItems,+ moveSidebarMenuItem,+ parseSidebarStartPage,+} from '#components/sidebar/sidebarMenu';+import type { SidebarMenuItemId } from '#components/sidebar/sidebarMenu';+import { useSidebarMenuItemDetails } from '#components/sidebar/useSidebarMenuItemDetails';+import { useSidebarMenu } from '#hooks/useSidebarMenu';++import { SettingsGroup } from './SettingsGroup';+import { SettingsRow } from './SettingsRow';+import { SidebarMenuListItem } from './SidebarMenuListItem';++export function SidebarSettings() {+ const { t } = useTranslation();+ const itemDetails = useSidebarMenuItemDetails();+ const { items, availableItems, startPage, saveItems, saveStartPage } =+ useSidebarMenu();++ const onToggleItem = (id: SidebarMenuItemId, isVisible: boolean) => {+ saveItems(+ items.map(item =>+ item.id === id ? { ...item, hidden: !isVisible } : item,+ ),+ );+ };++ const onResetToDefault = () => {+ const defaultItems = getDefaultSidebarMenuItems();+ saveItems(defaultItems);+ saveStartPage(parseSidebarStartPage(undefined, defaultItems));+ };++ const { dragAndDropHooks } = useDragAndDrop({+ getItems: keys =>+ [...keys].map(key => ({ 'text/plain': String(key) }) satisfies DragItem),+ renderDropIndicator: target => (+ <DropIndicator+ target={target}+ className={css({+ '&[data-drop-target]': {+ height: 4,+ backgroundColor: theme.tableBorderSeparator,+ opacity: 1,+ borderRadius: 4,+ },+ })}+ />+ ),+ onReorder: e => {+ const [key] = e.keys;+ saveItems(+ moveSidebarMenuItem(+ items,+ String(key),+ String(e.target.key),+ e.target.dropPosition,+ ),+ );+ },+ });++ return (+ <SettingsGroup title={t('Sidebar')}>+ <SettingsRow+ title={t('Pages')}+ description={t(+ 'Choose which pages appear in the sidebar and drag them into the order you prefer. Pages you switch off can be found here in Settings.',+ )}+ control={+ <Button variant="bare" onPress={onResetToDefault}>+ <Trans>Reset to default</Trans>+ </Button>+ }+ >+ <GridList+ aria-label={t('Sidebar pages')}+ items={availableItems}+ dragAndDropHooks={dragAndDropHooks}+ dependencies={[itemDetails, startPage]}+ className={css({ display: 'flex', flexDirection: 'column' })}+ >+ {item => (+ <SidebarMenuListItem+ key={item.id}+ item={item}+ label={itemDetails[item.id].title}+ Icon={itemDetails[item.id].Icon}+ isStartPage={item.id === startPage}+ onToggle={onToggleItem}+ />+ )}+ </GridList>+ </SettingsRow>+ <SettingsRow+ title={t('Start page')}+ description={t("Actual's home page.")}+ htmlFor="settings-sidebarStartPage"+ control={+ <Select+ id="settings-sidebarStartPage"+ value={startPage}+ onChange={saveStartPage}+ options={availableItems.map(item => [+ item.id,+ itemDetails[item.id].title,+ ])}+ />+ }+ />+ </SettingsGroup>+ );+}diff --git a/packages/desktop-client/src/components/settings/index.tsx b/packages/desktop-client/src/components/settings/index.tsxindex 42dd210737..0f707465c3 100644--- a/packages/desktop-client/src/components/settings/index.tsx+++ b/packages/desktop-client/src/components/settings/index.tsx@@ -42,6 +42,7 @@ import { SettingsBackButton } from './SettingsBackButton';import { SettingsGroup } from './SettingsGroup';import { SettingsNav } from './SettingsNav';import { SettingsRow } from './SettingsRow';+import { SidebarSettings } from './SidebarSettings';import { ThemeSettings } from './Themes';function About() {@@ -267,6 +268,7 @@ export function SettingsIndex() {export function GeneralSettings() {const { t } = useTranslation();+ const { isNarrowWidth } = useResponsive();const isCurrencyExperimentalEnabled = useFeatureFlag('currency');const serverURL = useServerURL();@@ -274,6 +276,7 @@ export function GeneralSettings() {<SettingsSections title={t('General')}><About /><ThemeSettings />+ {!isNarrowWidth && <SidebarSettings />}<FormatSettings />{isCurrencyExperimentalEnabled && <CurrencySettings />}<LanguageSettings />diff --git a/packages/desktop-client/src/components/sidebar/PrimaryButtons.tsx b/packages/desktop-client/src/components/sidebar/PrimaryButtons.tsxindex 92ecb0215a..5b966a90f8 100644--- a/packages/desktop-client/src/components/sidebar/PrimaryButtons.tsx+++ b/packages/desktop-client/src/components/sidebar/PrimaryButtons.tsx@@ -1,20 +1,30 @@import React from 'react';import { useTranslation } from 'react-i18next';-import { SvgCog, SvgReports, SvgWallet } from '@actual-app/components/icons/v1';-import { SvgCalendar3 } from '@actual-app/components/icons/v2';+import { SvgCog } from '@actual-app/components/icons/v1';import { View } from '@actual-app/components/view';+import { useSidebarMenu } from '#hooks/useSidebarMenu';+import { Item } from './Item';+import { getSidebarMenuItemPath } from './sidebarMenu';+import { useSidebarMenuItemDetails } from './useSidebarMenuItemDetails';export function PrimaryButtons() {const { t } = useTranslation();+ const { sidebarItems } = useSidebarMenu();+ const itemDetails = useSidebarMenuItemDetails();return (<View data-testid="sidebar-primary-buttons" style={{ flexShrink: 0 }}>- <Item title={t('Budget')} Icon={SvgWallet} to="/budget" />- <Item title={t('Reports')} Icon={SvgReports} to="/reports" />- <Item title={t('Schedules')} Icon={SvgCalendar3} to="/schedules" />+ {sidebarItems.map(item => (+ <Item+ key={item.id}+ title={itemDetails[item.id].title}+ Icon={itemDetails[item.id].Icon}+ to={getSidebarMenuItemPath(item.id, true)}+ />+ ))}<Item title={t('Settings')} Icon={SvgCog} to="/settings" /></View>);diff --git a/packages/desktop-client/src/components/sidebar/SidebarMenuRoute.tsx b/packages/desktop-client/src/components/sidebar/SidebarMenuRoute.tsxnew file mode 100644index 0000000000..6fd1c7915d--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/SidebarMenuRoute.tsx@@ -0,0 +1,56 @@+import type { ReactNode } from 'react';+import { Navigate, useLocation } from 'react-router';++import { useResponsive } from '@actual-app/components/hooks/useResponsive';++import { Page } from '#components/Page';+import { useSidebarMenu } from '#hooks/useSidebarMenu';++import {+ getSidebarMenuItemPath,+ isSettingsSectionOnMobile,+} from './sidebarMenu';+import type { SettingsSectionId } from './sidebarMenu';+import { useSidebarMenuItemDetails } from './useSidebarMenuItemDetails';++type SidebarMenuRouteProps = {+ id: SettingsSectionId;+ isInSettings?: boolean;+ children: ReactNode;+};++export function SidebarMenuRoute({+ id,+ isInSettings = false,+ children,+}: SidebarMenuRouteProps) {+ const { isNarrowWidth } = useResponsive();+ const { sidebarItems } = useSidebarMenu();+ const itemDetails = useSidebarMenuItemDetails();+ const location = useLocation();++ const isMobilePage = isNarrowWidth && !isSettingsSectionOnMobile(id);+ const isSettingsPage = isNarrowWidth+ ? !isMobilePage+ : !sidebarItems.some(item => item.id === id);++ if (isSettingsPage !== isInSettings) {+ return (+ <Navigate+ to={{+ pathname: getSidebarMenuItemPath(id, isInSettings),+ search: location.search,+ hash: location.hash,+ }}+ state={location.state}+ replace+ />+ );+ }++ if (isInSettings || isMobilePage) {+ return children;+ }++ return <Page header={itemDetails[id].title}>{children}</Page>;+}diff --git a/packages/desktop-client/src/components/sidebar/redesign/PrimaryNav.tsx b/packages/desktop-client/src/components/sidebar/redesign/PrimaryNav.tsxindex 4a65b7cc76..422d558257 100644--- a/packages/desktop-client/src/components/sidebar/redesign/PrimaryNav.tsx+++ b/packages/desktop-client/src/components/sidebar/redesign/PrimaryNav.tsx@@ -1,14 +1,15 @@-import { useTranslation } from 'react-i18next';--import { SvgReports, SvgWallet } from '@actual-app/components/icons/v1';-import { SvgCalendar3 } from '@actual-app/components/icons/v2';import { spacing } from '@actual-app/components/tokens';import { View } from '@actual-app/components/view';+import { getSidebarMenuItemPath } from '#components/sidebar/sidebarMenu';+import { useSidebarMenuItemDetails } from '#components/sidebar/useSidebarMenuItemDetails';+import { useSidebarMenu } from '#hooks/useSidebarMenu';+import { NavRow } from './NavRow';export function PrimaryNav() {- const { t } = useTranslation();+ const { sidebarItems } = useSidebarMenu();+ const itemDetails = useSidebarMenuItemDetails();return (<View@@ -18,9 +19,14 @@ export function PrimaryNav() {padding: `${spacing.xs}px ${spacing.sm}px 0`,}}>- <NavRow title={t('Budget')} Icon={SvgWallet} to="/budget" />- <NavRow title={t('Reports')} Icon={SvgReports} to="/reports" />- <NavRow title={t('Schedules')} Icon={SvgCalendar3} to="/schedules" />+ {sidebarItems.map(item => (+ <NavRow+ key={item.id}+ title={itemDetails[item.id].title}+ Icon={itemDetails[item.id].Icon}+ to={getSidebarMenuItemPath(item.id, true)}+ />+ ))}</View>);}diff --git a/packages/desktop-client/src/components/sidebar/sidebarMenu.test.ts b/packages/desktop-client/src/components/sidebar/sidebarMenu.test.tsnew file mode 100644index 0000000000..5e7a1534e4--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/sidebarMenu.test.ts@@ -0,0 +1,161 @@+import {+ getDefaultSidebarMenuItems,+ getSidebarMenuItemPath,+ isInMobileSettingsNav,+ moveSidebarMenuItem,+ parseSidebarMenuItems,+ parseSidebarStartPage,+} from './sidebarMenu';++describe('parseSidebarMenuItems', () => {+ it('returns the defaults when nothing is saved', () => {+ expect(parseSidebarMenuItems(undefined)).toEqual([+ { id: 'budget', hidden: false },+ { id: 'reports', hidden: false },+ { id: 'schedules', hidden: false },+ { id: 'payees', hidden: true },+ { id: 'tags', hidden: true },+ { id: 'rules', hidden: true },+ { id: 'bank-sync', hidden: true },+ ]);+ });++ it('returns the defaults for a malformed value', () => {+ expect(parseSidebarMenuItems('{not json')).toEqual(+ getDefaultSidebarMenuItems(),+ );+ });++ it('keeps the saved order and visibility', () => {+ const saved = [+ { id: 'payees', hidden: false },+ { id: 'budget', hidden: false },+ { id: 'reports', hidden: false },+ { id: 'schedules', hidden: true },+ { id: 'tags', hidden: true },+ { id: 'rules', hidden: false },+ { id: 'bank-sync', hidden: true },+ ];++ expect(parseSidebarMenuItems(JSON.stringify(saved))).toEqual(saved);+ });++ it('drops unknown and duplicate entries', () => {+ const items = parseSidebarMenuItems(+ JSON.stringify([+ { id: 'reports', hidden: false },+ { id: 'unknown', hidden: false },+ { id: 'reports', hidden: true },+ null,+ ]),+ );++ expect(items.filter(item => item.id === 'reports')).toEqual([+ { id: 'reports', hidden: false },+ ]);+ expect(items).toHaveLength(7);+ });++ it('inserts missing pages at their default position', () => {+ const items = parseSidebarMenuItems(+ JSON.stringify([+ { id: 'schedules', hidden: false },+ { id: 'budget', hidden: false },+ ]),+ );++ expect(items.map(item => item.id)).toEqual([+ 'reports',+ 'schedules',+ 'budget',+ 'payees',+ 'tags',+ 'rules',+ 'bank-sync',+ ]);+ expect(items.find(item => item.id === 'reports')?.hidden).toBe(false);+ expect(items.find(item => item.id === 'payees')?.hidden).toBe(true);+ });++ it('always keeps budget and reports in the sidebar', () => {+ const items = parseSidebarMenuItems(+ JSON.stringify(+ getDefaultSidebarMenuItems().map(item => ({ ...item, hidden: true })),+ ),+ );++ expect(items.filter(item => !item.hidden)).toEqual([+ { id: 'budget', hidden: false },+ { id: 'reports', hidden: false },+ ]);+ });+});++describe('parseSidebarStartPage', () => {+ const items = parseSidebarMenuItems(+ JSON.stringify([+ { id: 'reports', hidden: false },+ { id: 'budget', hidden: false },+ { id: 'schedules', hidden: true },+ ]),+ );++ it('returns the saved page whether or not it is in the sidebar', () => {+ expect(parseSidebarStartPage('budget', items)).toBe('budget');+ expect(parseSidebarStartPage('schedules', items)).toBe('schedules');+ });++ it('falls back to the first page', () => {+ expect(parseSidebarStartPage(undefined, items)).toBe('reports');+ expect(parseSidebarStartPage('unknown', items)).toBe('reports');+ });+});++describe('moveSidebarMenuItem', () => {+ const items = getDefaultSidebarMenuItems().slice(0, 3);++ it('moves a page before the target', () => {+ expect(+ moveSidebarMenuItem(items, 'schedules', 'budget', 'before').map(+ item => item.id,+ ),+ ).toEqual(['schedules', 'budget', 'reports']);+ });++ it('moves a page after the target', () => {+ expect(+ moveSidebarMenuItem(items, 'budget', 'schedules', 'after').map(+ item => item.id,+ ),+ ).toEqual(['reports', 'schedules', 'budget']);+ });++ it('leaves the order alone for an unknown target', () => {+ expect(moveSidebarMenuItem(items, 'budget', 'unknown', 'after')).toBe(+ items,+ );+ });+});++describe('isInMobileSettingsNav', () => {+ it('leaves schedules and tags out of the mobile settings menu', () => {+ expect(isInMobileSettingsNav('schedules')).toBe(false);+ expect(isInMobileSettingsNav('tags')).toBe(false);+ expect(isInMobileSettingsNav('payees')).toBe(true);+ expect(isInMobileSettingsNav('bank-sync')).toBe(true);+ });+});++describe('getSidebarMenuItemPath', () => {+ it('uses a top-level path for pages in the sidebar', () => {+ expect(getSidebarMenuItemPath('payees', true)).toBe('/payees');+ expect(getSidebarMenuItemPath('budget', true)).toBe('/budget');+ });++ it('keeps settings sections under /settings when they are not in the sidebar', () => {+ expect(getSidebarMenuItemPath('payees', false)).toBe('/settings/payees');+ expect(getSidebarMenuItemPath('schedules', false)).toBe(+ '/settings/schedules',+ );+ });+});diff --git a/packages/desktop-client/src/components/sidebar/sidebarMenu.ts b/packages/desktop-client/src/components/sidebar/sidebarMenu.tsnew file mode 100644index 0000000000..11a0c1ee43--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/sidebarMenu.ts@@ -0,0 +1,143 @@+export const SIDEBAR_MENU_ITEM_IDS = [+ 'budget',+ 'reports',+ 'schedules',+ 'payees',+ 'tags',+ 'rules',+ 'bank-sync',+] as const;++export type SidebarMenuItemId = (typeof SIDEBAR_MENU_ITEM_IDS)[number];++export type SidebarMenuItem = {+ id: SidebarMenuItemId;+ hidden: boolean;+};++const SETTINGS_SECTION_IDS = [+ 'schedules',+ 'payees',+ 'tags',+ 'rules',+ 'bank-sync',+] as const;++export type SettingsSectionId = (typeof SETTINGS_SECTION_IDS)[number];++export function isSettingsSection(+ id: SidebarMenuItemId,+): id is SettingsSectionId {+ return SETTINGS_SECTION_IDS.some(sectionId => sectionId === id);+}++export function isSidebarMenuItemLocked(id: SidebarMenuItemId): boolean {+ return !isSettingsSection(id);+}++export function isSettingsSectionOnMobile(id: SettingsSectionId): boolean {+ return id !== 'schedules';+}++export function isInMobileSettingsNav(id: SettingsSectionId): boolean {+ return isSettingsSectionOnMobile(id) && id !== 'tags';+}++function isHiddenByDefault(id: SidebarMenuItemId): boolean {+ return isSettingsSection(id) && id !== 'schedules';+}++function isKnownItemId(id: unknown): id is SidebarMenuItemId {+ return SIDEBAR_MENU_ITEM_IDS.some(itemId => itemId === id);+}++export function getDefaultSidebarMenuItems(): SidebarMenuItem[] {+ return SIDEBAR_MENU_ITEM_IDS.map(id => ({+ id,+ hidden: isHiddenByDefault(id),+ }));+}++export function getSidebarMenuItemPath(+ id: SidebarMenuItemId,+ isInSidebar: boolean,+): string {+ return isSettingsSection(id) && !isInSidebar ? `/settings/${id}` : `/${id}`;+}++export function parseSidebarMenuItems(+ raw: string | undefined,+): SidebarMenuItem[] {+ let saved: SidebarMenuItem[] = [];++ if (raw) {+ try {+ const parsed: unknown = JSON.parse(raw);+ if (Array.isArray(parsed)) {+ for (const entry of parsed) {+ if (+ entry &&+ typeof entry === 'object' &&+ 'id' in entry &&+ isKnownItemId(entry.id) &&+ !saved.some(item => item.id === entry.id)+ ) {+ saved.push({+ id: entry.id,+ hidden:+ 'hidden' in entry &&+ entry.hidden === true &&+ !isSidebarMenuItemLocked(entry.id),+ });+ }+ }+ }+ } catch {+ saved = [];+ }+ }++ for (const [defaultIdx, item] of getDefaultSidebarMenuItems().entries()) {+ if (saved.some(savedItem => savedItem.id === item.id)) {+ continue;+ }+ const insertAt = saved.findIndex(+ savedItem => SIDEBAR_MENU_ITEM_IDS.indexOf(savedItem.id) > defaultIdx,+ );+ if (insertAt === -1) {+ saved.push(item);+ } else {+ saved.splice(insertAt, 0, item);+ }+ }++ return saved;+}++export function parseSidebarStartPage(+ raw: string | undefined,+ items: SidebarMenuItem[],+): SidebarMenuItemId {+ return (items.find(item => item.id === raw) ?? items[0]).id;+}++export function moveSidebarMenuItem(+ items: SidebarMenuItem[],+ movedId: string,+ targetId: string,+ dropPosition: 'before' | 'after' | 'on',+): SidebarMenuItem[] {+ const moved = items.find(item => item.id === movedId);+ if (!moved || movedId === targetId) {+ return items;+ }++ const remaining = items.filter(item => item.id !== movedId);+ const targetIdx = remaining.findIndex(item => item.id === targetId);+ if (targetIdx === -1) {+ return items;+ }++ const insertAt = dropPosition === 'after' ? targetIdx + 1 : targetIdx;+ return [...remaining.slice(0, insertAt), moved, ...remaining.slice(insertAt)];+}diff --git a/packages/desktop-client/src/components/sidebar/useSidebarMenuItemDetails.ts b/packages/desktop-client/src/components/sidebar/useSidebarMenuItemDetails.tsnew file mode 100644index 0000000000..2e822dc06d--- /dev/null+++ b/packages/desktop-client/src/components/sidebar/useSidebarMenuItemDetails.ts@@ -0,0 +1,38 @@+import type { ComponentType, SVGProps } from 'react';+import { useTranslation } from 'react-i18next';++import {+ SvgLibrary,+ SvgReports,+ SvgTag,+ SvgTuning,+ SvgUserGroup,+ SvgWallet,+} from '@actual-app/components/icons/v1';+import { SvgCalendar3 } from '@actual-app/components/icons/v2';++import type { SidebarMenuItemId } from './sidebarMenu';++type SidebarMenuItemDetails = {+ title: string;+ Icon:+ | ComponentType<SVGProps<SVGElement>>+ | ComponentType<SVGProps<SVGSVGElement>>;+};++export function useSidebarMenuItemDetails(): Record<+ SidebarMenuItemId,+ SidebarMenuItemDetails+> {+ const { t } = useTranslation();++ return {+ budget: { title: t('Budget'), Icon: SvgWallet },+ reports: { title: t('Reports'), Icon: SvgReports },+ schedules: { title: t('Schedules'), Icon: SvgCalendar3 },+ payees: { title: t('Payees'), Icon: SvgUserGroup },+ tags: { title: t('Tags'), Icon: SvgTag },+ rules: { title: t('Rules'), Icon: SvgTuning },+ 'bank-sync': { title: t('Bank Sync'), Icon: SvgLibrary },+ };+}diff --git a/packages/desktop-client/src/components/tour/steps.tsx b/packages/desktop-client/src/components/tour/steps.tsxindex aef5453e35..98688d1504 100644--- a/packages/desktop-client/src/components/tour/steps.tsx+++ b/packages/desktop-client/src/components/tour/steps.tsx@@ -190,9 +190,10 @@ function getBudgetTourSteps({ navigate, budgetType }: TourStepDeps): Step[] {title: <Trans>Getting Around</Trans>,content: (<Trans>- The sidebar takes you to your budget, reports, and scheduled- transactions. You can find payees, rules, and tags under{' '}- <strong>Settings</strong>.+ Commonly used pages live in the sidebar, like your budget, reports,+ and scheduled transactions. Other less common ones are in{' '}+ <strong>Settings</strong>, such as the payees, rules and tags pages.+ You can also change these defaults in <strong>Settings</strong>.</Trans>),},diff --git a/packages/desktop-client/src/hooks/useSidebarMenu.ts b/packages/desktop-client/src/hooks/useSidebarMenu.tsnew file mode 100644index 0000000000..51b9bb5ca2--- /dev/null+++ b/packages/desktop-client/src/hooks/useSidebarMenu.ts@@ -0,0 +1,64 @@+import type { SyncedPrefs } from '@actual-app/core/types/prefs';++import {+ getSidebarMenuItemPath,+ parseSidebarMenuItems,+ parseSidebarStartPage,+} from '#components/sidebar/sidebarMenu';+import type {+ SidebarMenuItem,+ SidebarMenuItemId,+} from '#components/sidebar/sidebarMenu';+import { useIsTestEnv } from '#hooks/useIsTestEnv';+import { useSyncedPref } from '#hooks/useSyncedPref';+import { useSyncServerStatus } from '#hooks/useSyncServerStatus';+import { mergeSyncedPrefs, saveSyncedPrefs } from '#prefs/prefsSlice';+import { useDispatch } from '#redux';++export function useSidebarMenu() {+ const dispatch = useDispatch();+ const [itemsPref] = useSyncedPref('sidebar-menu-items');+ const [startPagePref] = useSyncedPref('sidebar-start-page');+ const syncServerStatus = useSyncServerStatus();+ const isTestEnv = useIsTestEnv();+ const isUsingServer = syncServerStatus !== 'no-server' || isTestEnv;++ const isItemAvailable = (id: SidebarMenuItemId) =>+ id !== 'bank-sync' || isUsingServer;++ const items = parseSidebarMenuItems(itemsPref);+ const availableItems = items.filter(item => isItemAvailable(item.id));+ const sidebarItems = availableItems.filter(item => !item.hidden);+ const settingsItems = availableItems.filter(item => item.hidden);++ const startPage = parseSidebarStartPage(startPagePref, availableItems);+ const startPath = getSidebarMenuItemPath(+ startPage,+ sidebarItems.some(item => item.id === startPage),+ );++ const savePrefs = (prefs: Partial<SyncedPrefs>) => {+ dispatch(mergeSyncedPrefs(prefs));+ void dispatch(saveSyncedPrefs({ prefs }));+ };++ const saveItems = (newItems: SidebarMenuItem[]) => {+ savePrefs({ 'sidebar-menu-items': JSON.stringify(newItems) });+ };++ const saveStartPage = (newStartPage: SidebarMenuItemId) => {+ savePrefs({ 'sidebar-start-page': newStartPage });+ };++ return {+ items,+ availableItems,+ sidebarItems,+ settingsItems,+ startPage,+ startPath,+ isItemAvailable,+ saveItems,+ saveStartPage,+ };+}diff --git a/packages/docs/docs/settings/index.md b/packages/docs/docs/settings/index.mdindex 6578bec3ff..b2e20a63fc 100644--- a/packages/docs/docs/settings/index.md+++ b/packages/docs/docs/settings/index.md@@ -2,20 +2,24 @@The Settings screen in Actual provides you with a number of options for managing the look and feel of your budget along with some more system specific settings. Most settings are self-explanatory.-You can access the Settings screen by clicking the down arrow by your budget name or going to the sidebar and clicking **Settings**.--There is an option to "Display a notification when updates are available" here.+You can access the Settings screen by clicking the down arrow by your budget name or by clicking **Settings** at the bottom of the sidebar. Settings are split into pages that you switch between using the navigation on the left of the Settings screen.### Notifications+The option **Display a notification when updates are available** shows a notice in the app when a new version of Actual is released.+The option **Show in-app notifications (release notes and announcements)** controls whether Actual shows you news from the project inside the app: the notification bell in the top bar, the Notifications page, and the message that appears after an update. It is on by default and applies to the device you change it on. See [Notifications](../notifications.md) for the full guide.### ThemesThemes change the user interface colors. Pick from the built-in **Light**, **Dark**, **Midnight**, or **Auto** themes, or install a community-built theme from the catalog. See [Custom Themes](../custom-themes.md) for the full guide.+### Sidebar++By default the sidebar shows **Budget**, **Reports** and **Schedules**. The **Sidebar** section lets you choose which pages appear there, drag them into order, and pick the **Start page**, the page Actual shows when it opens or when you go to its home page. Pages that are switched off, such as Payees, Rules and Tags, are listed in the Settings navigation instead. These settings are stored in your budget file, so they apply on every device that opens it. The mobile layout does not use these settings yet, but support for it is planned.+### FormattingThe formatting options allow you to select the following:diff --git a/packages/docs/docs/tour/user-interface.md b/packages/docs/docs/tour/user-interface.mdindex e56cf6c53e..5d406862b2 100644--- a/packages/docs/docs/tour/user-interface.md+++ b/packages/docs/docs/tour/user-interface.md@@ -22,12 +22,12 @@ Standard on most screens:## The Sidebar-From the sidebar, you have easy access to all Actual functions.+The sidebar is how you move between the main parts of Actual.<img width="261" alt="The sidebar with the navigation links, Settings and the accounts list labeled" src="/img/a-tour-of-actual/[email protected]" />-- **A. Navigation.** Access to your Budget, Reports and Schedules.-- **B. Settings.** Less used functions, like managing Payees and Rules, are found under _Settings_. This is also where you find the software settings.-- **C. Accounts.** The sidebar also holds all of your accounts, both on budget and off budget; these will display in a list under their respective heading.+- **A. Navigation.** The menu at the top links to your Budget, Reports and Schedules. Less used pages, like Payees, Rules and Tags, are in Settings. The [Sidebar](../settings/index.md#sidebar) section of the settings lets you choose which pages appear in the menu.+- **B. Settings.** Settings is at the bottom of the menu.+- **C. Accounts.** Below the menu are all of your accounts, both on budget and off budget, listed under their respective heading.-Most of these will we cover later in the tour.+Most of these we will cover later in the tour.diff --git a/packages/loot-core/src/types/prefs.ts b/packages/loot-core/src/types/prefs.tsindex 7e6ff34368..040bd68435 100644--- a/packages/loot-core/src/types/prefs.ts+++ b/packages/loot-core/src/types/prefs.ts@@ -42,6 +42,8 @@ export type SyncedPrefs = Partial<| 'transaction-table-columns'| `transaction-table-columns-${string}`| `show-group-${string}`+ | 'sidebar-menu-items'+ | 'sidebar-start-page'| 'sync-transfer-date'// Number of minutes between automatic bank syncs. '0' (or unset) disables// automatic syncing.diff --git a/upcoming-release-notes/customize-sidebar-menu.md b/upcoming-release-notes/customize-sidebar-menu.mdnew file mode 100644index 0000000000..e90d9f7192--- /dev/null+++ b/upcoming-release-notes/customize-sidebar-menu.md@@ -0,0 +1,6 @@+---+category: Features+authors: [matt-fidd]+---++Add a setting to choose which pages appear in the sidebar, their order and the page Actual opens on