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
This commit is contained in:
Maurice
2026-11-30 22:10:01 +01:00
parent 8fc7745d59
commit 714fc6beaf
12 changed files with 289 additions and 288 deletions
+1 -1
View File
@@ -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,
+2 -2
View File
@@ -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,
@@ -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 () => {
@@ -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. */}
<DialogShell onClose={handleClose} labelledBy={labelId} width="wide" blocked={confirmDiscard} header={header} footer={footer}>
<DialogShell onClose={handleClose} labelledBy={labelId} width="wide" blocked={confirmDiscard} covered={providerPickerOpen} header={header} footer={footer}>
<div className="grid grid-cols-1 items-stretch gap-x-6 gap-y-5 md:grid-cols-2">
<div className="flex min-w-0 flex-col gap-5">
<div>
@@ -319,86 +322,18 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips,
</div>
</div>
)}
{photoTab === 'external' && photoProvidersOn && (
<div className={`${PHOTO_PANEL} flex flex-col overflow-hidden`} style={{ height: 'min(56vh, 520px)' }}>
<div className="flex items-center justify-between gap-2 border-b border-edge-faint px-3 py-2">
<div className="min-w-0">
<p className="truncate font-semibold text-content" style={fs(11.5)}>
{t('journey.editor.externalPhotosFor', { date: new Date(entryDate + 'T00:00:00').toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' }) })}
</p>
<p className="truncate text-content-faint" style={fs(10.5)}>
{contextLocation?.name
? `${t('journey.editor.externalPhotosNearby') || 'Nearby photos first'}: ${contextLocation.name}`
: (t('journey.editor.externalPhotosNoLocation') || 'All photos from this day')}
</p>
</div>
{pendingProviderGroups.length > 0 && (
<button type="button" onClick={() => setPendingProviderGroups([])} className="inline-flex items-center gap-1.5 whitespace-nowrap text-content-muted hover:text-content" style={fs(10.5)}>
<span>{pendingProviderGroups.reduce((sum, group) => sum + group.assetIds.length, 0)} {t('journey.editor.externalPhotosQueued') || 'queued'}</span>{' '}
<span className="font-semibold text-content">{t('common.clear') || 'Clear'}</span>
</button>
)}
</div>
{providersLoading ? (
<div className="flex justify-center py-8"><Loader2 size={20} className="animate-spin text-content-faint" /></div>
) : availableProviders.length === 0 ? (
<div className="px-4 py-10 text-center text-content-muted" style={fs(12, 'body')}>{t('journey.editor.externalPhotosUnavailable') || 'No connected photo providers are available.'}</div>
) : (
<div className="flex h-full min-h-0 flex-col">
<div className="flex gap-1 overflow-x-auto border-b border-edge-faint px-3 py-2" style={fs(11.5)}>
{availableProviders.map(provider => (
<button type="button"
key={provider.id}
data-testid={`journey-external-provider-${provider.id}`}
onClick={() => setExternalProvider(provider.id)}
aria-pressed={externalProvider === provider.id}
className={`whitespace-nowrap rounded-[8px] px-2.5 py-1 font-medium ${externalProvider === provider.id ? 'bg-accent text-accent-text' : 'text-content-muted hover:bg-surface-hover hover:text-content'}`}
>
{provider.name}
</button>
))}
</div>
{activeExternalProvider && (
<div className="min-h-0 flex-1">
<ProviderPicker
key={`${activeExternalProvider}-${entryDate}`}
provider={activeExternalProvider}
userId={userId}
entries={[entry]}
trips={trips}
existingAssetIds={providerExistingAssetIds}
initialDate={entryDate}
contextLocation={contextLocation}
initialEntryId={entry.id || null}
embedded
onClose={() => 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)
}}
/>
</div>
)}
</div>
)}
</div>
{photoTab === 'external' && photoProvidersOn && !activeExternalProvider && (
providersLoading ? (
<div className="flex justify-center py-4"><Loader2 size={20} className="animate-spin text-content-faint" /></div>
) : (
<div className="py-3 text-center text-caption text-content-muted">{t('journey.editor.externalPhotosUnavailable')}</div>
)
)}
{queuedProviderPhotos > 0 && (
<button type="button" onClick={() => setPendingProviderGroups([])} className="mt-2 inline-flex items-center gap-1.5 whitespace-nowrap text-caption text-content-muted hover:text-content">
<span>{queuedProviderPhotos} {t('journey.editor.externalPhotosQueued')}</span>{' '}
<span className="font-semibold text-content">{t('common.clear')}</span>
</button>
)}
{(photos.length > 0 || pendingFiles.length > 0) && (
<div className="mt-3 flex flex-wrap gap-2">
@@ -690,6 +625,26 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips,
</div>
</DialogShell>
{providerPickerOpen && activeExternalProvider && (
<ProviderPicker
key={`${activeExternalProvider}-${entryDate}`}
provider={activeExternalProvider}
userId={userId}
entries={[entry]}
trips={trips}
existingAssetIds={providerExistingAssetIds}
initialDate={entryDate}
contextLocation={contextLocation}
initialEntryId={entry.id || null}
entryPicker={{ providers: availableProviders, onSelectProvider: setExternalProvider }}
onClose={closeProviderPicker}
onAdd={async groups => {
queueProviderPhotos(activeExternalProvider, groups)
closeProviderPicker()
}}
/>
)}
{/* Mounted only while asked, over the editor, which ignores Escape and its
backdrop until the question is answered. */}
{confirmDiscard && (
@@ -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()
})
@@ -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<EntryPhotoPickerFrameProps>;
};
}) {
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 && (
<div>{t('journey.editor.externalPhotosFor', {
date: new Date(`${initialDate}T00:00:00`).toLocaleDateString(locale, {
year: 'numeric', month: 'short', day: 'numeric',
}),
})}</div>
)}
<div>
{contextLocation?.name
? <>{t('journey.editor.externalPhotosNearby')} <bdi>{contextLocation.name}</bdi></>
: t('journey.editor.externalPhotosNoLocation')}
</div>
</>
);
// 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. */}
<div className={`flex-shrink-0 border-b border-zinc-200 dark:border-zinc-700 ${embedded ? 'px-3 py-2' : 'px-6 py-3'}`}>
<div className={`flex-shrink-0 border-b border-zinc-200 dark:border-zinc-700 ${entryPicker ? 'px-3 py-2' : 'px-6 py-3'}`}>
{entryPicker && entryPicker.providers.length > 1 && (
<div className="mb-2 flex gap-1 overflow-x-auto" role="group" aria-label={t('journey.editor.externalPhotos')}>
{entryPicker.providers.map((source) => (
<button
type="button"
key={source.id}
data-testid={`journey-external-provider-${source.id}`}
aria-pressed={provider === source.id}
onClick={() => entryPicker.onSelectProvider(source.id)}
className={`shrink-0 rounded-lg px-2.5 py-1 text-caption font-medium ${provider === source.id
? 'bg-accent text-accent-text'
: 'text-content-muted hover:bg-surface-hover hover:text-content'}`}
>
{source.name}
</button>
))}
</div>
)}
{/* Tabs */}
<div className={`flex gap-1.5 ${embedded && filter === 'day' ? '' : 'mb-3'}`}>
<div className={`flex gap-1.5 ${entryPicker ? 'overflow-x-auto' : ''} ${entryPicker && filter === 'day' ? '' : 'mb-3'}`}>
{[
...(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({
</div>
{/* Filter content — always visible row */}
{(!embedded || filter !== 'day') && (
{(!entryPicker || filter !== 'day') && (
<div className="flex min-h-[36px] items-center">
{filter === 'day' && initialDate && (
<div className="flex items-center gap-2 text-[12px] text-zinc-500">
@@ -531,7 +577,7 @@ export function ProviderPicker({
</div>
{/* Add-to entry selector */}
{!embedded && (
{!entryPicker && (
<div className="flex-shrink-0 border-b border-zinc-200 bg-zinc-50 px-6 py-2.5 dark:border-zinc-700 dark:bg-zinc-800/50">
<div className="relative flex items-center gap-2">
<span className="text-[10px] font-semibold tracking-[0.12em] text-zinc-500 uppercase">
@@ -666,7 +712,7 @@ export function ProviderPicker({
<div>
{groupPhotosByDate(sortedPhotos).map((group) => (
<div key={group.date}>
{(!embedded || filter !== 'day') && (
{(!entryPicker || filter !== 'day') && (
<p className="mt-4 mb-2 text-[11px] font-medium text-zinc-500 first:mt-0 dark:text-zinc-400">
{group.label}
</p>
@@ -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 = (
<DialogFooter>
<FooterSpacer />
<DialogButton onClick={onClose}>{t('common.cancel')}</DialogButton>
<DialogButton
variant="primary"
onClick={() => void addSelection()}
disabled={addDisabled}
icon={adding ? <Loader2 size={14} className="animate-spin" /> : undefined}
>
{t('common.add')} {selected.size > 0 ? `(${selected.size})` : ''}
</DialogButton>
</DialogFooter>
);
const EntryFrame = entryPicker?.Frame;
if (EntryFrame) {
return (
<EntryFrame title={providerName} subtitle={subtitle} onClose={onClose} footer={footer}>
{content}
</EntryFrame>
);
}
if (entryPicker || !phone) {
return (
<DialogShell
// With the add-to menu open, Escape and a click beside the dialog close
@@ -754,8 +822,9 @@ export function ProviderPicker({
}}
labelledBy={labelId}
width="wide"
fillHeight={!!entryPicker}
// The tabs change how much the grid holds, so the upper edge stays put.
align="top"
align={entryPicker ? 'center' : 'top'}
header={(
<DialogHeader
tile={<DialogTile><Images size={20} strokeWidth={1.9} className="text-content-muted" /></DialogTile>}
@@ -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={(
<DialogFooter>
<FooterSpacer />
<DialogButton onClick={onClose}>{t('common.cancel')}</DialogButton>
<DialogButton
variant="primary"
onClick={() => void addSelection()}
disabled={addDisabled}
icon={adding ? <Loader2 size={14} className="animate-spin" /> : undefined}
>
{t('common.add')} {selected.size > 0 ? `(${selected.size})` : ''}
</DialogButton>
</DialogFooter>
)}
footer={footer}
>
{content}
</DialogShell>
@@ -789,51 +846,36 @@ export function ProviderPicker({
return (
<div
data-testid={embedded ? 'journey-provider-picker-embedded' : undefined}
className={
embedded
? 'flex h-full min-h-0 w-full flex-col overflow-hidden'
: 'fixed inset-0 z-[9999] flex items-end justify-center overscroll-none bg-[rgba(9,9,11,0.75)] md:items-center md:p-5'
}
className="fixed inset-0 z-[9999] flex items-end justify-center overscroll-none bg-[rgba(9,9,11,0.75)] md:items-center md:p-5"
role="presentation"
onClick={embedded ? undefined : onClose}
onClick={onClose}
onTouchMove={(e) => {
if (!embedded && e.target === e.currentTarget) e.preventDefault();
if (e.target === e.currentTarget) e.preventDefault();
}}
>
<div
className={
embedded
? 'flex h-full w-full flex-col overflow-hidden bg-white dark:bg-zinc-900'
: 'flex max-h-[calc(100dvh-var(--bottom-nav-h)-20px)] w-full max-w-[720px] flex-col overflow-hidden rounded-t-2xl bg-white shadow-[0_20px_40px_rgba(0,0,0,0.2)] md:max-h-[85vh] md:max-w-[960px] md:rounded-2xl dark:bg-zinc-900'
}
className="flex max-h-[calc(100dvh-var(--bottom-nav-h)-20px)] w-full max-w-[720px] flex-col overflow-hidden rounded-t-2xl bg-white shadow-[0_20px_40px_rgba(0,0,0,0.2)] md:max-h-[85vh] md:max-w-[960px] md:rounded-2xl dark:bg-zinc-900"
style={{ paddingBottom: 'env(safe-area-inset-bottom, 0px)' }}
role="presentation"
onClick={(e) => e.stopPropagation()}
>
{/* Header */}
{!embedded && (
<div className="flex flex-shrink-0 items-center justify-between border-b border-zinc-200 px-6 py-4 dark:border-zinc-700">
<h2 className="text-[16px] font-bold text-zinc-900 dark:text-white">
{providerName}
</h2>
<button
type="button"
onClick={onClose}
className="flex h-8 w-8 items-center justify-center rounded-lg text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800"
>
<X size={16} />
</button>
</div>
)}
<div className="flex flex-shrink-0 items-center justify-between border-b border-zinc-200 px-6 py-4 dark:border-zinc-700">
<h2 className="text-[16px] font-bold text-zinc-900 dark:text-white">
{providerName}
</h2>
<button
type="button"
onClick={onClose}
className="flex h-8 w-8 items-center justify-center rounded-lg text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800"
>
<X size={16} />
</button>
</div>
{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. */}
<div className={`flex flex-shrink-0 items-center justify-end border-t border-zinc-200 bg-zinc-50 dark:border-zinc-700 dark:bg-zinc-800/50 ${embedded ? 'px-3 py-2' : 'px-6 py-4'}`}>
<div className="flex flex-shrink-0 items-center justify-end border-t border-zinc-200 bg-zinc-50 px-6 py-4 dark:border-zinc-700 dark:bg-zinc-800/50">
<div className="flex items-center gap-2">
<button
type="button"
@@ -181,6 +181,26 @@ export function useJourneyEntryForm({
const availableGalleryPhotos = galleryPhotos.filter((gp) => !photos.some((p) => p.id === gp.id));
const queuedProviderPhotos = pendingProviderGroups.reduce((sum, group) => sum + group.assetIds.length, 0);
const queueProviderPhotos = (provider: string, groups: ProviderPhotoGroup[]) => {
setPendingProviderGroups((previous) => {
const next = [...previous];
for (const group of groups) {
const index = next.findIndex((pick) => pick.provider === provider && pick.passphrase === group.passphrase);
if (index < 0) {
next.push({ ...group, provider });
continue;
}
const existing = next[index]!;
const assets = new Map(existing.assetIds.map((id, i) => [id, existing.mediaTypes?.[i] ?? 'image']));
group.assetIds.forEach((id, i) => {
if (!assets.has(id)) assets.set(id, group.mediaTypes?.[i] ?? 'image');
});
next[index] = { ...existing, assetIds: [...assets.keys()], mediaTypes: [...assets.values()] };
}
return next;
});
};
/** The provider assets already on the entry or queued for it, so the picker can mark them. */
const providerAssetIds = (provider: string | null): Set<string> => {
const ids = new Set<string>();
@@ -625,6 +645,7 @@ export function useJourneyEntryForm({
pendingPreviews,
pendingProviderGroups,
setPendingProviderGroups,
queueProviderPhotos,
showGalleryPick,
setShowGalleryPick,
isDirty,
+9 -3
View File
@@ -26,10 +26,14 @@ export interface DialogShellProps {
labelledBy: string
/** 520 px for a single question, 600 px for a detail, 720 px for an editor, 960 px for one in two columns. */
width?: keyof typeof PANEL_WIDTH
/** Fill the available height when the body is a browser with its own scrolling area. */
fillHeight?: boolean
/** 'top' pins the upper edge, so a dialog whose content changes height does not jump. */
align?: 'center' | 'top'
/** True while a question opened from here is being answered: Escape and the backdrop leave the dialog alone. */
blocked?: boolean
/** A separate dialog is open in front of this one. */
covered?: boolean
header: ReactNode
footer?: ReactNode
/** Makes the scrolling body a form. */
@@ -86,7 +90,7 @@ export function DialogShell({ open = true, ...frame }: DialogShellProps) {
return open ? <DialogFrame {...frame} /> : null
}
function DialogFrame({ onClose, labelledBy, width = 'detail', align = 'center', blocked = false, header, footer, onSubmit, children, bodyClassName, onPaste, discardGuard }: Omit<DialogShellProps, 'open'>) {
function DialogFrame({ onClose, labelledBy, width = 'detail', fillHeight = false, align = 'center', blocked = false, covered = false, header, footer, onSubmit, children, bodyClassName, onPaste, discardGuard }: Omit<DialogShellProps, 'open'>) {
const { t } = useTranslation()
const panelRef = useRef<HTMLDivElement>(null)
const pressedOn = useRef<EventTarget | null>(null)
@@ -95,7 +99,7 @@ function DialogFrame({ onClose, labelledBy, width = 'detail', align = 'center',
// The unsaved-changes question (#2253). The backdrop and Escape are the two
// ways out a hand can take by accident; both go through requestClose.
const { asking, markStart, requestClose, keepEditing, discard } = useDiscardGuard(discardGuard, onClose)
const held = blocked || asking
const held = blocked || covered || asking
useEffect(() => {
if (held) return
@@ -133,6 +137,8 @@ function DialogFrame({ onClose, labelledBy, width = 'detail', align = 'center',
return createPortal(
<div
role="presentation"
aria-hidden={covered || undefined}
inert={covered || undefined}
className={`${BACKDROP} ${align === 'top' ? 'items-start' : 'items-center'}`}
style={{ paddingTop: 40, paddingBottom: 'calc(40px + var(--bottom-nav-h, 0px))' }}
// Only a press that starts and ends on the backdrop closes: a selection
@@ -157,7 +163,7 @@ function DialogFrame({ onClose, labelledBy, width = 'detail', align = 'center',
}}
onPointerDownCapture={markStart}
onKeyDown={e => { if (panelRef.current) trapTab(e, panelRef.current) }}
className={`trek-modal-enter relative flex max-h-full w-full ${PANEL_WIDTH[width]} flex-col overflow-hidden rounded-[22px] bg-surface-card shadow-2xl outline-none`}
className={`trek-modal-enter relative flex max-h-full w-full ${PANEL_WIDTH[width]} flex-col overflow-hidden rounded-[22px] bg-surface-card shadow-2xl outline-none${fillHeight ? ' h-full' : ''}`}
>
{header}
{body}
+14 -7
View File
@@ -9,13 +9,13 @@ import { useOverlay } from '../overlayStack'
import { tickHaptic } from '../../native/haptics'
import { useNativeQuestion } from '../../native/useNativeQuestion'
export type MSheetVariant = 'card' | 'bottom' | 'drawer'
export type MSheetVariant = 'card' | 'bottom' | 'drawer' | 'fullscreen'
export type MSheetMaterial = 'glass' | 'bar-glass' | 'opaque'
interface MSheetProps {
open: boolean
onClose: () => void
/** card = centred floating card, bottom = docked panel above the nav, drawer = left drawer */
/** card = centred card, bottom = docked above the nav, drawer = side drawer, fullscreen = fills the window */
variant?: MSheetVariant
/**
* @deprecated Every sheet stands on the one opaque surface now (--m-sheetop),
@@ -31,6 +31,8 @@ interface MSheetProps {
*/
dimTransparent?: boolean
ariaLabel?: string
/** A separate sheet is open in front of this one. */
covered?: boolean
className?: string
children?: ReactNode
/**
@@ -92,6 +94,7 @@ const REGION: Record<MSheetVariant, string> = {
bottom:
'inset-x-4 top-[calc(var(--m-safe-top,12px)+56px)] bottom-[calc(var(--bottom-nav-h,84px)+16px)] justify-end short:top-[calc(var(--m-safe-top,12px)+8px)]',
drawer: 'start-0 top-0 bottom-0 w-[78%] max-w-[320px]',
fullscreen: 'inset-0',
}
// On a wide window (hooks/sizeClass.ts) a docked or floating sheet becomes
@@ -115,7 +118,7 @@ const SHORT_FORM_BOX = 'short:max-w-[640px] short:flex-1'
/** The region the sheet stands in, on a phone and on a wide window. */
function regionClass(variant: MSheetVariant, anchor: MSheetWideAnchor = 'center', form = false): string {
const base = 'pointer-events-none absolute flex flex-col'
if (variant === 'drawer') return `${base} ${REGION.drawer}`
if (variant === 'drawer' || variant === 'fullscreen') return `${base} ${REGION[variant]}`
// m-safe-trail: on a wide window the sheet keeps off the trailing side's safe area (a Duo's status capsule).
return `${base} m-safe-trail ${REGION[variant]} ${WIDE_REGION[anchor]}${form ? ` ${SHORT_FORM_REGION}` : ''}`
}
@@ -123,13 +126,13 @@ function regionClass(variant: MSheetVariant, anchor: MSheetWideAnchor = 'center'
/** The sheet's own box inside the region: its width, and the arrow when it has one. */
function boxClass(variant: MSheetVariant, width: MSheetWidth = 'regular', form = false): string {
const base = 'pointer-events-auto relative flex min-h-0 w-full flex-col'
if (variant === 'drawer') return `${base} h-full`
if (variant === 'drawer' || variant === 'fullscreen') return `${base} h-full`
return `${base} max-h-full ${WIDE_WIDTH[width]}${form ? ` ${SHORT_FORM_BOX}` : ''}`
}
/** The popover's arrow, pointing at the More button at the foot of the rail (wide windows only). */
function PopoverArrow({ variant, anchor }: { variant: MSheetVariant; anchor?: MSheetWideAnchor }) {
if (anchor !== 'rail-foot' || variant === 'drawer') return null
if (anchor !== 'rail-foot' || variant === 'drawer' || variant === 'fullscreen') return null
return (
<span
aria-hidden="true"
@@ -145,6 +148,7 @@ const SHAPE: Record<MSheetVariant, string> = {
bottom:
'[--m-sheet-r:26px] max-h-full shadow-[0_-8px_40px_-14px_rgba(0,0,0,.45)] wide:[--m-sheet-r:28px] wide:shadow-[0_30px_80px_-24px_rgba(0,0,0,.6)]',
drawer: '[--m-sheet-r:0px] h-full shadow-[0_0_60px_-10px_rgba(0,0,0,.5)]',
fullscreen: '[--m-sheet-r:0px] h-full border-0 pt-[var(--m-safe-t)] pb-[env(safe-area-inset-bottom,0px)]',
}
// The full-height form on a short window: square at the foot, where it meets
@@ -162,8 +166,8 @@ const SURFACE = 'bg-[color:var(--m-sheetop)] border border-[color:var(--m-shbr)]
// The docked sheet rises from below the screen edge like a native sheet; the
// card pops in place like an alert; the drawer slides from the side.
const ENTER: Record<MSheetVariant, string> = { card: 'm-sheet-in', bottom: 'm-sheet-up', drawer: 'm-drawer-in' }
const EXIT: Record<MSheetVariant, string> = { card: 'm-sheet-out', bottom: 'm-sheet-down', drawer: 'm-drawer-out' }
const ENTER: Record<MSheetVariant, string> = { card: 'm-sheet-in', bottom: 'm-sheet-up', drawer: 'm-drawer-in', fullscreen: 'm-fade-in' }
const EXIT: Record<MSheetVariant, string> = { card: 'm-sheet-out', bottom: 'm-sheet-down', drawer: 'm-drawer-out', fullscreen: 'm-fade-out' }
function sheetRoot(): HTMLElement {
return document.getElementById('m-sheet-root') ?? document.body
@@ -181,6 +185,7 @@ export default function MSheet({
variant = 'card',
dimTransparent = false,
ariaLabel,
covered = false,
className = '',
children,
discardGuard,
@@ -289,6 +294,8 @@ export default function MSheet({
<div
className="m-root fixed inset-0 z-[60]"
role="presentation"
aria-hidden={covered || undefined}
inert={covered || undefined}
onClick={(e) => {
if (e.target === e.currentTarget) requestClose()
}}
@@ -8,7 +8,7 @@ import MSheet from '../../components/MSheet'
import MIconBtn from '../../components/MIconBtn'
import MToggle from '../../components/MToggle'
import { SHEET_PRIMARY, SHEET_SECONDARY } from '../trip/sheets/MTripSheetUi'
import { FormSheetBody, SheetDateField } from '../trip/sheets/PlSheetChrome'
import { FormSheetBody, FormSheetHeader, SheetDateField } from '../trip/sheets/PlSheetChrome'
import { useAutoGrow } from '../../../hooks/useAutoGrow'
import { useTranslation } from '../../../i18n'
import CustomTimePicker from '../../../components/shared/CustomTimePicker'
@@ -17,12 +17,23 @@ import type { ResilientResult, UploadProgress } from '../../../utils/uploadQueue
import type { JourneyEntry, JourneyPhoto, GalleryPhoto, JourneyTrip } from '../../../store/journeyStore'
import { photoUrl, posterlessVideo } from '../../../pages/journeyDetail/JourneyDetailPage.helpers'
import JournalBody from '../../../components/Journey/JournalBody'
import { ProviderPicker } from '../../../components/Journey/JourneyDetailPageProviderPicker'
import { ProviderPicker, type EntryPhotoPickerFrameProps } from '../../../components/Journey/JourneyDetailPageProviderPicker'
import { MOBILE_MOODS, MOBILE_WEATHERS } from './mobileJourneyMeta'
import { useJourneyEntryForm, type PendingProviderGroup } from '../../../components/Journey/useJourneyEntryForm'
const NO_PROVIDERS: { id: string; name: string }[] = []
function EntryPhotoPickerSheet({ title, subtitle, onClose, footer, children }: EntryPhotoPickerFrameProps) {
const { t } = useTranslation()
return (
<MSheet open onClose={onClose} variant="fullscreen" ariaLabel={title}>
<FormSheetHeader icon={Images} title={title} subtitle={subtitle} onClose={onClose} closeLabel={t('common.close')} />
<div className="flex min-h-0 flex-1 flex-col">{children}</div>
{footer}
</MSheet>
)
}
/**
* A picked mood chip: its colour as the frame and the label, a light wash of it
* behind. The frame is the full colour because a tint alone left the grey neutral
@@ -107,7 +118,7 @@ export default function MJourneyEntrySheet({
locationName, locationLat, locationQuery, locationResults, showLocationResults, setShowLocationResults,
locating, locationError, mood, setMood, weather, setWeather, statsExcluded, setStatsExcluded, tripSuggestion,
isDraft, setIsDraft, pros, setPros, cons, setCons, tags, setTags, tagInput, setTagInput, saving, uploadProgress,
photos, photoOrder, canReorder, pendingFiles, setPendingFiles, pendingPreviews, setPendingProviderGroups,
photos, photoOrder, canReorder, pendingFiles, setPendingFiles, pendingPreviews, setPendingProviderGroups, queueProviderPhotos,
showGalleryPick, setShowGalleryPick, isDirty, availableGalleryPhotos, queuedProviderPhotos, providerAssetIds,
contextLocation, offersStatsToggle, addVerdictRow, verdictRowRef, addTag, handleSave, handleFileChange,
pickGalleryPhoto, removePhoto, searchLocation, pickLocation, handleUseCurrentLocation,
@@ -131,6 +142,8 @@ export default function MJourneyEntrySheet({
const activeProvider = externalProvider || providers[0]?.id || null
const providerExistingAssetIds = providerAssetIds(activeProvider)
const providerPickerOpen = !readOnly && !captureOnly && showExternal && !!activeProvider
const closeProviderPicker = () => setShowExternal(false)
const handleClose = () => {
if (!captureOnly && !readOnly && isDirty && !window.confirm(t('journey.editor.discardChangesConfirm'))) return
@@ -154,13 +167,14 @@ export default function MJourneyEntrySheet({
const eyebrow = 'font-geist text-[0.625rem] font-bold uppercase tracking-[.09em] text-m-faint'
const fieldShell = 'rounded-xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]'
return (
const editor = (
<MSheet
open
onClose={handleClose}
variant="card"
form
ariaLabel={heading}
covered={providerPickerOpen}
>
{/* FormSheetHeader's shape, with the move buttons between the title and the close. */}
<div className="m-fs-head flex flex-none items-center gap-3 px-[18px] pb-2 pt-4">
@@ -212,22 +226,22 @@ export default function MJourneyEntrySheet({
<>
<input ref={cameraRef} type="file" accept="image/*" capture="environment" className="hidden" onChange={handleFileChange} onClick={e => { (e.target as HTMLInputElement).value = '' }} />
<input ref={fileRef} type="file" accept="image/*,video/*" multiple className="hidden" onChange={handleFileChange} onClick={e => { (e.target as HTMLInputElement).value = '' }} />
<div className="flex gap-2">
<div className="flex flex-wrap gap-2">
<button
type="button"
onClick={() => (captureOnly ? cameraRef : fileRef).current?.click()}
disabled={saving}
className="flex min-w-0 flex-1 items-center justify-center gap-[6px] rounded-[14px] border-[1.5px] border-dashed border-[color:var(--m-rowbr)] p-3 text-center text-[0.75rem] font-semibold text-m-muted disabled:opacity-50"
className="flex min-w-0 flex-[1_1_7rem] items-center justify-center gap-[6px] rounded-[14px] border-[1.5px] border-dashed border-[color:var(--m-rowbr)] p-3 text-center text-[0.75rem] font-semibold text-m-muted disabled:opacity-50"
>
{uploadProgress ? (
<>
<span className="h-[14px] w-[14px] shrink-0 animate-spin rounded-full border-2 border-[color:var(--m-rowbr)] border-t-m-muted" />
<span className="truncate">{t('journey.editor.uploadingProgress', { done: String(uploadProgress.done), total: String(uploadProgress.total) })}</span>
<span className="min-w-0 break-words">{t('journey.editor.uploadingProgress', { done: String(uploadProgress.done), total: String(uploadProgress.total) })}</span>
</>
) : (
<>
{captureOnly ? <Camera size={14} strokeWidth={2.2} className="shrink-0" /> : <Plus size={14} strokeWidth={2.2} className="shrink-0" />}
<span className="truncate">{captureOnly ? t('journey.photo.add') : t('journey.editor.uploadPhotos')}</span>
<span className="min-w-0 break-words">{captureOnly ? t('journey.photo.add') : t('journey.editor.uploadPhotos')}</span>
</>
)}
</button>
@@ -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'
}`}
>
<Image size={14} strokeWidth={2} className="shrink-0" />
<span className="truncate">{captureOnly ? t('journey.share.gallery') : t('journey.editor.fromGallery')}</span>
<span className="min-w-0 break-words">{captureOnly ? t('journey.share.gallery') : t('journey.editor.fromGallery')}</span>
</button>
{/* 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 && (
<button
type="button"
onClick={() => { setShowExternal(v => !v); setShowGalleryPick(false) }}
onClick={() => { setShowExternal(true); setShowGalleryPick(false) }}
disabled={saving}
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-50 ${
showExternal
? 'border-[color:var(--m-act)] text-m-ink'
: 'border-dashed border-[color:var(--m-rowbr)] text-m-muted'
}`}
aria-haspopup="dialog"
className="flex min-w-0 flex-[1_1_7rem] items-center justify-center gap-[6px] rounded-[14px] border-[1.5px] border-dashed border-[color:var(--m-rowbr)] p-3 text-center text-[0.75rem] font-semibold text-m-muted disabled:opacity-50"
>
<Images size={14} strokeWidth={2} className="shrink-0" />
<span className="truncate">{t('journey.editor.externalPhotos')}</span>
<span className="min-w-0 break-words">{t('journey.editor.externalPhotos')}</span>
</button>
)}
</div>
{/* Outside the panel: picking collapses it again, and the queue has
to stay visible until the save actually writes it. */}
{!captureOnly && queuedProviderPhotos > 0 && (
<button
type="button"
onClick={() => setPendingProviderGroups([])}
className="mt-2 rounded-full border border-[color:var(--m-rowbr)] px-3 py-[5px] font-geist text-[0.65625rem] font-semibold text-m-muted"
>
{queuedProviderPhotos} {t('journey.editor.externalPhotosQueued')} · {t('common.clear')}
{queuedProviderPhotos} {t('journey.editor.externalPhotosQueued')} {t('common.clear')}
</button>
)}
{!captureOnly && showExternal && activeProvider && (
<div
className="mt-2 flex flex-col overflow-hidden rounded-[14px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]"
style={{ height: 'min(46vh, 420px)' }}
>
<div className="flex flex-none items-center gap-2 border-b border-[color:var(--m-rowbr)] px-3 py-2">
<span className="min-w-0 flex-1 truncate font-geist text-[0.6875rem] font-semibold text-m-muted">
{contextLocation?.name
? `${t('journey.editor.externalPhotosNearby')} · ${contextLocation.name}`
: t('journey.editor.externalPhotosNoLocation')}
</span>
</div>
{providers.length > 1 && (
<div className="flex flex-none gap-1 overflow-x-auto border-b border-[color:var(--m-rowbr)] px-3 py-2">
{providers.map(provider => (
<button
key={provider.id}
type="button"
data-testid={`journey-external-provider-${provider.id}`}
onClick={() => setExternalProvider(provider.id)}
className={`whitespace-nowrap rounded-full px-[10px] py-[4px] text-[0.6875rem] font-bold ${
activeProvider === provider.id ? 'bg-m-act text-m-actfg' : 'text-m-muted'
}`}
>
{provider.name}
</button>
))}
</div>
)}
{/* `embedded` is load-bearing: the standalone picker is
position:fixed, which the transformed MSheet panel would
anchor to itself and then clip. */}
<div className="min-h-0 flex-1">
<ProviderPicker
key={`${activeProvider}-${entryDate}`}
provider={activeProvider}
userId={userId}
entries={[entry]}
trips={trips}
existingAssetIds={providerExistingAssetIds}
initialDate={entryDate}
contextLocation={contextLocation}
initialEntryId={entry.id || null}
embedded
onClose={() => 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)
}}
/>
</div>
</div>
)}
{!captureOnly && showGalleryPick && (
<div className="mt-2 max-h-[160px] overflow-y-auto rounded-[14px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] p-2">
<div className="grid grid-cols-5 gap-[6px]">
@@ -819,4 +755,29 @@ export default function MJourneyEntrySheet({
</div>
</MSheet>
)
return (
<>
{editor}
{providerPickerOpen && activeProvider && (
<ProviderPicker
key={`${activeProvider}-${entryDate}`}
provider={activeProvider}
userId={userId}
entries={[entry]}
trips={trips}
existingAssetIds={providerExistingAssetIds}
initialDate={entryDate}
contextLocation={contextLocation}
initialEntryId={entry.id || null}
entryPicker={{ providers, onSelectProvider: setExternalProvider, Frame: EntryPhotoPickerSheet }}
onClose={closeProviderPicker}
onAdd={async groups => {
queueProviderPhotos(activeProvider, groups)
closeProviderPicker()
}}
/>
)}
</>
)
}
+3 -9
View File
@@ -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);
@@ -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' }));