mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
feat(trips): trip settings with a linked journal tab
The Share button becomes the trip's Settings, a round button beside the back pill. The dialog is rebuilt around three areas (People, Sharing, Journal) with a side navigation, a fixed height and 960 px width on wide screens. Journal links one of your journals from the Journey addon to the trip. Every trip member is ticked as a reader by default, each can be raised to editor or left out, and the people a save would let in for the first time are named before it saves. The link can be changed or removed. With a link the trip gets a Journal tab on desktop and phone that shows the Journey addon's own view, live through its sync and trip:journal:changed. Nothing shows with the addon off. members.shareTrip and nav.share are gone with the button that used them.
This commit is contained in:
@@ -18,7 +18,7 @@ import JourneyDayDawarich from '../components/Journey/JourneyDayDawarich'
|
||||
import MobileEntryView from '../components/Journey/MobileEntryView'
|
||||
import { useJourneyStore } from '../store/journeyStore'
|
||||
import { computeJourneyLifecycle } from '../utils/journeyLifecycle'
|
||||
import { useJourneyDetail } from './journeyDetail/useJourneyDetail'
|
||||
import { useJourneyDetail, type JourneyDetailOptions } from './journeyDetail/useJourneyDetail'
|
||||
import { createDraftJourneyEntry, pickGradient, groupByDate, formatDate, photoUrl, matchJourneyEntries } from './journeyDetail/JourneyDetailPage.helpers'
|
||||
import { EntryCard, SkeletonCard, CheckinCard } from '../components/Journey/JourneyDetailPageEntryCard'
|
||||
import { GalleryView } from '../components/Journey/JourneyDetailPageGalleryView'
|
||||
@@ -39,7 +39,12 @@ export default function JourneyDetailPage() {
|
||||
)
|
||||
}
|
||||
|
||||
function JourneyDetailPageDesktop() {
|
||||
/**
|
||||
* The journal screen. The journal page renders it for the route's journal; a trip
|
||||
* that links a journal renders the same screen inside its own tab (`embedded`),
|
||||
* so the trip shows the journal with nothing of it built twice.
|
||||
*/
|
||||
export function JourneyDetailPageDesktop({ journeyId, embedded = false }: JourneyDetailOptions = {}) {
|
||||
// Page = wiring container: load + live sync, view state, dialogs, the
|
||||
// scroll-synced map and the map/trip-date derivations live in the hook.
|
||||
const {
|
||||
@@ -62,13 +67,17 @@ function JourneyDetailPageDesktop() {
|
||||
feedEdge, scrollFeedTo,
|
||||
loadJourney, updateEntry, deleteEntry, reorderEntries, uploadPhotos, deletePhoto,
|
||||
addPickedProviderPhotos, addEntryProviderPhotos,
|
||||
} = useJourneyDetail()
|
||||
} = useJourneyDetail({ journeyId, embedded })
|
||||
// Inside a trip the trip draws the bar and owns the height; the journal fills
|
||||
// the box it is given and starts at its top.
|
||||
const frame = embedded ? 'h-full bg-zinc-50 dark:bg-zinc-950' : 'min-h-screen bg-zinc-50 dark:bg-zinc-950'
|
||||
const below = embedded ? undefined : { paddingTop: 'var(--nav-h, 0px)' }
|
||||
|
||||
if (loading || !current) {
|
||||
return (
|
||||
<div className="min-h-screen bg-zinc-50 dark:bg-zinc-950">
|
||||
<Navbar />
|
||||
<div style={{ paddingTop: 'var(--nav-h, 0px)' }} className="flex justify-center py-20">
|
||||
<div className={frame}>
|
||||
{!embedded && <Navbar />}
|
||||
<div style={below} className="flex justify-center py-20">
|
||||
<div className="w-6 h-6 border-2 border-zinc-300 border-t-zinc-900 rounded-full animate-spin" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -166,8 +175,8 @@ function JourneyDetailPageDesktop() {
|
||||
) : null
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-zinc-50 dark:bg-zinc-950">
|
||||
<Navbar />
|
||||
<div className={frame}>
|
||||
{!embedded && <Navbar />}
|
||||
|
||||
{/* Mobile combined map+timeline (Polarsteps-style) — renders as fullscreen overlay */}
|
||||
{showMobileCombined && (
|
||||
@@ -206,13 +215,15 @@ function JourneyDetailPageDesktop() {
|
||||
className="fixed inset-x-0 z-30 flex items-start justify-between gap-2 px-4"
|
||||
style={{ top: 'calc(var(--nav-h, 56px) + 12px)' }}
|
||||
>
|
||||
<button type="button"
|
||||
onClick={() => navigate('/journey')}
|
||||
aria-label={t('journey.detail.backToJourney')}
|
||||
className={barButton}
|
||||
>
|
||||
<ArrowLeft size={16} />
|
||||
</button>
|
||||
{!embedded && (
|
||||
<button type="button"
|
||||
onClick={() => navigate('/journey')}
|
||||
aria-label={t('journey.detail.backToJourney')}
|
||||
className={barButton}
|
||||
>
|
||||
<ArrowLeft size={16} />
|
||||
</button>
|
||||
)}
|
||||
|
||||
<div className="flex-1 min-w-0 flex justify-center">
|
||||
<div className="flex bg-surface-elevated backdrop-blur-lg border border-edge rounded-lg overflow-hidden shadow-lg">
|
||||
@@ -270,7 +281,7 @@ function JourneyDetailPageDesktop() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ paddingTop: 'var(--nav-h, 0px)' }} className={showMobileCombined ? 'hidden' : ''}>
|
||||
<div style={below} className={showMobileCombined ? 'hidden' : embedded ? 'h-full' : ''}>
|
||||
<div
|
||||
className={
|
||||
isMobile
|
||||
@@ -310,13 +321,15 @@ function JourneyDetailPageDesktop() {
|
||||
|
||||
<div className="relative z-[3] flex items-center justify-between mb-5">
|
||||
<div className="flex items-center gap-2">
|
||||
<button type="button"
|
||||
onClick={() => navigate('/journey')}
|
||||
aria-label={t('journey.detail.backToJourney')}
|
||||
className="w-[34px] h-[34px] rounded-full bg-white/15 backdrop-blur flex items-center justify-center hover:bg-white/25"
|
||||
>
|
||||
<ArrowLeft size={14} />
|
||||
</button>
|
||||
{!embedded && (
|
||||
<button type="button"
|
||||
onClick={() => navigate('/journey')}
|
||||
aria-label={t('journey.detail.backToJourney')}
|
||||
className="w-[34px] h-[34px] rounded-full bg-white/15 backdrop-blur flex items-center justify-center hover:bg-white/25"
|
||||
>
|
||||
<ArrowLeft size={14} />
|
||||
</button>
|
||||
)}
|
||||
{/* Status badge — keep completed/upcoming/draft/archived, but drop live + synced-with-trips per UX trim */}
|
||||
<div className="hidden md:flex items-center gap-2">
|
||||
{lifecycle !== 'live' && lifecycle !== 'archived' && (
|
||||
@@ -821,7 +834,7 @@ function JourneyDetailPageDesktop() {
|
||||
|
||||
{/* TREK Studio. It portals itself over the page, so this journey keeps
|
||||
rendering underneath and shows through the panel's margin. */}
|
||||
<Outlet />
|
||||
{!embedded && <Outlet />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import { latestReservation } from './tripPlanner/transportEditorOpeners'
|
||||
import {
|
||||
ReservationsPanel, FileManager, CostsPanel, ExpenseModal, CollabPanel,
|
||||
RoadtripSidebar, RoadtripCorridorPanel, RoadtripLimitsCard, RoadtripStopPopup, RoadtripStayModal, RoadtripTrackModal,
|
||||
TourWorkspaceRail, TourPlannerToursRail, TransportModal,
|
||||
TourWorkspaceRail, TourPlannerToursRail, TransportModal, TripJournalPanel,
|
||||
} from './tripPlanner/plannerLazy'
|
||||
import { LazyPanel } from './tripPlanner/LazyPanel'
|
||||
import { ListsContainer } from './tripPlanner/ListsContainer'
|
||||
@@ -70,7 +70,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
|
||||
trip, days, places, assignments, packingItems, todoItems, categories, reservations, budgetItems, files,
|
||||
selectedDayId, isLoading, tripActions, can, canUploadFiles,
|
||||
pushUndo, undo, canUndo, lastActionLabel, handleUndo,
|
||||
enabledAddons, collabFeatures, tripAccommodations, setTripAccommodations,
|
||||
enabledAddons, collabFeatures, journalId, tripAccommodations, setTripAccommodations,
|
||||
roadtripMode, toggleRoadtripMode, roadtripActive, roadtripRoutes, roadtripLineColors, roadtripMapLines, roadtripMapPlaces, collapsedRoadtripDays, toggleRoadtripDay, roadtripCorridor,
|
||||
overviewActive, tripOverview, toggleOverview, overviewShown,
|
||||
dawarichEnabled, dawarichTrailShown, toggleDawarichTrail, dawarichTrail, dawarichHiddenDates,
|
||||
@@ -242,7 +242,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
|
||||
return (
|
||||
<div style={{ position: 'fixed', inset: 0, display: 'flex', flexDirection: 'column', overflow: 'hidden', ...fontStyle }}>
|
||||
<HelpAnchor id={helpId} />
|
||||
<Navbar tripTitle={trip.title} tripId={tripId} showBack onBack={() => navigate('/dashboard')} onShare={() => setShowMembersModal(true)} />
|
||||
<Navbar tripTitle={trip.title} tripId={tripId} showBack onBack={() => navigate('/dashboard')} onSettings={() => setShowMembersModal(true)} />
|
||||
|
||||
<div className="bg-surface-elevated border-b border-edge-faint" style={{
|
||||
position: 'fixed', top: 'var(--nav-h)', insetInline: 0, zIndex: 40,
|
||||
@@ -792,7 +792,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
|
||||
</LazyPanel>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'journal' && <LazyPanel id="journal"><TripJournalPanel journeyId={journalId} /></LazyPanel>}
|
||||
|
||||
{activeTab.startsWith('plugin:') && (
|
||||
<div style={{ position: 'absolute', top: 0, insetInline: 0, bottom: 'var(--bottom-nav-h)', overflow: 'hidden' }}>
|
||||
|
||||
@@ -29,9 +29,23 @@ const NO_TRACKS: JourneyTrack[] = []
|
||||
* map/trip-date derivations. JourneyDetailPage stays a wiring container around
|
||||
* its large two-pane JSX and many presentational sub-components.
|
||||
* Behaviour is identical to the previous in-component logic.
|
||||
*
|
||||
* The journal can also show inside a trip that links it, as the same screen with
|
||||
* the same dialogs. There the trip names the journal (`journeyId`) instead of the
|
||||
* route, and `embedded` keeps the screen to its own box: no scroll lock on the
|
||||
* page, no `?create=` handling on the trip's URL, and no trip out to the journal
|
||||
* list when the journal goes away; the trip decides what shows then.
|
||||
*/
|
||||
export function useJourneyDetail() {
|
||||
const { id } = useParams()
|
||||
export interface JourneyDetailOptions {
|
||||
/** The journal to show; the route's `:id` when left out. */
|
||||
journeyId?: number
|
||||
/** Shown inside another screen (a trip) rather than as the journal page. */
|
||||
embedded?: boolean
|
||||
}
|
||||
|
||||
export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailOptions = {}) {
|
||||
const params = useParams()
|
||||
const id = journeyId != null ? String(journeyId) : params.id
|
||||
const navigate = useNavigate()
|
||||
const toast = useToast()
|
||||
const { t, locale } = useTranslation()
|
||||
@@ -67,9 +81,10 @@ export function useJourneyDetail() {
|
||||
const [showAddTrip, setShowAddTrip] = useState(false)
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
|
||||
// The bottom-nav "+" starts a new entry via ?create=entry.
|
||||
// The bottom-nav "+" starts a new entry via ?create=entry. Not inside a trip:
|
||||
// the trip's own `create` values live on that same URL.
|
||||
useEffect(() => {
|
||||
if (searchParams.get('create') === 'entry' && current && canEditEntries) {
|
||||
if (!embedded && searchParams.get('create') === 'entry' && current && canEditEntries) {
|
||||
setEditingEntry(createDraftJourneyEntry(current.id))
|
||||
setSearchParams(p => { p.delete('create'); return p }, { replace: true })
|
||||
}
|
||||
@@ -119,11 +134,11 @@ export function useJourneyDetail() {
|
||||
}, [current?.hide_skeletons])
|
||||
|
||||
useEffect(() => {
|
||||
if (notFound) {
|
||||
if (notFound && !embedded) {
|
||||
toast.error(t('journey.notFound'))
|
||||
navigate('/journey')
|
||||
}
|
||||
}, [notFound])
|
||||
}, [notFound, embedded])
|
||||
|
||||
// WebSocket real-time updates
|
||||
useEffect(() => {
|
||||
@@ -374,9 +389,9 @@ export function useJourneyDetail() {
|
||||
// the body must not scroll underneath it. Goes through the shared counter so a
|
||||
// modal opening on top of it cannot hand the page back early (#1809).
|
||||
useEffect(() => {
|
||||
if (isMobile) return
|
||||
if (isMobile || embedded) return
|
||||
return lockBodyScroll()
|
||||
}, [isMobile])
|
||||
}, [isMobile, embedded])
|
||||
|
||||
// Map only shows real journal entries — skeletons are trip-derived
|
||||
// suggestions, not something the user actually journaled at that spot.
|
||||
@@ -549,7 +564,7 @@ export function useJourneyDetail() {
|
||||
}, [])
|
||||
|
||||
return {
|
||||
id, navigate, toast, t, locale,
|
||||
id, navigate, toast, t, locale, embedded, notFound,
|
||||
openStudio, prefetchStudio,
|
||||
current, loading,
|
||||
canEditEntries, canEditJourney, myRole,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { JourneyDetailPageDesktop } from '../JourneyDetailPage';
|
||||
|
||||
/**
|
||||
* The trip's Journal tab on the desktop: the Journey addon's own journal view,
|
||||
* not a copy of it, so the journal looks and works the same in both places and
|
||||
* stays live through the journey's own sync. The wrapper moves the view's fixed
|
||||
* bars below the trip's tab bar (see .trip-embedded-journal).
|
||||
*/
|
||||
export default function TripJournalPanel({ journeyId }: { journeyId: number | null }) {
|
||||
if (journeyId == null) return null;
|
||||
return (
|
||||
<div className="trip-embedded-journal absolute inset-0 overflow-y-auto">
|
||||
<JourneyDetailPageDesktop journeyId={journeyId} embedded />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -17,6 +17,8 @@ export const ExpenseModal = lazyWithRetry(() =>
|
||||
import('../../components/Budget/CostsPanel').then(m => ({ default: m.ExpenseModal }))
|
||||
)
|
||||
export const CollabPanel = lazyWithRetry(() => import('../../components/Collab/CollabPanel'))
|
||||
// The Journey addon's journal view, which only a trip with a linked journal opens.
|
||||
export const TripJournalPanel = lazyWithRetry(() => import('./TripJournalPanel'))
|
||||
export const RoadtripSidebar = lazyWithRetry(() => import('../../components/Roadtrip/RoadtripSidebar'))
|
||||
export const RoadtripCorridorPanel = lazyWithRetry(() => import('../../components/Roadtrip/RoadtripCorridorPanel'))
|
||||
export const RoadtripLimitsCard = lazyWithRetry(() => import('../../components/Roadtrip/RoadtripLimitsCard'))
|
||||
|
||||
@@ -24,6 +24,8 @@ import { isServiceStopType } from '../../components/Roadtrip/roadtripModel'
|
||||
import { inspectorStay } from '../../components/Roadtrip/stayReading'
|
||||
import { usePlaceSelection } from '../../hooks/usePlaceSelection'
|
||||
import { useTourPlaceIds } from '../../hooks/useTourPlaceIds'
|
||||
import { LinkedJournalIcon } from '../../components/Trips/LinkedJournalIcon'
|
||||
import { useTripJournal } from '../../components/Trips/useTripJournalLink'
|
||||
import { useAddonStore } from '../../store/addonStore'
|
||||
import { usePlannerHistory } from '../../hooks/usePlannerHistory'
|
||||
import { useIsTouch } from '../../hooks/useIsTouch'
|
||||
@@ -198,6 +200,7 @@ export function useTripPlanner() {
|
||||
|
||||
// A trip-page plugin may replace core tabs while it's active (its manifest names
|
||||
// them; 'plan' is never replaceable) and may pick where its own tab sits.
|
||||
const journal = useTripJournal(Number.isFinite(tripId) ? tripId : null)
|
||||
const replacedTabs = new Set(tripPagePlugins.flatMap(p => p.tripPage?.replaces ?? []))
|
||||
const TRIP_TABS = [
|
||||
{ id: 'plan', label: t(TRIP_TAB_LABEL_KEYS.plan), icon: Map },
|
||||
@@ -211,6 +214,8 @@ export function useTripPlanner() {
|
||||
...(enabledAddons.budget ? [{ id: 'finanzplan', label: t(TRIP_TAB_LABEL_KEYS.finanzplan), icon: Wallet }] : []),
|
||||
...(enabledAddons.documents ? [{ id: 'dateien', label: t(TRIP_TAB_LABEL_KEYS.dateien), icon: FolderOpen }] : []),
|
||||
...(enabledAddons.collab ? [{ id: 'collab', label: t(TRIP_TAB_LABEL_KEYS.collab), icon: Users }] : []),
|
||||
// A journal from the Journey addon tied to this trip, for whoever the link lets in.
|
||||
...(journal.openJournalId != null ? [{ id: 'journal', label: t(TRIP_TAB_LABEL_KEYS.journal), icon: LinkedJournalIcon }] : []),
|
||||
].filter(tab => tab.id === 'plan' || !replacedTabs.has(tab.id))
|
||||
// Positioned plugin tabs splice in ascending order so two positions stay stable;
|
||||
// the rest append, exactly as before this capability existed.
|
||||
@@ -237,12 +242,14 @@ export function useTripPlanner() {
|
||||
// Same for the addon-owned tabs: until the feed answers, enabledAddons is a
|
||||
// guess, and evicting on a guess would drop a legitimately requested tab.
|
||||
if (!addonsLoaded) return
|
||||
// And for the Journal tab, until the link has been asked for.
|
||||
if (activeTab === 'journal' && !journal.settled) return
|
||||
const validTabIds = TRIP_TABS.map(t => t.id)
|
||||
if (!validTabIds.includes(activeTab)) {
|
||||
setActiveTab('plan')
|
||||
sessionStorage.setItem(`trip-tab-${tripId}`, 'plan')
|
||||
}
|
||||
}, [activeTab, enabledAddons, addonsLoaded, tripPluginIds, pluginsLoaded, isMobile])
|
||||
}, [activeTab, enabledAddons, addonsLoaded, tripPluginIds, pluginsLoaded, isMobile, journal.settled, journal.openJournalId])
|
||||
|
||||
const handleTabChange = (rawTabId: string): void => {
|
||||
// A core tab a plugin replaced is gone from the bar, but a programmatic jump
|
||||
@@ -653,7 +660,7 @@ export function useTripPlanner() {
|
||||
trip, days, places, assignments, storedAssignments, packingItems, todoItems, categories, reservations, budgetItems, files,
|
||||
selectedDayId, isLoading, tripActions, can, canUploadFiles,
|
||||
pushUndo, undo, canUndo, lastActionLabel, handleUndo,
|
||||
enabledAddons, collabFeatures, tripAccommodations, setTripAccommodations,
|
||||
enabledAddons, collabFeatures, journalId: journal.openJournalId, tripAccommodations, setTripAccommodations,
|
||||
roadtripMode, toggleRoadtripMode, roadtripActive, roadtripFeedActive, roadtripRoutes, roadtripLineColors, roadtripMapLines, roadtripMapPlaces, collapsedRoadtripDays, toggleRoadtripDay, roadtripCorridor,
|
||||
overviewShown, toggleOverview, overviewActive, tripOverview,
|
||||
dawarichTrailShown, toggleDawarichTrail, dawarichTrail, dawarichHiddenDates, dawarichEnabled: !!enabledAddons.dawarich,
|
||||
|
||||
Reference in New Issue
Block a user