mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
fix(ci): repair Journey route registration and shared client behavior
Register the public view route, align generated entities and test fixtures, and share the scoped reads and access switches. Keep gallery and notification writes in order, and submit the email subscription from the dialog footer.
This commit is contained in:
@@ -56,11 +56,6 @@ export default function MJourneySettingsSheet({
|
||||
journeyId: journey.id,
|
||||
onLinked: () => { setAddTripOpen(false); onRefresh() },
|
||||
})
|
||||
const {
|
||||
link: shareLink, copied, shareUrl, createLink: createShareLink, togglePerm: toggleSharePerm,
|
||||
deleteLink: deleteShareLink, copyLink: copyShareUrl, setProtection,
|
||||
} = useJourneyShareLink(journey.id)
|
||||
const shareAccess = useJourneyShareAccess(journey.id, shareLink, setProtection)
|
||||
const coverRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
const coverSrc = journeyCoverSrc(journey.cover_image)
|
||||
@@ -241,72 +236,7 @@ export default function MJourneySettingsSheet({
|
||||
|
||||
<MTripAccessList access={journey.trip_access} />
|
||||
|
||||
<SheetSection title={t('journey.share.publicShare')}>
|
||||
{!shareLink ? (
|
||||
<button type="button" onClick={createShareLink} className={`${SHEET_PRIMARY} justify-center`}>
|
||||
<LinkIcon size={14} strokeWidth={2.2} />
|
||||
{t('journey.share.createLink')}
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
{shareUrl && (
|
||||
<MLinkField
|
||||
url={shareUrl}
|
||||
copied={copied}
|
||||
onCopy={copyShareUrl}
|
||||
copyLabel={t('journey.share.copy')}
|
||||
copiedLabel={t('journey.share.copied')}
|
||||
shareLabel={t('common.share')}
|
||||
/>
|
||||
)}
|
||||
{shareAccess.views > 0 && (
|
||||
<div className="flex items-center gap-1.5 ps-1 font-geist text-caption text-m-muted">
|
||||
<Eye size={12} strokeWidth={2} />
|
||||
<span>{t('journey.share.views', { count: shareAccess.views })}</span>
|
||||
{shareAccess.lastViewed && <span>{t('journey.share.lastViewed', { date: shareAccess.lastViewed })}</span>}
|
||||
</div>
|
||||
)}
|
||||
{([
|
||||
{ key: 'share_timeline' as const, label: t('journey.share.timeline'), icon: List },
|
||||
{ key: 'share_gallery' as const, label: t('journey.share.gallery'), icon: Grid3x3 },
|
||||
{ key: 'share_map' as const, label: t('journey.share.map'), icon: MapPin },
|
||||
]).map(({ key, label, icon: Icon }) => (
|
||||
<ToggleRow
|
||||
key={key}
|
||||
icon={<Icon size={16} strokeWidth={2} />}
|
||||
label={label}
|
||||
checked={shareLink[key]}
|
||||
onChange={() => toggleSharePerm(key)}
|
||||
/>
|
||||
))}
|
||||
<MShareMapExtras link={shareLink} onToggle={toggleSharePerm} />
|
||||
<ToggleRow
|
||||
icon={<MessageCircle size={16} strokeWidth={2} />}
|
||||
label={t('journey.share.allowComments')}
|
||||
hint={shareLink.share_timeline ? t('journey.share.allowCommentsHint') : t('journey.share.needsTimeline')}
|
||||
checked={!!shareLink.share_timeline && !!shareLink.allow_comments}
|
||||
disabled={!shareLink.share_timeline}
|
||||
onChange={() => { void toggleSharePerm('allow_comments') }}
|
||||
/>
|
||||
<ToggleRow
|
||||
icon={<BellPlus size={16} strokeWidth={2} />}
|
||||
label={t('journey.share.allowFollowers')}
|
||||
hint={t('journey.share.allowFollowersHint')}
|
||||
checked={!!shareLink.allow_subscriptions}
|
||||
onChange={() => { void toggleSharePerm('allow_subscriptions') }}
|
||||
/>
|
||||
{shareLink.allow_subscriptions && <MShareFollowers access={shareAccess} />}
|
||||
<MShareAccess access={shareAccess} />
|
||||
<button
|
||||
type="button"
|
||||
onClick={deleteShareLink}
|
||||
className="flex h-[38px] w-full items-center justify-center gap-1.5 rounded-full text-[length:calc(12px*var(--fs-scale-body,1))] font-semibold text-[color:var(--m-st-danger)]"
|
||||
>
|
||||
<Trash2 size={13} strokeWidth={2.2} /> {t('journey.share.removeLink')}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</SheetSection>
|
||||
<MShareSection journeyId={journey.id} />
|
||||
|
||||
<button type="button" onClick={handleArchiveToggle} disabled={archiving} className={`${SHEET_SECONDARY} flex-none`}>
|
||||
{journey.status === 'archived' ? <ArchiveRestore size={14} strokeWidth={2.2} /> : <Archive size={14} strokeWidth={2.2} />}
|
||||
@@ -437,6 +367,83 @@ function MRecordingPrepRow({ prep, enabled }: { prep: JourneyRecordingPrepState;
|
||||
)
|
||||
}
|
||||
|
||||
function MShareSection({ journeyId }: { journeyId: number }) {
|
||||
const { t } = useTranslation()
|
||||
const {
|
||||
link: shareLink, copied, shareUrl, createLink: createShareLink, togglePerm: toggleSharePerm,
|
||||
deleteLink: deleteShareLink, copyLink: copyShareUrl, setProtection,
|
||||
} = useJourneyShareLink(journeyId)
|
||||
const shareAccess = useJourneyShareAccess(journeyId, shareLink, setProtection)
|
||||
return (
|
||||
<SheetSection title={t('journey.share.publicShare')}>
|
||||
{!shareLink ? (
|
||||
<button type="button" onClick={createShareLink} className={`${SHEET_PRIMARY} justify-center`}>
|
||||
<LinkIcon size={14} strokeWidth={2.2} />
|
||||
{t('journey.share.createLink')}
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
{shareUrl && (
|
||||
<MLinkField
|
||||
url={shareUrl}
|
||||
copied={copied}
|
||||
onCopy={copyShareUrl}
|
||||
copyLabel={t('journey.share.copy')}
|
||||
copiedLabel={t('journey.share.copied')}
|
||||
shareLabel={t('common.share')}
|
||||
/>
|
||||
)}
|
||||
{shareAccess.views > 0 && (
|
||||
<div className="flex items-center gap-1.5 ps-1 font-geist text-caption text-m-muted">
|
||||
<Eye size={12} strokeWidth={2} />
|
||||
<span>{t('journey.share.views', { count: shareAccess.views })}</span>
|
||||
{shareAccess.lastViewed && <span>{t('journey.share.lastViewed', { date: shareAccess.lastViewed })}</span>}
|
||||
</div>
|
||||
)}
|
||||
{([
|
||||
{ key: 'share_timeline' as const, label: t('journey.share.timeline'), icon: List },
|
||||
{ key: 'share_gallery' as const, label: t('journey.share.gallery'), icon: Grid3x3 },
|
||||
{ key: 'share_map' as const, label: t('journey.share.map'), icon: MapPin },
|
||||
]).map(({ key, label, icon: Icon }) => (
|
||||
<ToggleRow
|
||||
key={key}
|
||||
icon={<Icon size={16} strokeWidth={2} />}
|
||||
label={label}
|
||||
checked={shareLink[key]}
|
||||
onChange={() => toggleSharePerm(key)}
|
||||
/>
|
||||
))}
|
||||
<MShareMapExtras link={shareLink} onToggle={toggleSharePerm} />
|
||||
<ToggleRow
|
||||
icon={<MessageCircle size={16} strokeWidth={2} />}
|
||||
label={t('journey.share.allowComments')}
|
||||
hint={shareLink.share_timeline ? t('journey.share.allowCommentsHint') : t('journey.share.needsTimeline')}
|
||||
checked={!!shareLink.share_timeline && !!shareLink.allow_comments}
|
||||
disabled={!shareLink.share_timeline}
|
||||
onChange={() => { void toggleSharePerm('allow_comments') }}
|
||||
/>
|
||||
<ToggleRow
|
||||
icon={<BellPlus size={16} strokeWidth={2} />}
|
||||
label={t('journey.share.allowFollowers')}
|
||||
hint={t('journey.share.allowFollowersHint')}
|
||||
checked={!!shareLink.allow_subscriptions}
|
||||
onChange={() => { void toggleSharePerm('allow_subscriptions') }}
|
||||
/>
|
||||
{shareLink.allow_subscriptions && <MShareFollowers access={shareAccess} />}
|
||||
<MShareAccess access={shareAccess} />
|
||||
<button
|
||||
type="button"
|
||||
onClick={deleteShareLink}
|
||||
className="flex h-[38px] w-full items-center justify-center gap-1.5 rounded-full text-[length:calc(12px*var(--fs-scale-body,1))] font-semibold text-[color:var(--m-st-danger)]"
|
||||
>
|
||||
<Trash2 size={13} strokeWidth={2.2} /> {t('journey.share.removeLink')}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</SheetSection>
|
||||
)
|
||||
}
|
||||
|
||||
type ShareAccess = ReturnType<typeof useJourneyShareAccess>
|
||||
|
||||
/** The addresses following the link (#1669): two counts, the list behind them. */
|
||||
|
||||
Reference in New Issue
Block a user