import { StyledCopyButtonContainer, StyledPublishContent, StyledPublishCopyContainer, StyledPublishExplanation, StyledSettingH2, StyledStopPublishContainer, } from './style'; import { useState } from 'react'; import { Button } from '@/ui/button'; import Input from '@/ui/input'; import { toast } from '@/ui/toast'; // import { useAppState } from '@/providers/app-state-provider3'; import { WorkspaceUnit } from '@affine/datacenter'; import { useWorkspaceHelper } from '@/hooks/use-workspace-helper'; import { useTranslation } from '@affine/i18n'; import { EnableWorkspaceButton } from '../enable-workspace'; export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => { const shareUrl = window.location.host + '/public-workspace/' + workspace.id; const { publishWorkspace } = useWorkspaceHelper(); const { t } = useTranslation(); const [loaded, setLoaded] = useState(false); const togglePublic = async (flag: boolean) => { try { await publishWorkspace(workspace.id.toString(), flag); } catch (e) { toast('Failed to publish workspace'); } }; const copyUrl = () => { navigator.clipboard.writeText(shareUrl); toast('Copied url to clipboard'); }; return ( <> {workspace.provider === 'affine' ? (
{workspace.published ? ( <> The current workspace has been published to the web, everyone can view the contents of this workspace through the link. {t('Share with link')} ) : ( {t('Publishing Description')}
)}
{workspace.published ? ( ) : ( <> )}
) : ( <> Publishing to web requires AFFiNE Cloud service.
)} ); };