fix: Remove broken comment ability on templates
This commit is contained in:
@@ -781,8 +781,7 @@ export const openDocumentComments = createAction({
|
|||||||
const can = stores.policies.abilities(activeDocumentId ?? "");
|
const can = stores.policies.abilities(activeDocumentId ?? "");
|
||||||
return (
|
return (
|
||||||
!!activeDocumentId &&
|
!!activeDocumentId &&
|
||||||
can.read &&
|
can.comment &&
|
||||||
!can.restore &&
|
|
||||||
!!stores.auth.team?.getPreference(TeamPreference.Commenting)
|
!!stores.auth.team?.getPreference(TeamPreference.Commenting)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import Revision from "~/models/Revision";
|
|||||||
import DocumentMeta from "~/components/DocumentMeta";
|
import DocumentMeta from "~/components/DocumentMeta";
|
||||||
import Fade from "~/components/Fade";
|
import Fade from "~/components/Fade";
|
||||||
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
||||||
|
import usePolicy from "~/hooks/usePolicy";
|
||||||
import useStores from "~/hooks/useStores";
|
import useStores from "~/hooks/useStores";
|
||||||
import { documentPath, documentInsightsPath } from "~/utils/routeHelpers";
|
import { documentPath, documentInsightsPath } from "~/utils/routeHelpers";
|
||||||
|
|
||||||
@@ -18,18 +19,11 @@ type Props = {
|
|||||||
/* The document to display meta data for */
|
/* The document to display meta data for */
|
||||||
document: Document;
|
document: Document;
|
||||||
revision?: Revision;
|
revision?: Revision;
|
||||||
isDraft: boolean;
|
|
||||||
to?: LocationDescriptor;
|
to?: LocationDescriptor;
|
||||||
rtl?: boolean;
|
rtl?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
function TitleDocumentMeta({
|
function TitleDocumentMeta({ to, document, revision, ...rest }: Props) {
|
||||||
to,
|
|
||||||
isDraft,
|
|
||||||
document,
|
|
||||||
revision,
|
|
||||||
...rest
|
|
||||||
}: Props) {
|
|
||||||
const { views, comments, ui } = useStores();
|
const { views, comments, ui } = useStores();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
@@ -38,6 +32,7 @@ function TitleDocumentMeta({
|
|||||||
const totalViewers = documentViews.length;
|
const totalViewers = documentViews.length;
|
||||||
const onlyYou = totalViewers === 1 && documentViews[0].userId;
|
const onlyYou = totalViewers === 1 && documentViews[0].userId;
|
||||||
const viewsLoadedOnMount = React.useRef(totalViewers > 0);
|
const viewsLoadedOnMount = React.useRef(totalViewers > 0);
|
||||||
|
const can = usePolicy(document.id);
|
||||||
|
|
||||||
const Wrapper = viewsLoadedOnMount.current ? React.Fragment : Fade;
|
const Wrapper = viewsLoadedOnMount.current ? React.Fragment : Fade;
|
||||||
|
|
||||||
@@ -46,7 +41,7 @@ function TitleDocumentMeta({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Meta document={document} revision={revision} to={to} replace {...rest}>
|
<Meta document={document} revision={revision} to={to} replace {...rest}>
|
||||||
{team.getPreference(TeamPreference.Commenting) && (
|
{team.getPreference(TeamPreference.Commenting) && can.comment && (
|
||||||
<>
|
<>
|
||||||
•
|
•
|
||||||
<CommentLink
|
<CommentLink
|
||||||
@@ -60,7 +55,7 @@ function TitleDocumentMeta({
|
|||||||
</CommentLink>
|
</CommentLink>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{totalViewers && !isDraft ? (
|
{totalViewers && !document.isDraft && !document.isTemplate ? (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
•
|
•
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
|
|||||||
/>
|
/>
|
||||||
{!shareId && (
|
{!shareId && (
|
||||||
<DocumentMeta
|
<DocumentMeta
|
||||||
isDraft={isDraft}
|
|
||||||
document={document}
|
document={document}
|
||||||
to={
|
to={
|
||||||
match.path === matchDocumentHistory
|
match.path === matchDocumentHistory
|
||||||
|
|||||||
Reference in New Issue
Block a user