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