From 714fc6beaf4b47087ef36a1b22e016e941ed7023 Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 30 Nov 2026 22:10:01 +0100 Subject: [PATCH] fix(journey): give the entry photo picker its own dialog The entry editor capped the provider picker in a small panel, so filters and competing footers displaced the photo grid. Open the picker over the editor at the available height on desktop and at full screen on mobile. Keep queued photos and draft edits in the editor until it is saved. Closes #3266 --- client/scripts/size-baseline.json | 2 +- client/scripts/theme-baseline.json | 4 +- .../JourneyDetailPageEntryEditor.test.tsx | 33 ++-- .../Journey/JourneyDetailPageEntryEditor.tsx | 125 ++++--------- .../JourneyDetailPageProviderPicker.test.tsx | 7 +- .../JourneyDetailPageProviderPicker.tsx | 172 +++++++++++------- .../components/Journey/useJourneyEntryForm.ts | 21 +++ client/src/components/shared/DialogShell.tsx | 12 +- client/src/mobile/components/MSheet.tsx | 21 ++- .../screens/journey/MJourneyEntrySheet.tsx | 149 ++++++--------- client/src/pages/JourneyDetailPage.test.tsx | 12 +- .../journey/MJourneyEntrySheet.test.tsx | 19 +- 12 files changed, 289 insertions(+), 288 deletions(-) diff --git a/client/scripts/size-baseline.json b/client/scripts/size-baseline.json index 6e880c4b4..8f908e437 100644 --- a/client/scripts/size-baseline.json +++ b/client/scripts/size-baseline.json @@ -17,7 +17,7 @@ "src/components/Studio/countryShapes.ts": 2595, "src/index.css": 1636, "src/mobile/screens/admin/MAdminPluginsPanel.tsx": 1503, - "src/pages/JourneyDetailPage.test.tsx": 3886, + "src/pages/JourneyDetailPage.test.tsx": 3880, "src/pages/LoginPage.tsx": 1273, "src/pages/TripPlannerPage.tsx": 1127, "src/pages/tripPlanner/useTripPlanner.roadtrip.test.tsx": 3518, diff --git a/client/scripts/theme-baseline.json b/client/scripts/theme-baseline.json index 0e6fe135c..380d752d7 100644 --- a/client/scripts/theme-baseline.json +++ b/client/scripts/theme-baseline.json @@ -36,7 +36,7 @@ "components/Journey/JourneyDetailPageGalleryView.tsx": 15, "components/Journey/JourneyDetailPageMapView.tsx": 50, "components/Journey/JourneyDetailPagePhotoGrid.tsx": 6, - "components/Journey/JourneyDetailPageProviderPicker.tsx": 163, + "components/Journey/JourneyDetailPageProviderPicker.tsx": 161, "components/Journey/JourneyDetailPageScrollTrigger.tsx": 4, "components/Journey/JourneyDetailPageVerdictSection.tsx": 51, "components/Journey/JourneyEntryCover.tsx": 13, @@ -182,7 +182,7 @@ "mobile/screens/journey/MJourney.tsx": 10, "mobile/screens/journey/MJourneyCreateSheet.tsx": 7, "mobile/screens/journey/MJourneyDetail.tsx": 6, - "mobile/screens/journey/MJourneyEntrySheet.tsx": 48, + "mobile/screens/journey/MJourneyEntrySheet.tsx": 46, "mobile/screens/journey/MJourneySettingsSheet.tsx": 2, "mobile/screens/journey/mobileJourneyMeta.ts": 4, "mobile/screens/notifications/MNotificationRow.tsx": 4, diff --git a/client/src/components/Journey/JourneyDetailPageEntryEditor.test.tsx b/client/src/components/Journey/JourneyDetailPageEntryEditor.test.tsx index 443f07f56..27367aa78 100644 --- a/client/src/components/Journey/JourneyDetailPageEntryEditor.test.tsx +++ b/client/src/components/Journey/JourneyDetailPageEntryEditor.test.tsx @@ -469,7 +469,7 @@ describe('EntryEditor', () => { await user.click(screen.getByRole('button', { name: /Upload photos/ })) await user.click(screen.getByRole('button', { name: 'External photos' })) - expect(await screen.findByTestId('journey-external-provider-immich')).toBeInTheDocument() + expect(await screen.findByRole('dialog', { name: 'Immich' })).toBeVisible() }) it('FE-JRN-EDITOR-020: queues photos picked from a connected provider and clears them again', async () => { @@ -478,8 +478,11 @@ describe('EntryEditor', () => { mountEditor(buildEntry({ id: 10, location_lat: 41.9, location_lng: 12.5, location_name: 'Rome' })) await user.click(screen.getByRole('button', { name: 'External photos' })) - expect(await screen.findByTestId('journey-external-provider-immich')).toBeInTheDocument() - expect(screen.getByText('Nearby photos first: Rome')).toBeInTheDocument() + const picker = await screen.findByRole('dialog', { name: 'Immich' }) + expect(picker).toHaveClass('h-full') + expect(screen.getByRole('button', { name: 'Cancel' })).toBeVisible() + expect(screen.queryByRole('button', { name: 'Save' })).not.toBeInTheDocument() + expect(picker).toHaveTextContent('Nearby photos first Rome') expect(screen.getByText('Photos for Mar 15, 2026')).toBeInTheDocument() await user.click(await screen.findByAltText('')) @@ -720,13 +723,15 @@ describe('EntryEditor', () => { await user.click(screen.getByRole('button', { name: 'Add (1)' })) await screen.findByRole('button', { name: /1 queued Clear/ }) + await user.click(screen.getByRole('button', { name: 'External photos' })) await user.click(screen.getByTestId('journey-external-provider-photoprism')) - expect(screen.getByTestId('journey-external-provider-photoprism').className).toContain('bg-accent') + expect(screen.getByTestId('journey-external-provider-photoprism')).toHaveAttribute('aria-pressed', 'true') - // The picker's own cancel drops back to the first available provider. - await user.click(screen.getAllByRole('button', { name: 'Cancel' })[0]) - expect(screen.getByTestId('journey-external-provider-photoprism').className).not.toContain('bg-accent') + await user.keyboard('{Escape}') + expect(screen.queryByRole('dialog', { name: 'PhotoPrism' })).not.toBeInTheDocument() expect(screen.getByRole('button', { name: /1 queued Clear/ })).toBeInTheDocument() + await user.click(screen.getByRole('button', { name: 'External photos' })) + expect(screen.getByTestId('journey-external-provider-immich')).toHaveAttribute('aria-pressed', 'true') }) it('FE-JRN-EDITOR-033: merges a second pick into the already queued group', async () => { @@ -755,12 +760,14 @@ describe('EntryEditor', () => { await user.click(screen.getByRole('button', { name: 'Add (1)' })) await screen.findByRole('button', { name: /1 queued Clear/ }) - // The first asset stays selected but is now greyed out, so the second Add - // re-sends it and the merge has to skip the duplicate. - const remaining = screen.getAllByAltText('').find(img => !img.parentElement!.className.includes('opacity-40'))! + // The first asset is already queued, so it remains unavailable on reopening. + await user.click(screen.getByRole('button', { name: 'External photos' })) + const reopened = await screen.findAllByAltText('') + expect(reopened.find(img => assetIdOf(img) === firstId)?.parentElement).toBeDisabled() + const remaining = reopened.find(img => assetIdOf(img) !== firstId)! const secondId = assetIdOf(remaining) await user.click(remaining) - await user.click(screen.getByRole('button', { name: 'Add (2)' })) + await user.click(screen.getByRole('button', { name: 'Add (1)' })) expect(await screen.findByRole('button', { name: /2 queued Clear/ })).toBeInTheDocument() await user.click(screen.getByRole('button', { name: 'Save' })) @@ -782,7 +789,7 @@ describe('EntryEditor', () => { })) await user.click(screen.getByRole('button', { name: 'External photos' })) - await screen.findByTestId('journey-external-provider-immich') + await screen.findByRole('dialog', { name: 'Immich' }) await waitFor(() => expect(document.querySelector('.opacity-40')).toBeInTheDocument()) expect(screen.queryByRole('button', { name: /Select all/ })).not.toBeInTheDocument() @@ -796,7 +803,7 @@ describe('EntryEditor', () => { await user.click(screen.getByRole('button', { name: 'External photos' })) expect(await screen.findByText('All photos from this day')).toBeInTheDocument() - expect(await screen.findByTestId('journey-external-provider-immich')).toBeInTheDocument() + expect(await screen.findByRole('dialog', { name: 'Immich' })).toBeVisible() }) it('FE-JRN-EDITOR-040: ignores a link call that comes back without a photo', async () => { diff --git a/client/src/components/Journey/JourneyDetailPageEntryEditor.tsx b/client/src/components/Journey/JourneyDetailPageEntryEditor.tsx index 4b4b543f0..67174b47a 100644 --- a/client/src/components/Journey/JourneyDetailPageEntryEditor.tsx +++ b/client/src/components/Journey/JourneyDetailPageEntryEditor.tsx @@ -26,7 +26,7 @@ const CHIP_OFF = 'border-edge-faint bg-surface-card text-content-muted hover:tex const SOURCE = 'flex items-center justify-center gap-1.5 rounded-[12px] border py-4 font-medium disabled:cursor-default disabled:opacity-50' const SOURCE_OFF = 'border-dashed border-edge text-content-muted hover:border-content-faint hover:bg-surface-secondary hover:text-content' const SOURCE_ON = 'border-content bg-surface-secondary text-content' -/** The panel a photo source opens under the buttons: the gallery grid, the provider browser. */ +/** The gallery grid under the source buttons. */ const PHOTO_PANEL = 'mt-2 rounded-[12px] border border-edge-faint bg-surface-secondary' /** A control laid over a photo tile, raised on the card colour so it reads on any picture. */ const ON_PHOTO = 'bg-surface-card text-content shadow-sm' @@ -148,7 +148,7 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips, mood, setMood, weather, setWeather, statsExcluded, setStatsExcluded, tripSuggestion, isDraft, setIsDraft, pros, setPros, cons, setCons, tags, setTags, tagInput, setTagInput, addTag, saving, uploadProgress, photos, photoOrder, canReorder, pendingFiles, setPendingFiles, pendingPreviews: pendingUrls, - pendingProviderGroups, setPendingProviderGroups, showGalleryPick, setShowGalleryPick, isDirty, + queuedProviderPhotos, setPendingProviderGroups, queueProviderPhotos, showGalleryPick, setShowGalleryPick, isDirty, availableGalleryPhotos, providerAssetIds, contextLocation, offersStatsToggle, addVerdictRow, verdictRowRef, handleSave, handleFileChange, pickGalleryPhoto, removePhoto, searchLocation, pickLocation, handleUseCurrentLocation, } = useJourneyEntryForm({ @@ -193,6 +193,11 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips, const activeExternalProvider = externalProvider || availableProviders[0]?.id || null const providerExistingAssetIds = providerAssetIds(activeExternalProvider) + const providerPickerOpen = photoTab === 'external' && photoProvidersOn && !!activeExternalProvider + const closeProviderPicker = () => { + setPhotoTab('upload') + setExternalProvider(null) + } // Every way out (Cancel, the close button, Escape, the dimmed backdrop) comes // through here, so none of them drops an edit without asking first. @@ -232,9 +237,7 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips, return ( <> - {/* Pinned at the top: the photo panels, the verdict rows and the photo - strip all change the body's height while an entry is being written. */} - +
@@ -319,86 +322,18 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips,
)} - {photoTab === 'external' && photoProvidersOn && ( -
-
-
-

- {t('journey.editor.externalPhotosFor', { date: new Date(entryDate + 'T00:00:00').toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' }) })} -

-

- {contextLocation?.name - ? `${t('journey.editor.externalPhotosNearby') || 'Nearby photos first'}: ${contextLocation.name}` - : (t('journey.editor.externalPhotosNoLocation') || 'All photos from this day')} -

-
- {pendingProviderGroups.length > 0 && ( - - )} -
- {providersLoading ? ( -
- ) : availableProviders.length === 0 ? ( -
{t('journey.editor.externalPhotosUnavailable') || 'No connected photo providers are available.'}
- ) : ( -
-
- {availableProviders.map(provider => ( - - ))} -
- {activeExternalProvider && ( -
- setExternalProvider(null)} - onAdd={async groups => { - setPendingProviderGroups(previous => { - const next = [...previous] - for (const group of groups) { - const existing = next.find(item => item.provider === activeExternalProvider && item.passphrase === group.passphrase) - if (existing) { - const seen = new Set(existing.assetIds) - group.assetIds.forEach((assetId, index) => { - if (seen.has(assetId)) return - seen.add(assetId) - existing.assetIds.push(assetId) - existing.mediaTypes?.push(group.mediaTypes?.[index] || 'image') - }) - } else { - next.push({ ...group, provider: activeExternalProvider }) - } - } - return next - }) - setExternalProvider(null) - }} - /> -
- )} -
- )} -
+ {photoTab === 'external' && photoProvidersOn && !activeExternalProvider && ( + providersLoading ? ( +
+ ) : ( +
{t('journey.editor.externalPhotosUnavailable')}
+ ) + )} + {queuedProviderPhotos > 0 && ( + )} {(photos.length > 0 || pendingFiles.length > 0) && (
@@ -690,6 +625,26 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips,
+ {providerPickerOpen && activeExternalProvider && ( + { + queueProviderPhotos(activeExternalProvider, groups) + closeProviderPicker() + }} + /> + )} + {/* Mounted only while asked, over the editor, which ignores Escape and its backdrop until the question is answered. */} {confirmDiscard && ( diff --git a/client/src/components/Journey/JourneyDetailPageProviderPicker.test.tsx b/client/src/components/Journey/JourneyDetailPageProviderPicker.test.tsx index 70f9c840d..bc79a3487 100644 --- a/client/src/components/Journey/JourneyDetailPageProviderPicker.test.tsx +++ b/client/src/components/Journey/JourneyDetailPageProviderPicker.test.tsx @@ -392,11 +392,10 @@ describe('ProviderPicker', () => { } }) - it('FE-JRN-PICKER-018: the embedded variant drops the header, the add-to bar and the date captions', async () => { - mountPicker({ embedded: true, initialDate: '2026-03-15' }) + it('FE-JRN-PICKER-018: entry mode opens a taller picker and keeps the entry as its target', async () => { + mountPicker({ entryPicker: { providers: [{ id: 'immich', name: 'Immich' }], onSelectProvider: vi.fn() }, initialDate: '2026-03-15' }) - expect(await screen.findByTestId('journey-provider-picker-embedded')).toBeInTheDocument() - expect(screen.queryByRole('heading', { name: 'Immich' })).not.toBeInTheDocument() + expect(await screen.findByRole('dialog', { name: 'Immich' })).toHaveClass('h-full') expect(screen.queryByText('Add to')).not.toBeInTheDocument() expect(screen.queryByText('March 15, 2026')).not.toBeInTheDocument() }) diff --git a/client/src/components/Journey/JourneyDetailPageProviderPicker.tsx b/client/src/components/Journey/JourneyDetailPageProviderPicker.tsx index b3b6141b1..a0dd45923 100644 --- a/client/src/components/Journey/JourneyDetailPageProviderPicker.tsx +++ b/client/src/components/Journey/JourneyDetailPageProviderPicker.tsx @@ -1,5 +1,5 @@ import { ArrowRight, Calendar, Camera, Check, ChevronRight, Images, Loader2, Play, X } from 'lucide-react'; -import { useEffect, useId, useMemo, useRef, useState } from 'react'; +import { useEffect, useId, useMemo, useRef, useState, type ComponentType, type ReactNode } from 'react'; import { memoriesApi } from '../../api/client'; import { useTranslation } from '../../i18n'; import { useIsPhone } from '../../mobile/useIsPhone'; @@ -20,9 +20,18 @@ import type { JourneyEntry, JourneyTrip } from '../../store/journeyStore'; import { DatePicker } from './JourneyDetailPageDatePicker'; import { ScrollTrigger } from './JourneyDetailPageScrollTrigger'; import { providerAssetUrl } from './providerAssetUrl'; +import type { ConnectedPhotoProvider } from './useConnectedPhotoProviders'; export type ProviderPhotoGroup = { assetIds: string[]; passphrase?: string; mediaTypes?: string[] }; +export interface EntryPhotoPickerFrameProps { + title: string; + subtitle: ReactNode; + onClose: () => void; + footer: ReactNode; + children: ReactNode; +} + /** A tile as the search and album routes answer it; only what a pick needs is spelled out. */ type PickerAsset = ProviderPhotoAsset & { mediaType?: string }; @@ -50,7 +59,7 @@ export function ProviderPicker({ initialDate, contextLocation, initialEntryId, - embedded = false, + entryPicker, }: { provider: string; userId: number; @@ -62,9 +71,13 @@ export function ProviderPicker({ initialDate?: string; contextLocation?: (GeoPoint & { name?: string }) | null; initialEntryId?: number | null; - embedded?: boolean; + entryPicker?: { + providers: ConnectedPhotoProvider[]; + onSelectProvider: (provider: string) => void; + Frame?: ComponentType; + }; }) { - const { t } = useTranslation(); + const { t, locale } = useTranslation(); const phone = useIsPhone(); const labelId = useId(); const [filter, setFilter] = useState<'day' | 'trip' | 'custom' | 'all' | 'album'>(initialDate ? 'day' : 'trip'); @@ -329,7 +342,8 @@ export function ProviderPicker({ t('journey.stats.entries') : t('journey.picker.newGallery'); - const providerName = provider === 'immich' ? 'Immich' : provider === 'synologyphotos' ? 'Synology Photos' : provider; + const providerName = entryPicker?.providers.find((source) => source.id === provider)?.name ?? + (provider === 'immich' ? 'Immich' : provider === 'synologyphotos' ? 'Synology Photos' : provider); const addSelection = async () => { if (adding) return; @@ -357,15 +371,47 @@ export function ProviderPicker({ } }; - // Everything between the head and the foot, the same in all three frames below. + const subtitle = entryPicker && ( + <> + {initialDate && ( +
{t('journey.editor.externalPhotosFor', { + date: new Date(`${initialDate}T00:00:00`).toLocaleDateString(locale, { + year: 'numeric', month: 'short', day: 'numeric', + }), + })}
+ )} +
+ {contextLocation?.name + ? <>{t('journey.editor.externalPhotosNearby')} {contextLocation.name} + : t('journey.editor.externalPhotosNoLocation')} +
+ + ); + + // The filters and selection are the same in each frame. const content = ( <> - {/* Filter bar. Embedded in the entry editor this sits in a panel a few hundred - pixels tall, so its padding is the difference between three rows of - thumbnails and two. */} -
+
+ {entryPicker && entryPicker.providers.length > 1 && ( +
+ {entryPicker.providers.map((source) => ( + + ))} +
+ )} {/* Tabs */} -
+
{[ ...(initialDate ? [{ id: 'day' as const, label: t('journey.picker.day') || 'This day' }] : []), { id: 'trip' as const, label: t('journey.picker.tripPeriod') }, @@ -377,7 +423,7 @@ export function ProviderPicker({ type="button" key={f.id} onClick={() => switchTab(f.id)} - className={`rounded-lg px-3 py-1.5 text-[12px] font-medium transition-colors ${ + className={`rounded-lg px-3 py-1.5 text-[12px] font-medium transition-colors ${entryPicker ? 'shrink-0 whitespace-nowrap' : ''} ${ filter === f.id ? 'bg-zinc-900 text-white dark:bg-white dark:text-zinc-900' : 'text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800' @@ -396,7 +442,7 @@ export function ProviderPicker({
{/* Filter content — always visible row */} - {(!embedded || filter !== 'day') && ( + {(!entryPicker || filter !== 'day') && (
{filter === 'day' && initialDate && (
@@ -531,7 +577,7 @@ export function ProviderPicker({
{/* Add-to entry selector */} - {!embedded && ( + {!entryPicker && (
@@ -666,7 +712,7 @@ export function ProviderPicker({
{groupPhotosByDate(sortedPhotos).map((group) => (
- {(!embedded || filter !== 'day') && ( + {(!entryPicker || filter !== 'day') && (

{group.label}

@@ -741,9 +787,31 @@ export function ProviderPicker({ ); - // The desktop draws the standalone picker in the planner's dialog frame. The - // phone keeps its sheet below, and the embedded picker has no frame at all. - if (!embedded && !phone) { + const footer = ( + + + {t('common.cancel')} + void addSelection()} + disabled={addDisabled} + icon={adding ? : undefined} + > + {t('common.add')} {selected.size > 0 ? `(${selected.size})` : ''} + + + ); + + const EntryFrame = entryPicker?.Frame; + if (EntryFrame) { + return ( + + {content} + + ); + } + + if (entryPicker || !phone) { return ( } @@ -763,24 +832,12 @@ export function ProviderPicker({ labelId={labelId} onClose={onClose} title={providerName} + sub={subtitle} /> )} // The bars stay pinned above the grid, which scrolls on its own. bodyClassName="flex min-h-0 flex-1 flex-col" - footer={( - - - {t('common.cancel')} - void addSelection()} - disabled={addDisabled} - icon={adding ? : undefined} - > - {t('common.add')} {selected.size > 0 ? `(${selected.size})` : ''} - - - )} + footer={footer} > {content} @@ -789,51 +846,36 @@ export function ProviderPicker({ return (
{ - if (!embedded && e.target === e.currentTarget) e.preventDefault(); + if (e.target === e.currentTarget) e.preventDefault(); }} >
e.stopPropagation()} > {/* Header */} - {!embedded && ( -
-

- {providerName} -

- -
- )} +
+

+ {providerName} +

+ +
{content} - {/* Footer. The count used to sit here as its own pill as well as on the Add - button; one of the two was always saying it twice, and inside the entry - editor the row it took cost the grid a row of thumbnails (discussion - #2299). Embedded, the whole bar is tighter for the same reason. */} -
+
@@ -239,120 +253,42 @@ export default function MJourneyEntrySheet({ setShowExternal(false) }} disabled={!captureOnly && galleryPhotos.length === 0} - className={`flex min-w-0 flex-1 items-center justify-center gap-[6px] rounded-[14px] border-[1.5px] p-3 text-center text-[0.75rem] font-semibold disabled:opacity-40 ${ + className={`flex min-w-0 flex-[1_1_7rem] items-center justify-center gap-[6px] rounded-[14px] border-[1.5px] p-3 text-center text-[0.75rem] font-semibold disabled:opacity-40 ${ !captureOnly && showGalleryPick ? 'border-[color:var(--m-act)] text-m-ink' : 'border-dashed border-[color:var(--m-rowbr)] text-m-muted' }`} > - {captureOnly ? t('journey.share.gallery') : t('journey.editor.fromGallery')} + {captureOnly ? t('journey.share.gallery') : t('journey.editor.fromGallery')} {/* Immich/Synology, the same source the desktop editor offers (#1808). Only shown once a provider is actually connected: on a phone a - button that can only say "nothing connected" is not worth its width. - The icons keep their size and the labels truncate, so a third - button never squeezes the other two (#2908). */} + button that can only say "nothing connected" is not worth its width. */} {!captureOnly && providers.length > 0 && ( )}
- {/* Outside the panel: picking collapses it again, and the queue has - to stay visible until the save actually writes it. */} {!captureOnly && queuedProviderPhotos > 0 && ( )} - {!captureOnly && showExternal && activeProvider && ( -
-
- - {contextLocation?.name - ? `${t('journey.editor.externalPhotosNearby')} · ${contextLocation.name}` - : t('journey.editor.externalPhotosNoLocation')} - -
- {providers.length > 1 && ( -
- {providers.map(provider => ( - - ))} -
- )} - {/* `embedded` is load-bearing: the standalone picker is - position:fixed, which the transformed MSheet panel would - anchor to itself and then clip. */} -
- setShowExternal(false)} - onAdd={async groups => { - setPendingProviderGroups(previous => { - const next = [...previous] - for (const group of groups) { - const existing = next.find(item => item.provider === activeProvider && item.passphrase === group.passphrase) - if (existing) { - const seen = new Set(existing.assetIds) - group.assetIds.forEach((assetId, index) => { - if (seen.has(assetId)) return - seen.add(assetId) - existing.assetIds.push(assetId) - existing.mediaTypes?.push(group.mediaTypes?.[index] || 'image') - }) - } else { - next.push({ ...group, provider: activeProvider }) - } - } - return next - }) - setShowExternal(false) - }} - /> -
-
- )} - {!captureOnly && showGalleryPick && (
@@ -819,4 +755,29 @@ export default function MJourneyEntrySheet({
) + + return ( + <> + {editor} + {providerPickerOpen && activeProvider && ( + { + queueProviderPhotos(activeProvider, groups) + closeProviderPicker() + }} + /> + )} + + ) } diff --git a/client/src/pages/JourneyDetailPage.test.tsx b/client/src/pages/JourneyDetailPage.test.tsx index 5d6388cc6..cfb9e6d9d 100644 --- a/client/src/pages/JourneyDetailPage.test.tsx +++ b/client/src/pages/JourneyDetailPage.test.tsx @@ -3632,11 +3632,8 @@ describe('JourneyDetailPage', () => { await openEntryEditor(user); await user.click(screen.getByRole('button', { name: /external photos/i })); - await waitFor(() => { - expect(screen.getByTestId('journey-external-provider-immich')).toBeInTheDocument(); - }); - await user.click(screen.getByTestId('journey-external-provider-immich')); - await waitFor(() => expect(screen.getByTestId('journey-provider-picker-embedded')).toBeInTheDocument()); + const picker = await screen.findByRole('dialog', { name: 'Immich' }); + expect(picker).toHaveClass('h-full'); await waitFor(() => expect(screen.getByText(/This day|journey\.picker\.day/)).toBeInTheDocument()); await waitFor(() => expect(searches.length).toBeGreaterThan(0)); @@ -3691,10 +3688,7 @@ describe('JourneyDetailPage', () => { await renderAndWait(); await openEntryEditor(user); await user.click(screen.getByRole('button', { name: /external photos/i })); - await waitFor(() => expect(screen.getByTestId('journey-external-provider-immich')).toBeInTheDocument()); - await user.click(screen.getByTestId('journey-external-provider-immich')); - - const picker = await waitFor(() => screen.getByTestId('journey-provider-picker-embedded')); + const picker = await screen.findByRole('dialog', { name: 'Immich' }); await waitFor(() => expect(picker.querySelector('img[src*="/api/integrations/memories/"]')).toBeTruthy()); const photo = picker.querySelector('img[src*="/api/integrations/memories/"]')!; await user.click(photo.closest('[class*="aspect-square"]') as HTMLElement); diff --git a/client/tests/unit/mobile/journey/MJourneyEntrySheet.test.tsx b/client/tests/unit/mobile/journey/MJourneyEntrySheet.test.tsx index 39f4e8196..37e2cb486 100644 --- a/client/tests/unit/mobile/journey/MJourneyEntrySheet.test.tsx +++ b/client/tests/unit/mobile/journey/MJourneyEntrySheet.test.tsx @@ -1269,17 +1269,26 @@ describe('MJourneyEntrySheet external photos', () => { expect(probes).toBe(0); }); - it('FE-MOB-JENTRY-042: opens the embedded picker for a connected provider', async () => { + it('FE-MOB-JENTRY-042: opens a full-screen photo picker for a connected provider', async () => { useConnectedImmich(); const user = userEvent.setup(); mountSheet(buildEntry({ id: 5, location_lat: 41.9, location_lng: 12.5, location_name: 'Rome' }), { photoProviders: immich }); + await user.type(screen.getByPlaceholderText('Give this moment a name...'), 'Draft title'); await user.click(await screen.findByRole('button', { name: 'External photos' })); - expect(await screen.findByTestId('journey-provider-picker-embedded')).toBeInTheDocument(); - expect(screen.getByText('Nearby photos first · Rome')).toBeInTheDocument(); + const picker = await screen.findByRole('dialog', { name: 'Immich' }); + expect(picker).toHaveClass('h-full'); + expect(screen.getAllByRole('button', { name: 'Cancel' })).toHaveLength(1); + expect(screen.queryByRole('button', { name: 'Save' })).not.toBeInTheDocument(); + expect(picker).toHaveTextContent('Nearby photos first Rome'); // A single provider needs no chip row. expect(screen.queryByTestId('journey-external-provider-immich')).not.toBeInTheDocument(); + + await user.keyboard('{Escape}'); + expect(screen.queryByRole('dialog', { name: 'Immich' })).not.toBeInTheDocument(); + expect(screen.getByDisplayValue('Draft title')).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Save' })).toBeVisible(); }); it('FE-MOB-JENTRY-043: stays out of the quick capture sheet', async () => { @@ -1300,7 +1309,7 @@ describe('MJourneyEntrySheet external photos', () => { await user.click(await screen.findByAltText('')); await user.click(screen.getByRole('button', { name: 'Add (1)' })); - const queued = await screen.findByRole('button', { name: /1 queued · Clear/ }); + const queued = await screen.findByRole('button', { name: /1 queued Clear/ }); expect(queued).toBeInTheDocument(); await user.click(screen.getByRole('button', { name: 'Save' })); @@ -1321,7 +1330,7 @@ describe('MJourneyEntrySheet external photos', () => { await user.click(await screen.findByRole('button', { name: 'External photos' })); await user.click(await screen.findByAltText('')); await user.click(screen.getByRole('button', { name: 'Add (1)' })); - await user.click(await screen.findByRole('button', { name: /1 queued · Clear/ })); + await user.click(await screen.findByRole('button', { name: /1 queued Clear/ })); expect(screen.queryByRole('button', { name: /queued/ })).not.toBeInTheDocument(); await user.click(screen.getByRole('button', { name: 'Save' }));