Publish presentations: share-modal section + Preview button (UI)
Build and Deploy Verso / deploy (push) Successful in 7m53s

Wires the two entry points to the publishing backend:

- Share dialog: a "Share compiled presentation" section (owner only) with a
  public / logged-in-users-only choice, Publish/Unpublish, and a copyable link.
- Top-right toolbar: a "Preview" button that publishes a private (logged-in-
  users-only) link in one click and opens the standalone deck in a new tab
  (opened synchronously to dodge popup blockers).

Both talk to /project/:id/publish-presentation. Reuses existing i18n
(publish/unpublish/copy/preview); adds share_compiled_presentation(_info) and
presentation_link_public/private.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
claude
2026-06-01 14:39:39 +00:00
co-authored by Claude Opus 4.8
parent 18f9220e73
commit 59055aa67e
5 changed files with 202 additions and 0 deletions
@@ -0,0 +1,52 @@
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`, {
body: { visibility: 'private' },
})
.then((data: { url?: string }) => {
if (data?.url && win) {
win.location.href = data.url
} else if (data?.url) {
window.open(data.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>
)
}
@@ -3,6 +3,7 @@ import { ToolbarMenuBar } from './menu-bar'
import { ToolbarProjectTitle } from './project-title'
import { OnlineUsers } from './online-users'
import ShareProjectButton from './share-project-button'
import PresentationPreviewButton from './presentation-preview-button'
import ChangeLayoutButton from './change-layout-button'
import ShowHistoryButton from './show-history-button'
import { useLayoutContext } from '@/shared/context/layout-context'
@@ -59,6 +60,7 @@ export const Toolbar = () => {
{shouldDisplaySubmitButton && cobranding && (
<SubmitProjectButton cobranding={cobranding} />
)}
<PresentationPreviewButton />
<ShareProjectButton />
{getMeta('ol-showUpgradePrompt') && <UpgradeButton />}
</div>