diff --git a/app/actions/definitions/documents.tsx b/app/actions/definitions/documents.tsx
index 019297d976..60bf342902 100644
--- a/app/actions/definitions/documents.tsx
+++ b/app/actions/definitions/documents.tsx
@@ -750,7 +750,7 @@ export const importDocument = createAction({
return false;
},
- perform: ({ activeCollectionId, activeDocumentId, stores }) => {
+ perform: ({ activeDocumentId, activeCollectionId, stores }) => {
const { documents } = stores;
const input = document.createElement("input");
input.type = "file";
@@ -1081,12 +1081,17 @@ export const openDocumentComments = createAction({
analyticsName: "Open comments",
section: ActiveDocumentSection,
icon: ,
- visible: ({ activeDocumentId, stores }) => {
+ visible: ({ activeCollectionId, activeDocumentId, stores }) => {
const can = stores.policies.abilities(activeDocumentId ?? "");
+ const collection = activeCollectionId
+ ? stores.collections.get(activeCollectionId)
+ : undefined;
+
return (
!!activeDocumentId &&
can.comment &&
- !!stores.auth.team?.getPreference(TeamPreference.Commenting)
+ (collection?.canCreateComment ??
+ !!stores.auth.team?.getPreference(TeamPreference.Commenting))
);
},
perform: ({ activeDocumentId, stores }) => {
diff --git a/app/components/AuthenticatedLayout.tsx b/app/components/AuthenticatedLayout.tsx
index c167fa42af..405400bbfa 100644
--- a/app/components/AuthenticatedLayout.tsx
+++ b/app/components/AuthenticatedLayout.tsx
@@ -49,7 +49,7 @@ type Props = {
};
const AuthenticatedLayout: React.FC = ({ children }: Props) => {
- const { ui, auth } = useStores();
+ const { ui, auth, collections } = useStores();
const location = useLocation();
const layoutRef = React.useRef(null);
const can = usePolicy(ui.activeDocumentId);
@@ -108,7 +108,9 @@ const AuthenticatedLayout: React.FC = ({ children }: Props) => {
can.comment &&
ui.activeDocumentId &&
ui.commentsExpanded &&
- team.getPreference(TeamPreference.Commenting);
+ (ui.activeCollectionId
+ ? collections.get(ui.activeCollectionId)?.canCreateComment
+ : !!team.getPreference(TeamPreference.Commenting));
const sidebarRight = (
{
@@ -83,6 +84,7 @@ export const CollectionForm = observer(function CollectionForm_({
icon: collection?.icon,
sharing: collection?.sharing ?? true,
permission: collection?.permission,
+ commenting: collection?.commenting ?? true,
color: iconColor,
},
});
@@ -190,6 +192,15 @@ export const CollectionForm = observer(function CollectionForm_({
/>
)}
+ {team.getPreference(TeamPreference.Commenting) && (
+
+ )}
+