feat(studio): add photos from Immich and Synology like the journey gallery (#2271)

This commit is contained in:
Maurice
2026-10-01 14:19:51 +02:00
parent 81d7022b96
commit f9baf3395e
35 changed files with 265 additions and 28 deletions
+36 -4
View File
@@ -1,6 +1,6 @@
import { useEffect, useMemo, useRef, useState } from 'react'
import {
Camera, Check, ChevronDown, ChevronUp, Compass, Copy, FileDown, Files, ImageIcon, LayoutTemplate,
Camera, Check, ChevronDown, ImagePlus, ChevronUp, Compass, Copy, FileDown, Files, ImageIcon, LayoutTemplate,
Plus, Search, Shapes, Trash2, Upload, X,
} from 'lucide-react'
import type { BookElement, BookPageSetup, JourneyStats } from '@trek/shared'
@@ -86,7 +86,7 @@ const THUMB_CHROME = (2 + 3) * 2
export function StudioSidebar({
page, pxPerMm, bookView, source, stats, path, t, locale,
canEdit, onUpload, onToggleStop,
canEdit, onUpload, onToggleStop, providers = [], onBrowseProvider,
}: {
page: BookPageSetup
pxPerMm: number
@@ -104,6 +104,10 @@ export function StudioSidebar({
onUpload: StudioUploader
/** Switch a stop on or off in the figures. Resolves false when it did not land. */
onToggleStop: (entryId: number, excluded: boolean) => Promise<boolean>
/** Photo providers connected for this user, each a way in next to the upload (#2271). */
providers?: { id: string; name: string }[]
/** Opens the provider picker; answers the photo ids that landed, none when closed. */
onBrowseProvider?: (provider: string, entryId: number | null) => Promise<number[]>
}) {
const [section, setSection] = useState<Section>('pages')
@@ -135,7 +139,8 @@ export function StudioSidebar({
<aside className="st-panel st-side">
{section === 'pages' && <PagesPanel page={page} pxPerMm={pxPerMm} bookView={bookView} t={t} />}
{section === 'content' && (
<ContentPanel source={source} page={page} t={t} locale={locale} canEdit={canEdit} onUpload={onUpload} />
<ContentPanel source={source} page={page} t={t} locale={locale} canEdit={canEdit} onUpload={onUpload}
providers={providers} onBrowseProvider={onBrowseProvider} />
)}
{section === 'elements' && <StudioElementsPanel page={page} t={t} />}
{section === 'travel' && (
@@ -337,7 +342,7 @@ function PagesPanel({
* sees it the moment the panel does.
*/
function ContentPanel({
source, page, t, locale, canEdit, onUpload,
source, page, t, locale, canEdit, onUpload, providers = [], onBrowseProvider,
}: {
source: JourneySource
page: BookPageSetup
@@ -345,6 +350,8 @@ function ContentPanel({
locale: string
canEdit: boolean
onUpload: StudioUploader
providers?: { id: string; name: string }[]
onBrowseProvider?: (provider: string, entryId: number | null) => Promise<number[]>
}) {
const [tab, setTab] = useState<'photos' | 'text'>('photos')
const [query, setQuery] = useState('')
@@ -394,6 +401,19 @@ function ContentPanel({
}
}
/**
* From a photo provider (#2271): into the same place an upload goes, and the
* new pictures shown the same way, under their own filter.
*/
const pickFromProvider = async (provider: string) => {
if (!onBrowseProvider) return
const photoIds = await onBrowseProvider(provider, filter.kind === 'entry' ? filter.id : null)
if (photoIds.length) {
setFilter({ kind: 'recent', photoIds })
setQuery('')
}
}
/*
* The whole scrolling area takes a drop, not just the dashed cell: a drag
* from the desktop arrives with the pointer wherever it arrives, and a target
@@ -587,6 +607,18 @@ function ContentPanel({
</span>
</button>
)}
{canEdit && onBrowseProvider && providers.map(p => (
<button type="button"
key={p.id}
className="st-photo-cell is-upload"
onClick={() => { void pickFromProvider(p.id) }}
disabled={!!upload}
title={t('journey.studio.fromProviderHint', { name: p.name })}
>
<ImagePlus size={18} strokeWidth={1.6} />
<span>{t('journey.studio.fromProvider', { name: p.name })}</span>
</button>
))}
{photos.map(p => (
<button type="button"
key={p.photoId}