feat: publish workspace

This commit is contained in:
DiamondThree
2023-01-11 12:12:12 +08:00
parent eef467558e
commit ee6138134d
6 changed files with 38 additions and 57 deletions
@@ -9,20 +9,17 @@ import {
import { Button } from '@/ui/button';
import Input from '@/ui/input';
import { toast } from '@/ui/toast';
import { useConfirm } from '@/providers/ConfirmProvider';
// import { useAppState } from '@/providers/app-state-provider3';
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
import { WorkspaceUnit } from '@affine/datacenter';
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
const shareUrl =
window.location.host + '/workspace/' + workspace.id + '?share=true';
const { publishWorkspace } = useWorkspaceHelper();
const { publishWorkspace, enableWorkspace } = useWorkspaceHelper();
const { confirm } = useConfirm();
const togglePublic = (flag: boolean) => {
workspace.id && publishWorkspace(workspace?.id, flag);
const togglePublic = async (flag: boolean) => {
await publishWorkspace(workspace.id.toString(), flag);
};
const copyUrl = () => {
@@ -30,27 +27,12 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
toast('Copied url to clipboard');
};
const enableAffineCloud = () => {
confirm({
title: 'Enable AFFiNE Cloud?',
content: `If enabled, the data in this workspace will be backed up and synchronized via AFFiNE Cloud.`,
confirmText:
workspace.provider === 'local' ? 'Enable' : 'Sign in and Enable',
cancelText: 'Skip',
}).then(confirm => {
if (confirm) {
// if (user) {
// updateWorkspaceMeta(workspace.id, { type: 'cloud' });
// } else {
// login();
// updateWorkspaceMeta(workspace.id, { type: 'cloud' });
// }
}
});
const enableAffineCloud = async () => {
await enableWorkspace();
};
return (
<>
{workspace.provider === 'cloud' ? (
{workspace.provider === 'affine' ? (
<div>
<StyledPublishContent>
{workspace?.published ? (