Align trip tags and desktop UI with CI contracts

This commit is contained in:
Maurice
2026-12-05 12:24:04 +01:00
parent 3cd22b91ff
commit 53198b4d58
47 changed files with 685 additions and 515 deletions
+4
View File
@@ -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$/);
+4 -4
View File
@@ -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
+5 -10
View File
@@ -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,
@@ -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'
@@ -55,7 +55,7 @@ describe('CollabLinks', () => {
render(<CollabLinks tripId={1} />);
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();
});
@@ -16,7 +16,7 @@ describe('CollabPanelHead', () => {
const { rerender } = render(<CollabPanelHead icon={StickyNote} title="Notes" count={0} />);
expect(screen.queryByText('0')).toBeNull();
rerender(<CollabPanelHead icon={StickyNote} title="Notes" />);
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 () => {
@@ -530,7 +530,7 @@ describe('FileManager', () => {
const onUpload = vi.fn().mockResolvedValue({ file: { id: 56 } });
render(<FileManager {...defaultProps} onUpload={onUpload} />);
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', {
+2 -5
View File
@@ -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');
+2 -2
View File
@@ -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<boolean>(false)
+13 -5
View File
@@ -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 (
<button
@@ -17,5 +25,5 @@ export function AddRouteStop({ onClick, label, mobile = false }: { onClick: () =
</span>
{label}
</button>
)
);
}
@@ -5172,7 +5172,7 @@ describe('the day route-tools row', () => {
const day = buildDay({ id: 10, date: '2025-06-01', title: null })
render(<DayPlanSidebar {...makeDefaultProps({ days: [day], assignments: {} })} />)
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')
})
})
@@ -2531,7 +2531,7 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
<span className="whitespace-nowrap [@container(max-width:340px)]:hidden">{t('dayplan.route')}</span>
</button>
{/* The day's travel mode as one segmented control. */}
<div role="group" aria-label={t('dayplan.transportMode.change')}
<div role="group" aria-label={t('dayplan.route')}
className={`inline-flex h-8 flex-none items-center gap-1 rounded-[10px] px-1 ${ROUTE_TOOL}`}>
{routeProfileOptions.map(p => {
const ModeIcon = routeModeIcon(p.key)
@@ -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\)\]/)
})
})
@@ -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.')
@@ -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(<PlaceFormModal {...defaultProps} />);
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', () => {
@@ -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(<PlaceInspector {...defaultProps} files={[]} />);
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');
});
})
@@ -397,20 +397,7 @@ export default function PlaceInspector({
<div data-testid="inspector-scroll" className={`trek-desktop-panel trek-place-inspector-body ${collapsed ? 'hidden' : 'flex'} min-h-0 flex-1 flex-col gap-3 overflow-y-auto overscroll-contain bg-surface-card px-4 py-3 empty:hidden`}>
{(showRating || showParticipants) && (
<div className={DETAIL_GRID}>
{showRating && (
<DialogSection icon={Star} className={mode === 'trip' && onRate ? undefined : 'hidden md:block'} label={t('places.details.fact.rating')}>
<div className="flex flex-col gap-1.5">
{mode === 'trip' && onRate && (
<div className={`${BOX} px-3 py-2`}>
<PlaceRating ratings={place.ratings ?? []} ratingAvg={place.rating_avg} onRate={rating => onRate(place.id, rating)} />
</div>
)}
{shortReview && (
<p className="m-0 hidden italic text-content-muted md:block" style={{ ...fs(12, 'body'), overflowWrap: 'anywhere' }}>„{shortReview.text}"</p>
)}
</div>
</DialogSection>
)}
{showRating && <InspectorRating place={place} review={shortReview?.text} onRate={mode === 'trip' ? onRate : undefined} />}
{showParticipants && (
<ParticipantsBox tripMembers={tripMembers} participantIds={participantIds} allJoined={participantIds.length === 0}
onSetParticipants={onSetParticipants} selectedAssignmentId={selectedAssignmentId} selectedDayId={selectedDayId} />
@@ -570,6 +557,24 @@ export default function PlaceInspector({
)
}
function InspectorRating({ place, review, onRate }: { place: Place; review?: string; onRate?: PlaceInspectorProps['onRate'] }) {
const { t } = useTranslation()
return (
<DialogSection icon={Star} className={onRate ? undefined : 'hidden md:block'} label={t('places.details.fact.rating')}>
<div className="flex flex-col gap-1.5">
{onRate && (
<div className={`${BOX} px-3 py-2`}>
<PlaceRating ratings={place.ratings ?? []} ratingAvg={place.rating_avg} onRate={rating => onRate(place.id, rating)} />
</div>
)}
{review && (
<p className="m-0 hidden italic text-content-muted md:block" style={{ ...fs(12, 'body'), overflowWrap: 'anywhere' }}>„{review}"</p>
)}
</div>
</DialogSection>
)
}
/** Markdown in a framed box; it wraps long words instead of pushing the card wider. */
function MarkdownBox({ children }: { children: string }) {
return (
@@ -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;
});
@@ -124,10 +124,7 @@ function Row({ r, p, facts, files, costs, t, locale, onNavigate }: {
</div>
)}
</div>
<div className="text-end tabular-nums">
<div className="font-geist text-content-faint" style={fs(11)}>{facts.day ? [facts.day.label, facts.day.date].filter(Boolean).join(' ') : t('reservations.undated')}</div>
{facts.time && <div className="font-semibold text-content" style={fs(12.5, 'body')}>{facts.time}</div>}
</div>
<BookingRowWhen day={facts.day} time={facts.time} undated={t('reservations.undated')} />
<div className="flex items-center justify-end gap-1.5">
<TravelerStack travelers={r.travelers || []} />
{p.canEdit && <RoundAction label={t('common.edit')} onClick={() => p.onEdit(r)}><Pencil size={12} strokeWidth={2} /></RoundAction>}
@@ -136,3 +133,12 @@ function Row({ r, p, facts, files, costs, t, locale, onNavigate }: {
</div>
)
}
function BookingRowWhen({ day, time, undated }: Pick<BookingFacts, 'day' | 'time'> & { undated: string }) {
return (
<div className="text-end tabular-nums">
<div className="font-geist text-content-faint" style={fs(11)}>{day ? [day.label, day.date].filter(Boolean).join(' ') : undated}</div>
{time && <div className="font-semibold text-content" style={fs(12.5, 'body')}>{time}</div>}
</div>
)
}
@@ -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', () => {
@@ -14,7 +14,7 @@ describe('FigureBadge', () => {
const { container } = render(<FigureBadge lead={<Footprints size={10} aria-hidden />} 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')
@@ -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 (
<div
className="flex h-[32px] flex-shrink-0 items-center gap-2 rounded-xl border border-edge bg-surface-card pe-1.5 ps-3 text-content-muted"
role="progressbar"
aria-valuenow={progressPct}
aria-valuemin={0}
aria-valuemax={100}
>
<RotateCw size={13} className="animate-spin" aria-hidden />
<span className="min-w-0 truncate font-medium" style={{ fontSize: FS.control }}>
{t('roadtrip.poi.searching', { done, total })}
</span>
<span
className="ms-auto inline-flex h-[22px] shrink-0 items-center rounded-full bg-inverse px-2 font-geist font-semibold tabular-nums tracking-[0.08em] text-inverse-text"
style={{ fontSize: FS.micro }}
>
{`${progressPct}%`}
</span>
</div>
)
}
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 ? (
<div
className="flex h-[32px] flex-shrink-0 items-center gap-2 rounded-xl border border-edge bg-surface-card pe-1.5 ps-3 text-content-muted"
role="progressbar"
aria-valuenow={progressPct}
aria-valuemin={0}
aria-valuemax={100}
>
<RotateCw size={13} className="animate-spin" aria-hidden />
<span className="min-w-0 truncate font-medium" style={{ fontSize: FS.control }}>
{t('roadtrip.poi.searching', { done: search.progress.done, total: search.progress.total })}
</span>
<span
className="ms-auto inline-flex h-[22px] shrink-0 items-center rounded-full bg-inverse px-2 font-geist font-semibold tabular-nums tracking-[0.08em] text-inverse-text"
style={{ fontSize: FS.micro }}
>
{`${progressPct}%`}
</span>
</div>
) : null}
{search.loading && <CorridorSearchProgress done={search.progress.done} total={search.progress.total} progressPct={progressPct} />}
{warnings.length > 0 ? (
<div className="flex flex-shrink-0 flex-col gap-1.5">
@@ -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'
@@ -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')
})
})
@@ -1397,7 +1397,7 @@ describe('RoadtripSidebar with a hire car and the day\'s bookings (#2428)', () =
const onOpenBooking = vi.fn()
wrap(<RoadtripSidebar routes={routes({ days: [day({ stops })], totalStops: 2 })} reservations={reservations} onOpenBooking={onOpenBooking} />)
// 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'))
@@ -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(<ModalRenderer notices={[makeNotice()]} />);
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(<ModalRenderer notices={[makeNotice()]} />);
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));
@@ -535,7 +535,7 @@ describe('TripFormModal', () => {
render(<TripFormModal {...defaultProps} trip={null} />);
// 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);
});
+163 -125
View File
@@ -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 (
<div className={`flex min-w-0 flex-wrap gap-1.5 ${className}`} title={tags.join(', ')}>
{tags.slice(0, limit).map(tag => (
<span key={tripTagKey(tag)} className={chipClassName}><span dir="auto" className="truncate">{tag}</span></span>
{tags.slice(0, limit).map((tag) => (
<span key={tripTagKey(tag)} className={chipClassName}>
<span dir="auto" className="truncate">
{tag}
</span>
</span>
))}
{tags.length > limit && <span className={chipClassName}>+{tags.length - limit}</span>}
</div>
)
);
}
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<string>, 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<HTMLInputElement>(null)
const rowRef = useRef<HTMLDivElement | null>(null)
const boundaryRef = useRef<HTMLElement | null>(null)
const menuRef = useRef<HTMLDivElement>(null)
const request = useRef<Promise<unknown> | null>(null)
const [active, setActive] = useState(false)
const [highlighted, setHighlighted] = useState(-1)
const [options, setOptions] = useState<string[]>([])
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<HTMLInputElement>(null);
const rowRef = useRef<HTMLDivElement | null>(null);
const boundaryRef = useRef<HTMLElement | null>(null);
const menuRef = useRef<HTMLDivElement>(null);
const request = useRef<Promise<unknown> | null>(null);
const [active, setActive] = useState(false);
const [highlighted, setHighlighted] = useState(-1);
const [options, setOptions] = useState<string[]>([]);
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<HTMLElement>('.overflow-y-auto') ?? null
}, [])
rowRef.current = row;
boundaryRef.current = row?.closest<HTMLElement>('.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 (
<div className={className}>
<div className={labelClass}>{t('mobileJourney.tags')}</div>
<TripTagChips tags={tags} className="mt-1.5" />
</div>
)
);
}
return (
<div
className={`relative space-y-2 ${className}`}
onBlur={event => {
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
? <span className={labelClass}>{t('mobileJourney.tags')}</span>
: <label htmlFor={id} className={labelClass}>{t('mobileJourney.tags')}</label>}
{atLimit ? (
<span className={labelClass}>{t('mobileJourney.tags')}</span>
) : (
<label htmlFor={id} className={labelClass}>
{t('mobileJourney.tags')}
</label>
)}
{tags.length > 0 && (
<div className="flex min-w-0 flex-wrap gap-1.5">
{tags.map(tag => (
<span key={tripTagKey(tag)} className={`trek-form-chip ${selectedChip} pe-0 py-0`}>
<span className="truncate" dir="auto" title={tag}>{tag}</span>
{tags.map((tag) => (
<span key={tripTagKey(tag)} className={`trek-form-chip ${selectedChip} py-0 pe-0`}>
<span className="truncate" dir="auto" title={tag}>
{tag}
</span>
<button
type="button"
aria-label={`${t('common.remove')}: ${tag}`}
onClick={() => onChange(tags.filter(name => tripTagKey(name) !== tripTagKey(tag)))}
onClick={() => onChange(tags.filter((name) => tripTagKey(name) !== tripTagKey(tag)))}
className="grid size-8 shrink-0 place-items-center rounded-full hover:opacity-75 focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-4 focus-visible:outline-current"
>
<X size={14} aria-hidden />
@@ -135,33 +162,40 @@ export function TripTagField({ tags, draft, onChange, onDraftChange, readOnly, i
aria-expanded={menuOpen}
aria-controls={menuOpen ? menuId : undefined}
aria-activedescendant={activeTag ? `${menuId}-${highlighted}` : undefined}
onChange={event => {
onDraftChange(event.target.value)
setActive(true)
setHighlighted(-1)
onChange={(event) => {
onDraftChange(event.target.value);
setActive(true);
setHighlighted(-1);
}}
onFocus={() => {
setActive(true)
request.current ??= tripRepo.list()
setActive(true);
request.current ??= tripRepo
.list()
.then(({ trips, archivedTrips }) => setOptions(tripTagOptions([...trips, ...archivedTrips], locale)))
.catch(() => { request.current = null })
.catch(() => {
request.current = null;
});
}}
onKeyDown={event => {
if (event.nativeEvent.isComposing) return
onKeyDown={(event) => {
if (event.nativeEvent.isComposing) return;
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && suggestions.length) {
event.preventDefault()
const backwards = event.key === 'ArrowUp'
const last = suggestions.length - 1
event.preventDefault();
const backwards = event.key === 'ArrowUp';
const last = suggestions.length - 1;
const next = backwards
? highlighted <= 0 ? last : highlighted - 1
: highlighted >= last ? 0 : highlighted + 1
setActive(true)
setHighlighted(next)
menuRef.current?.children[next]?.scrollIntoView({ block: 'nearest' })
? highlighted <= 0
? last
: highlighted - 1
: highlighted >= last
? 0
: highlighted + 1;
setActive(true);
setHighlighted(next);
menuRef.current?.children[next]?.scrollIntoView({ block: 'nearest' });
}
if (event.key === 'Enter' && (activeTag || draftKey)) {
event.preventDefault()
if (activeTag || canAdd) add(activeTag ?? draft)
event.preventDefault();
if (activeTag || canAdd) add(activeTag ?? draft);
}
}}
className={`min-w-0 flex-1 ${inputClass}`}
@@ -178,35 +212,39 @@ export function TripTagField({ tags, draft, onChange, onDraftChange, readOnly, i
</button>
</div>
)}
{menuOpen && position && createPortal(
<div
ref={menuRef}
id={menuId}
className="trek-select-menu fixed z-[99999] flex flex-wrap content-start gap-1.5 overflow-y-auto overscroll-contain rounded-xl border border-edge bg-surface-card p-2 shadow-lg"
data-side={flipped ? 'top' : 'bottom'}
style={menuStyle}
role="listbox"
aria-label={t('dashboard.tags.existing')}
>
{suggestions.map((tag, index) => (
<button
type="button"
key={tripTagKey(tag)}
id={`${menuId}-${index}`}
role="option"
aria-selected={index === highlighted}
tabIndex={-1}
className={`${chip} min-h-8 border border-edge text-content hover:bg-surface-hover ${index === highlighted ? 'bg-surface-hover' : 'bg-surface-card'}`}
onMouseDown={event => event.preventDefault()}
onClick={() => add(tag)}
>
<Plus className="shrink-0" size={12} aria-hidden />
<span dir="auto" className="truncate">{tag}</span>
</button>
))}
</div>,
document.body,
)}
{menuOpen &&
position &&
createPortal(
<div
ref={menuRef}
id={menuId}
className="trek-select-menu fixed z-[var(--z-overlay)] flex flex-wrap content-start gap-1.5 overflow-y-auto overscroll-contain rounded-xl border border-edge bg-surface-card p-2 shadow-lg"
data-side={flipped ? 'top' : 'bottom'}
style={menuStyle}
role="listbox"
aria-label={t('dashboard.tags.existing')}
>
{suggestions.map((tag, index) => (
<button
type="button"
key={tripTagKey(tag)}
id={`${menuId}-${index}`}
role="option"
aria-selected={index === highlighted}
tabIndex={-1}
className={`${chip} min-h-8 border border-edge text-content hover:bg-surface-hover ${index === highlighted ? 'bg-surface-hover' : 'bg-surface-card'}`}
onMouseDown={(event) => event.preventDefault()}
onClick={() => add(tag)}
>
<Plus className="shrink-0" size={12} aria-hidden />
<span dir="auto" className="truncate">
{tag}
</span>
</button>
))}
</div>,
document.body
)}
</div>
)
);
}
+20 -15
View File
@@ -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 = <Tag size={14} aria-hidden />
const { t } = useTranslation();
if (!tags.length) return null;
const icon = <Tag size={14} aria-hidden />;
return (
<div className={`min-w-0 max-w-48 ${className}`}>
<CustomSelect
ariaLabel={t('dashboard.tags.filter')}
value={selected}
onChange={value => 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}
/>
</div>
)
);
}
+4 -6
View File
@@ -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 };
}
@@ -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);
-233
View File
@@ -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)); }
}
+1
View File
@@ -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'
@@ -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<typeof useTranslation>['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 ? <Check size={18} /> : <Tag size={18} />,
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: <CalendarPlus size={18} />, 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 ? <Check size={18} /> : <Tag size={18} />,
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).
+1 -1
View File
@@ -212,7 +212,7 @@ export default function AdminUsersTab({ admin, t, locale }: AdminUsersTabProps):
<DialogFooter>
<FooterSpacer />
<DialogButton onClick={() => setShowCreateInvite(false)}>{t('common.cancel')}</DialogButton>
<DialogButton variant="primary" onClick={handleCreateInvite} icon={<Copy size={14} strokeWidth={2.1} />}>
<DialogButton variant="primary" onClick={() => void handleCreateInvite()} icon={<Copy size={14} strokeWidth={2.1} />}>
{t('admin.invite.createAndCopy')}
</DialogButton>
</DialogFooter>
+294
View File
@@ -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;
}
}
@@ -60,6 +60,9 @@ function buildDash(over: Record<string, unknown> = {}): Record<string, unknown>
loadError: false,
retryLoad: vi.fn(),
tripFilter: 'planned',
tagOptions: [],
selectedTag: '',
setTripTagFilter: vi.fn(),
setTripFilter: vi.fn(),
viewMode: 'grid',
toggleViewMode: vi.fn(),
+1
View File
@@ -442,6 +442,7 @@ export const PLUGIN_ENTITY_FIELDS = {
'is_owner',
'owner_username',
'shared_count',
'tags',
],
place: [
'id',
+2 -2
View File
@@ -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<AssistantAttachments>(this);
assistant_threads_collection = new Collection<AssistantThreads>(this);
budget_category_order_collection = new Collection<BudgetCategoryOrder>(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(),
@@ -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';
@@ -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',
+10 -1
View File
@@ -35,7 +35,16 @@ export function withoutFeedToken<T>(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
+21 -5
View File
@@ -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,
@@ -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.
@@ -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<string, unknown>;
expect(tags_json).toBeNull();
expect(typed).toEqual({ ...tripFields, tags: [] });
});
});
@@ -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<string, unknown>) {
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<string, unknown>));
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<string, unknown>));
// 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<string, unknown>));
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<string, unknown>));
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<string, unknown>)));
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<string, unknown>)));
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<string, unknown>)));
expect(rows.map((r) => r.id)).toEqual([memberOf.id, owned.id]);
});
+7 -3
View File
@@ -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'] }),
}),
);
});
});