mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-04 19:11:57 +08:00
feat(core): add no access to share menu (#10927)
This commit is contained in:
+5
-1
@@ -68,10 +68,12 @@ export const DetailPageWrapper = ({
|
||||
children,
|
||||
skeleton,
|
||||
notFound,
|
||||
canAccess,
|
||||
}: PropsWithChildren<{
|
||||
pageId: string;
|
||||
skeleton: ReactNode;
|
||||
notFound: ReactNode;
|
||||
canAccess?: boolean;
|
||||
}>) => {
|
||||
const { doc, editor, docListReady } = useLoadDoc(pageId);
|
||||
// if sync engine has been synced and the page is null, show 404 page.
|
||||
@@ -79,8 +81,10 @@ export const DetailPageWrapper = ({
|
||||
return notFound;
|
||||
}
|
||||
|
||||
if (!doc || !editor) {
|
||||
if (canAccess === undefined || !doc || !editor) {
|
||||
return skeleton;
|
||||
} else if (!canAccess) {
|
||||
return notFound;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -368,6 +368,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
||||
export const Component = () => {
|
||||
const params = useParams();
|
||||
const recentPages = useService(RecentDocsService);
|
||||
const guardService = useService(GuardService);
|
||||
|
||||
useEffect(() => {
|
||||
if (params.pageId) {
|
||||
@@ -379,10 +380,14 @@ export const Component = () => {
|
||||
}, [params, recentPages]);
|
||||
|
||||
const pageId = params.pageId;
|
||||
const canAccess = useLiveData(
|
||||
pageId ? guardService.can$('Doc_Read', pageId) : undefined
|
||||
);
|
||||
|
||||
return pageId ? (
|
||||
<DetailPageWrapper
|
||||
pageId={pageId}
|
||||
canAccess={canAccess}
|
||||
skeleton={<PageDetailSkeleton />}
|
||||
notFound={<PageNotFound noPermission />}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user