The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
feat(managed): an install's own admin tabs on the phone too
Mauricee5a119b6bd0d
diff --git a/client/src/managed/index.tsx b/client/src/managed/index.tsxindex dbe5a90c5..7899781ff 100644--- a/client/src/managed/index.tsx+++ b/client/src/managed/index.tsx@@ -78,6 +78,12 @@ export interface ManagedAdminTab {group?: 'users' | 'config' | 'integration' | 'maintenance'/** Rendered in the tab body. /admin already requires an admin to get here. */element: ReactElement+ /**+ * The same tab laid out for a phone, in the mobile admin's section picker.+ * Without it the phone shows `element`, which then has to hold up on a narrow+ * screen by itself.+ */+ mobileElement?: ReactElement}/** Extra protected routes. Spread into the router next to the built-in ones. */diff --git a/client/src/mobile/screens/admin/MAdmin.tsx b/client/src/mobile/screens/admin/MAdmin.tsxindex 309a1a7b2..4c29ccc7b 100644--- a/client/src/mobile/screens/admin/MAdmin.tsx+++ b/client/src/mobile/screens/admin/MAdmin.tsx@@ -44,6 +44,7 @@ import MAdminSheets from './MAdminSheets'import MAdminStoragePanel from './MAdminStoragePanel'import MAdminUsersSection from './MAdminUsersSection'import { MAdminButton } from './MAdminUi'+import { managedAdminTabs } from '../../../managed'// Stat card of the 2×2 grid (design §6.3): 34px icon tile, 19px/800 number,// small tracking label. Count-up animation matches the desktop stat cards.@@ -98,6 +99,8 @@ export default function MAdmin() {...(managed ? [] : [{ id: 'backup', label: t('admin.tabs.backup'), icon: Database }]),{ id: 'audit', label: t('admin.tabs.audit'), icon: ScrollText },...(devMode ? [{ id: 'dev-notifications', label: 'Dev: Notifications', icon: Bug }] : []),+ // The install's own tabs (managed/index.tsx), after the built-in ones as on the desktop.+ ...managedAdminTabs.map(tab => ({ id: tab.id, label: tab.label, icon: tab.Icon })),]const activeSection = sections.find((s) => s.id === activeTab) ?? sections[0]@@ -227,6 +230,9 @@ export default function MAdmin() {{activeTab === 'backup' && <MAdminBackupPanel />}{activeTab === 'audit' && <MAdminAuditLogPanel serverTimezone={serverTimezone} />}{activeTab === 'dev-notifications' && <MAdminDevNotificationsPanel />}+ {managedAdminTabs.map(tab =>+ activeTab === tab.id ? <div key={tab.id}>{tab.mobileElement ?? tab.element}</div> : null,+ )}<MAdminSheets admin={admin} t={t} /></div>diff --git a/client/tests/unit/mobile/admin/MAdmin.managed.test.tsx b/client/tests/unit/mobile/admin/MAdmin.managed.test.tsxnew file mode 100644index 000000000..f14c681a9--- /dev/null+++ b/client/tests/unit/mobile/admin/MAdmin.managed.test.tsx@@ -0,0 +1,79 @@+import { CreditCard, LifeBuoy } from 'lucide-react';+import { http, HttpResponse } from 'msw';+import { Route, Routes } from 'react-router';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import MAdmin from '../../../../src/mobile/screens/admin/MAdmin';+import { useAuthStore } from '../../../../src/store/authStore';+import { buildAdmin } from '../../../helpers/factories';+import { server } from '../../../helpers/msw/server';+import { fireEvent, render, screen, waitFor } from '../../../helpers/render';+import { resetAllStores, seedStore } from '../../../helpers/store';++// An install that fills the admin-tab attachment point (managed/index.tsx): one tab+// with a phone layout of its own, one without.+vi.mock('../../../../src/managed', () => ({+ managedRoutes: [],+ managedNavItems: [],+ visibleManagedNavItems: () => [],+ managedAdminTabs: [+ {+ id: 'subscription',+ label: 'Subscription',+ Icon: CreditCard,+ group: 'maintenance',+ element: <div data-testid="desktop-subscription" />,+ mobileElement: <div data-testid="phone-subscription" />,+ },+ {+ id: 'support',+ label: 'Help and support',+ Icon: LifeBuoy,+ group: 'maintenance',+ element: <div data-testid="desktop-support" />,+ },+ ],+}));++function renderAdmin() {+ return render(+ <Routes>+ <Route path="/admin" element={<MAdmin />} />+ </Routes>,+ { initialEntries: ['/admin'] }+ );+}++beforeEach(() => {+ resetAllStores();+ seedStore(useAuthStore, { isAuthenticated: true, user: buildAdmin() });+ server.use(+ http.get('/api/admin/collab-features', () =>+ HttpResponse.json({ chat: true, notes: true, polls: true, whatsnext: true })+ ),+ http.get('/api/admin/places-photos', () => HttpResponse.json({ enabled: false })),+ http.get('/api/admin/places-autocomplete', () => HttpResponse.json({ enabled: false })),+ http.get('/api/admin/places-details', () => HttpResponse.json({ enabled: false })),+ http.get('/api/admin/invites/trips', () => HttpResponse.json({ trips: [] }))+ );+});++afterEach(() => {+ server.resetHandlers();+});++describe('MAdmin with an install’s own tabs', () => {+ it('FE-MOB-ADMIN-MANAGED-001: lists them in the section picker and shows their phone layout', async () => {+ renderAdmin();+ fireEvent.click(screen.getByRole('button', { name: 'Administration' }));+ fireEvent.click(screen.getByRole('button', { name: 'Subscription' }));+ await waitFor(() => expect(screen.getByTestId('phone-subscription')).toBeInTheDocument());+ expect(screen.queryByTestId('desktop-subscription')).not.toBeInTheDocument();+ });++ it('FE-MOB-ADMIN-MANAGED-002: a tab without a phone layout shows its desktop element', async () => {+ renderAdmin();+ fireEvent.click(screen.getByRole('button', { name: 'Administration' }));+ fireEvent.click(screen.getByRole('button', { name: 'Help and support' }));+ await waitFor(() => expect(screen.getByTestId('desktop-support')).toBeInTheDocument());+ });+});