mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fix permission call
This commit is contained in:
@@ -30,13 +30,10 @@ export function PageShareModal({ readOnly }: PageShareModalProps) {
|
||||
|
||||
const { data: page } = usePageQuery({ pageId: pageSlugId });
|
||||
const pageId = page?.id;
|
||||
const isRestricted = page?.permissions?.hasRestriction ?? false;
|
||||
|
||||
const { data: restrictionInfo, isLoading: restrictionLoading } =
|
||||
usePageRestrictionInfoQuery(pageId);
|
||||
|
||||
const isRestricted =
|
||||
restrictionInfo?.hasDirectRestriction ||
|
||||
restrictionInfo?.hasInheritedRestriction;
|
||||
usePageRestrictionInfoQuery(opened ? pageId : undefined);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -47,7 +44,7 @@ export function PageShareModal({ readOnly }: PageShareModalProps) {
|
||||
<Indicator
|
||||
color={isRestricted ? "red" : "green"}
|
||||
offset={5}
|
||||
disabled={!restrictionInfo}
|
||||
disabled={!page?.permissions}
|
||||
withBorder
|
||||
>
|
||||
{isRestricted ? (
|
||||
|
||||
@@ -26,7 +26,7 @@ import { IPagination, QueryParams } from "@/lib/types";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export function usePageRestrictionInfoQuery(
|
||||
pageId: string,
|
||||
pageId: string | undefined,
|
||||
): UseQueryResult<IPageRestrictionInfo, Error> {
|
||||
return useQuery({
|
||||
queryKey: ["page-restriction-info", pageId],
|
||||
|
||||
@@ -17,7 +17,6 @@ import { useTranslation } from "react-i18next";
|
||||
import { useQueryEmit } from "@/features/websocket/use-query-emit";
|
||||
import { useIsCloudEE } from "@/hooks/use-is-cloud-ee";
|
||||
import { useGetSpaceBySlugQuery } from "@/features/space/queries/space-query.ts";
|
||||
import { usePagePermission } from "@/ee/page-permission";
|
||||
|
||||
function CommentListWithTabs() {
|
||||
const { t } = useTranslation();
|
||||
@@ -34,10 +33,7 @@ function CommentListWithTabs() {
|
||||
const isCloudEE = useIsCloudEE();
|
||||
const { data: space } = useGetSpaceBySlugQuery(page?.space?.slug);
|
||||
|
||||
const { canEdit: canComment } = usePagePermission(
|
||||
page?.id,
|
||||
space?.membership?.permissions,
|
||||
);
|
||||
const canComment = page?.permissions?.canEdit ?? false;
|
||||
|
||||
// Separate active and resolved comments
|
||||
const { activeComments, resolvedComments } = useMemo(() => {
|
||||
|
||||
@@ -22,6 +22,10 @@ export interface IPage {
|
||||
lastUpdatedBy: ILastUpdatedBy;
|
||||
deletedBy: IDeletedBy;
|
||||
space: Partial<ISpace>;
|
||||
permissions?: {
|
||||
canEdit: boolean;
|
||||
hasRestriction: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface ICreator {
|
||||
|
||||
@@ -13,8 +13,6 @@ import { IconAlertTriangle, IconFileOff } from "@tabler/icons-react";
|
||||
import { Button } from "@mantine/core";
|
||||
import { Link } from "react-router-dom";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { usePagePermission } from "@/ee/page-permission";
|
||||
|
||||
const MemoizedFullEditor = React.memo(FullEditor);
|
||||
const MemoizedPageHeader = React.memo(PageHeader);
|
||||
const MemoizedHistoryModal = React.memo(HistoryModal);
|
||||
@@ -54,7 +52,7 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
||||
} = usePageQuery({ pageId: extractPageSlugId(pageSlug) });
|
||||
const { data: space } = useGetSpaceBySlugQuery(page?.space?.slug);
|
||||
|
||||
const { canEdit } = usePagePermission(page?.id, space?.membership?.permissions);
|
||||
const canEdit = page?.permissions?.canEdit ?? false;
|
||||
|
||||
if (isLoading) {
|
||||
return <></>;
|
||||
|
||||
Reference in New Issue
Block a user