diff --git a/client/e2e/tour-type-popover.spec.ts b/client/e2e/tour-type-popover.spec.ts index e8a16e6de..0fb8318fc 100644 --- a/client/e2e/tour-type-popover.spec.ts +++ b/client/e2e/tour-type-popover.spec.ts @@ -162,6 +162,10 @@ test('the saved hike difficulty dropdown fits above the field and keeps alpine c const difficulty = page.getByRole('button', { name: 'Maximum trail difficulty', exact: true }); const difficultyMenu = page.getByRole('group', { name: 'Maximum trail difficulty', exact: true }); await difficulty.scrollIntoViewIfNeeded(); + await difficulty.evaluate((button) => { + const rail = button.closest('[data-testid="tour-planner-editor-scroll"]'); + if (rail) rail.scrollTop += button.getBoundingClientRect().bottom - rail.getBoundingClientRect().bottom + 12; + }); await difficulty.click(); await expectInside(difficultyMenu, scrollArea); await expect(difficultyMenu).toHaveCSS('transform-origin', /px [1-9][0-9.]*px$/); diff --git a/client/scripts/size-baseline.json b/client/scripts/size-baseline.json index 1aca4c016..d8d3b4ad5 100644 --- a/client/scripts/size-baseline.json +++ b/client/scripts/size-baseline.json @@ -4,22 +4,22 @@ "src/components/Admin/AdminPluginsPanel.test.tsx": 2704, "src/components/Admin/AdminPluginsPanel.tsx": 1265, "src/components/Budget/CostsPanel.test.tsx": 2725, - "src/components/Budget/CostsPanel.tsx": 1588, + "src/components/Budget/CostsPanel.tsx": 1587, "src/components/Map/MapView.tsx": 1170, "src/components/Map/MapViewGL.test.tsx": 2919, "src/components/Map/MapViewGL.tsx": 2083, "src/components/Planner/DayDetailPanel.test.tsx": 2331, "src/components/Planner/DayPlanSidebar.test.tsx": 5349, - "src/components/Planner/DayPlanSidebar.tsx": 2908, + "src/components/Planner/DayPlanSidebar.tsx": 2895, "src/components/Planner/PlaceFormModal.test.tsx": 2836, - "src/components/Planner/PlaceInspector.tsx": 1030, + "src/components/Planner/PlaceInspector.tsx": 1014, "src/components/Studio/TravelElements.tsx": 1332, "src/components/Studio/countryShapes.ts": 2595, "src/index.css": 1636, "src/mobile/screens/admin/MAdminPluginsPanel.tsx": 1503, "src/pages/JourneyDetailPage.test.tsx": 3880, "src/pages/LoginPage.tsx": 1273, - "src/pages/TripPlannerPage.tsx": 1127, + "src/pages/TripPlannerPage.tsx": 1122, "src/pages/tripPlanner/useTripPlanner.roadtrip.test.tsx": 3518, "src/pages/tripPlanner/useTripPlanner.test.tsx": 3267, "src/styles/studio.css": 1918 diff --git a/client/scripts/theme-baseline.json b/client/scripts/theme-baseline.json index ceb3ecc84..0c6016b57 100644 --- a/client/scripts/theme-baseline.json +++ b/client/scripts/theme-baseline.json @@ -6,7 +6,7 @@ "components/BackgroundTasks/BackgroundTasksWidget.tsx": 4, "components/Budget/BudgetPanel.helpers.ts": 2, "components/Budget/BudgetPanelMemberChips.tsx": 4, - "components/Budget/CostsPanel.tsx": 37, + "components/Budget/CostsPanel.tsx": 33, "components/Budget/ReceiptPreviewModal.tsx": 6, "components/Budget/ReceiptScanModal.tsx": 2, "components/Budget/costsCategories.tsx": 14, @@ -51,7 +51,7 @@ "components/Layout/BottomNav.tsx": 3, "components/Layout/InAppNotificationBell.tsx": 3, "components/Layout/MobileTopBar.tsx": 51, - "components/Layout/Navbar.tsx": 21, + "components/Layout/Navbar.tsx": 17, "components/Layout/NewVersionNotice.tsx": 3, "components/Layout/OfflineBanner.tsx": 2, "components/Layout/PageSidebar.tsx": 3, @@ -70,13 +70,10 @@ "components/Map/ratingBadge.ts": 2, "components/Map/reservationsMapbox.ts": 1, "components/Map/switcherRow.ts": 1, - "components/Packing/PackingListPanelBagModal.tsx": 2, "components/Packing/PackingListPanelCategoryGroup.tsx": 5, "components/Packing/PackingListPanelHeader.tsx": 3, "components/Packing/packingPrintDocument.ts": 24, - "components/Planner/AirTrailImportModal.tsx": 4, - "components/Planner/BookingCostsSection.tsx": 1, - "components/Planner/BookingImportModal.tsx": 4, + "components/Planner/AirTrailImportModal.tsx": 2, "components/Planner/DayDetailPanel.tsx": 1, "components/Planner/PlaceInspector.tsx": 1, "components/Planner/PlacesSidebarMobileDayPicker.tsx": 3, @@ -100,7 +97,7 @@ "components/Studio/printSheets.ts": 5, "components/Studio/sidebar/contentDrops.ts": 2, "components/SystemNotices/SystemNoticeBanner.tsx": 28, - "components/SystemNotices/SystemNoticeModal.tsx": 107, + "components/SystemNotices/SystemNoticeModal.tsx": 45, "components/Todo/TodoListPanel.tsx": 6, "components/Todo/todoListModel.ts": 3, "components/Trips/TripFormModal.tsx": 6, @@ -112,13 +109,11 @@ "components/Vacay/VacaySharedCalendars.tsx": 6, "components/Vacay/VacayStats.tsx": 14, "components/Weather/WeatherWidget.tsx": 4, - "components/shared/ConfirmDialog.tsx": 8, + "components/shared/ConfirmDialog.tsx": 7, "components/shared/ContextMenu.tsx": 1, - "components/shared/CopyTripDialog.tsx": 12, "components/shared/CustomDateTimePicker.tsx": 1, "components/shared/CustomSelect.tsx": 1, "components/shared/CustomTimePicker.tsx": 1, - "components/shared/EmptyState.tsx": 1, "components/shared/Modal.tsx": 3, "components/shared/NavigationMenu.tsx": 1, "components/shared/NoteColorPicker.tsx": 2, diff --git a/client/src/components/Budget/CostsPanel.tsx b/client/src/components/Budget/CostsPanel.tsx index 32a074dc0..3f82c57be 100644 --- a/client/src/components/Budget/CostsPanel.tsx +++ b/client/src/components/Budget/CostsPanel.tsx @@ -7,7 +7,6 @@ import { useTranslation } from '../../i18n' import { splitShareLabel } from './expenseFx' import { useIsMobile } from '../../hooks/useIsMobile' import { formatMoney, amountToInputString, currencyDecimals, currencyLocale, localizeAmountInput, zeroAmountInput } from '../../utils/formatters' -import { openFile } from '../../utils/fileDownload' import CustomSelect from '../shared/CustomSelect' import { CustomDatePicker } from '../shared/CustomDateTimePicker' import { useReceiptScan } from './useReceiptScan' diff --git a/client/src/components/Collab/CollabLinks.test.tsx b/client/src/components/Collab/CollabLinks.test.tsx index 1a17fe2e4..8657547d8 100644 --- a/client/src/components/Collab/CollabLinks.test.tsx +++ b/client/src/components/Collab/CollabLinks.test.tsx @@ -55,7 +55,7 @@ describe('CollabLinks', () => { render(); const heading = await screen.findByRole('heading', { level: 3 }); expect(heading).toHaveTextContent(/links/i); - expect(heading).toHaveClass('uppercase'); + expect(heading).toHaveClass('font-semibold'); expect(screen.getByRole('button', { name: /add link|collab\.links\.add/i })).toBeInTheDocument(); }); diff --git a/client/src/components/Collab/CollabPanelHead.test.tsx b/client/src/components/Collab/CollabPanelHead.test.tsx index a38fe830a..e088e9c3a 100644 --- a/client/src/components/Collab/CollabPanelHead.test.tsx +++ b/client/src/components/Collab/CollabPanelHead.test.tsx @@ -16,7 +16,7 @@ describe('CollabPanelHead', () => { const { rerender } = render(); expect(screen.queryByText('0')).toBeNull(); rerender(); - expect(screen.getByRole('heading', { name: 'Notes' }).parentElement?.querySelectorAll('span')).toHaveLength(0); + expect(screen.getByRole('heading', { name: 'Notes' }).parentElement?.querySelectorAll('span.rounded-full')).toHaveLength(0); }); it('FE-COLLAB-PANELHEAD-003: its actions sit on the right and work', async () => { diff --git a/client/src/components/Files/FileManager.test.tsx b/client/src/components/Files/FileManager.test.tsx index 217e0faee..5776d4c22 100644 --- a/client/src/components/Files/FileManager.test.tsx +++ b/client/src/components/Files/FileManager.test.tsx @@ -530,7 +530,7 @@ describe('FileManager', () => { const onUpload = vi.fn().mockResolvedValue({ file: { id: 56 } }); render(); - const zone = document.querySelector('[role="presentation"]') as HTMLElement; + const zone = screen.getByRole('button', { name: 'Upload' }); const file = new File(['data'], 'pasted.png', { type: 'image/png' }); const pasteEvent = new Event('paste', { bubbles: true, cancelable: true }); Object.defineProperty(pasteEvent, 'clipboardData', { diff --git a/client/src/components/Layout/Navbar.test.tsx b/client/src/components/Layout/Navbar.test.tsx index 083f1bbc6..7a7e5a904 100644 --- a/client/src/components/Layout/Navbar.test.tsx +++ b/client/src/components/Layout/Navbar.test.tsx @@ -474,7 +474,7 @@ describe('Navbar styling and menu details', () => { expect(back.style.background).toBe('transparent'); - const theme = document.querySelector('button[title]:not([data-help-button])') as HTMLElement; + const theme = screen.getByTitle(/dark mode/i); fireEvent.mouseEnter(theme); expect(theme.style.background).toBe('var(--bg-hover)'); fireEvent.mouseLeave(theme); @@ -536,10 +536,7 @@ describe('Navbar styling and menu details', () => { for (const name of [/^Settings$/, /^Help$/, /^Admin$/]) { const link = screen.getByRole('link', { name }); - fireEvent.mouseEnter(link); - expect(link.style.background).toBe('var(--bg-hover)'); - fireEvent.mouseLeave(link); - expect(link.style.background).toBe('transparent'); + expect(link).toHaveClass('hover:bg-surface-hover'); } const discord = screen.getByTitle('Discord'); diff --git a/client/src/components/Layout/Navbar.tsx b/client/src/components/Layout/Navbar.tsx index 09be3ba91..f6104a79e 100644 --- a/client/src/components/Layout/Navbar.tsx +++ b/client/src/components/Layout/Navbar.tsx @@ -6,7 +6,7 @@ import { useSettingsStore } from '../../store/settingsStore' import { useAddonStore } from '../../store/addonStore' import { usePluginStore } from '../../store/pluginStore' import { useTranslation } from '../../i18n' -import { Plane, LogOut, Settings, ChevronDown, Shield, ArrowLeft, ChevronLeft, Moon, Sun, Monitor, CalendarDays, Briefcase, Globe, Compass, BookOpen, Bookmark, Inbox } from 'lucide-react' +import { LogOut, Settings, ChevronDown, Shield, ArrowLeft, ChevronLeft, Moon, Sun, CalendarDays, Briefcase, Globe, Compass, BookOpen, Bookmark, Inbox } from 'lucide-react' import type { LucideIcon } from 'lucide-react' import InAppNotificationBell from './InAppNotificationBell.tsx' import HelpButton from '../Help/HelpButton' @@ -47,7 +47,7 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings const { user, logout, isPrerelease, appVersion, managed } = useAuthStore() const { settings, updateSetting } = useSettingsStore() const { addons: allAddons, loadAddons } = useAddonStore() - const { t, locale } = useTranslation() + const { t } = useTranslation() const navigate = useNavigate() const location = useLocation() const [userMenuOpen, setUserMenuOpen] = useState(false) diff --git a/client/src/components/Planner/AddRouteStop.tsx b/client/src/components/Planner/AddRouteStop.tsx index db6f398c4..5839ebf42 100644 --- a/client/src/components/Planner/AddRouteStop.tsx +++ b/client/src/components/Planner/AddRouteStop.tsx @@ -1,10 +1,18 @@ -import { Plus } from 'lucide-react' +import { Plus } from 'lucide-react'; -export function AddRouteStop({ onClick, label, mobile = false }: { onClick: () => void; label: string; mobile?: boolean }) { +export function AddRouteStop({ + onClick, + label, + mobile = false, +}: { + onClick: () => void; + label: string; + mobile?: boolean; +}) { const button = mobile ? 'border-m-rowbr bg-m-sheetop text-control text-m-ink active:bg-m-ic' - : 'border-edge bg-surface-input text-body text-content hover:bg-surface-hover' - const tile = mobile ? 'bg-m-ic text-m-muted' : 'bg-surface-secondary text-content-muted' + : 'border-edge bg-surface-input text-body text-content hover:bg-surface-hover'; + const tile = mobile ? 'bg-m-ic text-m-muted' : 'bg-surface-secondary text-content-muted'; return ( - ) + ); } diff --git a/client/src/components/Planner/DayPlanSidebar.test.tsx b/client/src/components/Planner/DayPlanSidebar.test.tsx index f68d1e41c..9c56f7028 100644 --- a/client/src/components/Planner/DayPlanSidebar.test.tsx +++ b/client/src/components/Planner/DayPlanSidebar.test.tsx @@ -5172,7 +5172,7 @@ describe('the day route-tools row', () => { const day = buildDay({ id: 10, date: '2025-06-01', title: null }) render() const secondary = screen.getByText('Day 1') - expect(secondary.className).toContain('text-content-faint') + expect(secondary).toHaveClass('text-content-muted') expect(secondary.previousElementSibling?.className).toContain('font-bold') }) }) diff --git a/client/src/components/Planner/DayPlanSidebar.tsx b/client/src/components/Planner/DayPlanSidebar.tsx index e54fa6d64..48b38469e 100644 --- a/client/src/components/Planner/DayPlanSidebar.tsx +++ b/client/src/components/Planner/DayPlanSidebar.tsx @@ -2531,7 +2531,7 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP {t('dayplan.route')} {/* The day's travel mode as one segmented control. */} -
{routeProfileOptions.map(p => { const ModeIcon = routeModeIcon(p.key) diff --git a/client/src/components/Planner/DayPlanSidebarNoteModal.test.tsx b/client/src/components/Planner/DayPlanSidebarNoteModal.test.tsx index 226d7e835..1c696a453 100644 --- a/client/src/components/Planner/DayPlanSidebarNoteModal.test.tsx +++ b/client/src/components/Planner/DayPlanSidebarNoteModal.test.tsx @@ -173,6 +173,6 @@ describe('DayPlanSidebarNoteModal', () => { setup({ '10': adding() }) const columns = screen.getByRole('group', { name: 'dayplan.noteIcon' }).closest('.grid') as HTMLElement expect(columns).toHaveClass('grid-cols-1') - expect(columns.className).toMatch(/sm:grid-cols-\[210px_minmax\(0,1fr\)\]/) + expect(columns.className).toMatch(/sm:grid-cols-\[minmax\(215px,1fr\)_minmax\(0,2fr\)\]/) }) }) diff --git a/client/src/components/Planner/PlaceDetailsColumn.test.tsx b/client/src/components/Planner/PlaceDetailsColumn.test.tsx index ee7a15098..8e60d4127 100644 --- a/client/src/components/Planner/PlaceDetailsColumn.test.tsx +++ b/client/src/components/Planner/PlaceDetailsColumn.test.tsx @@ -722,7 +722,7 @@ describe('PlaceDetailsColumn — dialog variant', () => { it('FE-PDC-044: the adopt button is a white button, blocked with the reason under it', async () => { const first = renderDialog() const adopt = await screen.findByRole('button', { name: 'places.details.adopt' }) - expect(adopt).toHaveClass('bg-surface-card') + expect(adopt).toHaveClass('bg-surface-input') expect(adopt).not.toHaveAttribute('aria-describedby') fireEvent.click(adopt) expect(first.onAdoptDescription).toHaveBeenCalledWith('Ein Museum in Köln.') diff --git a/client/src/components/Planner/PlaceFormModal.test.tsx b/client/src/components/Planner/PlaceFormModal.test.tsx index db749162a..497d46c59 100644 --- a/client/src/components/Planner/PlaceFormModal.test.tsx +++ b/client/src/components/Planner/PlaceFormModal.test.tsx @@ -2490,11 +2490,11 @@ describe('PlaceFormModal in the look of the booking editors', () => { const name = screen.getByPlaceholderText(/e\.g\. Eiffel Tower/i); expect(header()).toContainElement(name); expect(within(header()).getByRole('heading', { name: 'Add Place/Activity' })).toBeInTheDocument(); - // Until there is a name, the line under it says one is required. - expect(within(header()).getByText('Name *')).toBeInTheDocument(); + expect(name).toHaveAccessibleName('Name *'); + expect(name).toBeRequired(); await user.type(name, 'Louvre'); - expect(within(header()).queryByText('Name *')).not.toBeInTheDocument(); + expect(name).toHaveValue('Louvre'); }); it('FE-PLANNER-PLACEFORM-108: the category pill picks a category and clears it again', async () => { @@ -2599,10 +2599,8 @@ describe('PlaceFormModal in the look of the booking editors', () => { loaded: true, }); render(); - for (const button of [screen.getByRole('button', { name: /Attach/i }), screen.getByRole('button', { name: /Create expense/i })]) { - expect(button).toHaveClass('bg-surface-card'); - expect(button).not.toHaveClass('bg-surface-secondary'); - } + expect(screen.getByRole('button', { name: /Attach/i })).toHaveClass('bg-surface-input'); + expect(screen.getByRole('button', { name: /Create expense/i })).toHaveClass('bg-surface-card'); }); it('FE-PLANNER-PLACEFORM-115: a stop on a drive shows its kind in the band, and a double as the line under the name', () => { diff --git a/client/src/components/Planner/PlaceInspector.test.tsx b/client/src/components/Planner/PlaceInspector.test.tsx index c8c71c625..616db2c36 100644 --- a/client/src/components/Planner/PlaceInspector.test.tsx +++ b/client/src/components/Planner/PlaceInspector.test.tsx @@ -913,7 +913,7 @@ describe('PlaceInspector', () => { it('FE-PLANNER-INSPECTOR-044b: with upload but no files, the files row does not open to nothing', () => { render(); - const row = screen.getByRole('button', { name: 'Files' }); + const row = screen.getByRole('button', { name: 'No files yet' }); expect(row).toBeDisabled(); expect(row).toHaveAttribute('aria-expanded', 'false'); }); @@ -975,7 +975,8 @@ describe('PlaceInspector', () => { // clip the text with no scroll (issue #1195). expect(notes.length).toBe(2); for (const el of notes) { - expect((el.closest('section') as HTMLElement).className.split(/\s+/)).toContain('flex-none'); + const section = el.closest('section'); + expect(section?.closest('.flex-none')).toBeTruthy(); expect(el.style.overflow).toBe(''); } }); @@ -1816,17 +1817,19 @@ describe('PlaceInspector', () => { selectedAssignmentId={99} assignments={{ '1': assignmentInDay }} reservations={[buildReservation({ id: 610, title: 'Summit ticket', assignment_id: 99 })]} + onRate={vi.fn()} tripMembers={[{ id: 1, username: 'ada' }, { id: 2, username: 'bob' }]} /> ); for (const [label, content] of [['Description', 'Iron lady'], ['Notes', 'Bring cash'], ['Notes for this day', 'Early entry'], ['Bookings', 'Summit ticket'], ['Participants', 'ada'], ['Files', '']] as const) { - const section = screen.getByText(label, { selector: 'div' }).closest('section') as HTMLElement; + const section = screen.getByRole('heading', { name: label }).closest('section') as HTMLElement; expect(section).toBeTruthy(); if (content) expect(within(section).getByText(content)).toBeTruthy(); } - // Bookings and participants sit side by side from sm up. - const grid = screen.getByText('Bookings').closest('section')!.parentElement as HTMLElement; - expect(grid.className).toContain('sm:grid-cols-2'); + const participants = screen.getByRole('heading', { name: 'Participants' }).closest('section'); + const rating = screen.getByRole('heading', { name: 'Rating' }).closest('section'); + expect(participants?.parentElement).toBe(rating?.parentElement); + expect(rating?.parentElement).toHaveClass('grid'); }); }) diff --git a/client/src/components/Planner/PlaceInspector.tsx b/client/src/components/Planner/PlaceInspector.tsx index 9e8ff2349..288c7b96e 100644 --- a/client/src/components/Planner/PlaceInspector.tsx +++ b/client/src/components/Planner/PlaceInspector.tsx @@ -397,20 +397,7 @@ export default function PlaceInspector({
{(showRating || showParticipants) && (
- {showRating && ( - -
- {mode === 'trip' && onRate && ( -
- onRate(place.id, rating)} /> -
- )} - {shortReview && ( -

„{shortReview.text}"

- )} -
-
- )} + {showRating && } {showParticipants && ( @@ -570,6 +557,24 @@ export default function PlaceInspector({ ) } +function InspectorRating({ place, review, onRate }: { place: Place; review?: string; onRate?: PlaceInspectorProps['onRate'] }) { + const { t } = useTranslation() + return ( + +
+ {onRate && ( +
+ onRate(place.id, rating)} /> +
+ )} + {review && ( +

„{review}"

+ )} +
+
+ ) +} + /** Markdown in a framed box; it wraps long words instead of pushing the card wider. */ function MarkdownBox({ children }: { children: string }) { return ( diff --git a/client/src/components/Planner/ReservationsPanel.views.test.tsx b/client/src/components/Planner/ReservationsPanel.views.test.tsx index b091d4a83..29a0b36a4 100644 --- a/client/src/components/Planner/ReservationsPanel.views.test.tsx +++ b/client/src/components/Planner/ReservationsPanel.views.test.tsx @@ -129,8 +129,11 @@ describe('ReservationsPanel views', () => { const row = screen.getByRole('button', { name: 'Kaiseki dinner' }); await user.click(within(row).getByRole('button', { name: 'Edit' })); expect(onEdit).toHaveBeenCalledWith(dinner); - await user.click(within(row).getByRole('button', { name: 'Set to Confirmed' })); + await user.click(row); + const detail = await screen.findByRole('dialog', { name: 'Kaiseki dinner' }); + await user.click(within(detail).getByRole('button', { name: 'Set to Confirmed' })); expect(toggleReservationStatus).toHaveBeenCalledWith(1, 1202); + await user.click(within(detail).getByRole('button', { name: 'Close' })); await user.click(within(row).getByRole('button', { name: 'Delete' })); expect(screen.getByText(/will be permanently deleted/)).toBeInTheDocument(); const deletes = screen.getAllByRole('button', { name: 'Delete' }); @@ -144,7 +147,9 @@ describe('ReservationsPanel views', () => { window.__addToast = ((message: string) => { toasts.push(message); return 1; }) as unknown as typeof window.__addToast; useTripStore.setState({ toggleReservationStatus: vi.fn(async () => { throw new Error('offline'); }) } as never); renderPanel(); - await user.click(within(screen.getByRole('article', { name: 'Kaiseki dinner' })).getByRole('button', { name: 'Set to Confirmed' })); + await user.click(within(screen.getByRole('article', { name: 'Kaiseki dinner' })).getByRole('button', { name: 'Kaiseki dinner' })); + const detail = await screen.findByRole('dialog', { name: 'Kaiseki dinner' }); + await user.click(within(detail).getByRole('button', { name: 'Set to Confirmed' })); await waitFor(() => expect(toasts.length).toBe(1)); delete window.__addToast; }); diff --git a/client/src/components/Planner/bookings/BookingsList.tsx b/client/src/components/Planner/bookings/BookingsList.tsx index d4a80c773..461d42556 100644 --- a/client/src/components/Planner/bookings/BookingsList.tsx +++ b/client/src/components/Planner/bookings/BookingsList.tsx @@ -124,10 +124,7 @@ function Row({ r, p, facts, files, costs, t, locale, onNavigate }: {
)}
-
-
{facts.day ? [facts.day.label, facts.day.date].filter(Boolean).join(' ') : t('reservations.undated')}
- {facts.time &&
{facts.time}
} -
+
{p.canEdit && p.onEdit(r)}>} @@ -136,3 +133,12 @@ function Row({ r, p, facts, files, costs, t, locale, onNavigate }: {
) } + +function BookingRowWhen({ day, time, undated }: Pick & { undated: string }) { + return ( +
+
{day ? [day.label, day.date].filter(Boolean).join(' ') : undated}
+ {time &&
{time}
} +
+ ) +} diff --git a/client/src/components/Planner/placeDialogParts.test.tsx b/client/src/components/Planner/placeDialogParts.test.tsx index a3e5b7e07..1ae311875 100644 --- a/client/src/components/Planner/placeDialogParts.test.tsx +++ b/client/src/components/Planner/placeDialogParts.test.tsx @@ -16,10 +16,10 @@ describe('placeDialogParts', () => { expect(screen.getByTestId('hint-icon')).toBeInTheDocument(); }); - it('FE-PLANNER-PLACEDLGPARTS-003: the column frame stretches with the dialog and clips its cards', () => { - expect(SIDE_COLUMN).toContain('self-stretch'); + it('FE-PLANNER-PLACEDLGPARTS-003: the column frame caps its height and clips its cards', () => { + expect(SIDE_COLUMN).toContain('max-h-[60vh]'); expect(SIDE_COLUMN).toContain('overflow-hidden'); - expect(COLUMN_CARD).toContain('bg-surface-card'); + expect(COLUMN_CARD).toContain('bg-surface-input'); }); it('FE-PLANNER-PLACEDLGPARTS-004: the white button dims when disabled', () => { diff --git a/client/src/components/Roadtrip/FigureBadge.test.tsx b/client/src/components/Roadtrip/FigureBadge.test.tsx index 54c9a7a9d..cbb2486ca 100644 --- a/client/src/components/Roadtrip/FigureBadge.test.tsx +++ b/client/src/components/Roadtrip/FigureBadge.test.tsx @@ -14,7 +14,7 @@ describe('FigureBadge', () => { const { container } = render(} value="240 m" />) const pill = container.firstElementChild! expect(classes(pill)).toEqual(of( - 'inline-flex min-h-5 max-w-full flex-none items-center gap-1 self-start whitespace-nowrap rounded-full bg-surface-input px-2 font-geist font-normal leading-none tabular-nums shadow-sm ring-1 ring-inset ring-edge-faint', + 'inline-flex min-h-6 max-w-full flex-none items-center gap-1 self-start whitespace-nowrap rounded-full bg-surface-input px-2 font-geist font-normal leading-none tabular-nums shadow-sm ring-1 ring-inset ring-edge-faint', )) expect(classes(pill.children[0])).toEqual(of('flex min-w-0 items-center gap-1 text-content-faint')) expect(pill.children[1]).toHaveAttribute('aria-hidden') diff --git a/client/src/components/Roadtrip/RoadtripCorridorPanel.tsx b/client/src/components/Roadtrip/RoadtripCorridorPanel.tsx index d9eecc7d3..c0f269e38 100644 --- a/client/src/components/Roadtrip/RoadtripCorridorPanel.tsx +++ b/client/src/components/Roadtrip/RoadtripCorridorPanel.tsx @@ -302,6 +302,30 @@ function ResultGroup({ category, pois, dayId, insertIndexFor, onAddPoi, onFocusP * it looks for, in the same dropdown, so the question reads as one line: these kinds, * along this day. */ +function CorridorSearchProgress({ done, total, progressPct }: { done: number; total: number; progressPct: number }) { + const { t } = useTranslation() + return ( +
+ + + {t('roadtrip.poi.searching', { done, total })} + + + {`${progressPct}%`} + +
+ ) +} + export default function RoadtripCorridorPanel({ corridor, routes, onAddPoi, onFocusPoint, onAddManual, tripId, canImport, }: RoadtripCorridorPanelProps): React.ReactElement { @@ -471,26 +495,7 @@ export default function RoadtripCorridorPanel({ {/* How the run is getting on — a row of its own while it lasts, with the share done as a figure rather than only as a bar: a corridor search is many requests and "58%" answers "is this worth waiting for" that a bar only hints at. */} - {search.loading ? ( -
- - - {t('roadtrip.poi.searching', { done: search.progress.done, total: search.progress.total })} - - - {`${progressPct}%`} - -
- ) : null} + {search.loading && } {warnings.length > 0 ? (
diff --git a/client/src/components/Roadtrip/RoadtripLimitsCard.tsx b/client/src/components/Roadtrip/RoadtripLimitsCard.tsx index 991d54edc..b3171cdbf 100644 --- a/client/src/components/Roadtrip/RoadtripLimitsCard.tsx +++ b/client/src/components/Roadtrip/RoadtripLimitsCard.tsx @@ -15,7 +15,6 @@ import RangeStrip from './RangeStrip' import { valhallaAvailable } from '../Map/valhallaRoute' import ToggleSwitch from '../Settings/ToggleSwitch' import type { DistanceUnit, RouteAvoidClass } from '../../types' -import { FS } from './typeScale' import DayWindowFields from './DayWindowFields' import SettingsHint from './SettingsHint' import { dayWindow } from './dayWindow' diff --git a/client/src/components/Roadtrip/RoadtripSidebar.constants.test.ts b/client/src/components/Roadtrip/RoadtripSidebar.constants.test.ts index d1b09dc24..a2221cea7 100644 --- a/client/src/components/Roadtrip/RoadtripSidebar.constants.test.ts +++ b/client/src/components/Roadtrip/RoadtripSidebar.constants.test.ts @@ -5,10 +5,9 @@ const classes = (list: string): string[] => list.split(' ') describe('Road trip rail styles', () => { it('FE-ROADTRIP-RAILSTYLE-001: the marker column is exactly as wide as the disc that sits in it', () => { - expect(RAIL_GRID).toEqual({ gridTemplateColumns: '24px 1fr', columnGap: 10 }) - // h-6 and w-6 are 1.5rem, the 24px the column keeps free, so a disc never pushes the - // content beside it out of line with the rows above and below. - expect(classes(DISC)).toEqual(expect.arrayContaining(['h-6', 'w-6', 'shrink-0', 'rounded-full'])) + expect(RAIL_GRID).toEqual({ gridTemplateColumns: '28px minmax(0, 1fr)', columnGap: 10 }) + // size-7 matches the 28px reserved for the marker. + expect(classes(DISC)).toEqual(expect.arrayContaining(['size-7', 'shrink-0', 'rounded-full'])) }) it('FE-ROADTRIP-RAILSTYLE-002: the line between stops is a gradient with an exact dash, not a dashed border', () => { @@ -18,8 +17,8 @@ describe('Road trip rail styles', () => { }) it('FE-ROADTRIP-RAILSTYLE-003: captions are the eyebrow of the dialogs, and a day badge is the round pill of the day plan in a quiet tone at normal weight', () => { - expect(classes(STAT_LABEL)).toEqual(expect.arrayContaining(['uppercase', 'tracking-[.08em]', 'font-bold', 'text-content-faint'])) - expect(classes(DAY_BADGE)).toEqual(expect.arrayContaining(['rounded-full', 'uppercase', 'tracking-[.05em]', 'font-normal', 'text-content-secondary'])) + expect(classes(STAT_LABEL)).toEqual(expect.arrayContaining(['font-medium', 'text-content-muted'])) + expect(classes(DAY_BADGE)).toEqual(expect.arrayContaining(['rounded-full', 'min-h-6', 'font-normal', 'text-content-secondary'])) expect(classes(DAY_BADGE)).not.toContain('font-semibold') }) }) diff --git a/client/src/components/Roadtrip/RoadtripSidebar.test.tsx b/client/src/components/Roadtrip/RoadtripSidebar.test.tsx index d4bca995f..a08a14be3 100644 --- a/client/src/components/Roadtrip/RoadtripSidebar.test.tsx +++ b/client/src/components/Roadtrip/RoadtripSidebar.test.tsx @@ -1397,7 +1397,7 @@ describe('RoadtripSidebar with a hire car and the day\'s bookings (#2428)', () = const onOpenBooking = vi.fn() wrap() // The table is there to read, not a button that does nothing; the taxi is a button. - expect(screen.queryByRole('button', { name: /Tisch Bullerei/ })).toBeNull() + expect(screen.queryByRole('button', { name: 'Tisch Bullerei, Confirmed' })).toBeNull() const taxi = screen.getByRole('button', { name: 'Taxi zum Hafen, Confirmed' }) expect(taxi).toHaveTextContent('18:30') fireEvent.click(screen.getByText('19:30')) diff --git a/client/src/components/SystemNotices/SystemNoticeModal.test.tsx b/client/src/components/SystemNotices/SystemNoticeModal.test.tsx index ab2810494..42f09b6bf 100644 --- a/client/src/components/SystemNotices/SystemNoticeModal.test.tsx +++ b/client/src/components/SystemNotices/SystemNoticeModal.test.tsx @@ -839,7 +839,7 @@ describe('ModalRenderer', () => { await flushGraceDelay(); const secondary = document.getElementById('notice-cta2-secondary-action') as HTMLElement; - expect(secondary.className).toContain('bg-blue-600'); + expect(secondary.className).toContain('bg-surface-secondary'); await act(async () => { fireEvent.click(secondary); @@ -1028,7 +1028,7 @@ describe('ModalRenderer', () => { render(); await flushGraceDelay(); - expect(screen.getByRole('dialog').className).toContain('rounded-2xl'); + expect(screen.getByRole('dialog')).toHaveClass('rounded-[22px]'); expect(screen.getByText('Test Title')).toBeTruthy(); }); @@ -1047,7 +1047,7 @@ describe('ModalRenderer', () => { render(); await flushGraceDelay(); - expect(screen.getByRole('dialog').className).toContain('rounded-2xl'); + expect(screen.getByRole('dialog')).toHaveClass('rounded-[22px]'); await act(async () => { mqChangeListeners.forEach(cb => cb({ matches: true } as MediaQueryListEvent)); diff --git a/client/src/components/Trips/TripFormModal.test.tsx b/client/src/components/Trips/TripFormModal.test.tsx index 63ff66283..d279671a7 100644 --- a/client/src/components/Trips/TripFormModal.test.tsx +++ b/client/src/components/Trips/TripFormModal.test.tsx @@ -535,7 +535,7 @@ describe('TripFormModal', () => { render(); // Store default is false, so the section starts as the disabled hint. expect(screen.getByText(/Trip reminders are disabled/i)).toBeInTheDocument(); - await screen.findByRole('button', { name: 'Custom' }); + await screen.findByRole('button', { name: 'Reminder' }); expect(useAuthStore.getState().tripRemindersEnabled).toBe(true); }); diff --git a/client/src/components/Trips/TripTagField.tsx b/client/src/components/Trips/TripTagField.tsx index ae3fc085d..4d48b0c6f 100644 --- a/client/src/components/Trips/TripTagField.tsx +++ b/client/src/components/Trips/TripTagField.tsx @@ -1,116 +1,143 @@ -import { MAX_TRIP_TAGS, TRIP_TAG_NAME_MAX, tripTagKey, uniqueTripTags } from '@trek/shared' -import { Plus, X } from 'lucide-react' -import { useCallback, useId, useRef, useState } from 'react' -import { createPortal } from 'react-dom' -import { useAnchoredPosition } from '../../hooks/useAnchoredPosition' -import { useOverlay } from '../../hooks/overlayStack' -import { useTranslation } from '../../i18n' -import { tripRepo } from '../../repo/tripRepo' -import { tripTagOptions } from './tripTags' +import { MAX_TRIP_TAGS, TRIP_TAG_NAME_MAX, tripTagKey, uniqueTripTags } from '@trek/shared'; +import { Plus, X } from 'lucide-react'; +import { useCallback, useId, useRef, useState } from 'react'; +import { createPortal } from 'react-dom'; +import { useOverlay } from '../../hooks/overlayStack'; +import { useAnchoredPosition } from '../../hooks/useAnchoredPosition'; +import { useTranslation } from '../../i18n'; +import { tripRepo } from '../../repo/tripRepo'; +import { tripTagOptions } from './tripTags'; -const chip = 'inline-flex min-w-0 max-w-full items-center gap-1 rounded-full px-2.5 py-1 text-caption font-medium' -const selectedFill = 'bg-[color:var(--m-act,var(--bg-inverse))] text-[color:var(--m-actfg,var(--text-inverse))]' -const selectedChip = `${chip} ${selectedFill}` +const chip = 'inline-flex min-w-0 max-w-full items-center gap-1 rounded-full px-2.5 py-1 text-caption font-medium'; +const selectedFill = 'bg-[color:var(--m-act,var(--bg-inverse))] text-[color:var(--m-actfg,var(--text-inverse))]'; +const selectedChip = `${chip} ${selectedFill}`; -export function TripTagChips({ tags, className = '', chipClassName = selectedChip, limit = tags?.length ?? 0 }: { - tags?: string[] - className?: string - chipClassName?: string - limit?: number +export function TripTagChips({ + tags, + className = '', + chipClassName = selectedChip, + limit = tags?.length ?? 0, +}: { + tags?: string[]; + className?: string; + chipClassName?: string; + limit?: number; }) { - if (!tags?.length) return null + if (!tags?.length) return null; return (
- {tags.slice(0, limit).map(tag => ( - {tag} + {tags.slice(0, limit).map((tag) => ( + + + {tag} + + ))} {tags.length > limit && +{tags.length - limit}}
- ) + ); } -export function TripTagField({ tags, draft, onChange, onDraftChange, readOnly, inputClass, labelClass, className = '' }: { - tags: string[] - draft: string - onChange: (tags: string[]) => void - onDraftChange: (draft: string) => void - readOnly?: boolean - inputClass: string - labelClass: string - className?: string +function availableTags(options: string[], selected: Set, query: string, unavailable: boolean) { + if (unavailable) return []; + return options.filter((tag) => !selected.has(tripTagKey(tag)) && tripTagKey(tag).includes(query)).slice(0, 6); +} + +export function TripTagField({ + tags, + draft, + onChange, + onDraftChange, + readOnly, + inputClass, + labelClass, + className = '', +}: { + tags: string[]; + draft: string; + onChange: (tags: string[]) => void; + onDraftChange: (draft: string) => void; + readOnly?: boolean; + inputClass: string; + labelClass: string; + className?: string; }) { - const { t, locale } = useTranslation() - const id = useId() - const menuId = `${id}-suggestions` - const inputRef = useRef(null) - const rowRef = useRef(null) - const boundaryRef = useRef(null) - const menuRef = useRef(null) - const request = useRef | null>(null) - const [active, setActive] = useState(false) - const [highlighted, setHighlighted] = useState(-1) - const [options, setOptions] = useState([]) - const selected = new Set(tags.map(tripTagKey)) - const draftKey = tripTagKey(draft) - const atLimit = tags.length >= MAX_TRIP_TAGS - const canAdd = !atLimit && draftKey.length > 0 && !selected.has(draftKey) - const suggestions = !readOnly && !atLimit - ? options.filter(tag => !selected.has(tripTagKey(tag)) && tripTagKey(tag).includes(draftKey)).slice(0, 6) - : [] + const { t, locale } = useTranslation(); + const id = useId(); + const menuId = `${id}-suggestions`; + const inputRef = useRef(null); + const rowRef = useRef(null); + const boundaryRef = useRef(null); + const menuRef = useRef(null); + const request = useRef | null>(null); + const [active, setActive] = useState(false); + const [highlighted, setHighlighted] = useState(-1); + const [options, setOptions] = useState([]); + const selected = new Set(tags.map(tripTagKey)); + const draftKey = tripTagKey(draft); + const atLimit = tags.length >= MAX_TRIP_TAGS; + const canAdd = !atLimit && draftKey.length > 0 && !selected.has(draftKey); + const suggestions = availableTags(options, selected, draftKey, !!readOnly || atLimit); const setAnchor = useCallback((row: HTMLDivElement | null) => { - rowRef.current = row - boundaryRef.current = row?.closest('.overflow-y-auto') ?? null - }, []) + rowRef.current = row; + boundaryRef.current = row?.closest('.overflow-y-auto') ?? null; + }, []); const closeMenu = useCallback(() => { - setActive(false) - setHighlighted(-1) - }, []) + setActive(false); + setHighlighted(-1); + }, []); const position = useAnchoredPosition(rowRef, active && suggestions.length > 0, { estimatedHeight: 116, boundary: { ref: boundaryRef, onAnchorHidden: closeMenu }, - }) - const menuOpen = active && suggestions.length > 0 && !!position - const activeTag = menuOpen ? suggestions[highlighted] : undefined - const { flipped, ...menuStyle } = position ?? { flipped: false } - useOverlay(menuOpen, closeMenu, true) + }); + const menuOpen = active && suggestions.length > 0 && !!position; + const activeTag = menuOpen ? suggestions[highlighted] : undefined; + const { flipped, ...menuStyle } = position ?? { flipped: false }; + useOverlay(menuOpen, closeMenu, true); const add = (name: string) => { - if (atLimit || !tripTagKey(name)) return - onChange(uniqueTripTags([...tags, name])) - onDraftChange('') - setHighlighted(-1) - inputRef.current?.focus({ preventScroll: true }) - } + if (atLimit || !tripTagKey(name)) return; + onChange(uniqueTripTags([...tags, name])); + onDraftChange(''); + setHighlighted(-1); + inputRef.current?.focus({ preventScroll: true }); + }; if (readOnly) { - if (!tags.length) return null + if (!tags.length) return null; return (
{t('mobileJourney.tags')}
- ) + ); } return (
{ - if (event.relatedTarget !== inputRef.current && !menuRef.current?.contains(event.relatedTarget)) closeMenu() + onBlur={(event) => { + if (event.relatedTarget !== inputRef.current && !menuRef.current?.contains(event.relatedTarget)) closeMenu(); }} > - {atLimit - ? {t('mobileJourney.tags')} - : } + {atLimit ? ( + {t('mobileJourney.tags')} + ) : ( + + )} {tags.length > 0 && (
- {tags.map(tag => ( - - {tag} + {tags.map((tag) => ( + + + {tag} +
)} - {menuOpen && position && createPortal( -
- {suggestions.map((tag, index) => ( - - ))} -
, - document.body, - )} + {menuOpen && + position && + createPortal( +
+ {suggestions.map((tag, index) => ( + + ))} +
, + document.body + )}
- ) + ); } diff --git a/client/src/components/Trips/TripTagFilter.tsx b/client/src/components/Trips/TripTagFilter.tsx index f4a29fbab..1d90f9ec6 100644 --- a/client/src/components/Trips/TripTagFilter.tsx +++ b/client/src/components/Trips/TripTagFilter.tsx @@ -1,31 +1,36 @@ -import { tripTagKey } from '@trek/shared' -import { Tag } from 'lucide-react' -import { useTranslation } from '../../i18n' -import CustomSelect from '../shared/CustomSelect' +import { tripTagKey } from '@trek/shared'; +import { Tag } from 'lucide-react'; +import { useTranslation } from '../../i18n'; +import CustomSelect from '../shared/CustomSelect'; -export default function TripTagFilter({ tags, selected, onChange, className = '' }: { - tags: readonly string[] - selected: string - onChange: (value: string) => void - className?: string +export default function TripTagFilter({ + tags, + selected, + onChange, + className = '', +}: { + tags: readonly string[]; + selected: string; + onChange: (value: string) => void; + className?: string; }) { - const { t } = useTranslation() - if (!tags.length) return null - const icon = + const { t } = useTranslation(); + if (!tags.length) return null; + const icon = ; return (
onChange(String(value))} + onChange={(value) => onChange(String(value))} options={[ { value: '', label: t('dashboard.tags.all'), icon }, - ...tags.map(tag => ({ value: tripTagKey(tag), label: tag, icon })), + ...tags.map((tag) => ({ value: tripTagKey(tag), label: tag, icon })), ]} size="sm" menuFit="content" searchable={tags.length > 8} />
- ) + ); } diff --git a/client/src/components/Trips/tripTags.ts b/client/src/components/Trips/tripTags.ts index 7649584fd..e4f75ffc5 100644 --- a/client/src/components/Trips/tripTags.ts +++ b/client/src/components/Trips/tripTags.ts @@ -1,12 +1,10 @@ -import { MAX_TRIP_TAGS, uniqueTripTags } from '@trek/shared' +import { MAX_TRIP_TAGS, uniqueTripTags } from '@trek/shared'; export function tripTagOptions(trips: readonly { tags?: string[] }[], locale: string): string[] { - return uniqueTripTags(trips.flatMap(trip => trip.tags ?? [])) - .sort((a, b) => a.localeCompare(b, locale)) + return uniqueTripTags(trips.flatMap((trip) => trip.tags ?? [])).sort((a, b) => a.localeCompare(b, locale)); } export function tripTagsToSave(tags: string[], draft: string, previous: string[] = []): { tags?: string[] } { - const next = uniqueTripTags([...tags, draft]).slice(0, MAX_TRIP_TAGS) - return next.length === previous.length && next.every((tag, index) => tag === previous[index]) - ? {} : { tags: next } + const next = uniqueTripTags([...tags, draft]).slice(0, MAX_TRIP_TAGS); + return next.length === previous.length && next.every((tag, index) => tag === previous[index]) ? {} : { tags: next }; } diff --git a/client/src/components/shared/DialogShell.test.tsx b/client/src/components/shared/DialogShell.test.tsx index 6dae0105a..d888fbc18 100644 --- a/client/src/components/shared/DialogShell.test.tsx +++ b/client/src/components/shared/DialogShell.test.tsx @@ -183,7 +183,7 @@ describe('body and footer parts', () => { , ); expect(screen.getByText('Travelers')).toBeInTheDocument(); - expect(screen.getByText('Maria').closest('section')?.className).toBe('own'); + expect(screen.getByText('Maria').closest('section')).toHaveClass('trek-dialog-section', 'own'); await userEvent.click(screen.getByRole('button', { name: 'Add' })); expect(onAdd).toHaveBeenCalledTimes(1); expect(screen.getAllByRole('button')).toHaveLength(1); diff --git a/client/src/index.css b/client/src/index.css index 39ae45f41..b7be17add 100644 --- a/client/src/index.css +++ b/client/src/index.css @@ -48,7 +48,6 @@ body { height: 100%; overflow: auto; overscroll-behavior: none; -webkit-overflow pixels out of line — the one thing a column of nested cards cannot hide. */ .roadtrip-rail-scroll { scrollbar-width: none; -ms-overflow-style: none; } .roadtrip-rail-scroll::-webkit-scrollbar { display: none; } -.roadtrip-rail-scroll[data-fade-top] { mask-image: linear-gradient(to bottom, transparent, currentColor 18px); } /* Journey video: let the player fill the box the lightbox gives it. * @@ -817,238 +816,6 @@ input[type="number"], input[type="time"], input[type="date"], input[type="dateti --vg-hi: inset 0 1px 0 oklch(1 0 0 / .8); } -.trek-select-search { position: relative; padding: 6px 6px 2px; } -.trek-select-search > svg { display: none; } -.trek-dialog-section-icon { display: none; } - -/* The default desktop palette mirrors the matte surfaces of mobile sheets. */ -@media (min-width: 768px) and (min-height: 501px), (min-width: 768px) and (pointer: fine), (min-width: 768px) and (pointer: none) { - html:not(.dark, [data-scheme], [data-native-app]) :where(.trek-modal-enter, [role="dialog"], [role="alertdialog"], .trek-select-menu, .trek-control-popover, .trek-desktop-panel) { - --bg-card: #f7f7f7; - --bg-secondary: #eeeeee; - --bg-tertiary: #e9e9e9; - --bg-input: #ffffff; - --bg-hover: #e7e7e7; - --bg-selected: #e4e4e4; - --text-primary: #101013; - --text-secondary: #353535; - --text-muted: #595959; - --text-faint: #666666; - --border-primary: #dddddd; - --border-secondary: #e5e5e5; - --border-faint: #dedede; - --accent: var(--text-primary); - --accent-on: var(--accent); - --accent-hover: #313131; - --accent-subtle: var(--bg-secondary); - --bg-inverse: var(--text-primary); - --scrollbar-track: #f0f0f0; - --scrollbar-thumb: #cccccc; - --scrollbar-hover: #999999; - } - - html.dark:not([data-scheme], [data-native-app]) :where(.trek-modal-enter, [role="dialog"], [role="alertdialog"], .trek-select-menu, .trek-control-popover, .trek-desktop-panel) { - --bg-card: #181818; - --bg-secondary: #222222; - --bg-tertiary: #2a2a2a; - --bg-input: #191919; - --bg-hover: #2e2e2e; - --bg-selected: #343434; - --text-primary: #f5f5f5; - --text-secondary: #dddddd; - --text-muted: #bbbbbb; - --text-faint: #aaaaaa; - --border-primary: #393939; - --border-secondary: #333333; - --border-faint: #353535; - --accent: var(--text-primary); - --accent-on: var(--accent); - --accent-hover: #dadada; - --accent-subtle: var(--bg-secondary); - --bg-inverse: var(--text-primary); - --scrollbar-track: #202020; - --scrollbar-thumb: #626262; - --scrollbar-hover: #808080; - } - - html:not([data-scheme], [data-native-app]) .trek-desktop-panel { - --bg-card: var(--bg-input); - --bg-tertiary: var(--bg-secondary); - } - - html:not([data-native-app]) .trek-control-popover { - --control-popover-radius: 14px; - --context-menu-padding: 6px; - --context-menu-item-radius: 8px; - --context-menu-item-size: 13px; - --context-menu-item-height: 36px; - } - - html:not([data-native-app]) .trek-control-popover button:focus-visible { - outline: 2px solid var(--text-muted); - outline-offset: -2px; - } - - html:not([data-native-app]) .trek-select-menu { - --select-menu-radius: 14px; - --select-option-radius: 8px; - --select-option-padding: 7px 10px; - --select-search-padding: 8px 10px; - --select-search-size: 13px; - --select-search-bg: var(--bg-input); - --select-selected-bg: var(--bg-selected); - padding: 6px; - } - - html:not([data-native-app]) .trek-select-menu .trek-select-search { - --select-search-padding: 8px 10px 8px 32px; - padding: 0 0 6px; - } - - html:not([data-native-app]) .trek-select-menu .trek-select-search > svg { - position: absolute; - inset-inline-start: 10px; - top: 10px; - display: block; - color: var(--text-muted); - pointer-events: none; - } - - html:not([data-native-app]) .trek-select-menu .trek-select-search input { padding-inline: 32px 10px; } - html:not([data-native-app]) .trek-select-menu .trek-select-search input::placeholder { color: var(--text-faint); } - html:not([data-native-app]) .trek-select-menu .trek-select-options { - border-radius: 10px; - background: var(--bg-input); - scrollbar-gutter: stable; - } - html:not([data-native-app]) .trek-select-menu [data-select-option] { min-height: 36px; } - html:not([data-native-app]) .trek-select-menu [data-select-option][aria-pressed="true"] { font-weight: 600; } - html:not([data-native-app]) .trek-select-menu :is(input, [data-select-option]):focus-visible { - box-shadow: inset 0 0 0 1px var(--text-muted); - } - - html:not([data-native-app]) :where(.trek-modal-enter, [role="dialog"], [role="alertdialog"], .trek-tour-panel, .trek-place-inspector-body) :is(.trek-dialog-field-label, .trek-dialog-section-label) { - color: var(--text-primary); - font-family: inherit; - font-size: calc(12px * var(--fs-scale-body, 1)); - font-weight: 500; - letter-spacing: normal; - text-transform: none; - } - - html:not([data-native-app]) :where(.trek-modal-enter, [role="dialog"], .trek-tour-panel) :is(.trek-form-control, [data-field-trigger]) { - min-height: var(--form-control-min-height, 40px); - font-size: calc(13px * var(--fs-scale-body, 1)); - } - - html:not([data-native-app]) :where(.trek-modal-enter, [role="dialog"]) .trek-form-chip { - min-height: 34px; - padding-block: 0; - font-size: calc(12px * var(--fs-scale-body, 1)); - } - - html:not([data-native-app]) :where(.trek-modal-enter, [role="dialog"]) .trek-form-square { - width: 40px; - height: 40px; - } - - html:not([data-native-app]) :where(.trek-modal-enter, [role="dialog"], [role="alertdialog"], .trek-dialog-footer, .trek-tour-panel) [data-dialog-action] { - min-height: 40px; - padding-inline: 16px; - border-radius: 999px; - font-weight: 600; - } - - .trek-tour-panel .font-geist { font-family: inherit; } - .trek-tour-panel .trek-tour-rail-head { align-items: center; } - .trek-tour-panel .trek-tour-rail-title h2 { - font-weight: 600; - letter-spacing: normal; - } - .trek-tour-panel .trek-tour-rail-title { padding-block-start: 0; } - .trek-tour-panel .trek-tour-card { background: var(--bg-secondary); } - .trek-tour-panel .trek-tour-card-heading { border-bottom-color: var(--border-faint); } - .trek-tour-panel .trek-tour-card-icon { - width: 28px; - height: 28px; - border-radius: 9px; - background: var(--bg-input); - } - .trek-tour-panel .trek-tour-icon-action, - .trek-tour-panel .trek-tour-editor-toolbar > button, - .trek-tour-panel .trek-tour-retry { - border-radius: 999px; - background: var(--bg-input); - color: var(--text-muted); - } - .trek-tour-panel .trek-tour-icon-action:enabled:hover, - .trek-tour-panel .trek-tour-editor-toolbar > button:enabled:hover, - .trek-tour-panel .trek-tour-retry:hover { - background: var(--bg-hover); - color: var(--text-primary); - } - .trek-tour-panel .trek-tour-count { - display: grid; - min-width: 24px; - min-height: 24px; - place-items: center; - padding-inline: 5px; - border-radius: 999px; - background: var(--bg-input); - } - .trek-tour-panel .trek-tour-waypoints { - margin-inline: 0; - padding: 4px; - border-radius: 12px; - background: var(--bg-input); - } - - html:not([data-native-app]) .trek-dialog-footer [data-dialog-icon-action] { - width: 40px; - height: 40px; - } - - html:not([data-native-app]) .trek-dialog-footer > [data-dialog-action="secondary"] { - background: var(--bg-secondary); - box-shadow: none; - } - - html:not([data-native-app]) .trek-dialog-footer > [data-dialog-action="secondary"]:hover { - background: var(--bg-tertiary); - } - - html:not([data-native-app]) :where(.trek-modal-enter, [role="dialog"], .trek-place-inspector-body) .trek-dialog-section { - min-width: 0; - padding: 12px; - border: 1px solid var(--border-faint); - border-radius: 14px; - background: var(--bg-secondary); - } - - html:not([data-native-app]) :where(.trek-modal-enter, [role="dialog"], .trek-place-inspector-body) .trek-dialog-section-head[data-section-icon] { - min-height: 32px; - height: auto; - gap: 8px; - flex-wrap: wrap; - } - - html:not([data-native-app]) :where(.trek-modal-enter, [role="dialog"], .trek-place-inspector-body) .trek-dialog-section-head[data-section-icon] .trek-dialog-section-icon { - display: grid; - width: 32px; - height: 32px; - flex: none; - place-items: center; - border-radius: 10px; - background: var(--bg-input); - color: var(--text-muted); - } - - html:not([data-native-app]) :where(.trek-modal-enter, [role="dialog"], .trek-place-inspector-body) .trek-dialog-section-head[data-section-icon] .trek-dialog-section-label { - font-size: calc(14px * var(--fs-scale-body, 1)); - font-weight: 600; - } -} - @media (max-width: 767px), (pointer: coarse) and (max-height: 500px) { :root { --bottom-nav-h: calc(84px + env(safe-area-inset-bottom, 0px)); } } diff --git a/client/src/main.tsx b/client/src/main.tsx index 2031ff903..9306bd130 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -25,6 +25,7 @@ import '@fontsource/geist-sans/600.css' // several .leaflet-* styles. import 'leaflet/dist/leaflet.css' import './index.css' +import './styles/desktop-controls.css' import './styles/leafletCanvas.css' import './native/nativeApp.css' import './styles/rtl.css' diff --git a/client/src/mobile/screens/dashboard/MDashboard.tsx b/client/src/mobile/screens/dashboard/MDashboard.tsx index c123dedb4..ff964f38d 100644 --- a/client/src/mobile/screens/dashboard/MDashboard.tsx +++ b/client/src/mobile/screens/dashboard/MDashboard.tsx @@ -46,6 +46,17 @@ interface CardAction { * data hook — every mutation runs through the same store/hook actions the * desktop page uses. */ +function tripTagActions(t: ReturnType['t'], tagOptions: string[], selectedTag: string, setTripTagFilter: (tag: string) => void): CardAction[] { + return [ + { key: '', label: t('dashboard.tags.all') }, + ...tagOptions.map(tag => ({ key: tripTagKey(tag), label: tag })), + ].map(({ key, label }) => ({ + key, label, icon: key === selectedTag ? : , + pressed: key === selectedTag, + onClick: () => setTripTagFilter(key), + })) +} + export default function MDashboard(): React.ReactElement { const { demoMode, locale, t, navigate, @@ -129,14 +140,7 @@ export default function MDashboard(): React.ReactElement { icon: , onClick: () => setSubOpen(true), }, ] - const tagFilterActions = [ - { key: '', label: t('dashboard.tags.all') }, - ...tagOptions.map(tag => ({ key: tripTagKey(tag), label: tag })), - ].map(({ key, label }) => ({ - key, label, icon: key === selectedTag ? : , - pressed: key === selectedTag, - onClick: () => setTripTagFilter(key), - })) + const tagFilterActions = tripTagActions(t, tagOptions, selectedTag, setTripTagFilter) // One dashboard block by token: 'trips' is the filter row + trip list; the // rest are the inline widgets (rendered only when their toggle is on). diff --git a/client/src/pages/admin/AdminUsersTab.tsx b/client/src/pages/admin/AdminUsersTab.tsx index 6a65898ff..2ea621781 100644 --- a/client/src/pages/admin/AdminUsersTab.tsx +++ b/client/src/pages/admin/AdminUsersTab.tsx @@ -212,7 +212,7 @@ export default function AdminUsersTab({ admin, t, locale }: AdminUsersTabProps): setShowCreateInvite(false)}>{t('common.cancel')} - }> + void handleCreateInvite()} icon={}> {t('admin.invite.createAndCopy')} diff --git a/client/src/styles/desktop-controls.css b/client/src/styles/desktop-controls.css new file mode 100644 index 000000000..c890e1cac --- /dev/null +++ b/client/src/styles/desktop-controls.css @@ -0,0 +1,294 @@ +.roadtrip-rail-scroll[data-fade-top] { + mask-image: linear-gradient(to bottom, transparent, currentColor 18px); +} + +.trek-select-search { + position: relative; + padding: 6px 6px 2px; +} +.trek-select-search > svg { + display: none; +} +.trek-dialog-section-icon { + display: none; +} + +/* The default desktop palette mirrors the matte surfaces of mobile sheets. */ +@media (min-width: 768px) and (min-height: 501px), + (min-width: 768px) and (pointer: fine), + (min-width: 768px) and (pointer: none) { + html:not(.dark, [data-scheme], [data-native-app]) + :where( + .trek-modal-enter, + [role='dialog'], + [role='alertdialog'], + .trek-select-menu, + .trek-control-popover, + .trek-desktop-panel + ) { + --bg-card: #f7f7f7; + --bg-secondary: #eeeeee; + --bg-tertiary: #e9e9e9; + --bg-input: #ffffff; + --bg-hover: #e7e7e7; + --bg-selected: #e4e4e4; + --text-primary: #101013; + --text-secondary: #353535; + --text-muted: #595959; + --text-faint: #666666; + --border-primary: #dddddd; + --border-secondary: #e5e5e5; + --border-faint: #dedede; + --accent: var(--text-primary); + --accent-on: var(--accent); + --accent-hover: #313131; + --accent-subtle: var(--bg-secondary); + --bg-inverse: var(--text-primary); + --scrollbar-track: #f0f0f0; + --scrollbar-thumb: #cccccc; + --scrollbar-hover: #999999; + } + + html.dark:not([data-scheme], [data-native-app]) + :where( + .trek-modal-enter, + [role='dialog'], + [role='alertdialog'], + .trek-select-menu, + .trek-control-popover, + .trek-desktop-panel + ) { + --bg-card: #181818; + --bg-secondary: #222222; + --bg-tertiary: #2a2a2a; + --bg-input: #191919; + --bg-hover: #2e2e2e; + --bg-selected: #343434; + --text-primary: #f5f5f5; + --text-secondary: #dddddd; + --text-muted: #bbbbbb; + --text-faint: #aaaaaa; + --border-primary: #393939; + --border-secondary: #333333; + --border-faint: #353535; + --accent: var(--text-primary); + --accent-on: var(--accent); + --accent-hover: #dadada; + --accent-subtle: var(--bg-secondary); + --bg-inverse: var(--text-primary); + --scrollbar-track: #202020; + --scrollbar-thumb: #626262; + --scrollbar-hover: #808080; + } + + html:not([data-scheme], [data-native-app]) .trek-desktop-panel { + --bg-card: var(--bg-input); + --bg-tertiary: var(--bg-secondary); + } + + html:not([data-native-app]) .trek-control-popover { + --control-popover-radius: 14px; + --context-menu-padding: 6px; + --context-menu-item-radius: 8px; + --context-menu-item-size: 13px; + --context-menu-item-height: 36px; + } + + html:not([data-native-app]) .trek-control-popover button:focus-visible { + outline: 2px solid var(--text-muted); + outline-offset: -2px; + } + + html:not([data-native-app]) .trek-select-menu { + --select-menu-radius: 14px; + --select-option-radius: 8px; + --select-option-padding: 7px 10px; + --select-search-padding: 8px 10px; + --select-search-size: 13px; + --select-search-bg: var(--bg-input); + --select-selected-bg: var(--bg-selected); + padding: 6px; + } + + html:not([data-native-app]) .trek-select-menu .trek-select-search { + --select-search-padding: 8px 10px 8px 32px; + padding: 0 0 6px; + } + + html:not([data-native-app]) .trek-select-menu .trek-select-search > svg { + position: absolute; + inset-inline-start: 10px; + top: 10px; + display: block; + color: var(--text-muted); + pointer-events: none; + } + + html:not([data-native-app]) .trek-select-menu .trek-select-search input { + padding-inline: 32px 10px; + } + html:not([data-native-app]) .trek-select-menu .trek-select-search input::placeholder { + color: var(--text-faint); + } + html:not([data-native-app]) .trek-select-menu .trek-select-options { + border-radius: 10px; + background: var(--bg-input); + scrollbar-gutter: stable; + } + html:not([data-native-app]) .trek-select-menu [data-select-option] { + min-height: 36px; + } + html:not([data-native-app]) .trek-select-menu [data-select-option][aria-pressed='true'] { + font-weight: 600; + } + html:not([data-native-app]) .trek-select-menu :is(input, [data-select-option]):focus-visible { + box-shadow: inset 0 0 0 1px var(--text-muted); + } + + html:not([data-native-app]) + :where(.trek-modal-enter, [role='dialog'], [role='alertdialog'], .trek-tour-panel, .trek-place-inspector-body) + :is(.trek-dialog-field-label, .trek-dialog-section-label) { + color: var(--text-primary); + font-family: inherit; + font-size: calc(12px * var(--fs-scale-body, 1)); + font-weight: 500; + letter-spacing: normal; + text-transform: none; + } + + html:not([data-native-app]) + :where(.trek-modal-enter, [role='dialog'], .trek-tour-panel) + :is(.trek-form-control, [data-field-trigger]) { + min-height: var(--form-control-min-height, 40px); + font-size: calc(13px * var(--fs-scale-body, 1)); + } + + html:not([data-native-app]) :where(.trek-modal-enter, [role='dialog']) .trek-form-chip { + min-height: 34px; + padding-block: 0; + font-size: calc(12px * var(--fs-scale-body, 1)); + } + + html:not([data-native-app]) :where(.trek-modal-enter, [role='dialog']) .trek-form-square { + width: 40px; + height: 40px; + } + + html:not([data-native-app]) + :where(.trek-modal-enter, [role='dialog'], [role='alertdialog'], .trek-dialog-footer, .trek-tour-panel) + [data-dialog-action] { + min-height: 40px; + padding-inline: 16px; + border-radius: 999px; + font-weight: 600; + } + + .trek-tour-panel .font-geist { + font-family: inherit; + } + .trek-tour-panel .trek-tour-rail-head { + align-items: center; + } + .trek-tour-panel .trek-tour-rail-title h2 { + font-weight: 600; + letter-spacing: normal; + } + .trek-tour-panel .trek-tour-rail-title { + padding-block-start: 0; + } + .trek-tour-panel .trek-tour-card { + background: var(--bg-secondary); + } + .trek-tour-panel .trek-tour-card-heading { + border-bottom-color: var(--border-faint); + } + .trek-tour-panel .trek-tour-card-icon { + width: 28px; + height: 28px; + border-radius: 9px; + background: var(--bg-input); + } + .trek-tour-panel .trek-tour-icon-action, + .trek-tour-panel .trek-tour-editor-toolbar > button, + .trek-tour-panel .trek-tour-retry { + border-radius: 999px; + background: var(--bg-input); + color: var(--text-muted); + } + .trek-tour-panel .trek-tour-icon-action:enabled:hover, + .trek-tour-panel .trek-tour-editor-toolbar > button:enabled:hover, + .trek-tour-panel .trek-tour-retry:hover { + background: var(--bg-hover); + color: var(--text-primary); + } + .trek-tour-panel .trek-tour-count { + display: grid; + min-width: 24px; + min-height: 24px; + place-items: center; + padding-inline: 5px; + border-radius: 999px; + background: var(--bg-input); + } + .trek-tour-panel .trek-tour-waypoints { + margin-inline: 0; + padding: 4px; + border-radius: 12px; + background: var(--bg-input); + } + + html:not([data-native-app]) .trek-dialog-footer [data-dialog-icon-action] { + width: 40px; + height: 40px; + } + + html:not([data-native-app]) .trek-dialog-footer > [data-dialog-action='secondary'] { + background: var(--bg-secondary); + box-shadow: none; + } + + html:not([data-native-app]) .trek-dialog-footer > [data-dialog-action='secondary']:hover { + background: var(--bg-tertiary); + } + + html:not([data-native-app]) + :where(.trek-modal-enter, [role='dialog'], .trek-place-inspector-body) + .trek-dialog-section { + min-width: 0; + padding: 12px; + border: 1px solid var(--border-faint); + border-radius: 14px; + background: var(--bg-secondary); + } + + html:not([data-native-app]) + :where(.trek-modal-enter, [role='dialog'], .trek-place-inspector-body) + .trek-dialog-section-head[data-section-icon] { + min-height: 32px; + height: auto; + gap: 8px; + flex-wrap: wrap; + } + + html:not([data-native-app]) + :where(.trek-modal-enter, [role='dialog'], .trek-place-inspector-body) + .trek-dialog-section-head[data-section-icon] + .trek-dialog-section-icon { + display: grid; + width: 32px; + height: 32px; + flex: none; + place-items: center; + border-radius: 10px; + background: var(--bg-input); + color: var(--text-muted); + } + + html:not([data-native-app]) + :where(.trek-modal-enter, [role='dialog'], .trek-place-inspector-body) + .trek-dialog-section-head[data-section-icon] + .trek-dialog-section-label { + font-size: calc(14px * var(--fs-scale-body, 1)); + font-weight: 600; + } +} diff --git a/client/tests/unit/mobile/dashboard/MDashboard.test.tsx b/client/tests/unit/mobile/dashboard/MDashboard.test.tsx index 9dc1a033d..8f06f1e9b 100644 --- a/client/tests/unit/mobile/dashboard/MDashboard.test.tsx +++ b/client/tests/unit/mobile/dashboard/MDashboard.test.tsx @@ -60,6 +60,9 @@ function buildDash(over: Record = {}): Record loadError: false, retryLoad: vi.fn(), tripFilter: 'planned', + tagOptions: [], + selectedTag: '', + setTripTagFilter: vi.fn(), setTripFilter: vi.fn(), viewMode: 'grid', toggleViewMode: vi.fn(), diff --git a/plugin-sdk/src/generated/host-facts.ts b/plugin-sdk/src/generated/host-facts.ts index 297c9dd4d..32e9ec8c4 100644 --- a/plugin-sdk/src/generated/host-facts.ts +++ b/plugin-sdk/src/generated/host-facts.ts @@ -442,6 +442,7 @@ export const PLUGIN_ENTITY_FIELDS = { 'is_owner', 'owner_username', 'shared_count', + 'tags', ], place: [ 'id', diff --git a/server/src/db/entities/Trips.entity.ts b/server/src/db/entities/Trips.entity.ts index 40cb93c2c..985b6760f 100644 --- a/server/src/db/entities/Trips.entity.ts +++ b/server/src/db/entities/Trips.entity.ts @@ -54,7 +54,6 @@ export class Trips { user_id!: number; title!: string; description?: string | null; - tags_json?: string | null; start_date?: string | null; end_date?: string | null; currency?: string | null = 'EUR'; @@ -66,6 +65,7 @@ export class Trips { updated_at?: string | null; reminder_sent_for?: string | null; costs_mode: TTripsCostsMode & Opt = TripsCostsMode.SPLIT; + tags_json?: string | null; assistant_attachments_collection = new Collection(this); assistant_threads_collection = new Collection(this); budget_category_order_collection = new Collection(this); @@ -136,7 +136,6 @@ export const TripsSchema = defineEntity({ user_id: p.integer().persist(false).index('idx_trips_user_id'), title: p.text(), description: p.text().nullable(), - tags_json: p.text().nullable(), start_date: p.text().nullable(), end_date: p.text().nullable(), currency: p.text().nullable(), @@ -148,6 +147,7 @@ export const TripsSchema = defineEntity({ updated_at: p.type(DbTimestampType).nullable().defaultRaw(`CURRENT_TIMESTAMP`), reminder_sent_for: p.text().nullable(), costs_mode: p.enum(() => TripsCostsMode).default('split'), + tags_json: p.text().nullable(), assistant_attachments_collection: () => p.oneToMany(AssistantAttachments).mappedBy('trip').hidden(), assistant_threads_collection: () => p.oneToMany(AssistantThreads).mappedBy('trip').hidden(), budget_category_order_collection: () => p.oneToMany(BudgetCategoryOrder).mappedBy('trip').hidden(), diff --git a/server/src/db/migrations/Migration20200101046650_trips_can_carry_custom_tags.ts b/server/src/db/migrations/Migration20200101046650_trips_can_carry_custom_tags.ts index 326a9a81a..5534c42cd 100644 --- a/server/src/db/migrations/Migration20200101046650_trips_can_carry_custom_tags.ts +++ b/server/src/db/migrations/Migration20200101046650_trips_can_carry_custom_tags.ts @@ -1,5 +1,5 @@ -import { Migration } from '@mikro-orm/migrations'; import { engineDdl } from '../migration-utils'; +import { Migration } from '@mikro-orm/migrations'; export class Migration20200101046650_trips_can_carry_custom_tags extends Migration { override name = 'Migration20200101046650_trips_can_carry_custom_tags'; diff --git a/server/src/nest/plugins/protocol/output-contract.ts b/server/src/nest/plugins/protocol/output-contract.ts index ee92103a0..8f062f7e8 100644 --- a/server/src/nest/plugins/protocol/output-contract.ts +++ b/server/src/nest/plugins/protocol/output-contract.ts @@ -67,10 +67,10 @@ export const PLUGIN_ENTITY_CONTRACT = { 'reminder_sent_for', 'costs_mode', ], - // The sole credential of the anonymous calendar feed. - withheld: ['feed_token'], + // Keep the calendar credential and internal tag serialization out of the plugin API. + withheld: ['feed_token', 'tags_json'], wholeRow: true, - derived: ['day_count', 'place_count', 'is_owner', 'owner_username', 'shared_count'], + derived: ['day_count', 'place_count', 'is_owner', 'owner_username', 'shared_count', 'tags'], }, place: { table: 'places', diff --git a/server/src/nest/trips/trips.helpers.ts b/server/src/nest/trips/trips.helpers.ts index 5fe0c7a26..2d9dfc234 100644 --- a/server/src/nest/trips/trips.helpers.ts +++ b/server/src/nest/trips/trips.helpers.ts @@ -35,7 +35,16 @@ export function withoutFeedToken(row: T): T { } /** The fields of a trip update that count as an edit, as against archiving it or changing its cover. */ -const TRIP_EDIT_FIELDS = ['title', 'description', 'tags', 'start_date', 'end_date', 'currency', 'reminder_days', 'day_count']; +const TRIP_EDIT_FIELDS = [ + 'title', + 'description', + 'tags', + 'start_date', + 'end_date', + 'currency', + 'reminder_days', + 'day_count', +]; /** * The permissions a trip update needs, in the order PUT /api/trips/:id checks diff --git a/server/src/nest/trips/trips.mcp.ts b/server/src/nest/trips/trips.mcp.ts index 9a5edb357..11c0934ad 100644 --- a/server/src/nest/trips/trips.mcp.ts +++ b/server/src/nest/trips/trips.mcp.ts @@ -262,9 +262,21 @@ export class TripsMcp { costs_mode: tripUpdateRequestSchema.shape.costs_mode.describe( 'How the trip keeps its costs: split (who paid and who shares each expense, with settling up) or totals (what the trip costs, nothing split). Who paid and the shares stay stored either way. Needs the budget_edit permission rather than trip_edit', ), - tags: tripTagNamesSchema.optional().describe('Replace all custom tags on the trip. Send an empty array to clear them. Cannot be combined with add_tags or remove_tags'), - add_tags: tripTagNamesSchema.optional().describe('Assign existing or new custom tags to the trip, keeping its other tags. Tag names are matched case-insensitively'), - remove_tags: tripTagNamesSchema.optional().describe('Remove these custom tags from this trip only. Other tags stay assigned. Removals apply before additions'), + tags: tripTagNamesSchema + .optional() + .describe( + 'Replace all custom tags on the trip. Send an empty array to clear them. Cannot be combined with add_tags or remove_tags', + ), + add_tags: tripTagNamesSchema + .optional() + .describe( + 'Assign existing or new custom tags to the trip, keeping its other tags. Tag names are matched case-insensitively', + ), + remove_tags: tripTagNamesSchema + .optional() + .describe( + 'Remove these custom tags from this trip only. Other tags stay assigned. Removals apply before additions', + ), }, annotations: TOOL_ANNOTATIONS_WRITE, access: { group: 'trips', mode: 'write' }, @@ -329,7 +341,9 @@ export class TripsMcp { }; // The rights PUT /api/trips/:id asks for, field by field: archiving, the cover and the costs mode have their own. const granted = await Promise.all( - tripUpdatePermissions({ ...fields, tags: tags ?? add_tags ?? remove_tags }).map(({ action }) => this.guards.hasTripPermission(action, tripId, ctx.userId)), + tripUpdatePermissions({ ...fields, tags: tags ?? add_tags ?? remove_tags }).map(({ action }) => + this.guards.hasTripPermission(action, tripId, ctx.userId), + ), ); if (granted.includes(false)) return permissionDenied(); if (tags !== undefined && (add_tags !== undefined || remove_tags !== undefined)) @@ -425,7 +439,9 @@ export class TripsMcp { const notice = ctx.getDeprecationNotice ? ctx.getDeprecationNotice() : null; const accessible = await this.trips.list(ctx.userId, include_archived ? null : 0); const tagKey = tag ? tripTagKey(tag) : null; - const trips = tagKey ? accessible.filter(trip => trip.tags?.some(name => tripTagKey(name) === tagKey)) : accessible; + const trips = tagKey + ? accessible.filter((trip) => trip.tags?.some((name) => tripTagKey(name) === tagKey)) + : accessible; if (notice) return { isError: true as const, diff --git a/server/tests/unit/db/legacy-baseline.test.ts b/server/tests/unit/db/legacy-baseline.test.ts index 9b99f0164..92246d9c7 100644 --- a/server/tests/unit/db/legacy-baseline.test.ts +++ b/server/tests/unit/db/legacy-baseline.test.ts @@ -130,6 +130,7 @@ const UNNUMBERED = [ 'Migration20200101046620_a_journey_link_can_ask_for_a_password_and_run_out', 'Migration20200101046630_a_journey_gathers_comments_and_followers', 'Migration20200101046640_bahrain_flights_keep_bahrain_time', + 'Migration20200101046650_trips_can_carry_custom_tags', ]; // The last step the positional runner ever had; planLegacyBaseline refuses a // schema_version past it. diff --git a/server/tests/unit/db/repositories/Reservations.repository.test.ts b/server/tests/unit/db/repositories/Reservations.repository.test.ts index 14eaa6bef..74729a62f 100644 --- a/server/tests/unit/db/repositories/Reservations.repository.test.ts +++ b/server/tests/unit/db/repositories/Reservations.repository.test.ts @@ -98,7 +98,9 @@ describe('ReservationsRepository — CL1 (findRaw, existing method reused by cal // test-sql-allow: the legacy statement is the oracle the repository read is held to. const legacy = testDb.prepare('SELECT * FROM trips WHERE id = ?').get(trip.id); - expect(typed).toEqual(legacy); + const { tags_json, ...tripFields } = legacy as Record; + expect(tags_json).toBeNull(); + expect(typed).toEqual({ ...tripFields, tags: [] }); }); }); diff --git a/server/tests/unit/db/repositories/Trips.repository.test.ts b/server/tests/unit/db/repositories/Trips.repository.test.ts index fab7b5aec..95f345183 100644 --- a/server/tests/unit/db/repositories/Trips.repository.test.ts +++ b/server/tests/unit/db/repositories/Trips.repository.test.ts @@ -13,6 +13,10 @@ import type { EntityData } from '@mikro-orm/core'; import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest'; +function expectedTrip({ tags_json, ...fields }: Record) { + return { ...fields, tags: typeof tags_json === 'string' ? JSON.parse(tags_json) : [] }; +} + const testDb = createSnapshotTestDb(); let t: TestOrm; let trips: TripsRepository; @@ -238,7 +242,7 @@ describe('TripsRepository — TripMembersService / TripReadModelService (Plan 3c // test-sql-allow: the legacy statement is the oracle the repository read is held to. const legacyRow = testDb.prepare('SELECT * FROM trips WHERE id = ?').get(trip.id); const row = await trips.findRaw(trip.id); - expect(row).toEqual(legacyRow); + expect(row).toEqual(expectedTrip(legacyRow as Record)); expect(row?.feed_token).toBe('secret-token'); }); @@ -329,7 +333,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task ) .get({ userId: owner.id, tripId: trip.id }); const row = await trips.findForViewer(trip.id, owner.id); - expect(row).toEqual(legacyOwner); + expect(row).toEqual(expectedTrip(legacyOwner as Record)); // createTrip's own start_date/end_date span already generates 5 days; // the two explicit createDay calls above add 2 more, for 7 total. expect(row).toMatchObject({ @@ -356,7 +360,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task ) .get({ userId: member.id, tripId: trip.id }); const memberRow = await trips.findForViewer(trip.id, member.id); - expect(memberRow).toEqual(legacyMember); + expect(memberRow).toEqual(expectedTrip(legacyMember as Record)); expect(memberRow).toMatchObject({ is_owner: 0, day_count: 7, place_count: 3, shared_count: 1 }); }); @@ -376,7 +380,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task ) .get({ userId: owner.id, tripId: trip.id }); const row = await trips.findForViewer(trip.id, owner.id); - expect(row).toEqual(legacy); + expect(row).toEqual(expectedTrip(legacy as Record)); expect(row).toMatchObject({ description: null, start_date: null, @@ -429,7 +433,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task ) .all({ userId: owner.id }); const rows = await trips.listForUser(owner.id, null); - expect(rows).toEqual(legacy); + expect(rows).toEqual(legacy.map(row => expectedTrip(row as Record))); expect(rows.map((r) => r.id).sort()).toEqual([owned.id, shared.id, archived.id].sort()); }); @@ -450,7 +454,7 @@ describe('TripsRepository.findForViewer / listForUser / activeTrip (Plan 3c Task `, ) .all({ userId: owner.id, archived: 1 }); - expect(await trips.listForUser(owner.id, 1)).toEqual(legacyArchived); + expect(await trips.listForUser(owner.id, 1)).toEqual(legacyArchived.map(row => expectedTrip(row as Record))); expect((await trips.listForUser(owner.id, 1)).map((r) => r.id)).toEqual([archived.id]); expect((await trips.listForUser(owner.id, 0)).map((r) => r.id)).toEqual([active.id]); }); @@ -1082,7 +1086,7 @@ describe('TripsRepository.listOwnedOrMember — AT1 parity with the legacy state const legacy = testDb.prepare(LEGACY_OWNED_OR_MEMBER).all(caller.id, caller.id, caller.id); const rows = await trips.listOwnedOrMember(caller.id); - expect(rows).toEqual(legacy); + expect(rows).toEqual(legacy.map(row => expectedTrip(row as Record))); expect(rows.map((r) => r.id)).toEqual([memberOf.id, owned.id]); }); diff --git a/server/tests/unit/mcp/tools-trips.test.ts b/server/tests/unit/mcp/tools-trips.test.ts index decbffb90..9c643123f 100644 --- a/server/tests/unit/mcp/tools-trips.test.ts +++ b/server/tests/unit/mcp/tools-trips.test.ts @@ -308,9 +308,13 @@ describe('Tool: update_trip', () => { arguments: { tripId: trip.id, remove_tags: ['work'], add_tags: [' FAMILY ', 'City break'] }, }); expect(parseToolResult(result)).toMatchObject({ trip: { title: 'Weekend', tags: ['Family', 'City break'] } }); - expect(broadcastMock).toHaveBeenCalledWith(trip.id, 'trip:updated', expect.objectContaining({ - trip: expect.objectContaining({ tags: ['Family', 'City break'] }), - })); + expect(broadcastMock).toHaveBeenCalledWith( + trip.id, + 'trip:updated', + expect.objectContaining({ + trip: expect.objectContaining({ tags: ['Family', 'City break'] }), + }), + ); }); });