Co-authored-by: Hongtao Lye <codert.sn@gmail.com> Co-authored-by: liuyi <forehalo@gmail.com> Co-authored-by: LongYinan <lynweklm@gmail.com> Co-authored-by: X1a0t <405028157@qq.com> Co-authored-by: JimmFly <yangjinfei001@gmail.com> Co-authored-by: Peng Xiao <pengxiao@outlook.com> Co-authored-by: xiaodong zuo <53252747+zuoxiaodong0815@users.noreply.github.com> Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> Co-authored-by: Qi <474021214@qq.com> Co-authored-by: danielchim <kahungchim@gmail.com>
76 lines
2.1 KiB
TypeScript
76 lines
2.1 KiB
TypeScript
import { initEmptyPage } from '@affine/env/blocksuite';
|
|
import { PageNotFoundError } from '@affine/env/constant';
|
|
import type {
|
|
WorkspaceFlavour,
|
|
WorkspaceUISchema,
|
|
} from '@affine/env/workspace';
|
|
import { lazy, useCallback } from 'react';
|
|
|
|
import { useIsWorkspaceOwner } from '../../hooks/affine/use-is-workspace-owner';
|
|
import { useWorkspace } from '../../hooks/use-workspace';
|
|
import {
|
|
BlockSuitePageList,
|
|
NewWorkspaceSettingDetail,
|
|
PageDetailEditor,
|
|
Provider,
|
|
WorkspaceHeader,
|
|
} from '../shared';
|
|
|
|
const LoginCard = lazy(() =>
|
|
import('../../components/cloud/login-card').then(({ LoginCard }) => ({
|
|
default: LoginCard,
|
|
}))
|
|
);
|
|
|
|
export const UI = {
|
|
Provider,
|
|
LoginCard,
|
|
Header: WorkspaceHeader,
|
|
PageDetail: ({ currentWorkspaceId, currentPageId, onLoadEditor }) => {
|
|
const workspace = useWorkspace(currentWorkspaceId);
|
|
const page = workspace.blockSuiteWorkspace.getPage(currentPageId);
|
|
if (!page) {
|
|
throw new PageNotFoundError(workspace.blockSuiteWorkspace, currentPageId);
|
|
}
|
|
return (
|
|
<>
|
|
<PageDetailEditor
|
|
pageId={currentPageId}
|
|
onInit={useCallback(async page => initEmptyPage(page), [])}
|
|
onLoad={onLoadEditor}
|
|
workspace={workspace.blockSuiteWorkspace}
|
|
/>
|
|
</>
|
|
);
|
|
},
|
|
PageList: ({ blockSuiteWorkspace, onOpenPage, collection }) => {
|
|
return (
|
|
<BlockSuitePageList
|
|
listType="all"
|
|
collection={collection}
|
|
onOpenPage={onOpenPage}
|
|
blockSuiteWorkspace={blockSuiteWorkspace}
|
|
/>
|
|
);
|
|
},
|
|
NewSettingsDetail: ({
|
|
currentWorkspaceId,
|
|
onTransformWorkspace,
|
|
onDeleteLocalWorkspace,
|
|
onDeleteCloudWorkspace,
|
|
onLeaveWorkspace,
|
|
}) => {
|
|
const isOwner = useIsWorkspaceOwner(currentWorkspaceId);
|
|
return (
|
|
<NewWorkspaceSettingDetail
|
|
onDeleteLocalWorkspace={onDeleteLocalWorkspace}
|
|
onDeleteCloudWorkspace={onDeleteCloudWorkspace}
|
|
onLeaveWorkspace={onLeaveWorkspace}
|
|
workspaceId={currentWorkspaceId}
|
|
onTransferWorkspace={onTransformWorkspace}
|
|
isOwner={isOwner}
|
|
/>
|
|
);
|
|
},
|
|
} satisfies WorkspaceUISchema<WorkspaceFlavour.AFFINE_CLOUD>;
|