Build and Deploy Verso / deploy (push) Successful in 7m57s
Adds a project-members-only link tier and independent link rotation.
- Three tokens per project instead of two: publicToken (anyone), loginToken
(any logged-in user), memberToken (only users who can read the project).
serve() resolves the token to its tier and enforces accordingly — 'member'
requires AuthorizationManager.canUserReadProject.
- New POST /project/:id/publish-presentation/regenerate { tier } rotates a
single tier's token (invalidating only that old link), leaving the snapshot
and the other links intact.
- Share dialog now shows three links (members / logged-in / anyone), each with
its own Copy and Reset buttons; Publish refreshes, Unpublish removes all.
Preview button opens the logged-in-users link.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import OLButton from '@/shared/components/ol/ol-button'
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
import { useCallback, useState } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { postJSON } from '@/infrastructure/fetch-json'
|
|
import getMeta from '@/utils/meta'
|
|
|
|
// One-click shortcut: publish the compiled presentation as a private
|
|
// (logged-in-users-only) standalone page and open it in a new tab. For finer
|
|
// control (public links, unpublish) use the Share dialog.
|
|
export default function PresentationPreviewButton() {
|
|
const { t } = useTranslation()
|
|
const [loading, setLoading] = useState(false)
|
|
const projectId = getMeta('ol-project_id')
|
|
|
|
const handleClick = useCallback(() => {
|
|
setLoading(true)
|
|
// Open the tab synchronously inside the click handler to avoid popup
|
|
// blockers, then redirect it once we have the published URL.
|
|
const win = window.open('', '_blank')
|
|
postJSON(`/project/${projectId}/publish-presentation`)
|
|
.then((data: { loginUrl?: string }) => {
|
|
const url = data?.loginUrl
|
|
if (url && win) {
|
|
win.location.href = url
|
|
} else if (url) {
|
|
window.open(url, '_blank')
|
|
} else if (win) {
|
|
win.close()
|
|
}
|
|
})
|
|
.catch(() => {
|
|
if (win) win.close()
|
|
})
|
|
.finally(() => setLoading(false))
|
|
}, [projectId])
|
|
|
|
return (
|
|
<div className="ide-redesign-toolbar-button-container">
|
|
<OLButton
|
|
size="sm"
|
|
variant="secondary"
|
|
leadingIcon={<MaterialIcon type="slideshow" />}
|
|
onClick={handleClick}
|
|
disabled={loading}
|
|
>
|
|
{t('preview')}
|
|
</OLButton>
|
|
</div>
|
|
)
|
|
}
|