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